2010-03-25 03:32:37 +00:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Menu Visual Test: Default</title>
|
|
|
|
<link rel="stylesheet" href="../visual.css" type="text/css" />
|
|
|
|
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
|
2012-03-22 13:45:22 +00:00
|
|
|
<script type="text/javascript" src="../../../jquery-1.7.2.js"></script>
|
2010-03-25 03:32:37 +00:00
|
|
|
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
|
|
|
|
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
|
|
|
|
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
|
|
|
|
<script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
|
2010-04-21 19:01:08 +00:00
|
|
|
<script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script>
|
2010-04-30 08:18:36 +00:00
|
|
|
<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
|
2010-03-25 03:32:37 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
$(function() {
|
2010-04-30 08:18:36 +00:00
|
|
|
$.fn.themeswitcher && $('<div/>').css({
|
|
|
|
position: "absolute",
|
|
|
|
right: 10,
|
|
|
|
top: 10
|
|
|
|
}).appendTo(document.body).themeswitcher();
|
|
|
|
|
2010-03-25 03:32:37 +00:00
|
|
|
$.widget("ui.drilldown", {
|
|
|
|
_init: function() {
|
2012-02-12 14:14:36 +00:00
|
|
|
var that = this;
|
2010-03-25 03:32:37 +00:00
|
|
|
this.active = this.element.find(">ul").attr("tabindex", 0);
|
|
|
|
|
|
|
|
// hide submenus and create indicator icons
|
|
|
|
this.element.find("ul").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>').end().filter(":first").show();
|
|
|
|
|
|
|
|
this.element.find("ul").menu({
|
2010-04-30 11:04:09 +00:00
|
|
|
// disable built-in key handling
|
|
|
|
input: $(),
|
2010-03-25 03:32:37 +00:00
|
|
|
focus: function(event, ui) {
|
2012-02-12 14:14:36 +00:00
|
|
|
that.activeItem = ui.item;
|
2010-03-25 03:32:37 +00:00
|
|
|
},
|
2010-04-30 11:18:34 +00:00
|
|
|
select: function(event, ui) {
|
2012-02-12 14:14:36 +00:00
|
|
|
if (this != that.active[0]) {
|
2010-03-25 03:32:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var nested = $(">ul", ui.item);
|
|
|
|
if (nested.length) {
|
2012-02-12 14:14:36 +00:00
|
|
|
that._open(nested);
|
2010-03-25 03:32:37 +00:00
|
|
|
} else {
|
2012-02-12 14:14:36 +00:00
|
|
|
that.element.find("h3").text(ui.item.text());
|
|
|
|
that.options.select.apply(this, arguments);
|
2010-03-25 03:32:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.back = this.element.children(":last").button({
|
|
|
|
icons: {
|
|
|
|
primary: "ui-icon-carat-1-w"
|
|
|
|
}
|
|
|
|
}).click(function() {
|
2012-02-12 14:14:36 +00:00
|
|
|
that.up();
|
2010-03-25 03:32:37 +00:00
|
|
|
return false;
|
|
|
|
}).hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
_open: function(submenu) {
|
|
|
|
this.active = submenu.show().css({
|
2010-03-27 00:13:50 +00:00
|
|
|
opacity: 0
|
2010-03-25 03:32:37 +00:00
|
|
|
}).position({
|
|
|
|
my: "left top",
|
2010-03-27 00:13:50 +00:00
|
|
|
at: "right top",
|
2010-03-25 03:32:37 +00:00
|
|
|
of: this.widget()
|
2010-03-27 00:13:50 +00:00
|
|
|
}).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left top",
|
|
|
|
of: this.widget(),
|
|
|
|
using: function(to) {
|
|
|
|
$(this).animate({
|
|
|
|
left: to.left,
|
|
|
|
top: to.top,
|
|
|
|
opacity: 1
|
|
|
|
});
|
|
|
|
}
|
2010-03-25 03:32:37 +00:00
|
|
|
});
|
|
|
|
this.back.show();
|
|
|
|
},
|
|
|
|
|
|
|
|
up: function() {
|
|
|
|
if (this.active.parent()[0] == this.element[0]) {
|
|
|
|
return;
|
|
|
|
}
|
2010-03-27 00:13:50 +00:00
|
|
|
this.active.position({
|
|
|
|
my: "left top",
|
|
|
|
at: "right top",
|
|
|
|
of: this.widget(),
|
|
|
|
using: function(to) {
|
|
|
|
$(this).animate({
|
|
|
|
left: to.left,
|
|
|
|
top: to.top,
|
|
|
|
opacity: 0
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2010-03-25 03:32:37 +00:00
|
|
|
this.active = this.active.parent().parent().show();
|
2010-03-27 00:13:50 +00:00
|
|
|
this.activeItem = this.active.data("menu").active;
|
2010-03-25 03:32:37 +00:00
|
|
|
if (!this.active.parent().parent().is(":ui-menu")) {
|
|
|
|
this.back.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
down: function(event) {
|
|
|
|
var nested = this.activeItem.find(">ul");
|
|
|
|
if (nested.length) {
|
|
|
|
this._open(nested);
|
2011-02-24 09:06:08 +00:00
|
|
|
nested.menu("focus", event, nested.children(":first"))
|
2010-03-25 03:32:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function() {
|
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
},
|
|
|
|
|
|
|
|
widget: function() {
|
|
|
|
return this.element.find(">ul");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var drilldown = $("#drilldown").drilldown({
|
2010-04-30 11:18:34 +00:00
|
|
|
select: function(event, ui) {
|
2010-03-25 03:32:37 +00:00
|
|
|
$("#log").append("<div>Selected " + ui.item.text() + "</div>");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
drilldown.drilldown("widget").keydown(function(event) {
|
|
|
|
var menu = drilldown.data("drilldown").active.data("menu");
|
|
|
|
if (menu.widget().is(":hidden"))
|
|
|
|
return;
|
|
|
|
event.stopPropagation();
|
|
|
|
switch (event.keyCode) {
|
|
|
|
case $.ui.keyCode.PAGE_UP:
|
|
|
|
menu.previousPage();
|
|
|
|
break;
|
|
|
|
case $.ui.keyCode.PAGE_DOWN:
|
|
|
|
menu.nextPage();
|
|
|
|
break;
|
|
|
|
case $.ui.keyCode.UP:
|
|
|
|
menu.previous();
|
|
|
|
break;
|
|
|
|
case $.ui.keyCode.LEFT:
|
|
|
|
drilldown.drilldown("up");
|
|
|
|
break;
|
|
|
|
case $.ui.keyCode.RIGHT:
|
|
|
|
drilldown.drilldown("down");
|
|
|
|
break;
|
|
|
|
case $.ui.keyCode.DOWN:
|
|
|
|
menu.next();
|
|
|
|
event.preventDefault();
|
|
|
|
break;
|
|
|
|
case $.ui.keyCode.ENTER:
|
|
|
|
case $.ui.keyCode.TAB:
|
|
|
|
menu.select();
|
|
|
|
drilldown.drilldown("hide");
|
|
|
|
event.preventDefault();
|
|
|
|
break;
|
|
|
|
case $.ui.keyCode.ESCAPE:
|
|
|
|
drilldown.drilldown("hide", event);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
clearTimeout(menu.filterTimer);
|
|
|
|
var prev = menu.previousFilter || "";
|
|
|
|
var character = String.fromCharCode(event.keyCode);
|
|
|
|
var skip = false;
|
|
|
|
if (character == prev) {
|
|
|
|
skip = true;
|
|
|
|
} else {
|
|
|
|
character = prev + character;
|
|
|
|
}
|
|
|
|
|
|
|
|
var match = menu.widget().children("li").filter(function() {
|
|
|
|
return new RegExp("^" + character, "i").test($("a", this).text());
|
|
|
|
});
|
|
|
|
var match = skip && match.index(menu.active.next()) != -1 ? match.next() : match;
|
|
|
|
if (!match.length) {
|
|
|
|
character = String.fromCharCode(event.keyCode);
|
|
|
|
match = menu.widget().children("li").filter(function() {
|
|
|
|
return new RegExp("^" + character, "i").test($(this).text());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (match.length) {
|
2011-02-24 09:06:08 +00:00
|
|
|
menu.focus(event, match);
|
2010-03-25 03:32:37 +00:00
|
|
|
if (match.length > 1) {
|
|
|
|
menu.previousFilter = character;
|
|
|
|
menu.filterTimer = setTimeout(function() {
|
|
|
|
delete menu.previousFilter;
|
|
|
|
}, 1000);
|
|
|
|
} else {
|
|
|
|
delete menu.previousFilter;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
delete menu.previousFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
body { font-size:62.5%; }
|
|
|
|
.ui-menu { width: 200px; height: 170px; }
|
|
|
|
.ui-menu .ui-menu { position: absolute; }
|
|
|
|
.ui-menu .ui-icon { float: right; }
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="drilldown">
|
|
|
|
<h3>Make a selection...</h3>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<a href="#">Amsterdam</a>
|
|
|
|
<ul>
|
|
|
|
<li><a href="#">Aberdeen</a></li>
|
|
|
|
<li><a href="#">Ada</a></li>
|
|
|
|
<li>
|
|
|
|
<a href="#">Adamsville</a>
|
|
|
|
<ul>
|
|
|
|
<li><a href="#">Anaheim</a></li>
|
|
|
|
<li>
|
|
|
|
<a href="#">Cologne</a>
|
|
|
|
<ul>
|
|
|
|
<li><a href="#">Mberdeen</a></li>
|
|
|
|
<li><a href="#">Mda</a></li>
|
|
|
|
<li><a href="#">Mdamsville</a></li>
|
|
|
|
<li><a href="#">Mddyston</a></li>
|
|
|
|
<li><a href="#">Mmesville</a></li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li><a href="#">Frankfurt</a></li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li><a href="#">Addyston</a></li>
|
|
|
|
<li><a href="#">Amesville</a></li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li><a href="#">Anaheim</a></li>
|
|
|
|
<li><a href="#">Cologne</a></li>
|
|
|
|
<li><a href="#">Frankfurt</a></li>
|
|
|
|
<li>
|
|
|
|
<a href="#">Magdeburg</a>
|
|
|
|
<ul>
|
|
|
|
<li><a href="#">Mberdeen</a></li>
|
|
|
|
<li><a href="#">Mda</a></li>
|
|
|
|
<li><a href="#">Mdamsville</a></li>
|
|
|
|
<li><a href="#">Mddyston</a></li>
|
|
|
|
<li><a href="#">Mmesville</a></li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li><a href="#">Munich</a></li>
|
|
|
|
<li><a href="#">Utrecht</a></li>
|
|
|
|
<li><a href="#">Zurich</a></li>
|
|
|
|
</ul>
|
|
|
|
<a href="#">Go back</a>
|
|
|
|
</div>
|
|
|
|
|
2010-07-19 15:22:32 +00:00
|
|
|
<div class="ui-widget" style="clear: left; margin-top:2em; font-family:Arial">
|
2010-03-25 03:32:37 +00:00
|
|
|
Log:
|
|
|
|
<div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|