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
* Create the FCKeditorAPI object that is available as a global object in
22
* the page where the editor is placed in.
27
function InitializeAPI()
29
var oParentWindow = window.parent ;
31
if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) )
33
// Make the FCKeditorAPI object available in the parent window. Use
34
// eval so this core runs in the parent's scope and so it will still be
35
// available if the editor instance is removed ("Can't execute code
36
// from a freed script" error).
38
// Note: we check the existence of oEditor.GetParentForm because some external
39
// code (like JSON) can extend the Object protype and we get then extra oEditor
40
// objects that aren't really FCKeditor instances.
42
'var FCKeditorAPI = {' +
43
'Version : "2.4.3",' +
44
'VersionBuild : "15657",' +
45
'__Instances : new Object(),' +
47
'GetInstance : function( name )' +
49
'return this.__Instances[ name ];' +
52
'_FormSubmit : function()' +
54
'for ( var name in FCKeditorAPI.__Instances )' +
56
'var oEditor = FCKeditorAPI.__Instances[ name ] ;' +
57
'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' +
58
'oEditor.UpdateLinkedField() ;' +
60
'this._FCKOriginalSubmit() ;' +
63
'_FunctionQueue : {' +
64
'Functions : new Array(),' +
65
'IsRunning : false,' +
67
'Add : function( f )' +
69
'this.Functions.push( f );' +
70
'if ( !this.IsRunning )' +
74
'StartNext : function()' +
76
'var aQueue = this.Functions ;' +
77
'if ( aQueue.length > 0 )' +
79
'this.IsRunning = true;' +
83
'this.IsRunning = false;' +
86
'Remove : function( f )' +
88
'var aQueue = this.Functions;' +
90
'while( (fFunc = aQueue[ i ]) )' +
93
'aQueue.splice( i,1 );' +
101
// In IE, the "eval" function is not always available (it works with
102
// the JavaScript samples, but not with the ASP ones, for example).
103
// So, let's use the execScript instead.
104
if ( oParentWindow.execScript )
105
oParentWindow.execScript( sScript, 'JavaScript' ) ;
108
if ( FCKBrowserInfo.IsGecko10 )
110
// FF 1.0.4 gives an error with the request bellow. The
111
// following seams to work well.
112
eval.call( oParentWindow, sScript ) ;
114
else if ( FCKBrowserInfo.IsSafari )
116
// oParentWindow.eval in Safari executes in the calling window
117
// environment, instead of the parent one. The following should make it work.
118
var oParentDocument = oParentWindow.document ;
119
var eScript = oParentDocument.createElement('script') ;
120
eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ;
121
oParentDocument.documentElement.appendChild( eScript ) ;
124
oParentWindow.eval( sScript ) ;
127
FCKeditorAPI = oParentWindow.FCKeditorAPI ;
130
// Add the current instance to the FCKeditorAPI's instances collection.
131
FCKeditorAPI.__Instances[ FCK.Name ] = FCK ;
134
// Attach to the form onsubmit event and to the form.submit().
135
function _AttachFormSubmitToAPI()
137
// Get the linked field form.
138
var oForm = FCK.GetParentForm() ;
142
// Attach to the onsubmit event.
143
FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ;
145
// IE sees oForm.submit function as an 'object'.
146
if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) )
148
// Save the original submit.
149
oForm._FCKOriginalSubmit = oForm.submit ;
151
// Create our replacement for the submit.
152
oForm.submit = FCKeditorAPI._FormSubmit ;
157
function FCKeditorAPI_Cleanup()
159
delete FCKeditorAPI.__Instances[ FCK.Name ] ;
161
FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ;
b'\\ No newline at end of file'