X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fthemes%2Fdefault%2Ftheme.js;h=b2502024ece7414c567e04449d0acfb51a37c44c;hb=1056598c95187351dc58f4991d331e2258d038b5;hp=ef0f7c93a3218cbd24cef5bad532240c187456df;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/themes/default/theme.js b/_source/themes/default/theme.js index ef0f7c9..b250202 100644 --- a/_source/themes/default/theme.js +++ b/_source/themes/default/theme.js @@ -1,10 +1,17 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ +/** + * @name CKEDITOR.theme + * @class + */ + CKEDITOR.themes.add( 'default', (function() { + var hiddenSkins = {}; + function checkSharedSpace( editor, spaceName ) { var container, @@ -21,8 +28,10 @@ CKEDITOR.themes.add( 'default', (function() { // Creates an HTML structure that reproduces the editor class hierarchy. var html = - '' + - '' + + '' + + '' + '' + '' + '' + @@ -40,6 +49,10 @@ CKEDITOR.themes.add( 'default', (function() // Get the deeper inner
. container = mainContainer.getChild( [0,0,0,0] ); + // Save a reference to the shared space container. + !editor.sharedSpaces && ( editor.sharedSpaces = {} ); + editor.sharedSpaces[ spaceName ] = container; + // When the editor gets focus, we show the space container, hiding others. editor.on( 'focus', function() { @@ -65,7 +78,7 @@ CKEDITOR.themes.add( 'default', (function() return container; } - return { + return /** @lends CKEDITOR.theme */ { build : function( editor, themePath ) { var name = editor.name, @@ -110,14 +123,20 @@ CKEDITOR.themes.add( 'default', (function() sharedTop && ( sharedTop.setHtml( topHtml ) , topHtml = '' ); sharedBottoms && ( sharedBottoms.setHtml( bottomHtml ), bottomHtml = '' ); + var hideSkin = ''; + if ( hiddenSkins[ editor.skinClass ] ) + hideSkin = ''; + else + hiddenSkins[ editor.skinClass ] = 1; + var container = CKEDITOR.dom.element.createFromHtml( [ '' + '' + '' + - '' + - '' + - '' + + '' + + '' + + '' + '' + //Hide the container when loading skins, later restored by skin css. - '' + + hideSkin + '' + '' + '' ].join( '' ) ); @@ -157,6 +176,18 @@ CKEDITOR.themes.add( 'default', (function() // Disable browser context menu for editor's chrome. container.disableContextMenu(); + // Use a class to indicate that the current selection is in different direction than the UI. + editor.on( 'contentDirChanged', function( evt ) + { + var func = ( editor.lang.dir != evt.data ? 'add' : 'remove' ) + 'Class'; + + container.getChild( 1 )[ func ]( 'cke_mixed_dir_content' ); + + // Put the mixed direction class on the respective element also for shared spaces. + var toolbarSpace = this.sharedSpaces && this.sharedSpaces[ this.config.toolbarLocation ]; + toolbarSpace && toolbarSpace.getParent().getParent()[ func ]( 'cke_mixed_dir_content' ); + }); + editor.fireOnce( 'themeLoaded' ); editor.fireOnce( 'uiReady' ); }, @@ -166,7 +197,7 @@ CKEDITOR.themes.add( 'default', (function() var baseIdNumber = CKEDITOR.tools.getNextNumber(); var element = CKEDITOR.dom.element.createFromHtml( [ - '' + 'X' + '
' + - '' + + '' + + '' + '' + - '' + - '' + + '' + + '' + + '' + + '' + + '' + '
' + '
' + '
' + @@ -221,49 +256,43 @@ CKEDITOR.themes.add( 'default', (function() close : close, tabs : body.getChild( 2 ), contents : body.getChild( [ 3, 0, 0, 0 ] ), - footer : body.getChild( 4 ) + footer : body.getChild( [ 3, 0, 1, 0 ] ) } }; }, destroy : function( editor ) { - var container = editor.container; - - /* - * IE BUG: Removing the editor DOM elements while the selection is inside - * the editing area would break IE7/8's selection system. So we need to put - * the selection back to the parent document without scrolling the window. - * (#3812) - */ - if ( CKEDITOR.env.ie ) - { - container.setStyle( 'display', 'none' ); - - var $range = document.body.createTextRange(); - $range.moveToElementText( container.$ ); - try - { - // Putting the selection to a display:none element - this will certainly - // fail. But! We've just put the selection document back to the parent - // document without scrolling the window! - $range.select(); - } - catch ( e ) {} - } + var container = editor.container, + element = editor.element; if ( container ) + { + container.clearCustomData(); container.remove(); + } - if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) + if ( element ) { - editor.element.show(); + element.clearCustomData(); + editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.show(); delete editor.element; } } }; })() ); +/** + * Returns the DOM element that represents a theme space. The default theme defines + * three spaces, namely "top", "contents" and "bottom", representing the main + * blocks that compose the editor interface. + * @param {String} spaceName The space name. + * @returns {CKEDITOR.dom.element} The element that represents the space. + * @example + * // Hide the bottom space in the UI. + * var bottom = editor.getThemeSpace( 'bottom' ); + * bottom.setStyle( 'display', 'none' ); + */ CKEDITOR.editor.prototype.getThemeSpace = function( spaceName ) { var spacePrefix = 'cke_' + spaceName; @@ -272,12 +301,28 @@ CKEDITOR.editor.prototype.getThemeSpace = function( spaceName ) return space; }; +/** + * Resizes the editor interface. + * @param {Number|String} width The new width. It can be an pixels integer or a + * CSS size value. + * @param {Number|String} height The new height. It can be an pixels integer or + * a CSS size value. + * @param {Boolean} [isContentHeight] Indicates that the provided height is to + * be applied to the editor contents space, not to the entire editor + * interface. Defaults to false. + * @param {Boolean} [resizeInner] Indicates that the first inner interface + * element must receive the size, not the outer element. The default theme + * defines the interface inside a pair of span elements + * (<span><span>...</span></span>). By default the + * first span element receives the sizes. If this parameter is set to + * true, the second span is sized instead. + * @example + * editor.resize( 900, 300 ); + * @example + * editor.resize( '100%', 450, true ); + */ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner ) { - var numberRegex = /^\d+$/; - if ( numberRegex.test( width ) ) - width += 'px'; - var container = this.container, contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ), outer = resizeInner ? container.getChild( 1 ) : container; @@ -286,7 +331,8 @@ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, res // WEBKIT BUG: Webkit requires that we put the editor off from display when we // resize it. If we don't, the browser crashes! CKEDITOR.env.webkit && outer.setStyle( 'display', 'none' ); - outer.setStyle( 'width', width ); + // Set as border box width. (#5353) + outer.setSize( 'width', width, true ); if ( CKEDITOR.env.webkit ) { outer.$.offsetWidth; @@ -302,9 +348,16 @@ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, res this.fire( 'resize' ); }; +/** + * Gets the element that can be freely used to check the editor size. This method + * is mainly used by the resize plugin, which adds a UI handle that can be used + * to resize the editor. + * @returns {CKEDITOR.dom.element} The resizable element. + * @example + */ CKEDITOR.editor.prototype.getResizable = function() { - return this.container.getChild( 1 ); + return this.container; }; /** @@ -332,3 +385,10 @@ CKEDITOR.editor.prototype.getResizable = function() * top : 'someElementId' * }; */ + +/** + * Fired after the editor instance is resized through + * the {@link CKEDITOR.editor.prototype.resize} method. + * @name CKEDITOR.editor#resize + * @event + */