PluginProbe
Wp-Insert / 1.2
Wp-Insert v1.2
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / fckeditor / editor / _source / fckeditorapi.js

fckeditorapi.js in Wp-Insert 1.2, at fckeditor/editor/_source/fckeditorapi.js

359 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4
5 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
6
7 *
8
9 * == BEGIN LICENSE ==
10
11 *
12
13 * Licensed under the terms of any of the following licenses at your
14
15 * choice:
16
17 *
18
19 * - GNU General Public License Version 2 or later (the "GPL")
20
21 * http://www.gnu.org/licenses/gpl.html
22
23 *
24
25 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
26
27 * http://www.gnu.org/licenses/lgpl.html
28
29 *
30
31 * - Mozilla Public License Version 1.1 or later (the "MPL")
32
33 * http://www.mozilla.org/MPL/MPL-1.1.html
34
35 *
36
37 * == END LICENSE ==
38
39 *
40
41 * Create the FCKeditorAPI object that is available as a global object in
42
43 * the page where the editor is placed in.
44
45 */
46
47
48
49 var FCKeditorAPI ;
50
51
52
53 function InitializeAPI()
54
55 {
56
57 var oParentWindow = window.parent ;
58
59
60
61 if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) )
62
63 {
64
65 // Make the FCKeditorAPI object available in the parent window. Use
66
67 // eval so this core runs in the parent's scope and so it will still be
68
69 // available if the editor instance is removed ("Can't execute code
70
71 // from a freed script" error).
72
73
74
75 // Note: we check the existence of oEditor.GetParentForm because some external
76
77 // code (like JSON) can extend the Object prototype and we get then extra oEditor
78
79 // objects that aren't really FCKeditor instances.
80
81 var sScript =
82
83 'window.FCKeditorAPI = {' +
84
85 'Version : "2.6.4",' +
86
87 'VersionBuild : "21629",' +
88
89 'Instances : window.FCKeditorAPI && window.FCKeditorAPI.Instances || {},' +
90
91
92
93 'GetInstance : function( name )' +
94
95 '{' +
96
97 'return this.Instances[ name ];' +
98
99 '},' +
100
101
102
103 '_FormSubmit : function()' +
104
105 '{' +
106
107 'for ( var name in FCKeditorAPI.Instances )' +
108
109 '{' +
110
111 'var oEditor = FCKeditorAPI.Instances[ name ] ;' +
112
113 'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' +
114
115 'oEditor.UpdateLinkedField() ;' +
116
117 '}' +
118
119 'this._FCKOriginalSubmit() ;' +
120
121 '},' +
122
123
124
125 '_FunctionQueue : window.FCKeditorAPI && window.FCKeditorAPI._FunctionQueue || {' +
126
127 'Functions : new Array(),' +
128
129 'IsRunning : false,' +
130
131
132
133 'Add : function( f )' +
134
135 '{' +
136
137 'this.Functions.push( f );' +
138
139 'if ( !this.IsRunning )' +
140
141 'this.StartNext();' +
142
143 '},' +
144
145
146
147 'StartNext : function()' +
148
149 '{' +
150
151 'var aQueue = this.Functions ;' +
152
153 'if ( aQueue.length > 0 )' +
154
155 '{' +
156
157 'this.IsRunning = true;' +
158
159 'aQueue[0].call();' +
160
161 '}' +
162
163 'else ' +
164
165 'this.IsRunning = false;' +
166
167 '},' +
168
169
170
171 'Remove : function( f )' +
172
173 '{' +
174
175 'var aQueue = this.Functions;' +
176
177 'var i = 0, fFunc;' +
178
179 'while( (fFunc = aQueue[ i ]) )' +
180
181 '{' +
182
183 'if ( fFunc == f )' +
184
185 'aQueue.splice( i,1 );' +
186
187 'i++ ;' +
188
189 '}' +
190
191 'this.StartNext();' +
192
193 '}' +
194
195 '}' +
196
197 '}' ;
198
199
200
201 // In IE, the "eval" function is not always available (it works with
202
203 // the JavaScript samples, but not with the ASP ones, for example).
204
205 // So, let's use the execScript instead.
206
207 if ( oParentWindow.execScript )
208
209 oParentWindow.execScript( sScript, 'JavaScript' ) ;
210
211 else
212
213 {
214
215 if ( FCKBrowserInfo.IsGecko10 )
216
217 {
218
219 // FF 1.0.4 gives an error with the request bellow. The
220
221 // following seams to work well.
222
223 eval.call( oParentWindow, sScript ) ;
224
225 }
226
227 else if( FCKBrowserInfo.IsAIR )
228
229 {
230
231 FCKAdobeAIR.FCKeditorAPI_Evaluate( oParentWindow, sScript ) ;
232
233 }
234
235 else if ( FCKBrowserInfo.IsSafari )
236
237 {
238
239 // oParentWindow.eval in Safari executes in the calling window
240
241 // environment, instead of the parent one. The following should
242
243 // make it work.
244
245 var oParentDocument = oParentWindow.document ;
246
247 var eScript = oParentDocument.createElement('script') ;
248
249 eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ;
250
251 oParentDocument.documentElement.appendChild( eScript ) ;
252
253 }
254
255 else
256
257 oParentWindow.eval( sScript ) ;
258
259 }
260
261
262
263 FCKeditorAPI = oParentWindow.FCKeditorAPI ;
264
265
266
267 // The __Instances properly has been changed to the public Instances,
268
269 // but we should still have the "deprecated" version of it.
270
271 FCKeditorAPI.__Instances = FCKeditorAPI.Instances ;
272
273 }
274
275
276
277 // Add the current instance to the FCKeditorAPI's instances collection.
278
279 FCKeditorAPI.Instances[ FCK.Name ] = FCK ;
280
281 }
282
283
284
285 // Attach to the form onsubmit event and to the form.submit().
286
287 function _AttachFormSubmitToAPI()
288
289 {
290
291 // Get the linked field form.
292
293 var oForm = FCK.GetParentForm() ;
294
295
296
297 if ( oForm )
298
299 {
300
301 // Attach to the onsubmit event.
302
303 FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ;
304
305
306
307 // IE sees oForm.submit function as an 'object'.
308
309 if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) )
310
311 {
312
313 // Save the original submit.
314
315 oForm._FCKOriginalSubmit = oForm.submit ;
316
317
318
319 // Create our replacement for the submit.
320
321 oForm.submit = FCKeditorAPI._FormSubmit ;
322
323 }
324
325 }
326
327 }
328
329
330
331 function FCKeditorAPI_Cleanup()
332
333 {
334
335 if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat
336
337 && !window.FCKUnloadFlag )
338
339 return ;
340
341 delete FCKeditorAPI.Instances[ FCK.Name ] ;
342
343 }
344
345 function FCKeditorAPI_ConfirmCleanup()
346
347 {
348
349 if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat )
350
351 window.FCKUnloadFlag = true ;
352
353 }
354
355 FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ;
356
357 FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ;
358
359