From 105ef8b851756bb0345ee650a21797dd76c405d4 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 24 Feb 2011 22:57:44 +0100 Subject: [PATCH 1/2] Menu: Add ui-state-active to active menu bar button --- tests/visual/menu/menubar.html | 2 +- tests/visual/menu/menubar.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/visual/menu/menubar.html b/tests/visual/menu/menubar.html index d10b83aef..180084edd 100644 --- a/tests/visual/menu/menubar.html +++ b/tests/visual/menu/menubar.html @@ -1,4 +1,4 @@ - + Menu Visual Test: Default diff --git a/tests/visual/menu/menubar.js b/tests/visual/menu/menubar.js index f384668d4..0aadef944 100644 --- a/tests/visual/menu/menubar.js +++ b/tests/visual/menu/menubar.js @@ -13,7 +13,7 @@ $.widget("ui.menubar", { }, _create: function() { var self = this; - var items = this.element.children("button, a"); + var items = this.items = this.element.children("button, a"); var o = this.options; this.element.addClass('ui-menubar ui-widget-header ui-helper-clearfix'); @@ -69,17 +69,26 @@ $.widget("ui.menubar", { }); $(document).click(function(event) { - !$(event.target).closest(".ui-menubar").length && items.next("ul").hide(); + !$(event.target).closest(".ui-menubar").length && self._close(); }); }, + _close: function() { + this.items.next("ul").hide(); + this.items.removeClass("ui-state-active"); + }, + _open: function(event, menu) { - this.active && this.active.menu("closeAll").hide(); + if (this.active) { + this.active.menu("closeAll").hide(); + this.active.prev().removeClass("ui-state-active"); + } + var button = menu.prev().addClass("ui-state-active"); this.active = menu.show().position({ my: "left top", at: "left bottom", offset: "0 -1", - of: menu.prev() + of: button }).focus(); }, From 643e20ca3d1bba6b8b5f5761f8fa59aa3423ba09 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 24 Feb 2011 23:03:58 +0100 Subject: [PATCH 2/2] Menu: Optimize menu positioning in menubar --- tests/visual/menu/menubar.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/visual/menu/menubar.js b/tests/visual/menu/menubar.js index 0aadef944..cb7c87e0b 100644 --- a/tests/visual/menu/menubar.js +++ b/tests/visual/menu/menubar.js @@ -87,7 +87,6 @@ $.widget("ui.menubar", { this.active = menu.show().position({ my: "left top", at: "left bottom", - offset: "0 -1", of: button }).focus(); },