Ticket #6504: 6504_1.patch
File 6504_1.patch, 3.4 KB (added by , 10 years ago) |
---|
-
_source/core/editor.js
52 52 else 53 53 { 54 54 // Load the custom configuration file. 55 CKEDITOR.scriptLoader. load( customConfig, function()55 CKEDITOR.scriptLoader.queue( customConfig, function() 56 56 { 57 57 // If the CKEDITOR.editorConfig function has been properly 58 58 // defined in the custom configuration file, cache it. -
_source/core/scriptloader.js
15 15 */ 16 16 CKEDITOR.scriptLoader = (function() 17 17 { 18 var uniqueScripts = {}, 19 waitingList = {}; 18 var uniqueScripts = {}, 19 waitingList = {}, 20 pendingQueue = []; 20 21 21 22 return /** @lends CKEDITOR.scriptLoader */ { 22 23 /** … … 35 36 * the callback call. Default to {@link CKEDITOR}. 36 37 * @param {Boolean} [showBusy] Changes the cursor of the document while 37 38 + * the script is loaded. 39 * @param {Boolean} [ordered] Signals that the script is part of a queue. 38 40 * @example 39 41 * CKEDITOR.scriptLoader.load( '/myscript.js' ); 40 42 * @example … … 51 53 * alert( 'Number of failures: ' + failed.length ); 52 54 * }); 53 55 */ 54 load : function( scriptUrl, callback, scope, showBusy )56 load : function( scriptUrl, callback, scope, showBusy, ordered ) 55 57 { 56 58 var isString = ( typeof scriptUrl == 'string' ); 57 59 … … 106 108 for ( var i = 0 ; i < waitingInfo.length ; i++ ) 107 109 waitingInfo[ i ]( url, success ); 108 110 }; 111 112 if ( ordered ) 113 CKEDITOR.scriptLoader.advanceQueue(); 109 114 110 115 var loadScript = function( url ) 111 116 { … … 175 180 { 176 181 loadScript( scriptUrl[ i ] ); 177 182 } 178 } 183 }, 184 185 /** 186 * Loads a script in a queue, so only one of the scripts in the queue is 187 * to be loaded at the same time. 188 * @param {String|Array} scriptUrl One or more URLs pointing to the 189 * scripts to be loaded. 190 * @param {Function} [callback] A function to be called when the script 191 * is loaded and executed. If a string is passed to "scriptUrl", a 192 * boolean parameter is passed to the callback, indicating the 193 * success of the load. If an array is passed instead, two array 194 * parameters are passed to the callback; the first contains the 195 * URLs that have been properly loaded, and the second the failed 196 * ones. 197 * @example 198 * see CKEDITOR.scriptLoader.load 199 * 200 */ 201 queue : function( scriptUrl, callback ) 202 { 203 // Let's add this script to the queue 204 pendingQueue.push( {'url': scriptUrl, 'callback': callback} ); 205 206 // Load it if it's the only one in the queue at the moment 207 if ( pendingQueue.length == 1 ) 208 this.load( scriptUrl, callback, CKEDITOR, 0, 1); 209 }, 210 211 advanceQueue : function() 212 { 213 // Remove the first one 214 pendingQueue.shift(); 215 216 // Load the new one that it's first 217 if ( pendingQueue.length ) 218 this.load( pendingQueue[0].url, pendingQueue[0].callback, CKEDITOR, 0, 1); 219 } 179 220 }; 180 221 })();