From: jzaefferer Date: Tue, 22 Feb 2011 14:14:12 +0000 (+0100) Subject: Menu: Overhauled menubar, again starting with Michael Lang's fork. Added X-Git-Tag: 1.9m5~295 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f8091f761cf3705087efc90cc09f74e5f83744bb;p=jquery-ui.git Menu: Overhauled menubar, again starting with Michael Lang's fork. Added working keyboard navigation, including nested menus. Still need to properly style the menu buttons, e.g. highlight the button of the currently open menu. --- diff --git a/tests/visual/menu/flyoutmenu.js b/tests/visual/menu/flyoutmenu.js index 8534c9462..54ee8bb67 100644 --- a/tests/visual/menu/flyoutmenu.js +++ b/tests/visual/menu/flyoutmenu.js @@ -34,14 +34,17 @@ $.widget("ui.flyoutmenu", { }).keydown(function(event) { if (self.element.is(":hidden")) return; - event.stopPropagation(); switch (event.keyCode) { case $.ui.keyCode.LEFT: - self.left(event); + if (self.left(event)) { + event.stopImmediatePropagation(); + } event.preventDefault(); break; case $.ui.keyCode.RIGHT: - self.right(event); + if (self.right(event)) { + event.stopImmediatePropagation(); + } event.preventDefault(); break; case $.ui.keyCode.ESCAPE: @@ -98,22 +101,18 @@ $.widget("ui.flyoutmenu", { at: "right top", of: this.activeItem }); - $(document).one("click", function() { - //clicking outside menu flyouts should close all flyouts - //$(document).find(".ui-menu-flyout").hide(); - }) }, _select: function(event) { event.stopPropagation(); // TODO make _select cancelable? this._trigger( "select", event, { item: this.activeItem } ); - //this.activate(event, this.element.children("li").first()); this.hide(); }, left: function(event) { var newItem = this.activeItem.parents("li").first(); if (newItem.length) { this.activate(event, newItem); + return true; } }, right: function(event) { @@ -121,6 +120,7 @@ $.widget("ui.flyoutmenu", { if (newItem.length) { this._open(newItem.parent()); this.activate(event, newItem); + return true; } }, activate: function(event, item) { @@ -135,12 +135,6 @@ $.widget("ui.flyoutmenu", { show: function() { this.active = this.element; this.element.show(); - if (this.element.hasClass("ui-menu-flyout")) { - $(document).one("click", function() { - //clicking outside menu flyouts should close all flyouts - //$(document).find(".ui-menu-flyout").hide(); - }) - } }, hide: function() { this.activeItem = this.element.children("li").first(); diff --git a/tests/visual/menu/menubar.html b/tests/visual/menu/menubar.html index d1fc58fa7..c49abb2da 100644 --- a/tests/visual/menu/menubar.html +++ b/tests/visual/menu/menubar.html @@ -10,7 +10,11 @@ + + + @@ -66,6 +49,7 @@ File