fckxhtml_ie.js
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:

OA系统

开发平台:

C#

  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. FCKXHtml._GetMainXmlString = function()
  21. {
  22. return this.MainNode.xml ;
  23. }
  24. FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node, nodeName )
  25. {
  26. var aAttributes = htmlNode.attributes ;
  27. for ( var n = 0 ; n < aAttributes.length ; n++ )
  28. {
  29. var oAttribute = aAttributes[n] ;
  30. if ( oAttribute.specified )
  31. {
  32. var sAttName = oAttribute.nodeName.toLowerCase() ;
  33. var sAttValue ;
  34. // Ignore any attribute starting with "_fck".
  35. if ( sAttName.startsWith( '_fck' ) )
  36. continue ;
  37. // The following must be done because of a bug on IE regarding the style
  38. // attribute. It returns "null" for the nodeValue.
  39. else if ( sAttName == 'style' )
  40. sAttValue = htmlNode.style.cssText ;
  41. // There are two cases when the oAttribute.nodeValue must be used:
  42. // - for the "class" attribute
  43. // - for events attributes (on IE only).
  44. else if ( sAttName == 'class' || sAttName.indexOf('on') == 0 )
  45. sAttValue = oAttribute.nodeValue ;
  46. else if ( nodeName == 'body' && sAttName == 'contenteditable' )
  47. continue ;
  48. // XHTML doens't support attribute minimization like "CHECKED". It must be trasformed to cheched="checked".
  49. else if ( oAttribute.nodeValue === true )
  50. sAttValue = sAttName ;
  51. // We must use getAttribute to get it exactly as it is defined.
  52. else if ( ! (sAttValue = htmlNode.getAttribute( sAttName, 2 ) ) )
  53. sAttValue = oAttribute.nodeValue ;
  54. this._AppendAttribute( node, sAttName, sAttValue ) ;
  55. }
  56. }
  57. }
  58. FCKXHtml.TagProcessors['meta'] = function( node, htmlNode )
  59. {
  60. var oHttpEquiv = node.attributes.getNamedItem( 'http-equiv' ) ;
  61. if ( oHttpEquiv == null || oHttpEquiv.value.length == 0 )
  62. {
  63. // Get the http-equiv value from the outerHTML.
  64. var sHttpEquiv = htmlNode.outerHTML.match( FCKRegexLib.MetaHttpEquiv ) ;
  65. if ( sHttpEquiv )
  66. {
  67. sHttpEquiv = sHttpEquiv[1] ;
  68. FCKXHtml._AppendAttribute( node, 'http-equiv', sHttpEquiv ) ;
  69. }
  70. }
  71. return node ;
  72. }
  73. // IE automaticaly changes <FONT> tags to <FONT size=+0>.
  74. FCKXHtml.TagProcessors['font'] = function( node, htmlNode )
  75. {
  76. if ( node.attributes.length == 0 )
  77. node = FCKXHtml.XML.createDocumentFragment() ;
  78. FCKXHtml._AppendChildNodes( node, htmlNode ) ;
  79. return node ;
  80. }
  81. // IE doens't see the value attribute as an attribute for the <INPUT> tag.
  82. FCKXHtml.TagProcessors['input'] = function( node, htmlNode )
  83. {
  84. if ( htmlNode.name )
  85. FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
  86. if ( htmlNode.value && !node.attributes.getNamedItem( 'value' ) )
  87. FCKXHtml._AppendAttribute( node, 'value', htmlNode.value ) ;
  88. if ( !node.attributes.getNamedItem( 'type' ) )
  89. FCKXHtml._AppendAttribute( node, 'type', 'text' ) ;
  90. return node ;
  91. }
  92. // IE ignores the "SELECTED" attribute so we must add it manually.
  93. FCKXHtml.TagProcessors['option'] = function( node, htmlNode )
  94. {
  95. if ( htmlNode.selected && !node.attributes.getNamedItem( 'selected' ) )
  96. FCKXHtml._AppendAttribute( node, 'selected', 'selected' ) ;
  97. FCKXHtml._AppendChildNodes( node, htmlNode ) ;
  98. return node ;
  99. }
  100. // IE ignores the "COORDS" and "SHAPE" attribute so we must add it manually.
  101. FCKXHtml.TagProcessors['area'] = function( node, htmlNode )
  102. {
  103. if ( ! node.attributes.getNamedItem( 'coords' ) )
  104. {
  105. var sCoords = htmlNode.getAttribute( 'coords', 2 ) ;
  106. if ( sCoords && sCoords != '0,0,0' )
  107. FCKXHtml._AppendAttribute( node, 'coords', sCoords ) ;
  108. }
  109. if ( ! node.attributes.getNamedItem( 'shape' ) )
  110. {
  111. var sCoords = htmlNode.getAttribute( 'shape', 2 ) ;
  112. if ( sCoords && sCoords.length > 0 )
  113. FCKXHtml._AppendAttribute( node, 'shape', sCoords ) ;
  114. }
  115. return node ;
  116. }
  117. FCKXHtml.TagProcessors['label'] = function( node, htmlNode )
  118. {
  119. if ( htmlNode.htmlFor.length > 0 )
  120. FCKXHtml._AppendAttribute( node, 'for', htmlNode.htmlFor ) ;
  121. FCKXHtml._AppendChildNodes( node, htmlNode ) ;
  122. return node ;
  123. }
  124. FCKXHtml.TagProcessors['form'] = function( node, htmlNode )
  125. {
  126. if ( htmlNode.acceptCharset && htmlNode.acceptCharset.length > 0 && htmlNode.acceptCharset != 'UNKNOWN' )
  127. FCKXHtml._AppendAttribute( node, 'accept-charset', htmlNode.acceptCharset ) ;
  128. if ( htmlNode.name ) 
  129. FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ; 
  130. FCKXHtml._AppendChildNodes( node, htmlNode ) ;
  131. return node ;
  132. }
  133. // IE doens't hold the name attribute as an attribute for the <TEXTAREA> and <SELECT> tags.
  134. FCKXHtml.TagProcessors['textarea'] = FCKXHtml.TagProcessors['select'] = function( node, htmlNode )
  135. if ( htmlNode.name ) 
  136. FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ; 
  137. FCKXHtml._AppendChildNodes( node, htmlNode ) ; 
  138.  
  139. return node ; 
  140. // On very rare cases, IE is loosing the "align" attribute for DIV. (right align and apply bulleted list)
  141. FCKXHtml.TagProcessors['div'] = function( node, htmlNode )
  142. {
  143. if ( htmlNode.align.length > 0 )
  144. FCKXHtml._AppendAttribute( node, 'align', htmlNode.align ) ;
  145. FCKXHtml._AppendChildNodes( node, htmlNode ) ;
  146. return node ;
  147. }