X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fthemes%2Fdefault%2Ftheme.js;h=96ff928b48067e0fe83d71e2aae8bc6a64233679;hb=941b0a9ba4e673e292510d80a5a86806994b8ea6;hp=b3057d085806775f27b3dec7ea911eac0be797ae;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/themes/default/theme.js b/_source/themes/default/theme.js index b3057d0..96ff928 100644 --- a/_source/themes/default/theme.js +++ b/_source/themes/default/theme.js @@ -1,10 +1,70 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.themes.add( 'default', (function() { + function checkSharedSpace( editor, spaceName ) + { + var container, + element; + + // Try to retrieve the target element from the sharedSpaces settings. + element = editor.config.sharedSpaces; + element = element && element[ spaceName ]; + element = element && CKEDITOR.document.getById( element ); + + // If the element is available, we'll then create the container for + // the space. + if ( element ) + { + // Creates an HTML structure that reproduces the editor class hierarchy. + var html = + '' + + '' + + '' + + '' + + '' + + '
' + + '
'; + + var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) ); + + // Only the first container starts visible. Others get hidden. + if ( element.getCustomData( 'cke_hasshared' ) ) + mainContainer.hide(); + else + element.setCustomData( 'cke_hasshared', 1 ); + + // Get the deeper inner
. + container = mainContainer.getChild( [0,0,0,0] ); + + // When the editor gets focus, we show the space container, hiding others. + editor.on( 'focus', function() + { + for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ ) + { + if ( sibling.type == CKEDITOR.NODE_ELEMENT + && !sibling.equals( mainContainer ) + && sibling.hasClass( 'cke_shared' ) ) + { + sibling.hide(); + } + } + + mainContainer.show(); + }); + + editor.on( 'destroy', function() + { + mainContainer.remove(); + }); + } + + return container; + } + return { build : function( editor, themePath ) { @@ -44,11 +104,17 @@ CKEDITOR.themes.add( 'default', (function() style += "width: " + width + ";"; } + var sharedTop = topHtml && checkSharedSpace( editor, 'top' ), + sharedBottoms = checkSharedSpace( editor, 'bottom' ); + + sharedTop && ( sharedTop.setHtml( topHtml ) , topHtml = '' ); + sharedBottoms && ( sharedBottoms.setHtml( bottomHtml ), bottomHtml = '' ); + var container = CKEDITOR.dom.element.createFromHtml( [ '' + - - '
' + + '' + '
' + '
' + '
' + 'X' + '
' + '
' + - '
' + + '' + + '' + + '
' + '
' + '
' + '
' + @@ -119,7 +190,8 @@ CKEDITOR.themes.add( 'default', (function() '
' + '
' + '
' + - '
', + '' + + '', //Hide the container when loading skins, later restored by skin css. ( CKEDITOR.env.ie ? '' : '' ), @@ -129,11 +201,13 @@ CKEDITOR.themes.add( 'default', (function() .replace( /#/g, '_' + baseIdNumber ) .replace( /%/g, 'cke_dialog_' ) ); - var body = element.getChild( [ 0, 0 ] ); + var body = element.getChild( [ 0, 0, 0, 0, 0 ] ), + title = body.getChild( 0 ), + close = body.getChild( 1 ); // Make the Title and Close Button unselectable. - body.getChild( 0 ).unselectable(); - body.getChild( 1 ).unselectable(); + title.unselectable(); + close.unselectable(); return { @@ -141,10 +215,10 @@ CKEDITOR.themes.add( 'default', (function() parts : { dialog : element.getChild( 0 ), - title : body.getChild( 0 ), - close : body.getChild( 1 ), + title : title, + close : close, tabs : body.getChild( 2 ), - contents : body.getChild( 3 ), + contents : body.getChild( [ 3, 0, 0, 0 ] ), footer : body.getChild( 4 ) } }; @@ -202,9 +276,9 @@ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, res if ( numberRegex.test( width ) ) width += 'px'; - var contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ); - var outer = resizeInner ? contents.getAscendant( 'table' ).getParent() - : contents.getAscendant( 'table' ).getParent().getParent().getParent(); + var container = this.container, + contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ), + outer = resizeInner ? container.getChild( 0 ) : container; // Resize the width first. // WEBKIT BUG: Webkit requires that we put the editor off from display when we @@ -228,5 +302,31 @@ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, res CKEDITOR.editor.prototype.getResizable = function() { - return this.container.getChild( [ 0, 0 ] ); + return this.container.getChild( 0 ); }; + +/** + * Makes it possible to place some of the editor UI blocks, like the toolbar + * and the elements path, into any element in the page. + * The elements used to hold the UI blocks can be shared among several editor + * instances. In that case, only the blocks of the active editor instance will + * display. + * @name CKEDITOR.config.sharedSpaces + * @type Object + * @default undefined + * @example + * // Place the toolbar inside the element with ID "someElementId" and the + * // elements path into the element with ID "anotherId". + * config.sharedSpaces = + * { + * top : 'someElementId', + * bottom : 'anotherId' + * }; + * @example + * // Place the toolbar inside the element with ID "someElementId". The + * // elements path will remain attached to the editor UI. + * config.sharedSpaces = + * { + * top : 'someElementId' + * }; + */