JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / _source / themes / default / theme.js
index 669aeb3..b1e94ba 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -26,7 +26,9 @@ CKEDITOR.themes.add( 'default', (function()
                {\r
                        // Creates an HTML structure that reproduces the editor class hierarchy.\r
                        var html =\r
-                               '<span class="cke_shared">' +\r
+                               '<span class="cke_shared "' +\r
+                               ' dir="'+ editor.lang.dir + '"' +\r
+                               '>' +\r
                                '<span class="' + editor.skinClass + ' ' + editor.id + ' cke_editor_' + editor.name + '">' +\r
                                '<span class="' + CKEDITOR.env.cssClass + '">' +\r
                                '<span class="cke_wrapper cke_' + editor.lang.dir + '">' +\r
@@ -45,6 +47,10 @@ CKEDITOR.themes.add( 'default', (function()
                        // Get the deeper inner <div>.\r
                        container = mainContainer.getChild( [0,0,0,0] );\r
 \r
+                       // Save a reference to the shared space container.\r
+                       !editor.sharedSpaces && ( editor.sharedSpaces = {} );\r
+                       editor.sharedSpaces[ spaceName ] = container;\r
+\r
                        // When the editor gets focus, we show the space container, hiding others.\r
                        editor.on( 'focus', function()\r
                                {\r
@@ -122,7 +128,7 @@ CKEDITOR.themes.add( 'default', (function()
                                        ' dir="', editor.lang.dir, '"' +\r
                                        ' title="', ( CKEDITOR.env.gecko ? ' ' : '' ), '"' +\r
                                        ' lang="', editor.langCode, '"' +\r
-                                       ( CKEDITOR.env.webkit? ' tabindex="' + tabIndex + '"' : '' ) +\r
+                                               ( CKEDITOR.env.webkit? ' tabindex="' + tabIndex + '"' : '' ) +\r
                                        ' role="application"' +\r
                                        ' aria-labelledby="cke_', name, '_arialbl"' +\r
                                        ( style ? ' style="' + style + '"' : '' ) +\r
@@ -162,6 +168,18 @@ CKEDITOR.themes.add( 'default', (function()
                        // Disable browser context menu for editor's chrome.\r
                        container.disableContextMenu();\r
 \r
+                       // Use a class to indicate that the current selection is in different direction than the UI.\r
+                       editor.on( 'contentDirChanged', function( evt )\r
+                       {\r
+                               var func = ( editor.lang.dir != evt.data ? 'add' : 'remove' ) + 'Class';\r
+\r
+                               container.getChild( 1 )[ func ]( 'cke_mixed_dir_content' );\r
+\r
+                               // Put the mixed direction class on the respective element also for shared spaces.\r
+                               var toolbarSpace = this.sharedSpaces && this.sharedSpaces[ this.config.toolbarLocation ];\r
+                               toolbarSpace && toolbarSpace.getParent().getParent()[ func ]( 'cke_mixed_dir_content' );\r
+                       });\r
+\r
                        editor.fireOnce( 'themeLoaded' );\r
                        editor.fireOnce( 'uiReady' );\r
                },\r
@@ -237,17 +255,21 @@ CKEDITOR.themes.add( 'default', (function()
 \r
                destroy : function( editor )\r
                {\r
-                       var container = editor.container;\r
-                       container.clearCustomData();\r
-                       editor.element.clearCustomData();\r
+                       var container = editor.container,\r
+                               element = editor.element;\r
 \r
                        if ( container )\r
+                       {\r
+                               container.clearCustomData();\r
                                container.remove();\r
+                       }\r
 \r
-                       if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )\r
-                               editor.element.show();\r
-\r
-                       delete editor.element;\r
+                       if ( element )\r
+                       {\r
+                               element.clearCustomData();\r
+                               editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.show();\r
+                               delete editor.element;\r
+                       }\r
                }\r
        };\r
 })() );\r
@@ -327,7 +349,7 @@ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, res
  */\r
 CKEDITOR.editor.prototype.getResizable = function()\r
 {\r
-       return this.container.getChild( 1 );\r
+       return this.container;\r
 };\r
 \r
 /**\r
@@ -359,6 +381,6 @@ CKEDITOR.editor.prototype.getResizable = function()
 /**\r
  * Fired after the editor instance is resized through\r
  * the {@link CKEDITOR.editor.prototype.resize} method.\r
- * @name CKEDITOR#resize\r
+ * @name CKEDITOR.editor#resize\r
  * @event\r
  */\r