source: companies/serpro/expressoMail1_2/js/fckeditor/editor/_source/internals/fckxhtml_ie.js @ 903

Revision 903, 5.3 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1/*
2 * FCKeditor - The text editor for internet
3 * Copyright (C) 2003-2006 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 * "Support Open Source software. What about a donation today?"
12 *
13 * File Name: fckxhtml_ie.js
14 *      Defines the FCKXHtml object, responsible for the XHTML operations.
15 *      IE specific.
16 *
17 * File Authors:
18 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
19 */
20
21FCKXHtml._GetMainXmlString = function()
22{
23        return this.MainNode.xml ;
24}
25
26FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node, nodeName )
27{
28        var aAttributes = htmlNode.attributes ;
29
30        for ( var n = 0 ; n < aAttributes.length ; n++ )
31        {
32                var oAttribute = aAttributes[n] ;
33
34                if ( oAttribute.specified )
35                {
36                        var sAttName = oAttribute.nodeName.toLowerCase() ;
37                        var sAttValue ;
38
39                        // Ignore any attribute starting with "_fck".
40                        if ( sAttName.startsWith( '_fck' ) )
41                                continue ;
42                        // The following must be done because of a bug on IE regarding the style
43                        // attribute. It returns "null" for the nodeValue.
44                        else if ( sAttName == 'style' )
45                                sAttValue = htmlNode.style.cssText ;
46                        // There are two cases when the oAttribute.nodeValue must be used:
47                        //              - for the "class" attribute
48                        //              - for events attributes (on IE only).
49                        else if ( sAttName == 'class' || sAttName.indexOf('on') == 0 )
50                                sAttValue = oAttribute.nodeValue ;
51                        else if ( nodeName == 'body' && sAttName == 'contenteditable' )
52                                continue ;
53                        // XHTML doens't support attribute minimization like "CHECKED". It must be trasformed to cheched="checked".
54                        else if ( oAttribute.nodeValue === true )
55                                sAttValue = sAttName ;
56                        // We must use getAttribute to get it exactly as it is defined.
57                        else if ( ! (sAttValue = htmlNode.getAttribute( sAttName, 2 ) ) )
58                                sAttValue = oAttribute.nodeValue ;
59
60                        this._AppendAttribute( node, sAttName, sAttValue ) ;
61                }
62        }
63}
64
65FCKXHtml.TagProcessors['meta'] = function( node, htmlNode )
66{
67        var oHttpEquiv = node.attributes.getNamedItem( 'http-equiv' ) ;
68
69        if ( oHttpEquiv == null || oHttpEquiv.value.length == 0 )
70        {
71                // Get the http-equiv value from the outerHTML.
72                var sHttpEquiv = htmlNode.outerHTML.match( FCKRegexLib.MetaHttpEquiv ) ;
73
74                if ( sHttpEquiv )
75                {
76                        sHttpEquiv = sHttpEquiv[1] ;
77                        FCKXHtml._AppendAttribute( node, 'http-equiv', sHttpEquiv ) ;
78                }
79        }
80
81        return node ;
82}
83
84// IE automaticaly changes <FONT> tags to <FONT size=+0>.
85FCKXHtml.TagProcessors['font'] = function( node, htmlNode )
86{
87        if ( node.attributes.length == 0 )
88                node = FCKXHtml.XML.createDocumentFragment() ;
89
90        FCKXHtml._AppendChildNodes( node, htmlNode ) ;
91
92        return node ;
93}
94
95// IE doens't see the value attribute as an attribute for the <INPUT> tag.
96FCKXHtml.TagProcessors['input'] = function( node, htmlNode )
97{
98        if ( htmlNode.name )
99                FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
100
101        if ( htmlNode.value && !node.attributes.getNamedItem( 'value' ) )
102                FCKXHtml._AppendAttribute( node, 'value', htmlNode.value ) ;
103
104        if ( !node.attributes.getNamedItem( 'type' ) )
105                FCKXHtml._AppendAttribute( node, 'type', 'text' ) ;
106
107        return node ;
108}
109
110// IE ignores the "SELECTED" attribute so we must add it manually.
111FCKXHtml.TagProcessors['option'] = function( node, htmlNode )
112{
113        if ( htmlNode.selected && !node.attributes.getNamedItem( 'selected' ) )
114                FCKXHtml._AppendAttribute( node, 'selected', 'selected' ) ;
115
116        FCKXHtml._AppendChildNodes( node, htmlNode ) ;
117
118        return node ;
119}
120
121// IE ignores the "COORDS" and "SHAPE" attribute so we must add it manually.
122FCKXHtml.TagProcessors['area'] = function( node, htmlNode )
123{
124        if ( ! node.attributes.getNamedItem( 'coords' ) )
125        {
126                var sCoords = htmlNode.getAttribute( 'coords', 2 ) ;
127                if ( sCoords && sCoords != '0,0,0' )
128                        FCKXHtml._AppendAttribute( node, 'coords', sCoords ) ;
129        }
130
131        if ( ! node.attributes.getNamedItem( 'shape' ) )
132        {
133                var sCoords = htmlNode.getAttribute( 'shape', 2 ) ;
134                if ( sCoords && sCoords.length > 0 )
135                        FCKXHtml._AppendAttribute( node, 'shape', sCoords ) ;
136        }
137
138        return node ;
139}
140
141FCKXHtml.TagProcessors['label'] = function( node, htmlNode )
142{
143        if ( htmlNode.htmlFor.length > 0 )
144                FCKXHtml._AppendAttribute( node, 'for', htmlNode.htmlFor ) ;
145
146        FCKXHtml._AppendChildNodes( node, htmlNode ) ;
147
148        return node ;
149}
150
151FCKXHtml.TagProcessors['form'] = function( node, htmlNode )
152{
153        if ( htmlNode.acceptCharset && htmlNode.acceptCharset.length > 0 && htmlNode.acceptCharset != 'UNKNOWN' )
154                FCKXHtml._AppendAttribute( node, 'accept-charset', htmlNode.acceptCharset ) ;
155
156        if ( htmlNode.name )
157                FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
158
159        FCKXHtml._AppendChildNodes( node, htmlNode ) ;
160
161        return node ;
162}
163
164// IE doens't hold the name attribute as an attribute for the <TEXTAREA> and <SELECT> tags.
165FCKXHtml.TagProcessors['textarea'] = FCKXHtml.TagProcessors['select'] = function( node, htmlNode )
166{
167        if ( htmlNode.name )
168                FCKXHtml._AppendAttribute( node, 'name', htmlNode.name ) ;
169
170        FCKXHtml._AppendChildNodes( node, htmlNode ) ;
171 
172        return node ;
173}
174
175// On very rare cases, IE is loosing the "align" attribute for DIV. (right align and apply bulleted list)
176FCKXHtml.TagProcessors['div'] = function( node, htmlNode )
177{
178        if ( htmlNode.align.length > 0 )
179                FCKXHtml._AppendAttribute( node, 'align', htmlNode.align ) ;
180
181        FCKXHtml._AppendChildNodes( node, htmlNode ) ;
182
183        return node ;
184}
Note: See TracBrowser for help on using the repository browser.