--- /dev/null
+/*\r
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+ * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
+ *\r
+ * == BEGIN LICENSE ==\r
+ *\r
+ * Licensed under the terms of any of the following licenses at your\r
+ * choice:\r
+ *\r
+ * - GNU General Public License Version 2 or later (the "GPL")\r
+ * http://www.gnu.org/licenses/gpl.html\r
+ *\r
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+ * http://www.gnu.org/licenses/lgpl.html\r
+ *\r
+ * - Mozilla Public License Version 1.1 or later (the "MPL")\r
+ * http://www.mozilla.org/MPL/MPL-1.1.html\r
+ *\r
+ * == END LICENSE ==\r
+ *\r
+ * Create the FCKeditorAPI object that is available as a global object in\r
+ * the page where the editor is placed in.\r
+ */\r
+\r
+var FCKeditorAPI ;\r
+\r
+function InitializeAPI()\r
+{\r
+ var oParentWindow = window.parent ;\r
+\r
+ if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) )\r
+ {\r
+ // Make the FCKeditorAPI object available in the parent window. Use\r
+ // eval so this core runs in the parent's scope and so it will still be\r
+ // available if the editor instance is removed ("Can't execute code\r
+ // from a freed script" error).\r
+\r
+ // Note: we check the existence of oEditor.GetParentForm because some external\r
+ // code (like JSON) can extend the Object prototype and we get then extra oEditor\r
+ // objects that aren't really FCKeditor instances.\r
+ var sScript =\r
+ 'window.FCKeditorAPI = {' +\r
+ 'Version : "2.6.4",' +\r
+ 'VersionBuild : "21629",' +\r
+ 'Instances : window.FCKeditorAPI && window.FCKeditorAPI.Instances || {},' +\r
+\r
+ 'GetInstance : function( name )' +\r
+ '{' +\r
+ 'return this.Instances[ name ];' +\r
+ '},' +\r
+\r
+ '_FormSubmit : function()' +\r
+ '{' +\r
+ 'for ( var name in FCKeditorAPI.Instances )' +\r
+ '{' +\r
+ 'var oEditor = FCKeditorAPI.Instances[ name ] ;' +\r
+ 'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' +\r
+ 'oEditor.UpdateLinkedField() ;' +\r
+ '}' +\r
+ 'this._FCKOriginalSubmit() ;' +\r
+ '},' +\r
+\r
+ '_FunctionQueue : window.FCKeditorAPI && window.FCKeditorAPI._FunctionQueue || {' +\r
+ 'Functions : new Array(),' +\r
+ 'IsRunning : false,' +\r
+\r
+ 'Add : function( f )' +\r
+ '{' +\r
+ 'this.Functions.push( f );' +\r
+ 'if ( !this.IsRunning )' +\r
+ 'this.StartNext();' +\r
+ '},' +\r
+\r
+ 'StartNext : function()' +\r
+ '{' +\r
+ 'var aQueue = this.Functions ;' +\r
+ 'if ( aQueue.length > 0 )' +\r
+ '{' +\r
+ 'this.IsRunning = true;' +\r
+ 'aQueue[0].call();' +\r
+ '}' +\r
+ 'else ' +\r
+ 'this.IsRunning = false;' +\r
+ '},' +\r
+\r
+ 'Remove : function( f )' +\r
+ '{' +\r
+ 'var aQueue = this.Functions;' +\r
+ 'var i = 0, fFunc;' +\r
+ 'while( (fFunc = aQueue[ i ]) )' +\r
+ '{' +\r
+ 'if ( fFunc == f )' +\r
+ 'aQueue.splice( i,1 );' +\r
+ 'i++ ;' +\r
+ '}' +\r
+ 'this.StartNext();' +\r
+ '}' +\r
+ '}' +\r
+ '}' ;\r
+\r
+ // In IE, the "eval" function is not always available (it works with\r
+ // the JavaScript samples, but not with the ASP ones, for example).\r
+ // So, let's use the execScript instead.\r
+ if ( oParentWindow.execScript )\r
+ oParentWindow.execScript( sScript, 'JavaScript' ) ;\r
+ else\r
+ {\r
+ if ( FCKBrowserInfo.IsGecko10 )\r
+ {\r
+ // FF 1.0.4 gives an error with the request bellow. The\r
+ // following seams to work well.\r
+ eval.call( oParentWindow, sScript ) ;\r
+ }\r
+ else if( FCKBrowserInfo.IsAIR )\r
+ {\r
+ FCKAdobeAIR.FCKeditorAPI_Evaluate( oParentWindow, sScript ) ;\r
+ }\r
+ else if ( FCKBrowserInfo.IsSafari )\r
+ {\r
+ // oParentWindow.eval in Safari executes in the calling window\r
+ // environment, instead of the parent one. The following should\r
+ // make it work.\r
+ var oParentDocument = oParentWindow.document ;\r
+ var eScript = oParentDocument.createElement('script') ;\r
+ eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ;\r
+ oParentDocument.documentElement.appendChild( eScript ) ;\r
+ }\r
+ else\r
+ oParentWindow.eval( sScript ) ;\r
+ }\r
+\r
+ FCKeditorAPI = oParentWindow.FCKeditorAPI ;\r
+\r
+ // The __Instances properly has been changed to the public Instances,\r
+ // but we should still have the "deprecated" version of it.\r
+ FCKeditorAPI.__Instances = FCKeditorAPI.Instances ;\r
+ }\r
+\r
+ // Add the current instance to the FCKeditorAPI's instances collection.\r
+ FCKeditorAPI.Instances[ FCK.Name ] = FCK ;\r
+}\r
+\r
+// Attach to the form onsubmit event and to the form.submit().\r
+function _AttachFormSubmitToAPI()\r
+{\r
+ // Get the linked field form.\r
+ var oForm = FCK.GetParentForm() ;\r
+\r
+ if ( oForm )\r
+ {\r
+ // Attach to the onsubmit event.\r
+ FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ;\r
+\r
+ // IE sees oForm.submit function as an 'object'.\r
+ if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) )\r
+ {\r
+ // Save the original submit.\r
+ oForm._FCKOriginalSubmit = oForm.submit ;\r
+\r
+ // Create our replacement for the submit.\r
+ oForm.submit = FCKeditorAPI._FormSubmit ;\r
+ }\r
+ }\r
+}\r
+\r
+function FCKeditorAPI_Cleanup()\r
+{\r
+ if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat\r
+ && !window.FCKUnloadFlag )\r
+ return ;\r
+ delete FCKeditorAPI.Instances[ FCK.Name ] ;\r
+}\r
+function FCKeditorAPI_ConfirmCleanup()\r
+{\r
+ if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat )\r
+ window.FCKUnloadFlag = true ;\r
+}\r
+FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ;\r
+FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ;\r