Skip to content

Commit df9e850

Browse files
committed
Merge branch 't/10010' into major
2 parents 7754ef7 + a54fd1f commit df9e850

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

plugins/toolbar/samples/toolbar.html

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ <h2 class="samples">Full toolbar configuration</h2>
9595
(function() {
9696
'use strict';
9797

98+
var buttonsNames;
99+
98100
CKEDITOR.config.extraPlugins = 'toolbar';
99101

100102
CKEDITOR.on( 'instanceReady', function( evt ) {
@@ -112,6 +114,9 @@ <h2 class="samples">Full toolbar configuration</h2>
112114
return;
113115
}
114116

117+
if ( !buttonsNames )
118+
buttonsNames = createButtonsNamesHash( editor.ui.items );
119+
115120
// Toolbar isn't set explicitly, so it was created automatically from toolbarGroups.
116121
if ( !editor.config.toolbar ) {
117122
output +=
@@ -132,7 +137,6 @@ <h2 class="samples">Full toolbar configuration</h2>
132137
CKEDITOR.dom.element.createFromHtml( preOutput ).replace( pre );
133138
} );
134139

135-
136140
CKEDITOR.replace( 'editorCurrent', { height: 100 } );
137141
CKEDITOR.replace( 'editorFull', {
138142
// Reset toolbar settings, so full toolbar will be generated automatically.
@@ -180,7 +184,35 @@ <h2 class="samples">Full toolbar configuration</h2>
180184
function dumpToolbarItems( items ) {
181185
if ( typeof items == 'string' )
182186
return '\'' + items + '\'';
183-
return '[ \'' + items.join( '\', \'' ) + '\' ]';
187+
188+
var names = [],
189+
i, item;
190+
191+
for ( var i = 0; i < items.length; ++i ) {
192+
item = items[ i ];
193+
if ( typeof item == 'string' )
194+
names.push( item );
195+
else {
196+
if ( item.type == CKEDITOR.UI_SEPARATOR )
197+
names.push( '-' );
198+
else
199+
names.push( buttonsNames[ item.name ] );
200+
}
201+
}
202+
203+
return '[ \'' + names.join( '\', \'' ) + '\' ]';
204+
}
205+
206+
// Creates { 'lowercased': 'LowerCased' } buttons names hash.
207+
function createButtonsNamesHash( items ) {
208+
var hash = {},
209+
name;
210+
211+
for ( name in items ) {
212+
hash[ items[ name ].name ] = name;
213+
}
214+
215+
return hash;
184216
}
185217

186218
})();

0 commit comments

Comments
 (0)