JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / themes / default / theme.js
index a281843..9eb488d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -10,6 +10,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
 CKEDITOR.themes.add( 'default', (function()\r
 {\r
+       var hiddenSkins = {};\r
+\r
        function checkSharedSpace( editor, spaceName )\r
        {\r
                var container,\r
@@ -26,7 +28,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
@@ -119,6 +123,12 @@ CKEDITOR.themes.add( 'default', (function()
                        sharedTop               && ( sharedTop.setHtml( topHtml )               , topHtml = '' );\r
                        sharedBottoms   && ( sharedBottoms.setHtml( bottomHtml ), bottomHtml = '' );\r
 \r
+                       var hideSkin = '<style>.' + editor.skinClass + '{visibility:hidden;}</style>';\r
+                       if ( hiddenSkins[ editor.skinClass ] )\r
+                               hideSkin = '';\r
+                       else\r
+                               hiddenSkins[ editor.skinClass ] = 1;\r
+\r
                        var container = CKEDITOR.dom.element.createFromHtml( [\r
                                '<span' +\r
                                        ' id="cke_', name, '"' +\r
@@ -140,7 +150,7 @@ CKEDITOR.themes.add( 'default', (function()
                                                                '<tr', bottomHtml       ? '' : ' style="display:none"', ' role="presentation"><td id="cke_bottom_'      , name, '" class="cke_bottom" role="presentation">'     , bottomHtml    , '</td></tr>' +\r
                                                        '</tbody></table>' +\r
                                                        //Hide the container when loading skins, later restored by skin css.\r
-                                                       '<style>.', editor.skinClass, '{visibility:hidden;}</style>' +\r
+                                                       hideSkin +\r
                                                '</span>' +\r
                                        '</span>' +\r
                                '</span>' ].join( '' ) );\r
@@ -166,6 +176,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
@@ -220,6 +242,20 @@ CKEDITOR.themes.add( 'default', (function()
                                title = body.getChild( 0 ),\r
                                close = body.getChild( 1 );\r
 \r
+                       // IFrame shim for dialog that masks activeX in IE. (#7619)\r
+                       if ( CKEDITOR.env.ie && !CKEDITOR.env.ie6Compat )\r
+                       {\r
+                               var isCustomDomain = CKEDITOR.env.isCustomDomain(),\r
+                                       src = 'javascript:void(function(){' + encodeURIComponent( 'document.open();' + ( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) + 'document.close();' ) + '}())',\r
+                                       iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +\r
+                                                       ' frameBorder="0"' +\r
+                                                       ' class="cke_iframe_shim"' +\r
+                                                       ' src="' + src + '"' +\r
+                                                       ' tabIndex="-1"' +\r
+                                                       '></iframe>' );\r
+                               iframe.appendTo( body.getParent() );\r
+                       }\r
+\r
                        // Make the Title and Close Button unselectable.\r
                        title.unselectable();\r
                        close.unselectable();\r
@@ -241,17 +277,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
@@ -299,25 +339,23 @@ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, res
 {\r
        var container = this.container,\r
                contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ),\r
+               contentsFrame = CKEDITOR.env.webkit && this.document && this.document.getWindow().$.frameElement,\r
                outer = resizeInner ? container.getChild( 1 ) : container;\r
 \r
-       // Resize the width first.\r
-       // WEBKIT BUG: Webkit requires that we put the editor off from display when we\r
-       // resize it. If we don't, the browser crashes!\r
-       CKEDITOR.env.webkit && outer.setStyle( 'display', 'none' );\r
        // Set as border box width. (#5353)\r
        outer.setSize( 'width',  width, true );\r
-       if ( CKEDITOR.env.webkit )\r
-       {\r
-               outer.$.offsetWidth;\r
-               outer.setStyle( 'display', '' );\r
-       }\r
+\r
+       // WebKit needs to refresh the iframe size to avoid rendering issues. (1/2) (#8348)\r
+       contentsFrame && ( contentsFrame.style.width = '1%' );\r
 \r
        // Get the height delta between the outer table and the content area.\r
        // If we're setting the content area's height, then we don't need the delta.\r
        var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );\r
        contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' );\r
 \r
+       // WebKit needs to refresh the iframe size to avoid rendering issues. (2/2) (#8348)\r
+       contentsFrame && ( contentsFrame.style.width = '100%' );\r
+\r
        // Emit a resize event.\r
        this.fire( 'resize' );\r
 };\r
@@ -326,12 +364,13 @@ CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, res
  * Gets the element that can be freely used to check the editor size. This method\r
  * is mainly used by the resize plugin, which adds a UI handle that can be used\r
  * to resize the editor.\r
+ * @param {Boolean} forContents Whether to return the "contents" part of the theme instead of the container.\r
  * @returns {CKEDITOR.dom.element} The resizable element.\r
  * @example\r
  */\r
-CKEDITOR.editor.prototype.getResizable = function()\r
+CKEDITOR.editor.prototype.getResizable = function( forContents )\r
 {\r
-       return this.container.getChild( 1 );\r
+       return forContents ? CKEDITOR.document.getById( 'cke_contents_' + this.name ) : this.container;\r
 };\r
 \r
 /**\r
@@ -363,6 +402,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