]> source.dussan.org Git - jquery-ui.git/commitdiff
Improved drilldown keyboard handling
authorjzaefferer <joern.zaefferer@gmail.com>
Wed, 24 Mar 2010 22:01:43 +0000 (18:01 -0400)
committerjzaefferer <joern.zaefferer@gmail.com>
Wed, 24 Mar 2010 22:01:43 +0000 (18:01 -0400)
tests/visual/menu/drilldown.html

index 78b8cf9f28e54650e6451e893e406172c861dc6b..a97d8322c272309876d78a154d9e2a0ea7a31d83 100644 (file)
@@ -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('<span class="ui-icon ui-icon-carat-1-e"></span>').end().filter(":first").show();      
                                        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("<div>Selected " + ui.item.text() + "</div>");
                        }
                });
                
-               $().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();
                                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();
                        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);