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