X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fthemes%2Fdefault%2Ftheme.js;h=ef0f7c93a3218cbd24cef5bad532240c187456df;hb=059b4c2fef02528bf1af189f7996e80652faddfb;hp=6e6a8731254643b0874eb86c34c2378f9554ef21;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d;p=ckeditor.git diff --git a/_source/themes/default/theme.js b/_source/themes/default/theme.js index 6e6a873..ef0f7c9 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,23 +104,31 @@ 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( [ '' + - '' + - '' + - '' + - '' + - '' + - '' + + '' + editor.lang.editor + '' + + '' + + '' + + '
' , topHtml , '
', contentsHtml, '
' , bottomHtml , '
' + + '' + + '' + + '' + '' + //Hide the container when loading skins, later restored by skin css. '' + @@ -68,8 +136,8 @@ CKEDITOR.themes.add( 'default', (function() '
' + '
' ].join( '' ) ); - container.getChild( [0, 0, 0, 0, 0] ).unselectable(); - container.getChild( [0, 0, 0, 0, 2] ).unselectable(); + container.getChild( [1, 0, 0, 0, 0] ).unselectable(); + container.getChild( [1, 0, 0, 0, 2] ).unselectable(); if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) container.insertAfter( element ); @@ -98,21 +166,23 @@ CKEDITOR.themes.add( 'default', (function() var baseIdNumber = CKEDITOR.tools.getNextNumber(); var element = CKEDITOR.dom.element.createFromHtml( [ - '