]> source.dussan.org Git - jquery-ui.git/commitdiff
Menubar: Close menu on input click when already open
authorjzaefferer <joern.zaefferer@gmail.com>
Mon, 28 Feb 2011 21:53:06 +0000 (22:53 +0100)
committerjzaefferer <joern.zaefferer@gmail.com>
Mon, 28 Feb 2011 21:53:06 +0000 (22:53 +0100)
tests/visual/menu/menubar.js

index 57d9ee5de155571324f63981c122495881204185..afddd76a6e79933471038e5cb4188e35f426b5d7 100644 (file)
@@ -49,13 +49,16 @@ $.widget("ui.menubar", {
                        var input = $(this),
                                   menu = input.next("ul");
                        
-                       input
-                          .bind("click focus mouseenter", function(event) {
+                       input.bind("click focus mouseenter", function(event) {
+                               event.preventDefault();
+                               event.stopPropagation();
+                               if (menu.is(":visible") && self.active && self.active[0] == menu[0]) {
+                                       self._close();
+                                       return;
+                               }
                                if (menu.length && (!/^mouse/.test(event.type) || self.active && self.active.is(":visible") )) {
                                        self._open(event, menu);
                                }
-                               event.preventDefault();
-                               event.stopPropagation();
                        })
                        .addClass("ui-button ui-widget ui-button-text-only ui-menubar-link")
                        .wrapInner("<span class='ui-button-text'></span>");