JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.0_full
[ckeditor.git] / _source / plugins / toolbar / plugin.js
diff --git a/_source/plugins/toolbar/plugin.js b/_source/plugins/toolbar/plugin.js
deleted file mode 100644 (file)
index a6cd8d0..0000000
+++ /dev/null
@@ -1,546 +0,0 @@
-/*\r
-Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-/**\r
- * @fileOverview The "toolbar" plugin. Renders the default toolbar interface in\r
- * the editor.\r
- */\r
-\r
-(function()\r
-{\r
-       var toolbox = function()\r
-       {\r
-               this.toolbars = [];\r
-               this.focusCommandExecuted = false;\r
-       };\r
-\r
-       toolbox.prototype.focus = function()\r
-       {\r
-               for ( var t = 0, toolbar ; toolbar = this.toolbars[ t++ ] ; )\r
-               {\r
-                       for ( var i = 0, item ; item = toolbar.items[ i++ ] ; )\r
-                       {\r
-                               if ( item.focus )\r
-                               {\r
-                                       item.focus();\r
-                                       return;\r
-                               }\r
-                       }\r
-               }\r
-       };\r
-\r
-       var commands =\r
-       {\r
-               toolbarFocus :\r
-               {\r
-                       modes : { wysiwyg : 1, source : 1 },\r
-                       readOnly : 1,\r
-\r
-                       exec : function( editor )\r
-                       {\r
-                               if ( editor.toolbox )\r
-                               {\r
-                                       editor.toolbox.focusCommandExecuted = true;\r
-\r
-                                       // Make the first button focus accessible for IE. (#3417)\r
-                                       // Adobe AIR instead need while of delay.\r
-                                       if ( CKEDITOR.env.ie || CKEDITOR.env.air )\r
-                                               setTimeout( function(){ editor.toolbox.focus(); }, 100 );\r
-                                       else\r
-                                               editor.toolbox.focus();\r
-                               }\r
-                       }\r
-               }\r
-       };\r
-\r
-       CKEDITOR.plugins.add( 'toolbar',\r
-       {\r
-               requires : [ 'button' ],\r
-               init : function( editor )\r
-               {\r
-                       var endFlag;\r
-\r
-                       var itemKeystroke = function( item, keystroke )\r
-                       {\r
-                               var next, toolbar;\r
-                               var rtl = editor.lang.dir == 'rtl',\r
-                                       toolbarGroupCycling = editor.config.toolbarGroupCycling;\r
-\r
-                               toolbarGroupCycling = toolbarGroupCycling === undefined || toolbarGroupCycling;\r
-\r
-                               switch ( keystroke )\r
-                               {\r
-                                       case 9 :                                        // TAB\r
-                                       case CKEDITOR.SHIFT + 9 :       // SHIFT + TAB\r
-                                               // Cycle through the toolbars, starting from the one\r
-                                               // closest to the current item.\r
-                                               while ( !toolbar || !toolbar.items.length )\r
-                                               {\r
-                                                       toolbar = keystroke == 9 ?\r
-                                                               ( ( toolbar ? toolbar.next : item.toolbar.next ) || editor.toolbox.toolbars[ 0 ] ) :\r
-                                                               ( ( toolbar ? toolbar.previous : item.toolbar.previous ) || editor.toolbox.toolbars[ editor.toolbox.toolbars.length - 1 ] );\r
-\r
-                                                       // Look for the first item that accepts focus.\r
-                                                       if ( toolbar.items.length )\r
-                                                       {\r
-                                                               item = toolbar.items[ endFlag ? ( toolbar.items.length - 1 ) : 0 ];\r
-                                                               while ( item && !item.focus )\r
-                                                               {\r
-                                                                       item = endFlag ? item.previous : item.next;\r
-\r
-                                                                       if ( !item )\r
-                                                                               toolbar = 0;\r
-                                                               }\r
-                                                       }\r
-                                               }\r
-\r
-                                               if ( item )\r
-                                                       item.focus();\r
-\r
-                                               return false;\r
-\r
-                                       case rtl ? 37 : 39 :            // RIGHT-ARROW\r
-                                       case 40 :                                       // DOWN-ARROW\r
-                                               next = item;\r
-                                               do\r
-                                               {\r
-                                                       // Look for the next item in the toolbar.\r
-                                                       next = next.next;\r
-\r
-                                                       // If it's the last item, cycle to the first one.\r
-                                                       if ( !next && toolbarGroupCycling )\r
-                                                               next = item.toolbar.items[ 0 ];\r
-                                               }\r
-                                               while ( next && !next.focus )\r
-\r
-                                               // If available, just focus it, otherwise focus the\r
-                                               // first one.\r
-                                               if ( next )\r
-                                                       next.focus();\r
-                                               else\r
-                                                       // Send a TAB.\r
-                                                       itemKeystroke( item, 9 );\r
-\r
-                                               return false;\r
-\r
-                                       case rtl ? 39 : 37 :            // LEFT-ARROW\r
-                                       case 38 :                                       // UP-ARROW\r
-                                               next = item;\r
-                                               do\r
-                                               {\r
-                                                       // Look for the previous item in the toolbar.\r
-                                                       next = next.previous;\r
-\r
-                                                       // If it's the first item, cycle to the last one.\r
-                                                       if ( !next && toolbarGroupCycling )\r
-                                                               next = item.toolbar.items[ item.toolbar.items.length - 1 ];\r
-                                               }\r
-                                               while ( next && !next.focus )\r
-\r
-                                               // If available, just focus it, otherwise focus the\r
-                                               // last one.\r
-                                               if ( next )\r
-                                                       next.focus();\r
-                                               else\r
-                                               {\r
-                                                       endFlag = 1;\r
-                                                       // Send a SHIFT + TAB.\r
-                                                       itemKeystroke( item, CKEDITOR.SHIFT + 9 );\r
-                                                       endFlag = 0;\r
-                                               }\r
-\r
-                                               return false;\r
-\r
-                                       case 27 :                                       // ESC\r
-                                               editor.focus();\r
-                                               return false;\r
-\r
-                                       case 13 :                                       // ENTER\r
-                                       case 32 :                                       // SPACE\r
-                                               item.execute();\r
-                                               return false;\r
-                               }\r
-                               return true;\r
-                       };\r
-\r
-                       editor.on( 'themeSpace', function( event )\r
-                               {\r
-                                       if ( event.data.space == editor.config.toolbarLocation )\r
-                                       {\r
-                                               editor.toolbox = new toolbox();\r
-\r
-                                               var labelId = CKEDITOR.tools.getNextId();\r
-\r
-                                               var output = [ '<div class="cke_toolbox" role="group" aria-labelledby="', labelId, '" onmousedown="return false;"' ],\r
-                                                       expanded =  editor.config.toolbarStartupExpanded !== false,\r
-                                                       groupStarted;\r
-\r
-                                               output.push( expanded ? '>' : ' style="display:none">' );\r
-\r
-                                               // Sends the ARIA label.\r
-                                               output.push( '<span id="', labelId, '" class="cke_voice_label">', editor.lang.toolbars, '</span>' );\r
-\r
-                                               var toolbars = editor.toolbox.toolbars,\r
-                                                       toolbar =\r
-                                                                       ( editor.config.toolbar instanceof Array ) ?\r
-                                                                               editor.config.toolbar\r
-                                                                       :\r
-                                                                               editor.config[ 'toolbar_' + editor.config.toolbar ];\r
-\r
-                                               for ( var r = 0 ; r < toolbar.length ; r++ )\r
-                                               {\r
-                                                       var toolbarId,\r
-                                                               toolbarObj = 0,\r
-                                                               toolbarName,\r
-                                                               row = toolbar[ r ],\r
-                                                               items;\r
-\r
-                                                       // It's better to check if the row object is really\r
-                                                       // available because it's a common mistake to leave\r
-                                                       // an extra comma in the toolbar definition\r
-                                                       // settings, which leads on the editor not loading\r
-                                                       // at all in IE. (#3983)\r
-                                                       if ( !row )\r
-                                                               continue;\r
-\r
-                                                       if ( groupStarted )\r
-                                                       {\r
-                                                               output.push( '</div>' );\r
-                                                               groupStarted = 0;\r
-                                                       }\r
-\r
-                                                       if ( row === '/' )\r
-                                                       {\r
-                                                               output.push( '<div class="cke_break"></div>' );\r
-                                                               continue;\r
-                                                       }\r
-\r
-                                                       items = row.items || row;\r
-\r
-                                                       // Create all items defined for this toolbar.\r
-                                                       for ( var i = 0 ; i < items.length ; i++ )\r
-                                                       {\r
-                                                               var item,\r
-                                                                       itemName = items[ i ],\r
-                                                                       canGroup;\r
-\r
-                                                               item = editor.ui.create( itemName );\r
-\r
-                                                               if ( item )\r
-                                                               {\r
-                                                                       canGroup = item.canGroup !== false;\r
-\r
-                                                                       // Initialize the toolbar first, if needed.\r
-                                                                       if ( !toolbarObj )\r
-                                                                       {\r
-                                                                               // Create the basic toolbar object.\r
-                                                                               toolbarId = CKEDITOR.tools.getNextId();\r
-                                                                               toolbarObj = { id : toolbarId, items : [] };\r
-                                                                               toolbarName = row.name && ( editor.lang.toolbarGroups[ row.name ] || row.name );\r
-\r
-                                                                               // Output the toolbar opener.\r
-                                                                               output.push( '<span id="', toolbarId, '" class="cke_toolbar"',\r
-                                                                                       ( toolbarName ? ' aria-labelledby="'+ toolbarId +  '_label"' : '' ),\r
-                                                                                       ' role="toolbar">' );\r
-\r
-                                                                               // If a toolbar name is available, send the voice label.\r
-                                                                               toolbarName && output.push( '<span id="', toolbarId, '_label" class="cke_voice_label">', toolbarName, '</span>' );\r
-\r
-                                                                               output.push( '<span class="cke_toolbar_start"></span>' );\r
-\r
-                                                                               // Add the toolbar to the "editor.toolbox.toolbars"\r
-                                                                               // array.\r
-                                                                               var index = toolbars.push( toolbarObj ) - 1;\r
-\r
-                                                                               // Create the next/previous reference.\r
-                                                                               if ( index > 0 )\r
-                                                                               {\r
-                                                                                       toolbarObj.previous = toolbars[ index - 1 ];\r
-                                                                                       toolbarObj.previous.next = toolbarObj;\r
-                                                                               }\r
-                                                                       }\r
-\r
-                                                                       if ( canGroup )\r
-                                                                       {\r
-                                                                               if ( !groupStarted )\r
-                                                                               {\r
-                                                                                       output.push( '<span class="cke_toolgroup" role="presentation">' );\r
-                                                                                       groupStarted = 1;\r
-                                                                               }\r
-                                                                       }\r
-                                                                       else if ( groupStarted )\r
-                                                                       {\r
-                                                                               output.push( '</span>' );\r
-                                                                               groupStarted = 0;\r
-                                                                       }\r
-\r
-                                                                       var itemObj = item.render( editor, output );\r
-                                                                       index = toolbarObj.items.push( itemObj ) - 1;\r
-\r
-                                                                       if ( index > 0 )\r
-                                                                       {\r
-                                                                               itemObj.previous = toolbarObj.items[ index - 1 ];\r
-                                                                               itemObj.previous.next = itemObj;\r
-                                                                       }\r
-\r
-                                                                       itemObj.toolbar = toolbarObj;\r
-                                                                       itemObj.onkey = itemKeystroke;\r
-\r
-                                                                       /*\r
-                                                                        * Fix for #3052:\r
-                                                                        * Prevent JAWS from focusing the toolbar after document load.\r
-                                                                        */\r
-                                                                       itemObj.onfocus = function()\r
-                                                                       {\r
-                                                                               if ( !editor.toolbox.focusCommandExecuted )\r
-                                                                                       editor.focus();\r
-                                                                       };\r
-                                                               }\r
-                                                       }\r
-\r
-                                                       if ( groupStarted )\r
-                                                       {\r
-                                                               output.push( '</span>' );\r
-                                                               groupStarted = 0;\r
-                                                       }\r
-\r
-                                                       if ( toolbarObj )\r
-                                                               output.push( '<span class="cke_toolbar_end"></span></span>' );\r
-                                               }\r
-\r
-                                               output.push( '</div>' );\r
-\r
-                                               if ( editor.config.toolbarCanCollapse )\r
-                                               {\r
-                                                       var collapserFn = CKEDITOR.tools.addFunction(\r
-                                                               function()\r
-                                                               {\r
-                                                                       editor.execCommand( 'toolbarCollapse' );\r
-                                                               });\r
-\r
-                                                       editor.on( 'destroy', function () {\r
-                                                                       CKEDITOR.tools.removeFunction( collapserFn );\r
-                                                               });\r
-\r
-                                                       var collapserId = CKEDITOR.tools.getNextId();\r
-\r
-                                                       editor.addCommand( 'toolbarCollapse',\r
-                                                               {\r
-                                                                       readOnly : 1,\r
-                                                                       exec : function( editor )\r
-                                                                       {\r
-                                                                               var collapser = CKEDITOR.document.getById( collapserId ),\r
-                                                                                       toolbox = collapser.getPrevious(),\r
-                                                                                       contents = editor.getThemeSpace( 'contents' ),\r
-                                                                                       toolboxContainer = toolbox.getParent(),\r
-                                                                                       contentHeight = parseInt( contents.$.style.height, 10 ),\r
-                                                                                       previousHeight = toolboxContainer.$.offsetHeight,\r
-                                                                                       collapsed = !toolbox.isVisible();\r
-\r
-                                                                               if ( !collapsed )\r
-                                                                               {\r
-                                                                                       toolbox.hide();\r
-                                                                                       collapser.addClass( 'cke_toolbox_collapser_min' );\r
-                                                                                       collapser.setAttribute( 'title', editor.lang.toolbarExpand );\r
-                                                                               }\r
-                                                                               else\r
-                                                                               {\r
-                                                                                       toolbox.show();\r
-                                                                                       collapser.removeClass( 'cke_toolbox_collapser_min' );\r
-                                                                                       collapser.setAttribute( 'title', editor.lang.toolbarCollapse );\r
-                                                                               }\r
-\r
-                                                                               // Update collapser symbol.\r
-                                                                               collapser.getFirst().setText( collapsed ?\r
-                                                                                       '\u25B2' :              // BLACK UP-POINTING TRIANGLE\r
-                                                                                       '\u25C0' );             // BLACK LEFT-POINTING TRIANGLE\r
-\r
-                                                                               var dy = toolboxContainer.$.offsetHeight - previousHeight;\r
-                                                                               contents.setStyle( 'height', ( contentHeight - dy ) + 'px' );\r
-\r
-                                                                               editor.fire( 'resize' );\r
-                                                                       },\r
-\r
-                                                                       modes : { wysiwyg : 1, source : 1 }\r
-                                                               } );\r
-\r
-                                                       output.push( '<a title="' + ( expanded ? editor.lang.toolbarCollapse : editor.lang.toolbarExpand )\r
-                                                                                                         + '" id="' + collapserId + '" tabIndex="-1" class="cke_toolbox_collapser' );\r
-\r
-                                                       if ( !expanded )\r
-                                                               output.push( ' cke_toolbox_collapser_min' );\r
-\r
-                                                       output.push( '" onclick="CKEDITOR.tools.callFunction(' + collapserFn + ')">',\r
-                                                                               '<span>&#9650;</span>',         // BLACK UP-POINTING TRIANGLE\r
-                                                                               '</a>' );\r
-                                               }\r
-\r
-                                               event.data.html += output.join( '' );\r
-                                       }\r
-                               });\r
-\r
-                       editor.on( 'destroy', function()\r
-                       {\r
-                               var toolbars, index = 0, i,\r
-                                               items, instance;\r
-                               toolbars = this.toolbox.toolbars;\r
-                               for ( ; index < toolbars.length; index++ )\r
-                               {\r
-                                       items = toolbars[ index ].items;\r
-                                       for ( i = 0; i < items.length; i++ )\r
-                                       {\r
-                                               instance = items[ i ];\r
-                                               if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );\r
-                                               if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );\r
-                                       }\r
-                               }\r
-                       });\r
-\r
-                       editor.addCommand( 'toolbarFocus', commands.toolbarFocus );\r
-\r
-                       editor.ui.add( '-', CKEDITOR.UI_SEPARATOR, {} );\r
-                       editor.ui.addHandler( CKEDITOR.UI_SEPARATOR,\r
-                       {\r
-                               create: function()\r
-                               {\r
-                                       return {\r
-                                               render : function( editor, output )\r
-                                               {\r
-                                                       output.push( '<span class="cke_separator" role="separator"></span>' );\r
-                                                       return {};\r
-                                               }\r
-                                       };\r
-                               }\r
-                       });\r
-               }\r
-       });\r
-})();\r
-\r
-CKEDITOR.UI_SEPARATOR = 'separator';\r
-\r
-/**\r
- * The "theme space" to which rendering the toolbar. For the default theme,\r
- * the recommended options are "top" and "bottom".\r
- * @type String\r
- * @default 'top'\r
- * @see CKEDITOR.config.theme\r
- * @example\r
- * config.toolbarLocation = 'bottom';\r
- */\r
-CKEDITOR.config.toolbarLocation = 'top';\r
-\r
-/**\r
- * The toolbar definition. It is an array of toolbars (strips),\r
- * each one being also an array, containing a list of UI items.\r
- * Note that this setting is composed by "toolbar_" added by the toolbar name,\r
- * which in this case is called "Basic". This second part of the setting name\r
- * can be anything. You must use this name in the\r
- * {@link CKEDITOR.config.toolbar} setting, so you instruct the editor which\r
- * toolbar_(name) setting to you.\r
- * @type Array\r
- * @example\r
- * // Defines a toolbar with only one strip containing the "Source" button, a\r
- * // separator and the "Bold" and "Italic" buttons.\r
- * <b>config.toolbar_Basic =\r
- * [\r
- *     [ 'Source', '-', 'Bold', 'Italic' ]\r
- * ]</b>;\r
- * config.toolbar = 'Basic';\r
- */\r
-CKEDITOR.config.toolbar_Basic =\r
-[\r
-       ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','About']\r
-];\r
-\r
-/**\r
- * This is the default toolbar definition used by the editor. It contains all\r
- * editor features.\r
- * @type Array\r
- * @default (see example)\r
- * @example\r
- * // This is actually the default value.\r
- * config.toolbar_Full =\r
- * [\r
- *     { name: 'document',    items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },\r
- *     { name: 'clipboard',   items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },\r
- *     { name: 'editing',     items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },\r
- *     { name: 'forms',       items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },\r
- *     '/',\r
- *     { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },\r
- *     { name: 'paragraph',   items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },\r
- *     { name: 'links',       items : [ 'Link','Unlink','Anchor' ] },\r
- *     { name: 'insert',      items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] },\r
- *     '/',\r
- *     { name: 'styles',      items : [ 'Styles','Format','Font','FontSize' ] },\r
- *     { name: 'colors',      items : [ 'TextColor','BGColor' ] },\r
- *     { name: 'tools',       items : [ 'Maximize', 'ShowBlocks','-','About' ] }\r
- * ];\r
- */\r
-CKEDITOR.config.toolbar_Full =\r
-[\r
-       { name: 'document',             items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },\r
-       { name: 'clipboard',    items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },\r
-       { name: 'editing',              items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },\r
-       { name: 'forms',                items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },\r
-       '/',\r
-       { name: 'basicstyles',  items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },\r
-       { name: 'paragraph',    items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },\r
-       { name: 'links',                items : [ 'Link','Unlink','Anchor' ] },\r
-       { name: 'insert',               items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },\r
-       '/',\r
-       { name: 'styles',               items : [ 'Styles','Format','Font','FontSize' ] },\r
-       { name: 'colors',               items : [ 'TextColor','BGColor' ] },\r
-       { name: 'tools',                items : [ 'Maximize', 'ShowBlocks','-','About' ] }\r
-];\r
-\r
-/**\r
- * The toolbox (alias toolbar) definition. It is a toolbar name or an array of\r
- * toolbars (strips), each one being also an array, containing a list of UI items.\r
- * @type Array|String\r
- * @default 'Full'\r
- * @example\r
- * // Defines a toolbar with only one strip containing the "Source" button, a\r
- * // separator and the "Bold" and "Italic" buttons.\r
- * config.toolbar =\r
- * [\r
- *     [ 'Source', '-', 'Bold', 'Italic' ]\r
- * ];\r
- * @example\r
- * // Load toolbar_Name where Name = Basic.\r
- * config.toolbar = 'Basic';\r
- */\r
-CKEDITOR.config.toolbar = 'Full';\r
-\r
-/**\r
- * Whether the toolbar can be collapsed by the user. If disabled, the collapser\r
- * button will not be displayed.\r
- * @type Boolean\r
- * @default true\r
- * @example\r
- * config.toolbarCanCollapse = false;\r
- */\r
-CKEDITOR.config.toolbarCanCollapse = true;\r
-\r
-/**\r
- * Whether the toolbar must start expanded when the editor is loaded.\r
- * @name CKEDITOR.config.toolbarStartupExpanded\r
- * @type Boolean\r
- * @default true\r
- * @example\r
- * config.toolbarStartupExpanded = false;\r
- */\r
-\r
-/**\r
- * When enabled, makes the arrow keys navigation cycle within the current\r
- * toolbar group. Otherwise the arrows will move trought all items available in\r
- * the toolbar. The TAB key will still be used to quickly jump among the\r
- * toolbar groups.\r
- * @name CKEDITOR.config.toolbarGroupCycling\r
- * @since 3.6\r
- * @type Boolean\r
- * @default true\r
- * @example\r
- * config.toolbarGroupCycling = false;\r
- */\r