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
24
// Constant for the Gecko Bogus Node.
25
//var GECKO_BOGUS = '<br _moz_editor_bogus_node="TRUE">' ;
26
var GECKO_BOGUS = '<br type="_moz">' ;
28
var FCKTools = new Object() ;
30
FCKTools.CreateBogusBR = function( targetDocument )
32
var eBR = targetDocument.createElement( 'br' ) ;
33
// eBR.setAttribute( '_moz_editor_bogus_node', 'TRUE' ) ;
34
eBR.setAttribute( 'type', '_moz' ) ;
38
// Returns a reference to the appended style sheet or an array with all the appended references
39
FCKTools.AppendStyleSheet = function( documentElement, cssFileUrlOrArray )
41
if ( typeof( cssFileUrlOrArray ) == 'string' )
42
return this._AppendStyleSheet( documentElement, cssFileUrlOrArray ) ;
45
var aStyleSheeArray = new Array() ;
47
for ( var i = 0 ; i < cssFileUrlOrArray.length ; i++ )
48
aStyleSheeArray.push(this._AppendStyleSheet( documentElement, cssFileUrlOrArray[i] ) ) ;
50
return aStyleSheeArray ;
54
FCKTools.GetElementDocument = function ( element )
56
return element.ownerDocument || element.document ;
59
// Get the window object where the element is placed in.
60
FCKTools.GetElementWindow = function( element )
62
return this.GetDocumentWindow( this.GetElementDocument( element ) ) ;
65
FCKTools.GetDocumentWindow = function( document )
67
// With Safari, there is not way to retrieve the window from the document, so we must fix it.
68
if ( FCKBrowserInfo.IsSafari && !document.parentWindow )
69
this.FixDocumentParentWindow( window.top ) ;
71
return document.parentWindow || document.defaultView ;
75
This is a Safari specific function that fix the reference to the parent
76
window from the document object.
78
FCKTools.FixDocumentParentWindow = function( targetWindow )
80
targetWindow.document.parentWindow = targetWindow ;
82
for ( var i = 0 ; i < targetWindow.frames.length ; i++ )
83
FCKTools.FixDocumentParentWindow( targetWindow.frames[i] ) ;
86
FCKTools.HTMLEncode = function( text )
91
text = text.replace( /&/g, '&' ) ;
92
text = text.replace( /</g, '<' ) ;
93
text = text.replace( />/g, '>' ) ;
98
FCKTools.HTMLDecode = function( text )
103
text = text.replace( />/g, '>' ) ;
104
text = text.replace( /</g, '<' ) ;
105
text = text.replace( /&/g, '&' ) ;
111
* Adds an option to a SELECT element.
113
FCKTools.AddSelectOption = function( selectElement, optionText, optionValue )
115
var oOption = FCKTools.GetElementDocument( selectElement ).createElement( "OPTION" ) ;
117
oOption.text = optionText ;
118
oOption.value = optionValue ;
120
selectElement.options.add(oOption) ;
125
FCKTools.RunFunction = function( func, thisObject, paramsArray, timerWindow )
128
this.SetTimeout( func, 0, thisObject, paramsArray, timerWindow ) ;
131
FCKTools.SetTimeout = function( func, milliseconds, thisObject, paramsArray, timerWindow )
133
return ( timerWindow || window ).setTimeout(
137
func.apply( thisObject, [].concat( paramsArray ) ) ;
139
func.apply( thisObject ) ;
144
FCKTools.SetInterval = function( func, milliseconds, thisObject, paramsArray, timerWindow )
146
return ( timerWindow || window ).setInterval(
149
func.apply( thisObject, paramsArray || [] ) ;
154
FCKTools.ConvertStyleSizeToHtml = function( size )
156
return size.EndsWith( '%' ) ? size : parseInt( size, 10 ) ;
159
FCKTools.ConvertHtmlSizeToStyle = function( size )
161
return size.EndsWith( '%' ) ? size : ( size + 'px' ) ;
164
// START iCM MODIFICATIONS
165
// Amended to accept a list of one or more ascensor tag names
166
// Amended to check the element itself before working back up through the parent hierarchy
167
FCKTools.GetElementAscensor = function( element, ascensorTagNames )
169
// var e = element.parentNode ;
171
var lstTags = "," + ascensorTagNames.toUpperCase() + "," ;
175
if ( lstTags.indexOf( "," + e.nodeName.toUpperCase() + "," ) != -1 )
182
// END iCM MODIFICATIONS
184
FCKTools.CreateEventListener = function( func, params )
188
var aAllParams = [] ;
190
for ( var i = 0 ; i < arguments.length ; i++ )
191
aAllParams.push( arguments[i] ) ;
193
func.apply( this, aAllParams.concat( params ) ) ;
199
FCKTools.IsStrictMode = function( document )
201
// There is no compatMode in Safari, but it seams that it always behave as
202
// CSS1Compat, so let's assume it as the default.
203
return ( 'CSS1Compat' == ( document.compatMode || 'CSS1Compat' ) ) ;
206
// Transforms a "arguments" object to an array.
207
FCKTools.ArgumentsToArray = function( args, startIndex, maxLength )
209
startIndex = startIndex || 0 ;
210
maxLength = maxLength || args.length ;
212
var argsArray = new Array() ;
214
for ( var i = startIndex ; i < startIndex + maxLength && i < args.length ; i++ )
215
argsArray.push( args[i] ) ;
220
FCKTools.CloneObject = function( sourceObject )
222
var fCloneCreator = function() {} ;
223
fCloneCreator.prototype = sourceObject ;
224
return new fCloneCreator ;
227
FCKTools.GetLastItem = function( list )
229
if ( list.length > 0 )
230
return list[ list.length - 1 ] ;