From: jzaefferer Date: Mon, 28 Feb 2011 21:53:06 +0000 (+0100) Subject: Menubar: Close menu on input click when already open X-Git-Tag: 1.9m5~247 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=58b730f7c7a2fa848eeab12c5b26736a102ed1a4;p=jquery-ui.git Menubar: Close menu on input click when already open --- diff --git a/tests/visual/menu/menubar.js b/tests/visual/menu/menubar.js index 57d9ee5de..afddd76a6 100644 --- a/tests/visual/menu/menubar.js +++ b/tests/visual/menu/menubar.js @@ -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("");