1 | /*
|
---|
2 | * FCKeditor - The text editor for internet
|
---|
3 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben
|
---|
4 | *
|
---|
5 | * Licensed under the terms of the GNU Lesser General Public License:
|
---|
6 | * http://www.opensource.org/licenses/lgpl-license.php
|
---|
7 | *
|
---|
8 | * For further information visit:
|
---|
9 | * http://www.fckeditor.net/
|
---|
10 | *
|
---|
11 | * "Support Open Source software. What about a donation today?"
|
---|
12 | *
|
---|
13 | * File Name: fckeditorapi.js
|
---|
14 | * Create the FCKeditorAPI object that is available as a global object in
|
---|
15 | * the page where the editor is placed in.
|
---|
16 | *
|
---|
17 | * File Authors:
|
---|
18 | * Frederico Caldeira Knabben (fredck@fckeditor.net)
|
---|
19 | */
|
---|
20 |
|
---|
21 | var FCKeditorAPI ;
|
---|
22 |
|
---|
23 | function InitializeAPI()
|
---|
24 | {
|
---|
25 | if ( !( FCKeditorAPI = window.parent.FCKeditorAPI ) )
|
---|
26 | {
|
---|
27 | // Make the FCKeditorAPI object available in the parent window. Use
|
---|
28 | // eval so it is independent from this window and so it will still be
|
---|
29 | // available if the editor instance is removed ("Can't execute code
|
---|
30 | // from a freed script" error).
|
---|
31 | var sScript = '\
|
---|
32 | var FCKeditorAPI = {\
|
---|
33 | Version : \'2.3.2\',\
|
---|
34 | VersionBuild : \'1082\',\
|
---|
35 | __Instances : new Object(),\
|
---|
36 | GetInstance : function( instanceName )\
|
---|
37 | {\
|
---|
38 | return this.__Instances[ instanceName ] ;\
|
---|
39 | },\
|
---|
40 | _FunctionQueue : {\
|
---|
41 | Functions : new Array(),\
|
---|
42 | IsRunning : false,\
|
---|
43 | Add : function( functionToAdd )\
|
---|
44 | {\
|
---|
45 | this.Functions.push( functionToAdd ) ;\
|
---|
46 | if ( !this.IsRunning )\
|
---|
47 | this.StartNext() ;\
|
---|
48 | },\
|
---|
49 | StartNext : function()\
|
---|
50 | {\
|
---|
51 | var aQueue = this.Functions ;\
|
---|
52 | if ( aQueue.length > 0 )\
|
---|
53 | {\
|
---|
54 | this.IsRunning = true ;\
|
---|
55 | aQueue[0].call() ;\
|
---|
56 | }\
|
---|
57 | else\
|
---|
58 | this.IsRunning = false ;\
|
---|
59 | },\
|
---|
60 | Remove : function( func )\
|
---|
61 | {\
|
---|
62 | var aQueue = this.Functions ;\
|
---|
63 | var i = 0, fFunc ;\
|
---|
64 | while( fFunc = aQueue[ i ] )\
|
---|
65 | {\
|
---|
66 | if ( fFunc == func )\
|
---|
67 | aQueue.splice( i,1 ) ;\
|
---|
68 | i++ ;\
|
---|
69 | }\
|
---|
70 | this.StartNext() ;\
|
---|
71 | }\
|
---|
72 | }\
|
---|
73 | }' ;
|
---|
74 |
|
---|
75 | // In IE, the "eval" function is not always available (it works with
|
---|
76 | // the JavaScript samples, but not with the ASP ones, for example).
|
---|
77 | // So, let's use the execScript instead.
|
---|
78 | if ( window.parent.execScript )
|
---|
79 | window.parent.execScript( sScript, 'JavaScript' ) ;
|
---|
80 | else
|
---|
81 | {
|
---|
82 | if ( FCKBrowserInfo.IsGecko10 )
|
---|
83 | {
|
---|
84 | // FF 1.0.4 gives an error with the above request. The
|
---|
85 | // following seams to work well. It could become to official
|
---|
86 | // implementation for all browsers, but we need to check it.
|
---|
87 | eval.call( window.parent, sScript ) ;
|
---|
88 | }
|
---|
89 | else
|
---|
90 | window.parent.eval( sScript ) ;
|
---|
91 | }
|
---|
92 |
|
---|
93 | FCKeditorAPI = window.parent.FCKeditorAPI ;
|
---|
94 | }
|
---|
95 |
|
---|
96 | // Add the current instance to the FCKeditorAPI's instances collection.
|
---|
97 | FCKeditorAPI.__Instances[ FCK.Name ] = FCK ;
|
---|
98 | }
|
---|
99 |
|
---|
100 | function FCKeditorAPI_Cleanup()
|
---|
101 | {
|
---|
102 | FCKeditorAPI.__Instances[ FCK.Name ] = null ;
|
---|
103 | }
|
---|
104 | FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ; |
---|