diff options
author | jzaefferer <joern.zaefferer@gmail.com> | 2010-12-22 18:31:27 +0100 |
---|---|---|
committer | jzaefferer <joern.zaefferer@gmail.com> | 2010-12-22 18:31:27 +0100 |
commit | 3552947c19b8ea1b779dc9809783c6ac6a218d68 (patch) | |
tree | 61b23078b9ff83f65bd5258bc4dd9efed5ac5f7a /tests/visual | |
parent | 8d39171fa285519203688084f3cf66c1e2ae0ada (diff) | |
parent | 70e8e9f294729f120f7b52fb9803fddfd37e464e (diff) | |
download | jquery-ui-3552947c19b8ea1b779dc9809783c6ac6a218d68.tar.gz jquery-ui-3552947c19b8ea1b779dc9809783c6ac6a218d68.zip |
Merge remote branch 'origin/menu'
Conflicts:
demos/autocomplete/categories.html
demos/autocomplete/combobox.html
demos/autocomplete/custom-data.html
demos/autocomplete/default.html
demos/autocomplete/folding.html
demos/autocomplete/multiple-remote.html
demos/autocomplete/multiple.html
demos/autocomplete/remote-jsonp.html
demos/autocomplete/remote-with-cache.html
demos/autocomplete/remote.html
demos/autocomplete/xml.html
demos/button/splitbutton.html
demos/index.html
tests/visual/menu/nested.html
themes/base/jquery.ui.autocomplete.css
ui/jquery.ui.autocomplete.js
Diffstat (limited to 'tests/visual')
-rw-r--r-- | tests/visual/all.html | 1 | ||||
-rw-r--r-- | tests/visual/autocomplete/autocomplete.html | 1 | ||||
-rw-r--r-- | tests/visual/compound/widgets_in_dialog.html | 2 | ||||
-rw-r--r-- | tests/visual/index.html | 8 | ||||
-rw-r--r-- | tests/visual/menu/contextmenu.html | 55 | ||||
-rw-r--r-- | tests/visual/menu/drilldown.html | 17 | ||||
-rw-r--r-- | tests/visual/menu/menu.html | 60 | ||||
-rw-r--r-- | tests/visual/menu/menubar.html | 94 | ||||
-rw-r--r-- | tests/visual/menu/nested.html | 10 | ||||
-rw-r--r-- | tests/visual/position/position.html | 2 |
10 files changed, 168 insertions, 82 deletions
diff --git a/tests/visual/all.html b/tests/visual/all.html index 4bbd323b0..c50465a47 100644 --- a/tests/visual/all.html +++ b/tests/visual/all.html @@ -11,6 +11,7 @@ <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script type="text/javascript" src="../../ui/jquery.ui.accordion.js"></script> + <script type="text/javascript" src="../../ui/jquery.ui.menu.js"></script> <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script> <script type="text/javascript" src="../../ui/jquery.ui.datepicker.js"></script> diff --git a/tests/visual/autocomplete/autocomplete.html b/tests/visual/autocomplete/autocomplete.html index 9b0ba66f6..199451e9c 100644 --- a/tests/visual/autocomplete/autocomplete.html +++ b/tests/visual/autocomplete/autocomplete.html @@ -9,6 +9,7 @@ <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="../../../ui/jquery.ui.autocomplete.js"></script> <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> diff --git a/tests/visual/compound/widgets_in_dialog.html b/tests/visual/compound/widgets_in_dialog.html index 11120ea24..dc1b551cf 100644 --- a/tests/visual/compound/widgets_in_dialog.html +++ b/tests/visual/compound/widgets_in_dialog.html @@ -13,7 +13,7 @@ <script type="text/javascript" src="../../../ui/jquery.ui.resizable.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.accordion.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.autocomplete.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.datepicker.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.dialog.js"></script> diff --git a/tests/visual/index.html b/tests/visual/index.html index c7b709279..04e23fddd 100644 --- a/tests/visual/index.html +++ b/tests/visual/index.html @@ -41,6 +41,14 @@ <li><a href="button/button.html">Button</a></li> <li><a href="datepicker/datepicker.html">Datepicker</a></li> <li><a href="dialog/dialog.html">Dialog</a></li> + <li> + <a href="menu/menu.html">Menu</a> + <ul> + <li><a href="menu/contextmenu.html">Context Menu</a></li> + <li><a href="menu/nested.html">Nested Menu</a></li> + <li><a href="menu/drilldown.html">Drilldown Menu</a></li> + </ul> + </li> <li><a href="progressbar/progressbar.html">Progressbar</a></li> <li><a href="slider/slider.html">Slider</a></li> <li><a href="spinner/spinner.html">Spinner</a></li> diff --git a/tests/visual/menu/contextmenu.html b/tests/visual/menu/contextmenu.html index eb328abf0..d3fdc4e7c 100644 --- a/tests/visual/menu/contextmenu.html +++ b/tests/visual/menu/contextmenu.html @@ -8,7 +8,7 @@ <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.autocomplete.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { @@ -18,23 +18,24 @@ top: 10 }).appendTo(document.body).themeswitcher(); - var menus = $("#menu1, #menu2").menu({ - selected: function(event, ui) { - $("#log").append("<div>Selected " + ui.item.text() + "</div>"); - } - }).hide(); - - - $("button").click(function(event) { + $("button").each(function() { + $(this).next().menu({ + selected: function(event, ui) { + $(this).hide(); + $("#log").append("<div>Selected " + ui.item.text() + "</div>"); + }, + input: $(this) + }).hide(); + }).click(function(event) { // TODO required to prevent the click handler below from handling this event event.stopPropagation(); - $("#menu" + this.id).menu("deactivate").show().position({ + var menu = $("#menu" + this.id).menu("deactivate").show().position({ my: "left top", at: "right top", of: event.pageX > 0 ? event : this }); $(document).one("click", function() { - menus.hide(); + menu.hide(); }) }).keydown(function(event) { var menu = $("#menu" + this.id).data("menu"); @@ -42,24 +43,8 @@ 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.DOWN: - menu.next(); - event.preventDefault(); - break; - case $.ui.keyCode.ENTER: case $.ui.keyCode.TAB: - menu.select(); menu.widget().hide(); - event.preventDefault(); break; case $.ui.keyCode.ESCAPE: menu.widget().hide(); @@ -86,7 +71,7 @@ }); } if (match.length) { - menu.activate(match); + menu.activate(event, match); if (match.length > 1) { menu.previousFilter = character; menu.filterTimer = setTimeout(function() { @@ -111,7 +96,6 @@ <body> <button id="1">Show context menu 1</button> - <ul id="menu1"> <li><a href="#">Amsterdam</a></li> <li><a href="#">Anaheim</a></li> @@ -123,6 +107,12 @@ <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> + +<button id="2">Show context menu 2</button> <ul id="menu2"> <li><a href="#">Aberdeen</a></li> <li><a href="#">Ada</a></li> @@ -164,12 +154,5 @@ <li><a href="#">Amesville</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> - -<button id="2">Show context menu 2</button> - </body> </html> diff --git a/tests/visual/menu/drilldown.html b/tests/visual/menu/drilldown.html index 7bb7b03a2..65cdf1111 100644 --- a/tests/visual/menu/drilldown.html +++ b/tests/visual/menu/drilldown.html @@ -9,9 +9,16 @@ <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> - <script type="text/javascript" src="../../../ui/jquery.ui.autocomplete.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.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(); + $.widget("ui.drilldown", { _init: function() { var self = this; @@ -21,10 +28,12 @@ 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({ + // disable built-in key handling + input: $(), focus: function(event, ui) { self.activeItem = ui.item; }, - selected: function(event, ui) { + select: function(event, ui) { if (this != self.active[0]) { return; } @@ -33,7 +42,7 @@ self._open(nested); } else { self.element.find("h3").text(ui.item.text()); - self.options.selected.apply(this, arguments); + self.options.select.apply(this, arguments); } } }); @@ -115,7 +124,7 @@ }); var drilldown = $("#drilldown").drilldown({ - selected: function(event, ui) { + select: function(event, ui) { $("#log").append("<div>Selected " + ui.item.text() + "</div>"); } }); diff --git a/tests/visual/menu/menu.html b/tests/visual/menu/menu.html index 3a10da2e8..ec31a0f96 100644 --- a/tests/visual/menu/menu.html +++ b/tests/visual/menu/menu.html @@ -7,8 +7,7 @@ <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.autocomplete.js"></script> - <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> <script type="text/javascript"> $(function() { $.fn.themeswitcher && $('<div/>').css({ @@ -17,39 +16,25 @@ top: 10 }).appendTo(document.body).themeswitcher(); - var menus = $("#menu1, #menu2").menu({ - selected: function(event, ui) { - $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log"); - } - }).keydown(function(event) { - var menu = $(this).data("menu"); - if (menu.widget().is(":hidden")) - return; - event.stopPropagation(); - switch (event.keyCode) { - case $.ui.keyCode.PAGE_UP: - menu.previousPage(); - event.preventDefault(); - break; - case $.ui.keyCode.PAGE_DOWN: - menu.nextPage(); - event.preventDefault(); - break; - case $.ui.keyCode.UP: - menu.previous(); - event.preventDefault(); - break; - case $.ui.keyCode.DOWN: - menu.next(); - event.preventDefault(); - break; - case $.ui.keyCode.ENTER: - menu.select(); - event.preventDefault(); - break; - } - }); + function create() { + menus.menu({ + select: function(event, ui) { + $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log"); + } + }); + } + + var menus = $("#menu1, #menu2"); + create(); + $("#toggle-destroy").toggle(function() { + menus.menu("destroy"); + }, create); + $("#toggle-disable").toggle(function() { + menus.menu("disable"); + }, function() { + menus.menu("enable"); + }); }); </script> <style> @@ -60,7 +45,7 @@ </head> <body> -<ul id="menu1" tabindex="0"> +<ul id="menu1"> <li><a href="#">Aberdeen</a></li> <li><a href="#">Ada</a></li> <li><a href="#">Adamsville</a></li> @@ -68,7 +53,7 @@ <li><a href="#">Adelphi</a></li> </ul> -<ul id="menu2" tabindex="0"> +<ul id="menu2"> <li><a href="#">Aberdeen</a></li> <li><a href="#">Ada</a></li> <li><a href="#">Adamsville</a></li> @@ -114,5 +99,8 @@ <div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div> </div> +<button id="toggle-disable">Disable / Enable</button> +<button id="toggle-destroy">Destroy / Create</button> + </body> </html> diff --git a/tests/visual/menu/menubar.html b/tests/visual/menu/menubar.html new file mode 100644 index 000000000..087365c42 --- /dev/null +++ b/tests/visual/menu/menubar.html @@ -0,0 +1,94 @@ +<!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.2.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.button.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.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(); + + $(".menubar").children("a") + .button() + .click(function() { + var button = $(this); + var menu = button.next(); + if (menu.is(":visible")) { + menu.hide(); + return false; + } + menu.parent().find(".ui-menu").not(menu).hide(); + menu.show().css({ left:0, top: 0 }).position({ + my: "left top", + at: "left bottom", + of: button + }); + $(document).bind("click.menubar", function(event) { + if ($(event.target).closest(".ui-menu")[0] == menu[0]) { + return; + } + $(this).unbind(".menubar"); + menu.hide(); + }); + return false; + }) + .each(function() { + $(this).next().hide().menu({ + input: $(this), + select: function(event, ui) { + $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log"); + } + }); + }); + + }); + </script> + <style> + body { font-size:62.5%; } + .ui-menu { width: 200px; } + .menubar .ui-menu { position: absolute; } + </style> +</head> +<body> + +<div class="menubar ui-widget-header"> + <a href="#">File</a> + <ul> + <li><a href="#">Open...</a></li> + <li><a href="#">Save</a></li> + <li><a href="#">Save as...</a></li> + <li><a href="#">Close</a></li> + <li><a href="#">Quit</a></li> + </ul> + <a href="#">Edit</a> + <ul> + <li><a href="#">Copy</a></li> + <li><a href="#">Cut</a></li> + <li><a href="#">Paste</a></li> + </ul> + <a href="#">View</a> + <ul> + <li><a href="#">Fullscreen</a></li> + <li><a href="#">Fit into view</a></li> + <li><a href="#">Customize...</a></li> + </ul> +</div> + +<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> diff --git a/tests/visual/menu/nested.html b/tests/visual/menu/nested.html index c7f9a0914..2508c55c4 100644 --- a/tests/visual/menu/nested.html +++ b/tests/visual/menu/nested.html @@ -8,8 +8,8 @@ <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.autocomplete.js"></script> - <script type="text/javascript" src="../../../external/jquery.bgiframe-2.1.2.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> + <script type="text/javascript" src="../../../external/jquery.bgiframe-2.1.1.js"></script> <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { @@ -28,7 +28,9 @@ this.element.find("ul").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>'); this.element.find("ul").andSelf().menu({ - selected: this.options.selected, + // disable built-in key handling + input: $(), + select: this.options.select, focus: function(event, ui) { self.active = ui.item.parent(); self.activeItem = ui.item; @@ -75,7 +77,7 @@ }); var nestedmenu = $("#menu").nestedmenu({ - selected: function(event, ui) { + select: function(event, ui) { $("#log").append("<div>Selected " + ui.item.text() + "</div>"); } }).hide(); diff --git a/tests/visual/position/position.html b/tests/visual/position/position.html index 80452bc81..11fb48d6e 100644 --- a/tests/visual/position/position.html +++ b/tests/visual/position/position.html @@ -9,7 +9,7 @@ <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.autocomplete.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { |