--- /dev/null
+/*\r
+Copyright (c) 2003-2011, 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
+\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
+ init : function( editor )\r
+ {\r
+ var itemKeystroke = function( item, keystroke )\r
+ {\r
+ var next, nextToolGroup, groupItemsCount;\r
+ var rtl = editor.lang.dir == 'rtl';\r
+\r
+ switch ( keystroke )\r
+ {\r
+ case rtl ? 37 : 39 : // RIGHT-ARROW\r
+ case 9 : // TAB\r
+ do\r
+ {\r
+ // Look for the next item in the toolbar.\r
+ next = item.next;\r
+\r
+ if ( !next )\r
+ {\r
+ nextToolGroup = item.toolbar.next;\r
+ groupItemsCount = nextToolGroup && nextToolGroup.items.length;\r
+\r
+ // Bypass the empty toolgroups.\r
+ while ( groupItemsCount === 0 )\r
+ {\r
+ nextToolGroup = nextToolGroup.next;\r
+ groupItemsCount = nextToolGroup && nextToolGroup.items.length;\r
+ }\r
+\r
+ if ( nextToolGroup )\r
+ next = nextToolGroup.items[ 0 ];\r
+ }\r
+\r
+ item = next;\r
+ }\r
+ while ( item && !item.focus )\r
+\r
+ // If available, just focus it, otherwise focus the\r
+ // first one.\r
+ if ( item )\r
+ item.focus();\r
+ else\r
+ editor.toolbox.focus();\r
+\r
+ return false;\r
+\r
+ case rtl ? 39 : 37 : // LEFT-ARROW\r
+ case CKEDITOR.SHIFT + 9 : // SHIFT + TAB\r
+ do\r
+ {\r
+ // Look for the previous item in the toolbar.\r
+ next = item.previous;\r
+\r
+ if ( !next )\r
+ {\r
+ nextToolGroup = item.toolbar.previous;\r
+ groupItemsCount = nextToolGroup && nextToolGroup.items.length;\r
+\r
+ // Bypass the empty toolgroups.\r
+ while ( groupItemsCount === 0 )\r
+ {\r
+ nextToolGroup = nextToolGroup.previous;\r
+ groupItemsCount = nextToolGroup && nextToolGroup.items.length;\r
+ }\r
+\r
+ if ( nextToolGroup )\r
+ next = nextToolGroup.items[ groupItemsCount - 1 ];\r
+ }\r
+\r
+ item = next;\r
+ }\r
+ while ( item && !item.focus )\r
+\r
+ // If available, just focus it, otherwise focus the\r
+ // last one.\r
+ if ( item )\r
+ item.focus();\r
+ else\r
+ {\r
+ var lastToolbarItems = editor.toolbox.toolbars[ editor.toolbox.toolbars.length - 1 ].items;\r
+ lastToolbarItems[ lastToolbarItems.length - 1 ].focus();\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="toolbar" 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.toolbar, '</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 row = toolbar[ r ];\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
+ var toolbarId = CKEDITOR.tools.getNextId(),\r
+ toolbarObj = { id : toolbarId, items : [] };\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
+ output.push( '<span id="', toolbarId, '" class="cke_toolbar" role="presentation"><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
+ // Create all items defined for this toolbar.\r
+ for ( var i = 0 ; i < row.length ; i++ )\r
+ {\r
+ var item,\r
+ itemName = row[ i ];\r
+\r
+ if ( itemName == '-' )\r
+ item = CKEDITOR.ui.separator;\r
+ else\r
+ item = editor.ui.create( itemName );\r
+\r
+ if ( item )\r
+ {\r
+ if ( item.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
+ 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
+ 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>▲</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
+ if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;\r
+ }\r
+ }\r
+ });\r
+\r
+ editor.addCommand( 'toolbarFocus', commands.toolbarFocus );\r
+ }\r
+ });\r
+})();\r
+\r
+/**\r
+ * The UI element that renders a toolbar separator.\r
+ * @type Object\r
+ * @example\r
+ */\r
+CKEDITOR.ui.separator =\r
+{\r
+ render : function( editor, output )\r
+ {\r
+ output.push( '<span class="cke_separator" role="separator"></span>' );\r
+ return {};\r
+ }\r
+};\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
+ * ['Source','-','Save','NewPage','Preview','-','Templates'],\r
+ * ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],\r
+ * ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],\r
+ * ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],\r
+ * '/',\r
+ * ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\r
+ * ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],\r
+ * ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],\r
+ * ['BidiLtr', 'BidiRtl' ],\r
+ * ['Link','Unlink','Anchor'],\r
+ * ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],\r
+ * '/',\r
+ * ['Styles','Format','Font','FontSize'],\r
+ * ['TextColor','BGColor'],\r
+ * ['Maximize', 'ShowBlocks','-','About']\r
+ * ];\r
+ */\r
+CKEDITOR.config.toolbar_Full =\r
+[\r
+ ['Source','-','Save','NewPage','Preview','-','Templates'],\r
+ ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],\r
+ ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],\r
+ ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],\r
+ '/',\r
+ ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\r
+ ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],\r
+ ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],\r
+ ['BidiLtr', 'BidiRtl' ],\r
+ ['Link','Unlink','Anchor'],\r
+ ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],\r
+ '/',\r
+ ['Styles','Format','Font','FontSize'],\r
+ ['TextColor','BGColor'],\r
+ ['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