[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/editor/_source/classes/ -> fckstylesloader.js (source)

   1  /*
   2   * FCKeditor - The text editor for Internet - http://www.fckeditor.net
   3   * Copyright (C) 2003-2007 Frederico Caldeira Knabben
   4   * 
   5   * == BEGIN LICENSE ==
   6   * 
   7   * Licensed under the terms of any of the following licenses at your
   8   * choice:
   9   * 
  10   *  - GNU General Public License Version 2 or later (the "GPL")
  11   *    http://www.gnu.org/licenses/gpl.html
  12   * 
  13   *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14   *    http://www.gnu.org/licenses/lgpl.html
  15   * 
  16   *  - Mozilla Public License Version 1.1 or later (the "MPL")
  17   *    http://www.mozilla.org/MPL/MPL-1.1.html
  18   * 
  19   * == END LICENSE ==
  20   * 
  21   * File Name: fckstylesloader.js
  22   *     FCKStylesLoader Class: this class define objects that are responsible
  23   *     for loading the styles defined in the XML file.
  24   * 
  25   * File Authors:
  26   *         Frederico Caldeira Knabben (www.fckeditor.net)
  27   */
  28  
  29  var FCKStylesLoader = function()
  30  {
  31      this.Styles = new Object() ;
  32      this.StyleGroups = new Object() ;
  33      this.Loaded = false ;
  34      this.HasObjectElements = false ;
  35  }
  36  
  37  FCKStylesLoader.prototype.Load = function( stylesXmlUrl )
  38  {
  39      // Load the XML file into a FCKXml object.
  40      var oXml = new FCKXml() ;
  41      oXml.LoadUrl( stylesXmlUrl ) ;
  42      
  43      // Get the "Style" nodes defined in the XML file.
  44      var aStyleNodes = oXml.SelectNodes( 'Styles/Style' ) ;
  45      
  46      // Add each style to our "Styles" collection.
  47      for ( var i = 0 ; i < aStyleNodes.length ; i++ )
  48      {
  49          var sElement = aStyleNodes[i].attributes.getNamedItem('element').value.toUpperCase() ;
  50      
  51          // Create the style definition object.
  52          var oStyleDef = new FCKStyleDef( aStyleNodes[i].attributes.getNamedItem('name').value, sElement ) ;
  53          
  54          if ( oStyleDef.IsObjectElement )
  55              this.HasObjectElements = true ;
  56          
  57          // Get the attributes defined for the style (if any).
  58          var aAttNodes = oXml.SelectNodes( 'Attribute', aStyleNodes[i] ) ;
  59          
  60          // Add the attributes to the style definition object.
  61          for ( var j = 0 ; j < aAttNodes.length ; j++ )
  62          {
  63              var sAttName    = aAttNodes[j].attributes.getNamedItem('name').value ;
  64              var sAttValue    = aAttNodes[j].attributes.getNamedItem('value').value ;
  65  
  66              // IE changes the "style" attribute value when applied to an element
  67              // so we must get the final resulting value (for comparision issues).
  68              if ( sAttName.toLowerCase() == 'style' )
  69              {
  70                  var oTempE = document.createElement( 'SPAN' ) ;
  71                  oTempE.style.cssText = sAttValue ;
  72                  sAttValue = oTempE.style.cssText ;
  73              }
  74              
  75              oStyleDef.AddAttribute( sAttName, sAttValue ) ;
  76          }
  77  
  78          // Add the style to the "Styles" collection using it's name as the key.
  79          this.Styles[ oStyleDef.Name ] = oStyleDef ;
  80          
  81          // Add the style to the "StyleGroups" collection.
  82          var aGroup = this.StyleGroups[sElement] ;
  83          if ( aGroup == null )
  84          {
  85              this.StyleGroups[sElement] = new Array() ;
  86              aGroup = this.StyleGroups[sElement] ;
  87          }
  88          aGroup[aGroup.length] = oStyleDef ;
  89      }
  90      
  91      this.Loaded = true ;
  92  }


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7