JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.3.1_full
[ckeditor.git] / samples / plugins / toolbar / toolbar.html
index 6f0b044..8d231d9 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE html>\r
 <!--\r
 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
+For licensing, see LICENSE.md or http://ckeditor.com/license\r
 -->\r
 <html>\r
 <head>\r
@@ -10,7 +10,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        <meta name="ckeditor-sample-name" content="Toolbar Configurations">\r
        <meta name="ckeditor-sample-group" content="Advanced Samples">\r
        <meta name="ckeditor-sample-description" content="Configuring CKEditor to display full or custom toolbar layout.">\r
-       <meta name="ckeditor-sample-isnew" content="1">\r
        <script src="../../../ckeditor.js"></script>\r
        <link href="../../../samples/sample.css" rel="stylesheet">\r
 </head>\r
@@ -95,12 +94,14 @@ CKEDITOR.replace( <em>'textarea_id'</em>, {
 (function() {\r
        'use strict';\r
 \r
+       var buttonsNames;\r
+\r
        CKEDITOR.config.extraPlugins = 'toolbar';\r
 \r
        CKEDITOR.on( 'instanceReady', function( evt ) {\r
                var editor = evt.editor,\r
                        editorCurrent = editor.name == 'editorCurrent',\r
-                       defaultToolbar = !( editor.config.toolbar || editor.config.toolbarGroups ),\r
+                       defaultToolbar = !( editor.config.toolbar || editor.config.toolbarGroups || editor.config.removeButtons ),\r
                        pre = CKEDITOR.document.getById( editor.name + 'Cfg' ),\r
                        output = '';\r
 \r
@@ -112,6 +113,9 @@ CKEDITOR.replace( <em>'textarea_id'</em>, {
                                return;\r
                }\r
 \r
+               if ( !buttonsNames )\r
+                       buttonsNames = createButtonsNamesHash( editor.ui.items );\r
+\r
                // Toolbar isn't set explicitly, so it was created automatically from toolbarGroups.\r
                if ( !editor.config.toolbar ) {\r
                        output +=\r
@@ -132,12 +136,12 @@ CKEDITOR.replace( <em>'textarea_id'</em>, {
                CKEDITOR.dom.element.createFromHtml( preOutput ).replace( pre );\r
        } );\r
 \r
-\r
        CKEDITOR.replace( 'editorCurrent', { height: 100 } );\r
        CKEDITOR.replace( 'editorFull', {\r
                // Reset toolbar settings, so full toolbar will be generated automatically.\r
                toolbar: null,\r
                toolbarGroups: null,\r
+               removeButtons: null,\r
                height: 100\r
        } );\r
 \r
@@ -180,7 +184,35 @@ CKEDITOR.replace( <em>'textarea_id'</em>, {
        function dumpToolbarItems( items ) {\r
                if ( typeof items == 'string' )\r
                        return '\'' + items + '\'';\r
-               return '[ \'' + items.join( '\', \'' ) + '\' ]';\r
+\r
+               var names = [],\r
+                       i, item;\r
+\r
+               for ( var i = 0; i < items.length; ++i ) {\r
+                       item = items[ i ];\r
+                       if ( typeof item == 'string' )\r
+                               names.push( item );\r
+                       else {\r
+                               if ( item.type == CKEDITOR.UI_SEPARATOR )\r
+                                       names.push( '-' );\r
+                               else\r
+                                       names.push( buttonsNames[ item.name ] );\r
+                       }\r
+               }\r
+\r
+               return '[ \'' + names.join( '\', \'' ) + '\' ]';\r
+       }\r
+\r
+       // Creates { 'lowercased': 'LowerCased' } buttons names hash.\r
+       function createButtonsNamesHash( items ) {\r
+               var hash = {},\r
+                       name;\r
+\r
+               for ( name in items ) {\r
+                       hash[ items[ name ].name ] = name;\r
+               }\r
+\r
+               return hash;\r
        }\r
 \r
 })();\r