Dropdowns are now exclusive
authorAlexander Ebert <ebert@woltlab.com>
Wed, 4 Apr 2012 12:59:00 +0000 (14:59 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 4 Apr 2012 12:59:00 +0000 (14:59 +0200)
wcfsetup/install/files/js/WCF.js

index ff6827b825d869d2fc05304a0c8bac2268c061a8..96be903a56ce0f4fe42561c804ea3176d1a3cfb7 100644 (file)
@@ -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();