[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/fckeditor/editor/_source/internals/ -> fckxhtml_ie.js (source)

   1  /*
   2   * FCKeditor - The text editor for internet
   3   * Copyright (C) 2003-2006 Frederico Caldeira Knabben
   4   * 
   5   * Licensed under the terms of the GNU Lesser General Public License:
   6   *         http://www.opensource.org/licenses/lgpl-license.php
   7   * 
   8   * For further information visit:
   9   *         http://www.fckeditor.net/
  10   * 
  11   * "Support Open Source software. What about a donation today?"
  12   * 
  13   * File Name: fckxhtml_ie.js
  14   *     Defines the FCKXHtml object, responsible for the XHTML operations.
  15   *     IE specific.
  16   * 
  17   * File Authors:
  18   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  19   */
  20  
  21  FCKXHtml._GetMainXmlString = function()
  22  {
  23      return this.MainNode.xml ;
  24  }
  25  
  26  FCKXHtml._AppendEntity = function( xmlNode, entity )
  27  {
  28      xmlNode.appendChild( this.XML.createEntityReference( entity ) ) ;
  29  }
  30  
  31  FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node, nodeName )
  32  {
  33      var aAttributes = htmlNode.attributes ;
  34  
  35      for ( var n = 0 ; n < aAttributes.length ; n++ )
  36      {
  37          var oAttribute = aAttributes[n] ;
  38  
  39          if ( oAttribute.specified )
  40          {
  41              var sAttName = oAttribute.nodeName.toLowerCase() ;
  42              var sAttValue ;
  43  
  44              // Ignore any attribute starting with "_fck".
  45              if ( sAttName.startsWith( '_fck' ) )
  46                  continue ;
  47              // The following must be done because of a bug on IE regarding the style
  48              // attribute. It returns "null" for the nodeValue.
  49              else if ( sAttName == 'style' )
  50                  sAttValue = htmlNode.style.cssText ;
  51              // There are two cases when the oAttribute.nodeValue must be used:
  52              //        - for the "class" attribute
  53              //        - for events attributes (on IE only).
  54              else if ( sAttName == 'class' || sAttName.indexOf('on') == 0 )
  55                  sAttValue = oAttribute.nodeValue ;
  56              else if ( nodeName == 'body' && sAttName == 'contenteditable' )
  57                  continue ;
  58              // XHTML doens't support attribute minimization like "CHECKED". It must be trasformed to cheched="checked".
  59              else if ( oAttribute.nodeValue === true )
  60                  sAttValue = sAttName ;
  61              // We must use getAttribute to get it exactly as it is defined.
  62              else if ( ! (sAttValue = htmlNode.getAttribute( sAttName, 2 ) ) )
  63                  sAttValue = oAttribute.nodeValue ;
  64  
  65              if ( FCKConfig.ForceSimpleAmpersand && sAttValue.replace )
  66                  sAttValue = sAttValue.replace( /&/g, '___FCKAmp___' ) ;
  67  
  68              this._AppendAttribute( node, sAttName, sAttValue ) ;
  69          }
  70      }
  71  }
  72  
  73  FCKXHtml.TagProcessors['meta'] = function( node, htmlNode )
  74  {
  75      var oHttpEquiv = node.attributes.getNamedItem( 'http-equiv' ) ;
  76  
  77      if ( oHttpEquiv == null || oHttpEquiv.value.length == 0 )
  78      {
  79          // Get the http-equiv value from the outerHTML.
  80          var sHttpEquiv = htmlNode.outerHTML.match( FCKRegexLib.MetaHttpEquiv ) ;
  81  
  82          if ( sHttpEquiv )
  83          {
  84              sHttpEquiv = sHttpEquiv[1] ;
  85              FCKXHtml._AppendAttribute( node, 'http-equiv', sHttpEquiv ) ;
  86          }
  87      }
  88  
  89      return node ;
  90  }
  91  
  92  // IE automaticaly changes <FONT> tags to <FONT size=+0>.
  93  FCKXHtml.TagProcessors['font'] = function( node, htmlNode )
  94  {
  95      if ( node.attributes.length == 0 )
  96          node = FCKXHtml.XML.createDocumentFragment() ;
  97  
  98      FCKXHtml._AppendChildNodes( node, htmlNode ) ;
  99  
 100      return node ;
 101  }
 102  
 103  // IE doens't see the value attribute as an attribute for the <INPUT> tag.
 104  FCKXHtml.TagProcessors['input'] = function( node, htmlNode )
 105  {
 106      if ( htmlNode.name )
 107          FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
 108  
 109      if ( htmlNode.value && !node.attributes.getNamedItem( 'value' ) )
 110          FCKXHtml._AppendAttribute( node, 'value', htmlNode.value ) ;
 111  
 112      return node ;
 113  }
 114  
 115  // IE ignores the "SELECTED" attribute so we must add it manually.
 116  FCKXHtml.TagProcessors['option'] = function( node, htmlNode )
 117  {
 118      if ( htmlNode.selected && !node.attributes.getNamedItem( 'selected' ) )
 119          FCKXHtml._AppendAttribute( node, 'selected', 'selected' ) ;
 120  
 121      FCKXHtml._AppendChildNodes( node, htmlNode ) ;
 122  
 123      return node ;
 124  }
 125  
 126  // There is a BUG in IE regarding the ABBR tag (it has no support for it).
 127  FCKXHtml.TagProcessors['abbr'] = function( node, htmlNode )
 128  {
 129      // TODO: The XHTML processor duplicates the ABBR contents because of this 
 130      // code. We should find some way to move to the node after the /ABBR in the
 131      // _AppendChildNodes loop.
 132  
 133      var oNextNode = htmlNode.nextSibling ;
 134  
 135      while ( true )
 136      {
 137          if ( oNextNode && oNextNode.nodeName != '/ABBR' )
 138          {
 139              FCKXHtml._AppendNode( node, oNextNode ) ;
 140              oNextNode = oNextNode.nextSibling ;
 141          }
 142          else
 143              break ;
 144      }
 145  
 146      return node ;
 147  }
 148  
 149  // IE ignores the "COORDS" and "SHAPE" attribute so we must add it manually.
 150  FCKXHtml.TagProcessors['area'] = function( node, htmlNode )
 151  {
 152      if ( ! node.attributes.getNamedItem( 'coords' ) )
 153      {
 154          var sCoords = htmlNode.getAttribute( 'coords', 2 ) ;
 155          if ( sCoords && sCoords != '0,0,0' )
 156              FCKXHtml._AppendAttribute( node, 'coords', sCoords ) ;
 157      }
 158  
 159      if ( ! node.attributes.getNamedItem( 'shape' ) )
 160      {
 161          var sCoords = htmlNode.getAttribute( 'shape', 2 ) ;
 162          if ( sCoords && sCoords.length > 0 )
 163              FCKXHtml._AppendAttribute( node, 'shape', sCoords ) ;
 164      }
 165  
 166      return node ;
 167  }
 168  
 169  FCKXHtml.TagProcessors['label'] = function( node, htmlNode )
 170  {
 171      if ( htmlNode.htmlFor.length > 0 )
 172          FCKXHtml._AppendAttribute( node, 'for', htmlNode.htmlFor ) ;
 173  
 174      FCKXHtml._AppendChildNodes( node, htmlNode ) ;
 175  
 176      return node ;
 177  }
 178  
 179  FCKXHtml.TagProcessors['form'] = function( node, htmlNode )
 180  {
 181      if ( htmlNode.acceptCharset && htmlNode.acceptCharset.length > 0 && htmlNode.acceptCharset != 'UNKNOWN' )
 182          FCKXHtml._AppendAttribute( node, 'accept-charset', htmlNode.acceptCharset ) ;
 183  
 184      if ( htmlNode.name ) 
 185          FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ; 
 186  
 187      FCKXHtml._AppendChildNodes( node, htmlNode ) ;
 188  
 189      return node ;
 190  }
 191  
 192  // IE doens't hold the name attribute as an attribute for the <TEXTAREA> and <SELECT> tags.
 193  FCKXHtml.TagProcessors['textarea'] = FCKXHtml.TagProcessors['select'] = function( node, htmlNode )
 194  { 
 195      if ( htmlNode.name ) 
 196          FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ; 
 197  
 198      FCKXHtml._AppendChildNodes( node, htmlNode ) ; 
 199   
 200      return node ; 
 201  } 
 202  
 203  // On very rare cases, IE is loosing the "align" attribute for DIV. (right align and apply bulleted list)
 204  FCKXHtml.TagProcessors['div'] = function( node, htmlNode )
 205  {
 206      if ( htmlNode.align.length > 0 )
 207          FCKXHtml._AppendAttribute( node, 'align', htmlNode.align ) ;
 208  
 209      FCKXHtml._AppendChildNodes( node, htmlNode ) ;
 210  
 211      return node ;
 212  }


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics