Fixed a few issues with the recent dropdown changes
authorAlexander Ebert <ebert@woltlab.com>
Sat, 25 May 2013 15:44:41 +0000 (17:44 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 25 May 2013 15:44:41 +0000 (17:44 +0200)
wcfsetup/install/files/js/WCF.Label.js
wcfsetup/install/files/js/WCF.Message.js
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/style/dropdown.less
wcfsetup/install/files/style/message.less

index 23d3eb39a25f90e93f9e6ece15a8858aca9d32d2..c0093ab92235acf52ce027e73a82a5f7ed130cd6 100644 (file)
@@ -139,7 +139,7 @@ WCF.Label.Chooser = Class.extend({
                // pre-select labels
                if ($.getLength(selectedLabelIDs)) {
                        for (var $groupID in selectedLabelIDs) {
-                               this._groups[$groupID].find('.dropdownMenu > li').each($.proxy(function(index, label) {
+                               WCF.Dropdown.getDropdownMenu(this._groups[$groupID].wcfIdentify()).children('li').each($.proxy(function(index, label) {
                                        var $label = $(label);
                                        var $labelID = $label.data('labelID') || 0;
                                        if ($labelID && selectedLabelIDs[$groupID] == $labelID) {
@@ -178,19 +178,19 @@ WCF.Label.Chooser = Class.extend({
                        
                        if (!this._groups[$groupID]) {
                                this._groups[$groupID] = $group;
-                               var $dropdownMenu = $group.find('.dropdownMenu');
-                               $dropdownMenu.find('li').click($.proxy(this._click, this));
+                               var $dropdownMenu = WCF.Dropdown.getDropdownMenu($group.wcfIdentify());
+                               $dropdownMenu.children('li').data('groupID', $groupID).click($.proxy(this._click, this));
                                
                                if (!$group.data('forceSelection') || this._showWithoutSelection) {
                                        $('<li class="dropdownDivider" />').appendTo($dropdownMenu);
                                }
                                
                                if (this._showWithoutSelection) {
-                                       $('<li data-label-id="-1"><span><span class="badge label">' + WCF.Language.get('wcf.label.withoutSelection') + '</span></span></li>').appendTo($dropdownMenu).click($.proxy(this._click, this));
+                                       $('<li data-label-id="-1"><span><span class="badge label">' + WCF.Language.get('wcf.label.withoutSelection') + '</span></span></li>').data('groupID', $groupID).appendTo($dropdownMenu).click($.proxy(this._click, this));
                                }
                                
                                if (!$group.data('forceSelection')) {
-                                       var $buttonEmpty = $('<li data-label-id="0"><span><span class="badge label">' + WCF.Language.get('wcf.label.none') + '</span></span></li>').appendTo($dropdownMenu);
+                                       var $buttonEmpty = $('<li data-label-id="0"><span><span class="badge label">' + WCF.Language.get('wcf.label.none') + '</span></span></li>').data('groupID', $groupID).appendTo($dropdownMenu);
                                        $buttonEmpty.click($.proxy(this._click, this));
                                }
                        }
@@ -213,7 +213,7 @@ WCF.Label.Chooser = Class.extend({
         * @param       boolean         onInit
         */
        _selectLabel: function(label, onInit) {
-               var $group = label.parents('.dropdown');
+               var $group = this._groups[label.data('groupID')];
                
                // already initialized, ignore
                if (onInit && $group.data('labelID') !== undefined) {
index 41eddba791e595ddb78f215eb1ad5ac78f6ea8c6..676d7bf4ef5694d9ce439c1a631b07fbd9502a6d 100644 (file)
@@ -1163,11 +1163,11 @@ WCF.Message.InlineEditor = Class.extend({
        /**
         * Forces message options to stay visible if toggling dropdown menu.
         * 
-        * @param       jQuery          dropdown
+        * @param       string          containerID
         * @param       string          action
         */
-       _toggleDropdown: function(dropdown, action) {
-               dropdown.parents('.messageOptions').toggleClass('forceOpen');
+       _toggleDropdown: function(containerID, action) {
+               WCF.Dropdown.getDropdown(containerID).parents('.messageOptions').toggleClass('forceOpen');
        },
        
        /**
index a20904860f7e0844fe8936a31ec204e3c18fe8af..560f5d870686be784c73788b5e793acceb934b85 100755 (executable)
@@ -756,6 +756,24 @@ WCF.Dropdown = {
                }
        },
        
+       /**
+        * Initializes a dropdown fragment which behaves like a usual dropdown
+        * but is not controlled by a trigger element.
+        * 
+        * @param       jQuery          dropdown
+        * @param       jQuery          dropdownMenu
+        */
+       initDropdownFragment: function(dropdown, dropdownMenu) {
+               var $containerID = dropdown.wcfIdentify();
+               if (this._dropdowns[$containerID]) {
+                       console.debug("[WCF.Dropdown] Cannot register dropdown identified by '" + $containerID + "' as a fragement.");
+                       return;
+               }
+               
+               this._dropdowns[$containerID] = dropdown;
+               this._menus[$containerID] = dropdownMenu.detach().appendTo(this._menuContainer);
+       },
+       
        /**
         * Registers a callback notified upon dropdown state change.
         * 
@@ -805,8 +823,10 @@ WCF.Dropdown = {
                        }
                }
                
-               event.stopPropagation();
-               return false;
+               if (event !== null) {
+                       event.stopPropagation();
+                       return false;
+               }
        },
        
        /**
@@ -5208,6 +5228,8 @@ WCF.Search.Base = Class.extend({
                }
                
                this._searchInput.blur($.proxy(this._blur, this));
+               
+               WCF.Dropdown.initDropdownFragment(this._searchInput.parent(), this._list);
        },
        
        /**
index a70af791f00b4b4e57d5c52387360d0e33b6d3c6..56ccedc1ead409381f693a99edab5f594e1ded3d 100644 (file)
        padding: 4px 0;
        position: absolute;
        text-align: left;
-       z-index: 350;
+       z-index: 450;
        
        .boxShadow(2px, 2px, rgba(0, 0, 0, .2), 10px);
        
index 494417e07fd5d94a802b78bf9eddc92a0db82977..ba7a862a5a95ffc55c4188224166ec0609c355ea 100644 (file)
                position: relative;
                
                &.forceHidden nav {
-                       opacity: 0 !important;
+                       display: none !important;
                }
                
                &.forceOpen nav {