X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fthemes%2Fdefault%2Ftheme.js;h=b1e94ba8b1bbc55da452839319c4c174ed213320;hb=4e90e78dc97789709ee7404359a5517540c27553;hp=b3057d085806775f27b3dec7ea911eac0be797ae;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/themes/default/theme.js b/_source/themes/default/theme.js index b3057d0..b1e94ba 100644 --- a/_source/themes/default/theme.js +++ b/_source/themes/default/theme.js @@ -1,11 +1,82 @@ /* -Copyright (c) 2003-2009, 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() { - return { + 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] ); + + // 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() + { + 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 /** @lends CKEDITOR.theme */ { build : function( editor, themePath ) { var name = editor.name, @@ -44,23 +115,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 +147,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 ); @@ -86,6 +165,21 @@ CKEDITOR.themes.add( 'default', (function() */ editor.container = container; + // 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' ); }, @@ -95,21 +189,27 @@ CKEDITOR.themes.add( 'default', (function() var baseIdNumber = CKEDITOR.tools.getNextNumber(); var element = CKEDITOR.dom.element.createFromHtml( [ - '