Index: branches/5.3.x/core/admin_templates/js/toolbar.js =================================================================== diff -u -N -r15483 -r15902 --- branches/5.3.x/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 15483) +++ branches/5.3.x/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 15902) @@ -317,20 +317,36 @@ ToolBar.prototype._removeSeparators = function() { - // TODO: find a way to cut first and last separators from non-indexed array, like $new_buttons. - var $separator = false; - var $new_buttons = {}; + var $i, $buttons = [], $separator = false; - for (var $button_title in this.Buttons) { - if ($separator && this.Buttons[$button_title].Separator) { - continue; + // 1. convert to 0-based array && filter out trailing separators from the middle + $.each(this.Buttons, function ($button_title, $button) { + if ( $separator && $button.Separator ) { + // duplicate separator - skip + return true; } - $separator = this.Buttons[$button_title].Separator; - $new_buttons[$button_title] = this.Buttons[$button_title]; + // remember separator status + $buttons.push($button); + $separator = $button.Separator; + }); + + // 2. remove first separator + if ( $buttons.length && $buttons[0].Separator ) { + $buttons.shift(); } - this.Buttons = $new_buttons; + // 3. remove last separator + if ( $buttons.length && $buttons[$buttons.length - 1].Separator ) { + $buttons.pop(); + } + + // 4. convert to associative array + this.Buttons = {}; + + for ($i = 0; $i < $buttons.length; $i++) { + this.Buttons[$buttons[$i].Title] = $buttons[$i]; + } } ToolBar.prototype.Render = function($container)