X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fskins.js;h=f91d45c5fbdbeabb3b6dc8358d72fa9f3a8bb45a;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=2de74567a4b01ae96397060838426dbcb4867f1f;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/core/skins.js b/_source/core/skins.js index 2de7456..f91d45c 100644 --- a/_source/core/skins.js +++ b/_source/core/skins.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -16,15 +16,23 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.skins = (function() { // Holds the list of loaded skins. - var loaded = {}; - var preloaded = {}; - var paths = {}; + var loaded = {}, + paths = {}; - var loadedPart = function( skinName, part, callback ) + var loadPart = function( editor, skinName, part, callback ) { // Get the skin definition. var skinDefinition = loaded[ skinName ]; + if ( !editor.skin ) + { + editor.skin = skinDefinition; + + // Trigger init function if any. + if ( skinDefinition.init ) + skinDefinition.init( editor ); + } + var appendSkinPath = function( fileNames ) { for ( var n = 0 ; n < fileNames.length ; n++ ) @@ -33,23 +41,16 @@ CKEDITOR.skins = (function() } }; - // Check if we need to preload images from it. - if ( !preloaded[ skinName ] ) + function fixCSSTextRelativePath( cssStyleText, baseUrl ) { - var preload = skinDefinition.preload; - if ( preload && preload.length > 0 ) - { - appendSkinPath( preload ); - CKEDITOR.imageCacher.load( preload, function() + return cssStyleText.replace( /url\s*\(([\s'"]*)(.*?)([\s"']*)\)/g, + function( match, opener, path, closer ) { - preloaded[ skinName ] = 1; - loadedPart( skinName, part, callback ); + if ( /^\/|^\w?:/.test( path ) ) + return match; + else + return 'url(' + baseUrl + opener + path + closer + ')'; } ); - return; - } - - // Mark it as preloaded. - preloaded[ skinName ] = 1; } // Get the part definition. @@ -72,8 +73,8 @@ CKEDITOR.skins = (function() // Check whether the "css" and "js" properties have been defined // for that part. - var cssIsLoaded = !part.css || !part.css.length; - var jsIsLoaded = !part.js || !part.js.length; + var cssIsLoaded = !part.css || !part.css.length, + jsIsLoaded = !part.js || !part.js.length; // This is the function that will trigger the callback calls on // load. @@ -96,10 +97,23 @@ CKEDITOR.skins = (function() // Load the "css" pieces. if ( !cssIsLoaded ) { - appendSkinPath( part.css ); + var cssPart = part.css; - for ( var c = 0 ; c < part.css.length ; c++ ) - CKEDITOR.document.appendStyleSheet( part.css[ c ] ); + if ( CKEDITOR.tools.isArray( cssPart ) ) + { + appendSkinPath( cssPart ); + for ( var c = 0 ; c < cssPart.length ; c++ ) + CKEDITOR.document.appendStyleSheet( cssPart[ c ] ); + } + else + { + cssPart = fixCSSTextRelativePath( + cssPart, CKEDITOR.getUrl( paths[ skinName ] ) ); + // Processing Inline CSS part. + CKEDITOR.document.appendStyleText( cssPart ); + } + + part.css = cssPart; cssIsLoaded = 1; } @@ -135,6 +149,7 @@ CKEDITOR.skins = (function() skinDefinition.skinPath = paths[ skinName ] || ( paths[ skinName ] = CKEDITOR.getUrl( + '_source/' + // @Packager.RemoveLine 'skins/' + skinName + '/' ) ); }, @@ -155,29 +170,13 @@ CKEDITOR.skins = (function() skinPath = editor.skinPath; if ( loaded[ skinName ] ) - { - loadedPart( skinName, skinPart, callback ); - - // Get the skin definition. - var skinDefinition = loaded[ skinName ]; - - // Trigger init function if any. - if ( skinDefinition.init ) - skinDefinition.init( editor ); - } + loadPart( editor, skinName, skinPart, callback ); else { paths[ skinName ] = skinPath; - CKEDITOR.scriptLoader.load( skinPath + 'skin.js', function() + CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( skinPath + 'skin.js' ), function() { - loadedPart( skinName, skinPart, callback ); - - // Get the skin definition. - var skinDefinition = loaded[ skinName ]; - - // Trigger init function if any. - if ( skinDefinition.init ) - skinDefinition.init( editor ); + loadPart( editor, skinName, skinPart, callback ); }); } }