PluginProbe
Wp-Insert / 1.7
Wp-Insert v1.7
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.7, at fckeditor/editor/_source/fckeditorapi.js

180 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2009 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 * Create the FCKeditorAPI object that is available as a global object in
22 * the page where the editor is placed in.
23 */
24
25 var FCKeditorAPI ;
26
27 function InitializeAPI()
28 {
29 var oParentWindow = window.parent ;
30
31 if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) )
32 {
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).
37
38 // Note: we check the existence of oEditor.GetParentForm because some external
39 // code (like JSON) can extend the Object prototype and we get then extra oEditor
40 // objects that aren't really FCKeditor instances.
41 var sScript =
42 'window.FCKeditorAPI = {' +
43 'Version : "2.6.4",' +
44 'VersionBuild : "21629",' +
45 'Instances : window.FCKeditorAPI && window.FCKeditorAPI.Instances || {},' +
46
47 'GetInstance : function( name )' +
48 '{' +
49 'return this.Instances[ name ];' +
50 '},' +
51
52 '_FormSubmit : function()' +
53 '{' +
54 'for ( var name in FCKeditorAPI.Instances )' +
55 '{' +
56 'var oEditor = FCKeditorAPI.Instances[ name ] ;' +
57 'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' +
58 'oEditor.UpdateLinkedField() ;' +
59 '}' +
60 'this._FCKOriginalSubmit() ;' +
61 '},' +
62
63 '_FunctionQueue : window.FCKeditorAPI && window.FCKeditorAPI._FunctionQueue || {' +
64 'Functions : new Array(),' +
65 'IsRunning : false,' +
66
67 'Add : function( f )' +
68 '{' +
69 'this.Functions.push( f );' +
70 'if ( !this.IsRunning )' +
71 'this.StartNext();' +
72 '},' +
73
74 'StartNext : function()' +
75 '{' +
76 'var aQueue = this.Functions ;' +
77 'if ( aQueue.length > 0 )' +
78 '{' +
79 'this.IsRunning = true;' +
80 'aQueue[0].call();' +
81 '}' +
82 'else ' +
83 'this.IsRunning = false;' +
84 '},' +
85
86 'Remove : function( f )' +
87 '{' +
88 'var aQueue = this.Functions;' +
89 'var i = 0, fFunc;' +
90 'while( (fFunc = aQueue[ i ]) )' +
91 '{' +
92 'if ( fFunc == f )' +
93 'aQueue.splice( i,1 );' +
94 'i++ ;' +
95 '}' +
96 'this.StartNext();' +
97 '}' +
98 '}' +
99 '}' ;
100
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' ) ;
106 else
107 {
108 if ( FCKBrowserInfo.IsGecko10 )
109 {
110 // FF 1.0.4 gives an error with the request bellow. The
111 // following seams to work well.
112 eval.call( oParentWindow, sScript ) ;
113 }
114 else if( FCKBrowserInfo.IsAIR )
115 {
116 FCKAdobeAIR.FCKeditorAPI_Evaluate( oParentWindow, sScript ) ;
117 }
118 else if ( FCKBrowserInfo.IsSafari )
119 {
120 // oParentWindow.eval in Safari executes in the calling window
121 // environment, instead of the parent one. The following should
122 // make it work.
123 var oParentDocument = oParentWindow.document ;
124 var eScript = oParentDocument.createElement('script') ;
125 eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ;
126 oParentDocument.documentElement.appendChild( eScript ) ;
127 }
128 else
129 oParentWindow.eval( sScript ) ;
130 }
131
132 FCKeditorAPI = oParentWindow.FCKeditorAPI ;
133
134 // The __Instances properly has been changed to the public Instances,
135 // but we should still have the "deprecated" version of it.
136 FCKeditorAPI.__Instances = FCKeditorAPI.Instances ;
137 }
138
139 // Add the current instance to the FCKeditorAPI's instances collection.
140 FCKeditorAPI.Instances[ FCK.Name ] = FCK ;
141 }
142
143 // Attach to the form onsubmit event and to the form.submit().
144 function _AttachFormSubmitToAPI()
145 {
146 // Get the linked field form.
147 var oForm = FCK.GetParentForm() ;
148
149 if ( oForm )
150 {
151 // Attach to the onsubmit event.
152 FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ;
153
154 // IE sees oForm.submit function as an 'object'.
155 if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) )
156 {
157 // Save the original submit.
158 oForm._FCKOriginalSubmit = oForm.submit ;
159
160 // Create our replacement for the submit.
161 oForm.submit = FCKeditorAPI._FormSubmit ;
162 }
163 }
164 }
165
166 function FCKeditorAPI_Cleanup()
167 {
168 if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat
169 && !window.FCKUnloadFlag )
170 return ;
171 delete FCKeditorAPI.Instances[ FCK.Name ] ;
172 }
173 function FCKeditorAPI_ConfirmCleanup()
174 {
175 if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat )
176 window.FCKUnloadFlag = true ;
177 }
178 FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ;
179 FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ;
180