From: Alexander Ebert Date: Wed, 4 Apr 2012 12:59:00 +0000 (+0200) Subject: Dropdowns are now exclusive X-Git-Tag: 2.0.0_Beta_1~1167^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2b8f0792ea0215eb9f855d6719fe363a4537c08d;p=GitHub%2FWoltLab%2FWCF.git Dropdowns are now exclusive --- 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();