[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2005 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: fckscriptloader.js 14 * Defines the FCKScriptLoader object that is used to dynamically load 15 * scripts in the editor. 16 * 17 * File Authors: 18 * Frederico Caldeira Knabben (fredck@fckeditor.net) 19 */ 20 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 23 // downloaded. 24 var FCKScriptLoader = new Object() ; 25 FCKScriptLoader.IsLoading = false ; 26 FCKScriptLoader.Queue = new Array() ; 27 28 // Adds a script or css to the queue. 29 FCKScriptLoader.AddScript = function( scriptPath ) 30 { 31 FCKScriptLoader.Queue[ FCKScriptLoader.Queue.length ] = scriptPath ; 32 33 if ( !this.IsLoading ) 34 this.CheckQueue() ; 35 } 36 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() 41 { 42 // Check if the queue is not empty. 43 if ( this.Queue.length > 0 ) 44 { 45 this.IsLoading = true ; 46 47 // Get the first item in the queue 48 var sScriptPath = this.Queue[0] ; 49 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 ; 55 56 this.LoadFile( sScriptPath ) ; 57 } 58 else 59 { 60 this.IsLoading = false ; 61 62 // Call the "OnEmpty" event. 63 if ( this.OnEmpty ) 64 this.OnEmpty() ; 65 } 66 } 67 68 FCKScriptLoader.LoadFile = function( filePath ) 69 { 70 //window.status = ( 'Loading ' + filePath + '...' ) ; 71 72 // Dynamically load the file (it can be a CSS or a JS) 73 var e ; 74 75 // If it is a CSS 76 if ( filePath.lastIndexOf( '.css' ) > 0 ) 77 { 78 e = document.createElement( 'LINK' ) ; 79 e.rel = 'stylesheet' ; 80 e.type = 'text/css' ; 81 } 82 // It it is a JS 83 else 84 { 85 e = document.createElement( "script" ) ; 86 e.type = "text/javascript" ; 87 } 88 89 // Add the new object to the HEAD. 90 document.getElementsByTagName("head")[0].appendChild( e ) ; 91 92 // Start downloading it. 93 if ( e.tagName == 'LINK' ) 94 { 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 99 // can't wait for it. 100 else 101 FCKScriptLoader.CheckQueue() ; 102 103 e.href = filePath ; 104 } 105 else 106 { 107 // Gecko fires the "onload" event and IE fires "onreadystatechange" 108 e.onload = e.onreadystatechange = FCKScriptLoader_OnLoad ; 109 e.src = filePath ; 110 } 111 } 112 113 function FCKScriptLoader_OnLoad() 114 { 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() ; 119 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |