X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=samples%2Fplugins%2Ftoolbar%2Ftoolbar.html;h=6cf2ddf138f610d2a342daf6b324db30b398bdee;hb=aedb6521c23a81ccb889827a7ccc7b42eb93d14f;hp=631497594218a7f9766beffe978ee37e7b3709f1;hpb=4625dba05116026713fee9008dd93306be0d1553;p=ckeditor.git diff --git a/samples/plugins/toolbar/toolbar.html b/samples/plugins/toolbar/toolbar.html index 6314975..6cf2ddf 100644 --- a/samples/plugins/toolbar/toolbar.html +++ b/samples/plugins/toolbar/toolbar.html @@ -1,16 +1,15 @@ - Toolbar Configuration — CKEditor Sample + Toolbar Configuration — CKEditor Sample - @@ -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; } })(); @@ -192,7 +224,7 @@ CKEDITOR.replace( 'textarea_id', { CKEditor - The text editor for the Internet - http://ckeditor.com

- Copyright © 2003-2012, CKSource - Frederico + Copyright © 2003-2014, CKSource - Frederico Knabben. All rights reserved.