Ticket #4145: 4145.patch

File 4145.patch, 4.4 KB (added by Frederico Caldeira Knabben, 15 years ago)
  • _source/core/loader.js

     
    123123                                't=' + timestamp;
    124124                };
    125125
     126                var pendingLoad = [];
     127
    126128                /** @lends CKEDITOR.loader */
    127129                return {
    128130                        /**
     
    133135                         * alert( <b>CKEDITOR.loader.loadedScripts</b> );
    134136                         */
    135137                        loadedScripts : [],
     138                       
     139                        loadPending : function()
     140                        {
     141                                var scriptName = pendingLoad.shift();
     142                               
     143                                if ( !scriptName )
     144                                        return;
    136145
     146                                var scriptSrc = getUrl( '_source/' + scriptName + '.js' );
     147
     148                                var script = document.createElement( 'script' );
     149                                script.type = 'text/javascript';
     150                                script.src = scriptSrc;
     151
     152                                function onScriptLoaded()
     153                                {
     154                                        // Append this script to the list of loaded scripts.
     155                                        CKEDITOR.loader.loadedScripts.push( scriptName );
     156                                       
     157                                        // Load the next.
     158                                        CKEDITOR.loader.loadPending();
     159                                }
     160
     161                                // We must guarantee the execution order of the scripts, so we
     162                                // need to load them one by one. (#4145)
     163                                // The followin if/else block has been taken from the scriptloader core code.
     164                                if ( CKEDITOR.env.ie )
     165                                {
     166                                        /** @ignore */
     167                                        script.onreadystatechange = function()
     168                                        {
     169                                                if ( script.readyState == 'loaded' || script.readyState == 'complete' )
     170                                                {
     171                                                        script.onreadystatechange = null;
     172                                                        onScriptLoaded();
     173                                                }
     174                                        };
     175                                }
     176                                else
     177                                {
     178                                        /** @ignore */
     179                                        script.onload = function()
     180                                        {
     181                                                // Some browsers, such as Safari, may call the onLoad function
     182                                                // immediately. Which will break the loading sequence. (#3661)
     183                                                setTimeout( function() { onScriptLoaded( scriptName ); }, 0 );
     184                                        };
     185                                }
     186
     187                                document.body.appendChild( script );
     188                        },
     189
    137190                        /**
    138191                         * Loads a specific script, including its dependencies. This is not a
    139192                         * synchronous loading, which means that the code the be loaded will
     
    141194                         * @example
    142195                         * CKEDITOR.loader.load( 'core/dom/element' );
    143196                         */
    144                         load : function( scriptName )
     197                        load : function( scriptName, defer )
    145198                        {
    146199                                // Check if the script has already been loaded.
    147200                                if ( scriptName in this.loadedScripts )
     
    158211
    159212                                // Load all dependencies first.
    160213                                for ( var i = 0 ; i < dependencies.length ; i++ )
    161                                         this.load( dependencies[ i ] );
    162 
    163                                 // Append this script to the list of loaded scripts.
    164                                 this.loadedScripts.push( scriptName );
    165 
     214                                        this.load( dependencies[ i ], true );
     215                               
    166216                                var scriptSrc = getUrl( '_source/' + scriptName + '.js' );
    167217
    168218                                // Append the <script> element to the DOM.
    169219                                if ( document.body )
    170220                                {
    171                                         var script = document.createElement( 'script' );
    172                                         script.type = 'text/javascript';
    173                                         script.src = scriptSrc;
     221                                        pendingLoad.push( scriptName );
    174222
    175                                         document.body.appendChild( script );
     223                                        if ( !defer )
     224                                                this.loadPending();
    176225                                }
    177226                                else
    178227                                        document.write( '<script src="' + scriptSrc + '" type="text/javascript"><\/script>' );
  • _source/tests/core/bootstrap.html

     
    1212
    1313var before_loadFullCore = CKEDITOR.status;
    1414
     15var isLoaded;
     16
     17CKEDITOR.on( 'loaded', function()
     18        {
     19                isLoaded = true;
     20        });
     21
     22
    1523CKEDITOR.loadFullCore();
    1624
    1725        //]]>
     
    3240
    3341                test_status2 : function()
    3442                {
     43                        // In IE, CKEDITOR.on( 'loaded' ) will be called immediately if the scripts are cached.
     44                        if ( isLoaded )
     45                                return;
     46
    3547                        var testCase = this;
    3648                        CKEDITOR.on( 'loaded', function()
    3749                                {
  • CHANGES.html

     
    213213                <li><a href="http://dev.fckeditor.net/ticket/4123">#4123</a> : Some dialog buttons were broken in IE7 quirks.</li>
    214214                <li><a href="http://dev.fckeditor.net/ticket/4122">#4122</a> : [IE] The image dialog
    215215                        was being rendered improperly when loading an image with long URL.</li>
     216                <li><a href="http://dev.fckeditor.net/ticket/4145">#4145</a> : Fixed the on demand
     217                        (&quot;basic&quot;) loading model of the editor.</li>
    216218        </ul>
    217219        <h3>
    218220                CKEditor 3.0 RC</h3>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy