From: jzaefferer Date: Wed, 24 Mar 2010 22:01:43 +0000 (-0400) Subject: Improved drilldown keyboard handling X-Git-Tag: 1.8.1~5^2~62^2~27 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=27c5debb599b40dc9bd4d0c2267fa2afd48cbfc2;p=jquery-ui.git Improved drilldown keyboard handling --- diff --git a/tests/visual/menu/drilldown.html b/tests/visual/menu/drilldown.html index 78b8cf9f2..a97d8322c 100644 --- a/tests/visual/menu/drilldown.html +++ b/tests/visual/menu/drilldown.html @@ -14,7 +14,7 @@ $.widget("ui.drilldown", { _init: function() { var self = this; - this.active = this.element; + this.active = this.element.find(">ul").attr("tabindex", 0); // hide submenus and create indicator icons this.element.find("ul").hide().prev("a").prepend('').end().filter(":first").show(); @@ -84,17 +84,21 @@ parent.parent().removeData("submenu"); submenu = submenu.data("submenu"); }; + }, + + widget: function() { + return this.element.find(">ul"); } }); - var nestedmenu = $("#drilldown").drilldown({ + var drilldown = $("#drilldown").drilldown({ selected: function(event, ui) { $("#log").append("
Selected " + ui.item.text() + "
"); } }); - $().keydown(function(event) { - var menu = nestedmenu.data("drilldown").active.data("menu"); + drilldown.drilldown("widget").keydown(function(event) { + var menu = drilldown.data("drilldown").active.data("menu"); if (menu.widget().is(":hidden")) return; event.stopPropagation(); @@ -109,10 +113,10 @@ menu.previous(); break; case $.ui.keyCode.LEFT: - nestedmenu.nestedmenu("up"); + drilldown.drilldown("up"); break; case $.ui.keyCode.RIGHT: - nestedmenu.nestedmenu("down"); + drilldown.drilldown("down"); break; case $.ui.keyCode.DOWN: menu.next(); @@ -121,11 +125,11 @@ case $.ui.keyCode.ENTER: case $.ui.keyCode.TAB: menu.select(); - nestedmenu.nestedmenu("hide"); + drilldown.drilldown("hide"); event.preventDefault(); break; case $.ui.keyCode.ESCAPE: - nestedmenu.nestedmenu("hide"); + drilldown.drilldown("hide"); break; default: clearTimeout(menu.filterTimer);