From 2b8f0792ea0215eb9f855d6719fe363a4537c08d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 4 Apr 2012 14:59:00 +0200 Subject: [PATCH] Dropdowns are now exclusive --- wcfsetup/install/files/js/WCF.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index ff6827b825..96be903a56 100644 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -566,15 +566,20 @@ WCF.Dropdown = { * @param object event */ _toggle: function(event) { - console.debug($(event.currentTarget)); - console.debug($(event.currentTarget).data()); - var $dropdown = $('#' + $(event.currentTarget).data('toggle')).toggleClass('dropdownOpen'); - console.debug('Trying to toggle ' + $(event.currentTarget).data('toggle')); - if (!$dropdown.hasClass('dropdownOpen')) { - this._notifyCallbacks($dropdown, 'close'); - } - else { - this._notifyCallbacks($dropdown, 'open'); + var $target = $('#' + $(event.currentTarget).data('toggle')); + var $targetID = $target.wcfIdentify(); + + // close all dropdowns + for (var $containerID in this._dropdowns) { + var $dropdown = this._dropdowns[$containerID]; + if ($dropdown.hasClass('dropdownOpen')) { + $dropdown.removeClass('dropdownOpen'); + this._notifyCallbacks($dropdown, 'close'); + } + else if ($containerID === $targetID) { + $dropdown.addClass('dropdownOpen'); + this._notifyCallbacks($dropdown, 'open'); + } } event.stopPropagation(); -- 2.20.1