X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=samples%2Fplugins%2Ftoolbar%2Ftoolbar.html;h=8d231d94133baa1947cb45e0a30b008ccc9f10df;hp=6f0b044e546ddb0a2963f8e068fcc16b0261fbd1;hb=d330efeb22fbe5f5883c29ff0149f7b5a0040bbc;hpb=860af3c4bde9866c53d5123c57e3dc6166e0fe1e diff --git a/samples/plugins/toolbar/toolbar.html b/samples/plugins/toolbar/toolbar.html index 6f0b044..8d231d9 100644 --- a/samples/plugins/toolbar/toolbar.html +++ b/samples/plugins/toolbar/toolbar.html @@ -1,7 +1,7 @@ @@ -10,7 +10,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license - @@ -95,12 +94,14 @@ CKEDITOR.replace( 'textarea_id', { (function() { 'use strict'; + var buttonsNames; + CKEDITOR.config.extraPlugins = 'toolbar'; CKEDITOR.on( 'instanceReady', function( evt ) { var editor = evt.editor, editorCurrent = editor.name == 'editorCurrent', - defaultToolbar = !( editor.config.toolbar || editor.config.toolbarGroups ), + defaultToolbar = !( editor.config.toolbar || editor.config.toolbarGroups || editor.config.removeButtons ), pre = CKEDITOR.document.getById( editor.name + 'Cfg' ), output = ''; @@ -112,6 +113,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,12 +136,12 @@ 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. toolbar: null, toolbarGroups: null, + removeButtons: null, height: 100 } ); @@ -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; } })();