2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fckscriptloader.js
14
* Defines the FCKScriptLoader object that is used to dynamically load
15
* scripts in the editor.
18
* Frederico Caldeira Knabben (fredck@fckeditor.net)
21
// This object is used to download scripts and css files sequentialy.
22
// A file download is not started until the previous file was not completelly
24
var FCKScriptLoader = new Object() ;
25
FCKScriptLoader.IsLoading = false ;
26
FCKScriptLoader.Queue = new Array() ;
28
// Adds a script or css to the queue.
29
FCKScriptLoader.AddScript = function( scriptPath )
31
FCKScriptLoader.Queue[ FCKScriptLoader.Queue.length ] = scriptPath ;
33
if ( !this.IsLoading )
37
// Checks the queue to see if there is something to load.
38
// This function should not be called by code. It's a internal function
39
// that's called recursively.
40
FCKScriptLoader.CheckQueue = function()
42
// Check if the queue is not empty.
43
if ( this.Queue.length > 0 )
45
this.IsLoading = true ;
47
// Get the first item in the queue
48
var sScriptPath = this.Queue[0] ;
50
// Removes the first item from the queue
51
var oTempArray = new Array() ;
52
for ( i = 1 ; i < this.Queue.length ; i++ )
53
oTempArray[ i - 1 ] = this.Queue[ i ] ;
54
this.Queue = oTempArray ;
56
this.LoadFile( sScriptPath ) ;
60
this.IsLoading = false ;
62
// Call the "OnEmpty" event.
68
FCKScriptLoader.LoadFile = function( filePath )
70
//window.status = ( 'Loading ' + filePath + '...' ) ;
72
// Dynamically load the file (it can be a CSS or a JS)
76
if ( filePath.lastIndexOf( '.css' ) > 0 )
78
e = document.createElement( 'LINK' ) ;
79
e.rel = 'stylesheet' ;
85
e = document.createElement( "script" ) ;
86
e.type = "text/javascript" ;
89
// Add the new object to the HEAD.
90
document.getElementsByTagName("head")[0].appendChild( e ) ;
92
// Start downloading it.
93
if ( e.tagName == 'LINK' )
95
// IE must wait for the file to be downloaded.
96
if ( FCKBrowserInfo.IsIE )
97
e.onload = FCKScriptLoader_OnLoad ;
98
// Gecko doens't fire any event when the CSS is loaded, so we
101
FCKScriptLoader.CheckQueue() ;
107
// Gecko fires the "onload" event and IE fires "onreadystatechange"
108
e.onload = e.onreadystatechange = FCKScriptLoader_OnLoad ;
113
function FCKScriptLoader_OnLoad()
115
// Gecko doesn't have a "readyState" property
116
if ( this.tagName == 'LINK' || !this.readyState || this.readyState == 'loaded' )
117
// Load the next script available in the queue
118
FCKScriptLoader.CheckQueue() ;
b'\\ No newline at end of file'