fckxhtml_gecko.js
上传用户:ah_jiwei
上传日期:2022-07-24
资源大小:54044k
文件大小:3k
源码类别:

数据库编程

开发平台:

Visual C++

  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.  * Defines the FCKXHtml object, responsible for the XHTML operations.
  22.  * Gecko specific.
  23.  */
  24. FCKXHtml._GetMainXmlString = function()
  25. {
  26. // Create the XMLSerializer.
  27. var oSerializer = new XMLSerializer() ;
  28. // Return the serialized XML as a string.
  29. return oSerializer.serializeToString( this.MainNode ) ;
  30. }
  31. FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node )
  32. {
  33. var aAttributes = htmlNode.attributes ;
  34. for ( var n = 0 ; n < aAttributes.length ; n++ )
  35. {
  36. var oAttribute = aAttributes[n] ;
  37. if ( oAttribute.specified )
  38. {
  39. var sAttName = oAttribute.nodeName.toLowerCase() ;
  40. var sAttValue ;
  41. // Ignore any attribute starting with "_fck".
  42. if ( sAttName.StartsWith( '_fck' ) )
  43. continue ;
  44. // There is a bug in Mozilla that returns '_moz_xxx' attributes as specified.
  45. else if ( sAttName.indexOf( '_moz' ) == 0 )
  46. continue ;
  47. // There are one cases (on Gecko) when the oAttribute.nodeValue must be used:
  48. // - for the "class" attribute
  49. else if ( sAttName == 'class' )
  50. {
  51. sAttValue = oAttribute.nodeValue.replace( FCKRegexLib.FCK_Class, '' ) ;
  52. if ( sAttValue.length == 0 )
  53. continue ;
  54. }
  55. // XHTML doens't support attribute minimization like "CHECKED". It must be transformed to checked="checked".
  56. else if ( oAttribute.nodeValue === true )
  57. sAttValue = sAttName ;
  58. else
  59. sAttValue = htmlNode.getAttribute( sAttName, 2 ) ; // We must use getAttribute to get it exactly as it is defined.
  60. this._AppendAttribute( node, sAttName, sAttValue ) ;
  61. }
  62. }
  63. }
  64. if ( FCKBrowserInfo.IsOpera )
  65. {
  66. // Opera moves the <FCK:meta> element outside head (#1166).
  67. // Save a reference to the XML <head> node, so we can use it for
  68. // orphan <meta>s.
  69. FCKXHtml.TagProcessors['head'] = function( node, htmlNode )
  70. {
  71. FCKXHtml.XML._HeadElement = node ;
  72. node = FCKXHtml._AppendChildNodes( node, htmlNode, true ) ;
  73. return node ;
  74. }
  75. // Check whether a <meta> element is outside <head>, and move it to the
  76. // proper place.
  77. FCKXHtml.TagProcessors['meta'] = function( node, htmlNode, xmlNode )
  78. {
  79. if ( htmlNode.parentNode.nodeName.toLowerCase() != 'head' )
  80. {
  81. var headElement = FCKXHtml.XML._HeadElement ;
  82. if ( headElement && xmlNode != headElement )
  83. {
  84. delete htmlNode._fckxhtmljob ;
  85. FCKXHtml._AppendNode( headElement, htmlNode ) ;
  86. return null ;
  87. }
  88. }
  89. return node ;
  90. }
  91. }