From f37d07f4dde92fb1bd1cc6a8719b6b7c65b97130 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 22 Feb 2012 12:04:47 +0100 Subject: [PATCH] =?utf8?q?Javascriptmen=C3=BC:=20Eventhandling=20korrigier?= =?utf8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Der originale Ansatz war Handler einfach an irgendwas dranzuklatschen, und durch neue zu ersetzen wenn sich ein State geändert hat. Jetzt gibts es 3 Handler, die einen Großteil der Aufgaben übernehmen: - changeMenuBarState (auf und zuklappen, bei Topmenü Klick) - hideSubMenus (bei Klick auf alles, was nicht changeMenuBarState triggert) - unsetMenuBarState (Klick auf alles was Menü unkonditional schließt) --- js/dhtmlsuite/menu-for-applications.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/dhtmlsuite/menu-for-applications.js b/js/dhtmlsuite/menu-for-applications.js index 2fd192a0e..0b849bd2e 100644 --- a/js/dhtmlsuite/menu-for-applications.js +++ b/js/dhtmlsuite/menu-for-applications.js @@ -2343,6 +2343,14 @@ DHTMLSuite.menuBar.prototype = { // }}} , unsetMenuBarState : function() { this.menuBarState = false }, + changeMenuBarState: function (target) { + var parentId = target.id.replace(/[^0-9]/gi,''); + this.menuBarState = !this.menuBarState; + this.hideSubMenus(); + if(this.menuBarState) { + this.__expandGroup(parentId); + } + }, // {{{ __setBasicEvents() /** * Set basic events for the menu widget. @@ -2352,9 +2360,12 @@ DHTMLSuite.menuBar.prototype = { */ __setBasicEvents : function() { - DHTMLSuite.commonObj.addEvent(document.documentElement,"click",this.hideSubMenus); var menu = this; - $(document).mousedown(function(){ menu.unsetMenuBarState(); }); + $('div.DHTMLSuite_menuBar_sub').click(function() { menu.hideSubMenus(); menu.unsetMenuBarState() }); + $('div.DHTMLSuite_menuBar_top > div > div[objectref!="0"]').click(function() { menu.changeMenuBarState(this) }); + $('div.DHTMLSuite_menuBar_top').click(function(e) { + if ($(e.target).attr('class') == 'DHTMLSuite_menuBar_top') { menu.hideSubMenus(); menu.unsetMenuBarState() } + }); $('#win1').load(function(){ $('#win1').contents().mousedown(function(){ menu.hideSubMenus(); -- 2.20.1