--- /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
+ * @name CKEDITOR.theme\r
+ * @class\r
+ */\r
+\r
+CKEDITOR.themes.add( 'default', (function()\r
+{\r
+ var hiddenSkins = {};\r
+\r
+ function checkSharedSpace( editor, spaceName )\r
+ {\r
+ var container,\r
+ element;\r
+\r
+ // Try to retrieve the target element from the sharedSpaces settings.\r
+ element = editor.config.sharedSpaces;\r
+ element = element && element[ spaceName ];\r
+ element = element && CKEDITOR.document.getById( element );\r
+\r
+ // If the element is available, we'll then create the container for\r
+ // the space.\r
+ if ( element )\r
+ {\r
+ // Creates an HTML structure that reproduces the editor class hierarchy.\r
+ var html =\r
+ '<span class="cke_shared "' +\r
+ ' dir="'+ editor.lang.dir + '"' +\r
+ '>' +\r
+ '<span class="' + editor.skinClass + ' ' + editor.id + ' cke_editor_' + editor.name + '">' +\r
+ '<span class="' + CKEDITOR.env.cssClass + '">' +\r
+ '<span class="cke_wrapper cke_' + editor.lang.dir + '">' +\r
+ '<span class="cke_editor">' +\r
+ '<div class="cke_' + spaceName + '">' +\r
+ '</div></span></span></span></span></span>';\r
+\r
+ var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) );\r
+\r
+ // Only the first container starts visible. Others get hidden.\r
+ if ( element.getCustomData( 'cke_hasshared' ) )\r
+ mainContainer.hide();\r
+ else\r
+ element.setCustomData( 'cke_hasshared', 1 );\r
+\r
+ // Get the deeper inner <div>.\r
+ container = mainContainer.getChild( [0,0,0,0] );\r
+\r
+ // Save a reference to the shared space container.\r
+ !editor.sharedSpaces && ( editor.sharedSpaces = {} );\r
+ editor.sharedSpaces[ spaceName ] = container;\r
+\r
+ // When the editor gets focus, we show the space container, hiding others.\r
+ editor.on( 'focus', function()\r
+ {\r
+ for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ )\r
+ {\r
+ if ( sibling.type == CKEDITOR.NODE_ELEMENT\r
+ && !sibling.equals( mainContainer )\r
+ && sibling.hasClass( 'cke_shared' ) )\r
+ {\r
+ sibling.hide();\r
+ }\r
+ }\r
+\r
+ mainContainer.show();\r
+ });\r
+\r
+ editor.on( 'destroy', function()\r
+ {\r
+ mainContainer.remove();\r
+ });\r
+ }\r
+\r
+ return container;\r
+ }\r
+\r
+ return /** @lends CKEDITOR.theme */ {\r
+ build : function( editor, themePath )\r
+ {\r
+ var name = editor.name,\r
+ element = editor.element,\r
+ elementMode = editor.elementMode;\r
+\r
+ if ( !element || elementMode == CKEDITOR.ELEMENT_MODE_NONE )\r
+ return;\r
+\r
+ if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )\r
+ element.hide();\r
+\r
+ // Get the HTML for the predefined spaces.\r
+ var topHtml = editor.fire( 'themeSpace', { space : 'top', html : '' } ).html;\r
+ var contentsHtml = editor.fire( 'themeSpace', { space : 'contents', html : '' } ).html;\r
+ var bottomHtml = editor.fireOnce( 'themeSpace', { space : 'bottom', html : '' } ).html;\r
+\r
+ var height = contentsHtml && editor.config.height;\r
+\r
+ var tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0;\r
+\r
+ // The editor height is considered only if the contents space got filled.\r
+ if ( !contentsHtml )\r
+ height = 'auto';\r
+ else if ( !isNaN( height ) )\r
+ height += 'px';\r
+\r
+ var style = '';\r
+ var width = editor.config.width;\r
+\r
+ if ( width )\r
+ {\r
+ if ( !isNaN( width ) )\r
+ width += 'px';\r
+\r
+ style += "width: " + width + ";";\r
+ }\r
+\r
+ var sharedTop = topHtml && checkSharedSpace( editor, 'top' ),\r
+ sharedBottoms = checkSharedSpace( editor, 'bottom' );\r
+\r
+ sharedTop && ( sharedTop.setHtml( topHtml ) , topHtml = '' );\r
+ sharedBottoms && ( sharedBottoms.setHtml( bottomHtml ), bottomHtml = '' );\r
+\r
+ var hideSkin = '<style>.' + editor.skinClass + '{visibility:hidden;}</style>';\r
+ if ( hiddenSkins[ editor.skinClass ] )\r
+ hideSkin = '';\r
+ else\r
+ hiddenSkins[ editor.skinClass ] = 1;\r
+\r
+ var container = CKEDITOR.dom.element.createFromHtml( [\r
+ '<span' +\r
+ ' id="cke_', name, '"' +\r
+ ' class="', editor.skinClass, ' ', editor.id, ' cke_editor_', name, '"' +\r
+ ' dir="', editor.lang.dir, '"' +\r
+ ' title="', ( CKEDITOR.env.gecko ? ' ' : '' ), '"' +\r
+ ' lang="', editor.langCode, '"' +\r
+ ( CKEDITOR.env.webkit? ' tabindex="' + tabIndex + '"' : '' ) +\r
+ ' role="application"' +\r
+ ' aria-labelledby="cke_', name, '_arialbl"' +\r
+ ( style ? ' style="' + style + '"' : '' ) +\r
+ '>' +\r
+ '<span id="cke_', name, '_arialbl" class="cke_voice_label">' + editor.lang.editor + '</span>' +\r
+ '<span class="' , CKEDITOR.env.cssClass, '" role="presentation">' +\r
+ '<span class="cke_wrapper cke_', editor.lang.dir, '" role="presentation">' +\r
+ '<table class="cke_editor" border="0" cellspacing="0" cellpadding="0" role="presentation"><tbody>' +\r
+ '<tr', topHtml ? '' : ' style="display:none"', ' role="presentation"><td id="cke_top_' , name, '" class="cke_top" role="presentation">' , topHtml , '</td></tr>' +\r
+ '<tr', contentsHtml ? '' : ' style="display:none"', ' role="presentation"><td id="cke_contents_', name, '" class="cke_contents" style="height:', height, '" role="presentation">', contentsHtml, '</td></tr>' +\r
+ '<tr', bottomHtml ? '' : ' style="display:none"', ' role="presentation"><td id="cke_bottom_' , name, '" class="cke_bottom" role="presentation">' , bottomHtml , '</td></tr>' +\r
+ '</tbody></table>' +\r
+ //Hide the container when loading skins, later restored by skin css.\r
+ hideSkin +\r
+ '</span>' +\r
+ '</span>' +\r
+ '</span>' ].join( '' ) );\r
+\r
+ container.getChild( [1, 0, 0, 0, 0] ).unselectable();\r
+ container.getChild( [1, 0, 0, 0, 2] ).unselectable();\r
+\r
+ if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )\r
+ container.insertAfter( element );\r
+ else\r
+ element.append( container );\r
+\r
+ /**\r
+ * The DOM element that holds the main editor interface.\r
+ * @name CKEDITOR.editor.prototype.container\r
+ * @type CKEDITOR.dom.element\r
+ * @example\r
+ * var editor = CKEDITOR.instances.editor1;\r
+ * alert( <b>editor.container</b>.getName() ); "span"\r
+ */\r
+ editor.container = container;\r
+\r
+ // Disable browser context menu for editor's chrome.\r
+ container.disableContextMenu();\r
+\r
+ // Use a class to indicate that the current selection is in different direction than the UI.\r
+ editor.on( 'contentDirChanged', function( evt )\r
+ {\r
+ var func = ( editor.lang.dir != evt.data ? 'add' : 'remove' ) + 'Class';\r
+\r
+ container.getChild( 1 )[ func ]( 'cke_mixed_dir_content' );\r
+\r
+ // Put the mixed direction class on the respective element also for shared spaces.\r
+ var toolbarSpace = this.sharedSpaces && this.sharedSpaces[ this.config.toolbarLocation ];\r
+ toolbarSpace && toolbarSpace.getParent().getParent()[ func ]( 'cke_mixed_dir_content' );\r
+ });\r
+\r
+ editor.fireOnce( 'themeLoaded' );\r
+ editor.fireOnce( 'uiReady' );\r
+ },\r
+\r
+ buildDialog : function( editor )\r
+ {\r
+ var baseIdNumber = CKEDITOR.tools.getNextNumber();\r
+\r
+ var element = CKEDITOR.dom.element.createFromHtml( [\r
+ '<div class="', editor.id, '_dialog cke_editor_', editor.name.replace('.', '\\.'), '_dialog cke_skin_', editor.skinName,\r
+ '" dir="', editor.lang.dir, '"' +\r
+ ' lang="', editor.langCode, '"' +\r
+ ' role="dialog"' +\r
+ ' aria-labelledby="%title#"' +\r
+ '>' +\r
+ '<table class="cke_dialog', ' ' + CKEDITOR.env.cssClass,\r
+ ' cke_', editor.lang.dir, '" style="position:absolute" role="presentation">' +\r
+ '<tr><td role="presentation">' +\r
+ '<div class="%body" role="presentation">' +\r
+ '<div id="%title#" class="%title" role="presentation"></div>' +\r
+ '<a id="%close_button#" class="%close_button" href="javascript:void(0)" title="' + editor.lang.common.close+'" role="button"><span class="cke_label">X</span></a>' +\r
+ '<div id="%tabs#" class="%tabs" role="tablist"></div>' +\r
+ '<table class="%contents" role="presentation">' +\r
+ '<tr>' +\r
+ '<td id="%contents#" class="%contents" role="presentation"></td>' +\r
+ '</tr>' +\r
+ '<tr>' +\r
+ '<td id="%footer#" class="%footer" role="presentation"></td>' +\r
+ '</tr>' +\r
+ '</table>' +\r
+ '</div>' +\r
+ '<div id="%tl#" class="%tl"></div>' +\r
+ '<div id="%tc#" class="%tc"></div>' +\r
+ '<div id="%tr#" class="%tr"></div>' +\r
+ '<div id="%ml#" class="%ml"></div>' +\r
+ '<div id="%mr#" class="%mr"></div>' +\r
+ '<div id="%bl#" class="%bl"></div>' +\r
+ '<div id="%bc#" class="%bc"></div>' +\r
+ '<div id="%br#" class="%br"></div>' +\r
+ '</td></tr>' +\r
+ '</table>',\r
+\r
+ //Hide the container when loading skins, later restored by skin css.\r
+ ( CKEDITOR.env.ie ? '' : '<style>.cke_dialog{visibility:hidden;}</style>' ),\r
+\r
+ '</div>'\r
+ ].join( '' )\r
+ .replace( /#/g, '_' + baseIdNumber )\r
+ .replace( /%/g, 'cke_dialog_' ) );\r
+\r
+ var body = element.getChild( [ 0, 0, 0, 0, 0 ] ),\r
+ title = body.getChild( 0 ),\r
+ close = body.getChild( 1 );\r
+\r
+ // Make the Title and Close Button unselectable.\r
+ title.unselectable();\r
+ close.unselectable();\r
+\r
+\r
+ return {\r
+ element : element,\r
+ parts :\r
+ {\r
+ dialog : element.getChild( 0 ),\r
+ title : title,\r
+ close : close,\r
+ tabs : body.getChild( 2 ),\r
+ contents : body.getChild( [ 3, 0, 0, 0 ] ),\r
+ footer : body.getChild( [ 3, 0, 1, 0 ] )\r
+ }\r
+ };\r
+ },\r
+\r
+ destroy : function( editor )\r
+ {\r
+ var container = editor.container,\r
+ element = editor.element;\r
+\r
+ if ( container )\r
+ {\r
+ container.clearCustomData();\r
+ container.remove();\r
+ }\r
+\r
+ if ( element )\r
+ {\r
+ element.clearCustomData();\r
+ editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.show();\r
+ delete editor.element;\r
+ }\r
+ }\r
+ };\r
+})() );\r
+\r
+/**\r
+ * Returns the DOM element that represents a theme space. The default theme defines\r
+ * three spaces, namely "top", "contents" and "bottom", representing the main\r
+ * blocks that compose the editor interface.\r
+ * @param {String} spaceName The space name.\r
+ * @returns {CKEDITOR.dom.element} The element that represents the space.\r
+ * @example\r
+ * // Hide the bottom space in the UI.\r
+ * var bottom = editor.getThemeSpace( 'bottom' );\r
+ * bottom.setStyle( 'display', 'none' );\r
+ */\r
+CKEDITOR.editor.prototype.getThemeSpace = function( spaceName )\r
+{\r
+ var spacePrefix = 'cke_' + spaceName;\r
+ var space = this._[ spacePrefix ] ||\r
+ ( this._[ spacePrefix ] = CKEDITOR.document.getById( spacePrefix + '_' + this.name ) );\r
+ return space;\r
+};\r
+\r
+/**\r
+ * Resizes the editor interface.\r
+ * @param {Number|String} width The new width. It can be an pixels integer or a\r
+ * CSS size value.\r
+ * @param {Number|String} height The new height. It can be an pixels integer or\r
+ * a CSS size value.\r
+ * @param {Boolean} [isContentHeight] Indicates that the provided height is to\r
+ * be applied to the editor contents space, not to the entire editor\r
+ * interface. Defaults to false.\r
+ * @param {Boolean} [resizeInner] Indicates that the first inner interface\r
+ * element must receive the size, not the outer element. The default theme\r
+ * defines the interface inside a pair of span elements\r
+ * (<span><span>...</span></span>). By default the\r
+ * first span element receives the sizes. If this parameter is set to\r
+ * true, the second span is sized instead.\r
+ * @example\r
+ * editor.resize( 900, 300 );\r
+ * @example\r
+ * editor.resize( '100%', 450, true );\r
+ */\r
+CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner )\r
+{\r
+ var container = this.container,\r
+ contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ),\r
+ outer = resizeInner ? container.getChild( 1 ) : container;\r
+\r
+ // Resize the width first.\r
+ // WEBKIT BUG: Webkit requires that we put the editor off from display when we\r
+ // resize it. If we don't, the browser crashes!\r
+ CKEDITOR.env.webkit && outer.setStyle( 'display', 'none' );\r
+ // Set as border box width. (#5353)\r
+ outer.setSize( 'width', width, true );\r
+ if ( CKEDITOR.env.webkit )\r
+ {\r
+ outer.$.offsetWidth;\r
+ outer.setStyle( 'display', '' );\r
+ }\r
+\r
+ // Get the height delta between the outer table and the content area.\r
+ // If we're setting the content area's height, then we don't need the delta.\r
+ var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );\r
+ contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' );\r
+\r
+ // Emit a resize event.\r
+ this.fire( 'resize' );\r
+};\r
+\r
+/**\r
+ * Gets the element that can be freely used to check the editor size. This method\r
+ * is mainly used by the resize plugin, which adds a UI handle that can be used\r
+ * to resize the editor.\r
+ * @param {Boolean} forContents Whether to return the "contents" part of the theme instead of the container.\r
+ * @returns {CKEDITOR.dom.element} The resizable element.\r
+ * @example\r
+ */\r
+CKEDITOR.editor.prototype.getResizable = function( forContents )\r
+{\r
+ return forContents ? CKEDITOR.document.getById( 'cke_contents_' + this.name ) : this.container;\r
+};\r
+\r
+/**\r
+ * Makes it possible to place some of the editor UI blocks, like the toolbar\r
+ * and the elements path, into any element in the page.\r
+ * The elements used to hold the UI blocks can be shared among several editor\r
+ * instances. In that case, only the blocks of the active editor instance will\r
+ * display.\r
+ * @name CKEDITOR.config.sharedSpaces\r
+ * @type Object\r
+ * @default undefined\r
+ * @example\r
+ * // Place the toolbar inside the element with ID "someElementId" and the\r
+ * // elements path into the element with ID "anotherId".\r
+ * config.sharedSpaces =\r
+ * {\r
+ * top : 'someElementId',\r
+ * bottom : 'anotherId'\r
+ * };\r
+ * @example\r
+ * // Place the toolbar inside the element with ID "someElementId". The\r
+ * // elements path will remain attached to the editor UI.\r
+ * config.sharedSpaces =\r
+ * {\r
+ * top : 'someElementId'\r
+ * };\r
+ */\r
+\r
+/**\r
+ * Fired after the editor instance is resized through\r
+ * the {@link CKEDITOR.editor.prototype.resize} method.\r
+ * @name CKEDITOR.editor#resize\r
+ * @event\r
+ */\r