X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fskins.js;h=2876e55c32571d88f92416b478601bc18938b22f;hp=22ff5fcdbbcb4d3b1fa6fec6ae8591d807ba3e66;hb=941b0a9ba4e673e292510d80a5a86806994b8ea6;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d diff --git a/_source/core/skins.js b/_source/core/skins.js index 22ff5fc..2876e55 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-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -20,11 +20,20 @@ CKEDITOR.skins = (function() var preloaded = {}; var 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,6 +42,18 @@ CKEDITOR.skins = (function() } }; + function fixCSSTextRelativePath( cssStyleText, baseUrl ) + { + return cssStyleText.replace( /url\s*\(([\s'"]*)(.*?)([\s"']*)\)/g, + function( match, opener, path, closer ) + { + if ( /^\/|^\w?:/.test( path ) ) + return match; + else + return 'url(' + baseUrl + opener + path + closer + ')'; + } ); + } + // Check if we need to preload images from it. if ( !preloaded[ skinName ] ) { @@ -43,7 +64,7 @@ CKEDITOR.skins = (function() CKEDITOR.imageCacher.load( preload, function() { preloaded[ skinName ] = 1; - loadedPart( skinName, part, callback ); + loadPart( editor, skinName, part, callback ); } ); return; } @@ -96,10 +117,23 @@ CKEDITOR.skins = (function() // Load the "css" pieces. if ( !cssIsLoaded ) { - appendSkinPath( part.css ); + var cssPart = part.css; + + 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 ); + } - for ( var c = 0 ; c < part.css.length ; c++ ) - CKEDITOR.document.appendStyleSheet( part.css[ c ] ); + part.css = cssPart; cssIsLoaded = 1; } @@ -156,29 +190,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() { - 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 ); }); } }