]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Add ui-state-active to active menu bar button
authorjzaefferer <joern.zaefferer@gmail.com>
Thu, 24 Feb 2011 21:57:44 +0000 (22:57 +0100)
committerjzaefferer <joern.zaefferer@gmail.com>
Thu, 24 Feb 2011 21:57:44 +0000 (22:57 +0100)
tests/visual/menu/menubar.html
tests/visual/menu/menubar.js

index d10b83aef3608a3cab2427459a089aa13a2eb156..180084edd2d4fab4a9f4ab2552f30bc09c957b0c 100644 (file)
@@ -1,4 +1,4 @@
-<!doctype html>
+<!DOCTYPE html>
 <html>
 <head>
        <title>Menu Visual Test: Default</title>
index f384668d4a26ad9cf184e827b1a7e52619cb66a9..0aadef94496e9c7f8d038bc53c131dadd497fc76 100644 (file)
@@ -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();
        },