jquery-ui/tests/visual/menu/flyoutmenu.html

128 lines
3.4 KiB
HTML

<!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" />
<script type="text/javascript" src="../../../jquery-1.4.4.js"></script>
<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.menu.js"></script>
<script type="text/javascript" src="../../../external/jquery.bgiframe-2.1.2.js"></script>
<script type="text/javascript" src="flyoutmenu.js"></script>
<!--
<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
-->
<script type="text/javascript">
$(function() {
$.fn.themeswitcher && $('<div/>').css({
position: "absolute",
right: 10,
top: 10
}).appendTo(document.body).themeswitcher();
var menu = $("#menu");
var button = $("button").click(function(event) {
// TODO required to prevent the click handler below from handling this event
event.stopPropagation();
menu.flyoutmenu("show")
.focus()
.position({
my: "left top",
at: "right top",
of: this
});
$(document).one("click", function() {
menu.flyoutmenu("hide");
});
});
menu.flyoutmenu({
/* top-alignment
position: function(item) {
return {
my: "left top",
at: "right top",
of: item.parent()
}
},
*/
select: function(event, ui) {
$("#log").append("<div>Selected " + ui.item.children("a").text() + "(" + ui.item.children("a").attr("id") + ")</div>");
button.focus();
}
}).hide();
// equal height
//menu.find("ul").height(menu.height());
});
</script>
<style>
body { font-size:62.5%; }
.ui-menu { width: 200px; position: absolute; outline: none; }
.ui-menu .ui-icon { float: right; }
</style>
</head>
<body>
<button>Show context menu</button>
<br/>
<select>
<option>some option with some text</option>
</select>
<ul id="menu">
<li>
<a id="a1" href="#">Amsterdam</a>
<ul>
<li><a id="b1" href="#">Aberdeen</a></li>
<li><a id="b2" 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 id="a2" href="#">Anaheim</a></li>
<li><a id="a3" 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>
<div class="ui-widget" style="margin-top:2em; font-family:Arial">
Log:
<div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
</div>
</body>
</html>