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