source: branches/1.2/workflow/js/fckeditor/editor/_source/internals/fcktools_ie.js @ 1349

Revision 1349, 5.1 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
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 * Utility functions. (IE version).
22 */
23
24FCKTools.CancelEvent = function( e )
25{
26        return false ;
27}
28
29// Appends one or more CSS files to a document.
30FCKTools._AppendStyleSheet = function( documentElement, cssFileUrl )
31{
32        return documentElement.createStyleSheet( cssFileUrl ).owningElement ;
33}
34
35// Removes all attributes and values from the element.
36FCKTools.ClearElementAttributes = function( element )
37{
38        element.clearAttributes() ;
39}
40
41FCKTools.GetAllChildrenIds = function( parentElement )
42{
43        var aIds = new Array() ;
44        for ( var i = 0 ; i < parentElement.all.length ; i++ )
45        {
46                var sId = parentElement.all[i].id ;
47                if ( sId && sId.length > 0 )
48                        aIds[ aIds.length ] = sId ;
49        }
50        return aIds ;
51}
52
53FCKTools.RemoveOuterTags = function( e )
54{
55        e.insertAdjacentHTML( 'beforeBegin', e.innerHTML ) ;
56        e.parentNode.removeChild( e ) ;
57}
58
59FCKTools.CreateXmlObject = function( object )
60{
61        var aObjs ;
62
63        switch ( object )
64        {
65                case 'XmlHttp' :
66                        aObjs = [ 'MSXML2.XmlHttp', 'Microsoft.XmlHttp' ] ;
67                        break ;
68
69                case 'DOMDocument' :
70                        aObjs = [ 'MSXML2.DOMDocument', 'Microsoft.XmlDom' ] ;
71                        break ;
72        }
73
74        for ( var i = 0 ; i < 2 ; i++ )
75        {
76                try { return new ActiveXObject( aObjs[i] ) ; }
77                catch (e)
78                {}
79        }
80
81        if ( FCKLang.NoActiveX )
82        {
83                alert( FCKLang.NoActiveX ) ;
84                FCKLang.NoActiveX = null ;
85        }
86        return null ;
87}
88
89FCKTools.DisableSelection = function( element )
90{
91        element.unselectable = 'on' ;
92
93        var e, i = 0 ;
94        // The extra () is to avoid a warning with strict error checking. This is ok.
95        while ( (e = element.all[ i++ ]) )
96        {
97                switch ( e.tagName )
98                {
99                        case 'IFRAME' :
100                        case 'TEXTAREA' :
101                        case 'INPUT' :
102                        case 'SELECT' :
103                                /* Ignore the above tags */
104                                break ;
105                        default :
106                                e.unselectable = 'on' ;
107                }
108        }
109}
110
111FCKTools.GetScrollPosition = function( relativeWindow )
112{
113        var oDoc = relativeWindow.document ;
114
115        // Try with the doc element.
116        var oPos = { X : oDoc.documentElement.scrollLeft, Y : oDoc.documentElement.scrollTop } ;
117
118        if ( oPos.X > 0 || oPos.Y > 0 )
119                return oPos ;
120
121        // If no scroll, try with the body.
122        return { X : oDoc.body.scrollLeft, Y : oDoc.body.scrollTop } ;
123}
124
125FCKTools.AddEventListener = function( sourceObject, eventName, listener )
126{
127        sourceObject.attachEvent( 'on' + eventName, listener ) ;
128}
129
130FCKTools.RemoveEventListener = function( sourceObject, eventName, listener )
131{
132        sourceObject.detachEvent( 'on' + eventName, listener ) ;
133}
134
135// Listeners attached with this function cannot be detached.
136FCKTools.AddEventListenerEx = function( sourceObject, eventName, listener, paramsArray )
137{
138        // Ok... this is a closures party, but is the only way to make it clean of memory leaks.
139        var o = new Object() ;
140        o.Source = sourceObject ;
141        o.Params = paramsArray || [] ;  // Memory leak if we have DOM objects here.
142        o.Listener = function( ev )
143        {
144                return listener.apply( o.Source, [ ev ].concat( o.Params ) ) ;
145        }
146
147        if ( FCK.IECleanup )
148                FCK.IECleanup.AddItem( null, function() { o.Source = null ; o.Params = null ; } ) ;
149
150        sourceObject.attachEvent( 'on' + eventName, o.Listener ) ;
151
152        sourceObject = null ;   // Memory leak cleaner (because of the above closure).
153        paramsArray = null ;    // Memory leak cleaner (because of the above closure).
154}
155
156// Returns and object with the "Width" and "Height" properties.
157FCKTools.GetViewPaneSize = function( win )
158{
159        var oSizeSource ;
160
161        var oDoc = win.document.documentElement ;
162        if ( oDoc && oDoc.clientWidth )                         // IE6 Strict Mode
163                oSizeSource = oDoc ;
164        else
165                oSizeSource = top.document.body ;               // Other IEs
166
167        if ( oSizeSource )
168                return { Width : oSizeSource.clientWidth, Height : oSizeSource.clientHeight } ;
169        else
170                return { Width : 0, Height : 0 } ;
171}
172
173FCKTools.SaveStyles = function( element )
174{
175        var oSavedStyles = new Object() ;
176
177        if ( element.className.length > 0 )
178        {
179                oSavedStyles.Class = element.className ;
180                element.className = '' ;
181        }
182
183        var sInlineStyle = element.style.cssText ;
184
185        if ( sInlineStyle.length > 0 )
186        {
187                oSavedStyles.Inline = sInlineStyle ;
188                element.style.cssText = '' ;
189        }
190
191        return oSavedStyles ;
192}
193
194FCKTools.RestoreStyles = function( element, savedStyles )
195{
196        element.className               = savedStyles.Class || '' ;
197        element.style.cssText   = savedStyles.Inline || '' ;
198}
199
200FCKTools.RegisterDollarFunction = function( targetWindow )
201{
202        targetWindow.$ = targetWindow.document.getElementById ;
203}
204
205FCKTools.AppendElement = function( target, elementName )
206{
207        return target.appendChild( this.GetElementDocument( target ).createElement( elementName ) ) ;
208}
209
210// This function may be used by Regex replacements.
211FCKTools.ToLowerCase = function( strValue )
212{
213        return strValue.toLowerCase() ;
214}
Note: See TracBrowser for help on using the repository browser.