X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fthemes%2Fdefault%2Ftheme.js;h=96ff928b48067e0fe83d71e2aae8bc6a64233679;hp=97dd0ef2ab934eb5c35a246df3be798bff6ece68;hb=941b0a9ba4e673e292510d80a5a86806994b8ea6;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d diff --git a/_source/themes/default/theme.js b/_source/themes/default/theme.js index 97dd0ef..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( [ '' + @@ -210,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 @@ -236,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' + * }; + */