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
* Utility functions. (IE version).
24
FCKTools.CancelEvent = function( e )
29
// Appends one or more CSS files to a document.
30
FCKTools._AppendStyleSheet = function( documentElement, cssFileUrl )
32
return documentElement.createStyleSheet( cssFileUrl ).owningElement ;
35
// Removes all attributes and values from the element.
36
FCKTools.ClearElementAttributes = function( element )
38
element.clearAttributes() ;
41
FCKTools.GetAllChildrenIds = function( parentElement )
43
var aIds = new Array() ;
44
for ( var i = 0 ; i < parentElement.all.length ; i++ )
46
var sId = parentElement.all[i].id ;
47
if ( sId && sId.length > 0 )
48
aIds[ aIds.length ] = sId ;
53
FCKTools.RemoveOuterTags = function( e )
55
e.insertAdjacentHTML( 'beforeBegin', e.innerHTML ) ;
56
e.parentNode.removeChild( e ) ;
59
FCKTools.CreateXmlObject = function( object )
66
aObjs = [ 'MSXML2.XmlHttp', 'Microsoft.XmlHttp' ] ;
70
aObjs = [ 'MSXML2.DOMDocument', 'Microsoft.XmlDom' ] ;
74
for ( var i = 0 ; i < 2 ; i++ )
76
try { return new ActiveXObject( aObjs[i] ) ; }
81
if ( FCKLang.NoActiveX )
83
alert( FCKLang.NoActiveX ) ;
84
FCKLang.NoActiveX = null ;
89
FCKTools.DisableSelection = function( element )
91
element.unselectable = 'on' ;
94
// The extra () is to avoid a warning with strict error checking. This is ok.
95
while ( (e = element.all[ i++ ]) )
103
/* Ignore the above tags */
106
e.unselectable = 'on' ;
111
FCKTools.GetScrollPosition = function( relativeWindow )
113
var oDoc = relativeWindow.document ;
115
// Try with the doc element.
116
var oPos = { X : oDoc.documentElement.scrollLeft, Y : oDoc.documentElement.scrollTop } ;
118
if ( oPos.X > 0 || oPos.Y > 0 )
121
// If no scroll, try with the body.
122
return { X : oDoc.body.scrollLeft, Y : oDoc.body.scrollTop } ;
125
FCKTools.AddEventListener = function( sourceObject, eventName, listener )
127
sourceObject.attachEvent( 'on' + eventName, listener ) ;
130
FCKTools.RemoveEventListener = function( sourceObject, eventName, listener )
132
sourceObject.detachEvent( 'on' + eventName, listener ) ;
135
// Listeners attached with this function cannot be detached.
136
FCKTools.AddEventListenerEx = function( sourceObject, eventName, listener, paramsArray )
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 )
144
return listener.apply( o.Source, [ ev ].concat( o.Params ) ) ;
148
FCK.IECleanup.AddItem( null, function() { o.Source = null ; o.Params = null ; } ) ;
150
sourceObject.attachEvent( 'on' + eventName, o.Listener ) ;
152
sourceObject = null ; // Memory leak cleaner (because of the above closure).
153
paramsArray = null ; // Memory leak cleaner (because of the above closure).
156
// Returns and object with the "Width" and "Height" properties.
157
FCKTools.GetViewPaneSize = function( win )
161
var oDoc = win.document.documentElement ;
162
if ( oDoc && oDoc.clientWidth ) // IE6 Strict Mode
165
oSizeSource = top.document.body ; // Other IEs
168
return { Width : oSizeSource.clientWidth, Height : oSizeSource.clientHeight } ;
170
return { Width : 0, Height : 0 } ;
173
FCKTools.SaveStyles = function( element )
175
var oSavedStyles = new Object() ;
177
if ( element.className.length > 0 )
179
oSavedStyles.Class = element.className ;
180
element.className = '' ;
183
var sInlineStyle = element.style.cssText ;
185
if ( sInlineStyle.length > 0 )
187
oSavedStyles.Inline = sInlineStyle ;
188
element.style.cssText = '' ;
191
return oSavedStyles ;
194
FCKTools.RestoreStyles = function( element, savedStyles )
196
element.className = savedStyles.Class || '' ;
197
element.style.cssText = savedStyles.Inline || '' ;
200
FCKTools.RegisterDollarFunction = function( targetWindow )
202
targetWindow.$ = targetWindow.document.getElementById ;
205
FCKTools.AppendElement = function( target, elementName )
207
return target.appendChild( this.GetElementDocument( target ).createElement( elementName ) ) ;
210
// This function may be used by Regex replacements.
211
FCKTools.ToLowerCase = function( strValue )
213
return strValue.toLowerCase() ;
b'\\ No newline at end of file'