2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* Defines the FCKXHtml object, responsible for the XHTML operations.
25
FCKXHtml._GetMainXmlString = function()
27
return this.MainNode.xml ;
30
FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node, nodeName )
32
var aAttributes = htmlNode.attributes ;
34
for ( var n = 0 ; n < aAttributes.length ; n++ )
36
var oAttribute = aAttributes[n] ;
38
if ( oAttribute.specified )
40
var sAttName = oAttribute.nodeName.toLowerCase() ;
43
// Ignore any attribute starting with "_fck".
44
if ( sAttName.StartsWith( '_fck' ) )
46
// The following must be done because of a bug on IE regarding the style
47
// attribute. It returns "null" for the nodeValue.
48
else if ( sAttName == 'style' )
49
sAttValue = htmlNode.style.cssText.replace( FCKRegexLib.StyleProperties, FCKTools.ToLowerCase ) ;
50
// There are two cases when the oAttribute.nodeValue must be used:
51
// - for the "class" attribute
52
// - for events attributes (on IE only).
53
else if ( sAttName == 'class' || sAttName.indexOf('on') == 0 )
54
sAttValue = oAttribute.nodeValue ;
55
else if ( nodeName == 'body' && sAttName == 'contenteditable' )
57
// XHTML doens't support attribute minimization like "CHECKED". It must be trasformed to cheched="checked".
58
else if ( oAttribute.nodeValue === true )
59
sAttValue = sAttName ;
62
// We must use getAttribute to get it exactly as it is defined.
63
// There are some rare cases that IE throws an error here, so we must try/catch.
66
sAttValue = htmlNode.getAttribute( sAttName, 2 ) ;
70
this._AppendAttribute( node, sAttName, sAttValue || oAttribute.nodeValue ) ;
75
FCKXHtml.TagProcessors['meta'] = function( node, htmlNode )
77
var oHttpEquiv = node.attributes.getNamedItem( 'http-equiv' ) ;
79
if ( oHttpEquiv == null || oHttpEquiv.value.length == 0 )
81
// Get the http-equiv value from the outerHTML.
82
var sHttpEquiv = htmlNode.outerHTML.match( FCKRegexLib.MetaHttpEquiv ) ;
86
sHttpEquiv = sHttpEquiv[1] ;
87
FCKXHtml._AppendAttribute( node, 'http-equiv', sHttpEquiv ) ;
94
// IE automaticaly changes <FONT> tags to <FONT size=+0>.
95
FCKXHtml.TagProcessors['font'] = function( node, htmlNode )
97
if ( node.attributes.length == 0 )
98
node = FCKXHtml.XML.createDocumentFragment() ;
100
node = FCKXHtml._AppendChildNodes( node, htmlNode ) ;
105
// IE doens't see the value attribute as an attribute for the <INPUT> tag.
106
FCKXHtml.TagProcessors['input'] = function( node, htmlNode )
109
FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
111
if ( htmlNode.value && !node.attributes.getNamedItem( 'value' ) )
112
FCKXHtml._AppendAttribute( node, 'value', htmlNode.value ) ;
114
if ( !node.attributes.getNamedItem( 'type' ) )
115
FCKXHtml._AppendAttribute( node, 'type', 'text' ) ;
120
// IE ignores the "SELECTED" attribute so we must add it manually.
121
FCKXHtml.TagProcessors['option'] = function( node, htmlNode )
123
if ( htmlNode.selected && !node.attributes.getNamedItem( 'selected' ) )
124
FCKXHtml._AppendAttribute( node, 'selected', 'selected' ) ;
126
node = FCKXHtml._AppendChildNodes( node, htmlNode ) ;
131
// IE ignores the "COORDS" and "SHAPE" attribute so we must add it manually.
132
FCKXHtml.TagProcessors['area'] = function( node, htmlNode )
134
if ( ! node.attributes.getNamedItem( 'coords' ) )
136
var sCoords = htmlNode.getAttribute( 'coords', 2 ) ;
137
if ( sCoords && sCoords != '0,0,0' )
138
FCKXHtml._AppendAttribute( node, 'coords', sCoords ) ;
141
if ( ! node.attributes.getNamedItem( 'shape' ) )
143
var sShape = htmlNode.getAttribute( 'shape', 2 ) ;
144
if ( sShape && sShape.length > 0 )
145
FCKXHtml._AppendAttribute( node, 'shape', sShape ) ;
151
FCKXHtml.TagProcessors['label'] = function( node, htmlNode )
153
if ( htmlNode.htmlFor.length > 0 )
154
FCKXHtml._AppendAttribute( node, 'for', htmlNode.htmlFor ) ;
156
node = FCKXHtml._AppendChildNodes( node, htmlNode ) ;
161
FCKXHtml.TagProcessors['form'] = function( node, htmlNode )
163
if ( htmlNode.acceptCharset && htmlNode.acceptCharset.length > 0 && htmlNode.acceptCharset != 'UNKNOWN' )
164
FCKXHtml._AppendAttribute( node, 'accept-charset', htmlNode.acceptCharset ) ;
166
// IE has a bug and htmlNode.attributes['name'].specified=false if there is
167
// no element with id="name" inside the form (#360 and SF-BUG-1155726).
168
var nameAtt = htmlNode.attributes['name'] ;
170
if ( nameAtt && nameAtt.value.length > 0 )
171
FCKXHtml._AppendAttribute( node, 'name', nameAtt.value ) ;
173
node = FCKXHtml._AppendChildNodes( node, htmlNode ) ;
178
// IE doens't hold the name attribute as an attribute for the <TEXTAREA> and <SELECT> tags.
179
FCKXHtml.TagProcessors['textarea'] = FCKXHtml.TagProcessors['select'] = function( node, htmlNode )
182
FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
184
node = FCKXHtml._AppendChildNodes( node, htmlNode ) ;
189
// On very rare cases, IE is loosing the "align" attribute for DIV. (right align and apply bulleted list)
190
FCKXHtml.TagProcessors['div'] = function( node, htmlNode )
192
if ( htmlNode.align.length > 0 )
193
FCKXHtml._AppendAttribute( node, 'align', htmlNode.align ) ;
195
node = FCKXHtml._AppendChildNodes( node, htmlNode, true ) ;
b'\\ No newline at end of file'