Ticket #6504: 6504.patch

File 6504.patch, 3.4 KB (added by Alfonso Martínez de Lizarrondo, 13 years ago)

Proposed patch

  • _source/core/editor.js

     
    5252                else
    5353                {
    5454                        // Load the custom configuration file.
    55                         CKEDITOR.scriptLoader.load( customConfig, function()
     55                        CKEDITOR.scriptLoader.queue( customConfig, function()
    5656                                {
    5757                                        // If the CKEDITOR.editorConfig function has been properly
    5858                                        // defined in the custom configuration file, cache it.
  • _source/core/scriptloader.js

     
    1515 */
    1616CKEDITOR.scriptLoader = (function()
    1717{
    18         var uniqueScripts = {};
    19         var waitingList = {};
     18        var uniqueScripts = {},
     19                waitingList = {},
     20                pendingQueue = [];
    2021
    2122        return /** @lends CKEDITOR.scriptLoader */ {
    2223                /**
     
    3536                 *              the callback call. Default to {@link CKEDITOR}.
    3637                 * @param {Boolean} [noCheck] Indicates that the script must be loaded
    3738                 *              anyway, not checking if it has already loaded.
     39                 * @param {Boolean} [showBusy] Changes the cursor of the document while
     40                 *              the script is loaded
     41                 * @param {Boolean} [ordered] Signals that the script is part of a queue.
    3842                 * @example
    3943                 * CKEDITOR.scriptLoader.load( '/myscript.js' );
    4044                 * @example
     
    5155                 *         alert( 'Number of failures: ' + failed.length );
    5256                 *     });
    5357                 */
    54                 load : function( scriptUrl, callback, scope, noCheck, showBusy )
     58                load : function( scriptUrl, callback, scope, noCheck, showBusy, ordered )
    5559                {
    5660                        var isString = ( typeof scriptUrl == 'string' );
    5761
     
    9195                                        showBusy && CKEDITOR.document.getDocumentElement().removeStyle( 'cursor' );
    9296                                        doCallback( success );
    9397                                }
     98
     99                                if ( ordered )
     100                                        CKEDITOR.scriptLoader.advanceQueue();
    94101                        };
    95102
    96103                        var onLoad = function( url, success )
     
    178185                },
    179186
    180187                /**
     188                 * Loads a script in a queue, so only one of the scripts in the queue is
     189                 * to be loaded at the same time.
     190                 * @param {String|Array} scriptUrl One or more URLs pointing to the
     191                 *              scripts to be loaded.
     192                 * @param {Function} [callback] A function to be called when the script
     193                 *              is loaded and executed. If a string is passed to "scriptUrl", a
     194                 *              boolean parameter is passed to the callback, indicating the
     195                 *              success of the load. If an array is passed instead, two array
     196                 *              parameters are passed to the callback; the first contains the
     197                 *              URLs that have been properly loaded, and the second the failed
     198                 *              ones.
     199                 * @example
     200                 * see CKEDITOR.scriptLoader.load
     201                 *
     202                 */
     203                queue : function( scriptUrl, callback )
     204                {
     205                        // Let's add this script to the queue
     206                        pendingQueue.push( {'url': scriptUrl, 'callback': callback} );
     207
     208                        // Load it if it's the only one in the queue at the moment
     209                        if ( pendingQueue.length == 1 )
     210                                this.load( scriptUrl, callback, CKEDITOR, 0, 0, 1);
     211                },
     212
     213                advanceQueue : function()
     214                {
     215                        // Remove the first one
     216                        pendingQueue.shift();
     217
     218                        // Load the new one that it's first
     219                        if ( pendingQueue.length )
     220                                this.load( pendingQueue[0].url, pendingQueue[0].callback, CKEDITOR, 0, 0, 1);
     221                },
     222
     223                /**
    181224                 * Executes a JavaScript code into the current document.
    182225                 * @param {String} code The code to be executed.
    183226                 * @example
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy