X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=samples%2Fplugins%2Ftoolbar%2Ftoolbar.html;h=b0f7179a3c04f47f575e09fe11756086e627d7fb;hb=9ff13aaba26bcf5e5315d53a58465507b3c44196;hp=6f0b044e546ddb0a2963f8e068fcc16b0261fbd1;hpb=bbcc7027149eeec7493a43022d1de04081346667;p=ckeditor.git
diff --git a/samples/plugins/toolbar/toolbar.html b/samples/plugins/toolbar/toolbar.html
index 6f0b044..b0f7179 100644
--- a/samples/plugins/toolbar/toolbar.html
+++ b/samples/plugins/toolbar/toolbar.html
@@ -95,6 +95,8 @@ CKEDITOR.replace( 'textarea_id', {
(function() {
'use strict';
+ var buttonsNames;
+
CKEDITOR.config.extraPlugins = 'toolbar';
CKEDITOR.on( 'instanceReady', function( evt ) {
@@ -112,6 +114,9 @@ CKEDITOR.replace( 'textarea_id', {
return;
}
+ if ( !buttonsNames )
+ buttonsNames = createButtonsNamesHash( editor.ui.items );
+
// Toolbar isn't set explicitly, so it was created automatically from toolbarGroups.
if ( !editor.config.toolbar ) {
output +=
@@ -132,7 +137,6 @@ CKEDITOR.replace( 'textarea_id', {
CKEDITOR.dom.element.createFromHtml( preOutput ).replace( pre );
} );
-
CKEDITOR.replace( 'editorCurrent', { height: 100 } );
CKEDITOR.replace( 'editorFull', {
// Reset toolbar settings, so full toolbar will be generated automatically.
@@ -180,7 +184,35 @@ CKEDITOR.replace( 'textarea_id', {
function dumpToolbarItems( items ) {
if ( typeof items == 'string' )
return '\'' + items + '\'';
- return '[ \'' + items.join( '\', \'' ) + '\' ]';
+
+ var names = [],
+ i, item;
+
+ for ( var i = 0; i < items.length; ++i ) {
+ item = items[ i ];
+ if ( typeof item == 'string' )
+ names.push( item );
+ else {
+ if ( item.type == CKEDITOR.UI_SEPARATOR )
+ names.push( '-' );
+ else
+ names.push( buttonsNames[ item.name ] );
+ }
+ }
+
+ return '[ \'' + names.join( '\', \'' ) + '\' ]';
+ }
+
+ // Creates { 'lowercased': 'LowerCased' } buttons names hash.
+ function createButtonsNamesHash( items ) {
+ var hash = {},
+ name;
+
+ for ( name in items ) {
+ hash[ items[ name ].name ] = name;
+ }
+
+ return hash;
}
})();