source: extensions/FCKEditor/editor/_source/internals/fckxhtml_gecko.js @ 3295

Last change on this file since 3295 was 3295, checked in by patdenice, 15 years ago

New extension added:
FCK Editor (2.0.a)

File size: 3.2 KB
Line 
1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2009 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        return ( new XMLSerializer() ).serializeToString( this.MainNode ) ;
28}
29
30FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node )
31{
32        var aAttributes = htmlNode.attributes ;
33
34        for ( var n = 0 ; n < aAttributes.length ; n++ )
35        {
36                var oAttribute = aAttributes[n] ;
37
38                if ( oAttribute.specified )
39                {
40                        var sAttName = oAttribute.nodeName.toLowerCase() ;
41                        var sAttValue ;
42
43                        // Ignore any attribute starting with "_fck".
44                        if ( sAttName.StartsWith( '_fck' ) )
45                                continue ;
46                        // There is a bug in Mozilla that returns '_moz_xxx' attributes as specified.
47                        else if ( sAttName.indexOf( '_moz' ) == 0 )
48                                continue ;
49                        // There are one cases (on Gecko) when the oAttribute.nodeValue must be used:
50                        //              - for the "class" attribute
51                        else if ( sAttName == 'class' )
52                        {
53                                sAttValue = oAttribute.nodeValue.replace( FCKRegexLib.FCK_Class, '' ) ;
54                                if ( sAttValue.length == 0 )
55                                        continue ;
56                        }
57                        // XHTML doens't support attribute minimization like "CHECKED". It must be transformed to checked="checked".
58                        else if ( oAttribute.nodeValue === true )
59                                sAttValue = sAttName ;
60                        else
61                                sAttValue = htmlNode.getAttribute( sAttName, 2 ) ;      // We must use getAttribute to get it exactly as it is defined.
62
63                        this._AppendAttribute( node, sAttName, sAttValue ) ;
64                }
65        }
66}
67
68if ( FCKBrowserInfo.IsOpera )
69{
70        // Opera moves the <FCK:meta> element outside head (#1166).
71
72        // Save a reference to the XML <head> node, so we can use it for
73        // orphan <meta>s.
74        FCKXHtml.TagProcessors['head'] = function( node, htmlNode )
75        {
76                FCKXHtml.XML._HeadElement = node ;
77
78                node = FCKXHtml._AppendChildNodes( node, htmlNode, true ) ;
79
80                return node ;
81        }
82
83        // Check whether a <meta> element is outside <head>, and move it to the
84        // proper place.
85        FCKXHtml.TagProcessors['meta'] = function( node, htmlNode, xmlNode )
86        {
87                if ( htmlNode.parentNode.nodeName.toLowerCase() != 'head' )
88                {
89                        var headElement = FCKXHtml.XML._HeadElement ;
90
91                        if ( headElement && xmlNode != headElement )
92                        {
93                                delete htmlNode._fckxhtmljob ;
94                                FCKXHtml._AppendNode( headElement, htmlNode ) ;
95                                return null ;
96                        }
97                }
98
99                return node ;
100        }
101}
102
103if ( FCKBrowserInfo.IsGecko )
104{
105        // #2162, some Firefox extensions might add references to internal links
106        FCKXHtml.TagProcessors['link'] = function( node, htmlNode )
107        {
108                if ( htmlNode.href.substr(0, 9).toLowerCase() == 'chrome://' )
109                        return false ;
110
111                return node ;
112        }
113
114}
Note: See TracBrowser for help on using the repository browser.