2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fckstylesloader.js
14
* FCKStylesLoader Class: this class define objects that are responsible
15
* for loading the styles defined in the XML file.
18
* Frederico Caldeira Knabben (fredck@fckeditor.net)
21
var FCKStylesLoader = function()
23
this.Styles = new Object() ;
24
this.StyleGroups = new Object() ;
26
this.HasObjectElements = false ;
29
FCKStylesLoader.prototype.Load = function( stylesXmlUrl )
31
// Load the XML file into a FCKXml object.
32
var oXml = new FCKXml() ;
33
oXml.LoadUrl( stylesXmlUrl ) ;
35
// Get the "Style" nodes defined in the XML file.
36
var aStyleNodes = oXml.SelectNodes( 'Styles/Style' ) ;
38
// Add each style to our "Styles" collection.
39
for ( var i = 0 ; i < aStyleNodes.length ; i++ )
41
var sElement = aStyleNodes[i].attributes.getNamedItem('element').value.toUpperCase() ;
43
// Create the style definition object.
44
var oStyleDef = new FCKStyleDef( aStyleNodes[i].attributes.getNamedItem('name').value, sElement ) ;
46
if ( oStyleDef.IsObjectElement )
47
this.HasObjectElements = true ;
49
// Get the attributes defined for the style (if any).
50
var aAttNodes = oXml.SelectNodes( 'Attribute', aStyleNodes[i] ) ;
52
// Add the attributes to the style definition object.
53
for ( var j = 0 ; j < aAttNodes.length ; j++ )
55
var sAttName = aAttNodes[j].attributes.getNamedItem('name').value ;
56
var sAttValue = aAttNodes[j].attributes.getNamedItem('value').value ;
58
// IE changes the "style" attribute value when applied to an element
59
// so we must get the final resulting value (for comparision issues).
60
if ( sAttName.toLowerCase() == 'style' )
62
var oTempE = document.createElement( 'SPAN' ) ;
63
oTempE.style.cssText = sAttValue ;
64
sAttValue = oTempE.style.cssText ;
67
oStyleDef.AddAttribute( sAttName, sAttValue ) ;
70
// Add the style to the "Styles" collection using it's name as the key.
71
this.Styles[ oStyleDef.Name ] = oStyleDef ;
73
// Add the style to the "StyleGroups" collection.
74
var aGroup = this.StyleGroups[sElement] ;
77
this.StyleGroups[sElement] = new Array() ;
78
aGroup = this.StyleGroups[sElement] ;
80
aGroup[aGroup.length] = oStyleDef ;
b'\\ No newline at end of file'