JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1
[ckeditor.git] / _source / skins / kama / skin.js
index 63ab4a0..55a97dc 100644 (file)
@@ -1,11 +1,12 @@
 /*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
 CKEDITOR.skins.add( 'kama', (function()\r
 {\r
-       var preload = [];\r
+       var preload = [],\r
+               uiColorStylesheetId = 'cke_ui_color';\r
 \r
        if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 )\r
        {\r
@@ -89,12 +90,15 @@ CKEDITOR.skins.add( 'kama', (function()
                                        uiColorMenuCss[ i ] = uiColorMenuCss[ i ].split( '{' );\r
                        }\r
 \r
-                       function addStylesheet( document )\r
+                       function getStylesheet( document )\r
                        {\r
-                               var node = document.getHead().append( 'style' );\r
-                               node.setAttribute( "id", "cke_ui_color" );\r
-                               node.setAttribute( "type", "text/css" );\r
-\r
+                               var node = document.getById( uiColorStylesheetId );\r
+                               if( !node )\r
+                               {\r
+                                       node = document.getHead().append( 'style' );\r
+                                       node.setAttribute( "id", uiColorStylesheetId );\r
+                                       node.setAttribute( "type", "text/css" );\r
+                               }\r
                                return node;\r
                        }\r
 \r
@@ -105,10 +109,6 @@ CKEDITOR.skins.add( 'kama', (function()
                                {\r
                                        if ( CKEDITOR.env.webkit )\r
                                        {\r
-                                               // Truncate manually.\r
-                                               for ( i = 0 ; i < styleNodes[ id ].$.sheet.rules.length ; i++ )\r
-                                                       styleNodes[ id ].$.sheet.removeRule( i );\r
-\r
                                                for ( i = 0 ; i < styleContent.length ; i++ )\r
                                                {\r
                                                        content = styleContent[ i ][ 1 ];\r
@@ -125,9 +125,9 @@ CKEDITOR.skins.add( 'kama', (function()
                                                        content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );\r
 \r
                                                if ( CKEDITOR.env.ie )\r
-                                                       styleNodes[ id ].$.styleSheet.cssText = content;\r
+                                                       styleNodes[ id ].$.styleSheet.cssText += content;\r
                                                else\r
-                                                       styleNodes[ id ].setHtml( content );\r
+                                                       styleNodes[ id ].$.innerHTML += content;\r
                                        }\r
                                }\r
                        }\r
@@ -146,8 +146,8 @@ CKEDITOR.skins.add( 'kama', (function()
                                setUiColor : function( color )\r
                                {\r
                                        var cssContent,\r
-                                               uiStyle = addStylesheet( CKEDITOR.document ),\r
-                                               cssId = '#cke_' + editor.name.replace('.', '\\.');\r
+                                               uiStyle = getStylesheet( CKEDITOR.document ),\r
+                                               cssId = '.cke_editor_' + CKEDITOR.tools.escapeCssSelector( editor.name );\r
 \r
                                        var cssSelectors =\r
                                                [\r
@@ -186,7 +186,7 @@ CKEDITOR.skins.add( 'kama', (function()
                                // Add stylesheet if missing.\r
                                if ( !iframe.getById( 'cke_ui_color' ) )\r
                                {\r
-                                       var node = addStylesheet( iframe );\r
+                                       var node = getStylesheet( iframe );\r
                                        uiColorMenus.push( node );\r
 \r
                                        var color = editor.getUiColor();\r
@@ -203,63 +203,55 @@ CKEDITOR.skins.add( 'kama', (function()
        };\r
 })() );\r
 \r
-if ( CKEDITOR.dialog )\r
+(function()\r
 {\r
-       CKEDITOR.dialog.on( 'resize', function( evt )\r
-               {\r
-                       var data = evt.data,\r
-                               width = data.width,\r
-                               height = data.height,\r
-                               dialog = data.dialog,\r
-                               contents = dialog.parts.contents,\r
-                               standardsMode = !CKEDITOR.env.quirks;\r
+       CKEDITOR.dialog ? dialogSetup() : CKEDITOR.on( 'dialogPluginReady', dialogSetup );\r
 \r
-                       if ( data.skin != 'kama' )\r
-                               return;\r
+       function dialogSetup()\r
+       {\r
+               CKEDITOR.dialog.on( 'resize', function( evt )\r
+                       {\r
+                               var data = evt.data,\r
+                                       width = data.width,\r
+                                       height = data.height,\r
+                                       dialog = data.dialog,\r
+                                       contents = dialog.parts.contents;\r
+\r
+                               if ( data.skin != 'kama' )\r
+                                       return;\r
 \r
-                       contents.setStyles(\r
-                               ( CKEDITOR.env.ie || ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ) ?         // IE && FF2\r
+                               contents.setStyles(\r
                                        {\r
                                                width : width + 'px',\r
                                                height : height + 'px'\r
-                                       }\r
-                               :\r
-                                       {\r
-                                               // To avoid having scrollbars in the dialogs, we're\r
-                                               // (for now) using the "min-xxx" properties, for\r
-                                               // browsers which well support it (#3878).\r
-                                               'min-width' : width + 'px',\r
-                                               'min-height' : height + 'px'\r
                                        });\r
 \r
-                       if ( !CKEDITOR.env.ie )\r
-                               return;\r
-\r
-                       // Fix the size of the elements which have flexible lengths.\r
-                       setTimeout( function()\r
-                               {\r
-                                       var body = contents.getParent(),\r
-                                               innerDialog = body.getParent();\r
-\r
-                                       // tc\r
-                                       var el = innerDialog.getChild( 2 );\r
-                                       el.setStyle( 'width', ( body.$.offsetWidth ) + 'px' );\r
-\r
-                                       // bc\r
-                                       el = innerDialog.getChild( 7 );\r
-                                       el.setStyle( 'width', ( body.$.offsetWidth - 28 ) + 'px' );\r
-\r
-                                       // ml\r
-                                       el = innerDialog.getChild( 4 );\r
-                                       el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );\r
-\r
-                                       // mr\r
-                                       el = innerDialog.getChild( 5 );\r
-                                       el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );\r
-                               },\r
-                               100 );\r
-               });\r
-}\r
+                               // Fix the size of the elements which have flexible lengths.\r
+                               setTimeout( function()\r
+                                       {\r
+                                               var innerDialog = dialog.parts.dialog.getChild( [ 0, 0, 0 ] ),\r
+                                                       body = innerDialog.getChild( 0 );\r
+\r
+                                               // tc\r
+                                               var el = innerDialog.getChild( 2 );\r
+                                               el.setStyle( 'width', ( body.$.offsetWidth ) + 'px' );\r
+\r
+                                               // bc\r
+                                               el = innerDialog.getChild( 7 );\r
+                                               el.setStyle( 'width', ( body.$.offsetWidth - 28 ) + 'px' );\r
+\r
+                                               // ml\r
+                                               el = innerDialog.getChild( 4 );\r
+                                               el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );\r
+\r
+                                               // mr\r
+                                               el = innerDialog.getChild( 5 );\r
+                                               el.setStyle( 'height', ( body.$.offsetHeight - 31 - 14 ) + 'px' );\r
+                                       },\r
+                                       100 );\r
+                       });\r
+       }\r
+})();\r
 \r
 /**\r
  * The base user interface color to be used by the editor. Not all skins are\r