Fixed WCF.InlineEditor divider behavior
authorAlexander Ebert <ebert@woltlab.com>
Tue, 17 Jul 2012 18:35:58 +0000 (20:35 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 17 Jul 2012 18:35:58 +0000 (20:35 +0200)
The InlineEditor now longer appends divider if no previous items exist or the previous item was a divider.

wcfsetup/install/files/js/WCF.js

index d7889adc0e38f7417ac9b611340ed64ceced6b7e..29e23db4f1cc8b3aae242852cba8ec45b4ced0dd 100755 (executable)
@@ -4534,17 +4534,22 @@ WCF.InlineEditor = Class.extend({
                
                // validate options
                var $hasOptions = false;
+               var $lastElementType = '';
                for (var $i = 0, $length = this._options.length; $i < $length; $i++) {
                        var $option = this._options[$i];
                        
                        if ($option.optionName === 'divider') {
-                               $('<li class="dropdownDivider" />').appendTo(this._dropdowns[$elementID]);
+                               if ($lastElementType !== '' && $lastElementType !== 'divider') {
+                                       $('<li class="dropdownDivider" />').appendTo(this._dropdowns[$elementID]);
+                                       $lastElementType = $option.optionName;
+                               }
                        }
                        else if (this._validate($elementID, $option.optionName) || this._validateCallbacks($elementID, $option.optionName)) {
                                var $listItem = $('<li><span>' + $option.label + '</span></li>').appendTo(this._dropdowns[$elementID]);
                                $listItem.data('elementID', $elementID).data('optionName', $option.optionName).click($.proxy(this._click, this));
                                
                                $hasOptions = true;
+                               $lastElementType = $option.optionName;
                        }
                }