Ticket #6504: 6504_1.patch

File 6504_1.patch, 3.4 KB (added by Jakub Ś, 11 years ago)
  • _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                 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} [showBusy] Changes the cursor of the document while
    3738+                *              the script is loaded.
     39                 * @param {Boolean} [ordered] Signals that the script is part of a queue.
    3840                 * @example
    3941                 * CKEDITOR.scriptLoader.load( '/myscript.js' );
    4042                 * @example
     
    5153                 *         alert( 'Number of failures: ' + failed.length );
    5254                 *     });
    5355                 */
    54                 load : function( scriptUrl, callback, scope, showBusy )
     56                load : function( scriptUrl, callback, scope, showBusy, ordered )
    5557                {
    5658                        var isString = ( typeof scriptUrl == 'string' );
    5759
     
    106108                                for ( var i = 0 ; i < waitingInfo.length ; i++ )
    107109                                        waitingInfo[ i ]( url, success );
    108110                        };
     111                       
     112                        if ( ordered )
     113                    CKEDITOR.scriptLoader.advanceQueue();
    109114
    110115                        var loadScript = function( url )
    111116                        {
     
    175180                        {
    176181                                loadScript( scriptUrl[ i ] );
    177182                        }
    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                }
    179220        };
    180221})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy