Improved display of button dropdowns
authorAlexander Ebert <ebert@woltlab.com>
Thu, 21 Jan 2016 12:27:45 +0000 (13:27 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 21 Jan 2016 12:27:45 +0000 (13:27 +0100)
wcfsetup/install/files/js/WCF.js

index 6df5cb2e6c1b4af5fe6fb214e55042b3fd254db7..e8727cd30471b56345aa302628b0d822ba8ef77e 100755 (executable)
@@ -6047,7 +6047,16 @@ WCF.InlineEditor = Class.extend({
                // build dropdown
                var $trigger = null;
                if (!this._dropdowns[$elementID]) {
-                       this._triggerElements[$elementID] = $trigger = this._getTriggerElement(this._elements[$elementID]).addClass('dropdownToggle').wrap('<span class="dropdown" />');
+                       this._triggerElements[$elementID] = $trigger = this._getTriggerElement(this._elements[$elementID]).addClass('dropdownToggle');
+                       var parent = $trigger[0].parentNode;
+                       if (parent && parent.nodeName === 'LI' && parent.childElementCount === 1) {
+                               // do not add a wrapper element if the trigger is the only child
+                               parent.classList.add('dropdown');
+                       }
+                       else {
+                               $trigger.wrap('<span class="dropdown" />');
+                       }
+                       
                        this._dropdowns[$elementID] = $('<ul class="dropdownMenu" />').insertAfter($trigger);
                }
                this._dropdowns[$elementID].empty();