Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 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
 * File Name: fckxhtml_gecko.js
12
 * 	Defines the FCKXHtml object, responsible for the XHTML operations.
13
 * 	Gecko specific.
14
 *
15
 * File Authors:
16
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
17
 */
18
 
19
FCKXHtml._GetMainXmlString = function()
20
{
21
	// Create the XMLSerializer.
22
	var oSerializer = new XMLSerializer() ;
23
 
24
	if ( FCKConfig.ProcessHTMLEntities )
25
	{
26
		// Return the serialized XML as a string.
27
		// Due to a BUG on Gecko, the special chars sequence "#?-:" must be replaced with "&"
28
		// for the XHTML entities.
29
		return oSerializer.serializeToString( this.MainNode ).replace( FCKXHtmlEntities.GeckoEntitiesMarkerRegex, '&' ) ;
30
	}
31
	else
32
		return oSerializer.serializeToString( this.MainNode ) ;
33
}
34
 
35
// There is a BUG on Gecko... createEntityReference returns null.
36
// So we use a trick to append entities on it.
37
FCKXHtml._AppendEntity = function( xmlNode, entity )
38
{
39
	xmlNode.appendChild( this.XML.createTextNode( '#?-:' + entity + ';' ) ) ;
40
}
41
 
42
FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node )
43
{
44
	var aAttributes = htmlNode.attributes ;
45
 
46
	for ( var n = 0 ; n < aAttributes.length ; n++ )
47
	{
48
		var oAttribute = aAttributes[n] ;
49
 
50
		if ( oAttribute.specified )
51
		{
52
			var sAttName = oAttribute.nodeName.toLowerCase() ;
53
 
54
			// The "_fckxhtmljob" attribute is used to mark the already processed elements.
55
			if ( sAttName == '_fckxhtmljob' )
56
				continue ;
57
			// There is a bug in Mozilla that returns '_moz_xxx' attributes as specified.
58
			else if ( sAttName.indexOf( '_moz' ) == 0 )
59
				continue ;
60
			// There are one cases (on Gecko) when the oAttribute.nodeValue must be used:
61
			//		- for the "class" attribute
62
			else if ( sAttName == 'class' )
63
				var sAttValue = oAttribute.nodeValue ;
64
			// XHTML doens't support attribute minimization like "CHECKED". It must be trasformed to cheched="checked".
65
			else if ( oAttribute.nodeValue === true )
66
				sAttValue = sAttName ;
67
			else
68
				var sAttValue = htmlNode.getAttribute( sAttName, 2 ) ;	// We must use getAttribute to get it exactly as it is defined.
69
 
70
			if ( FCKConfig.ForceSimpleAmpersand && sAttValue.replace )
71
				sAttValue = sAttValue.replace( /&/g, '___FCKAmp___' ) ;
72
 
73
			this._AppendAttribute( node, sAttName, sAttValue ) ;
74
		}
75
	}
76
}