Ticket #4767: 4767_3.patch

File 4767_3.patch, 4.8 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Proposed patch

  • _source/core/ckeditor_basic.js

     
    231231                                }
    232232                        };
    233233
    234                         if ( window.addEventListener )
    235                                 window.addEventListener( 'load', onload, false );
    236                         else if ( window.attachEvent )
    237                                 window.attachEvent( 'onload', onload );
     234                        // If the initialization is done by putting ckeditor_source.js in the body then
     235                        // the scripts are loaded by setTimeout calls, so when it loads this one the document
     236                        // might be already loaded
     237                        // Unfortunately, Firefox <3.6 doesn't support document.readyState
     238                        if (document.readyState == 'complete')
     239                                setTimeout( onload, 0 );
     240                        else
     241                        {
     242                                if ( window.addEventListener )
     243                                        window.addEventListener( 'load', onload, false );
     244                                else if ( window.attachEvent )
     245                                        window.attachEvent( 'onload', onload );
     246                        }
    238247                })();
    239248
    240249                CKEDITOR.status = 'basic_loaded';
  • _source/core/loader.js

     
    161161
    162162                                // We must guarantee the execution order of the scripts, so we
    163163                                // need to load them one by one. (#4145)
    164                                 // The followin if/else block has been taken from the scriptloader core code.
    165                                 if ( CKEDITOR.env.ie )
     164                                // The following if/else block has been taken from the scriptloader core code.
     165                                if ( typeof(script.onreadystatechange) !== "undefined" )
    166166                                {
    167167                                        /** @ignore */
    168168                                        script.onreadystatechange = function()
     
    190190
    191191                        /**
    192192                         * Loads a specific script, including its dependencies. This is not a
    193                          * synchronous loading, which means that the code the be loaded will
     193                         * synchronous loading, which means that the code to be loaded will
    194194                         * not necessarily be available after this call.
    195195                         * @example
    196196                         * CKEDITOR.loader.load( 'core/dom/element' );
     
    217217                                var scriptSrc = getUrl( '_source/' + scriptName + '.js' );
    218218
    219219                                // Append the <script> element to the DOM.
    220                                 if ( document.body )
     220                                // If the page is fully loaded, we can't use document.write
     221                                // but if the script is run while the body is loading then it's safe to use it
     222                                // Unfortunately, Firefox <3.6 doesn't support document.readyState, so it won't get this improvement
     223                                if ( document.body && (!document.readyState || document.readyState == 'complete') )
    221224                                {
    222225                                        pendingLoad.push( scriptName );
    223226
  • ckeditor_basic_source.js

     
    1515// Set the script name to be loaded by the loader.
    1616CKEDITOR._autoLoad = 'core/ckeditor_basic';
    1717
    18 // Include the loader script.
    19 document.write(
    20         '<script type="text/javascript" src="' + CKEDITOR.getUrl( '_source/core/loader.js' ) + '"></script>' );
     18(function() {
     19        var src =  CKEDITOR.getUrl( '_source/core/loader.js' );
     20        // Include the loader script.
     21        if ( document.body && (!document.readyState || document.readyState == 'complete') )
     22        {
     23                var script = document.createElement( 'script' );
     24                script.type = 'text/javascript';
     25                script.src = src;
     26
     27                document.body.appendChild( script );
     28        }
     29        else
     30                document.write(
     31                        '<script type="text/javascript" src="' + src + '"></script>' );
     32})();
     33 No newline at end of file
  • ckeditor_source.js

     
    1212// request, having clear cache load of the editor code.
    1313// CKEDITOR.timestamp = ( new Date() ).valueOf();
    1414
    15 if ( CKEDITOR.loader )
    16         CKEDITOR.loader.load( 'core/ckeditor' );
    17 else
    18 {
    19         // Set the script name to be loaded by the loader.
    20         CKEDITOR._autoLoad = 'core/ckeditor';
     15(function() {
     16        if ( CKEDITOR.loader )
     17                CKEDITOR.loader.load( 'core/ckeditor' );
     18        else
     19        {
     20                // Set the script name to be loaded by the loader.
     21                CKEDITOR._autoLoad = 'core/ckeditor';
    2122
    22         // Include the loader script.
    23         document.write(
    24                 '<script type="text/javascript" src="' + CKEDITOR.getUrl( '_source/core/loader.js' ) + '"></script>' );
    25 }
     23                var src =  CKEDITOR.getUrl( '_source/core/loader.js' );
     24                // Include the loader script.
     25                if ( document.body && (!document.readyState || document.readyState == 'complete') )
     26                {
     27                        var script = document.createElement( 'script' );
     28                        script.type = 'text/javascript';
     29                        script.src = src;
     30
     31                        document.body.appendChild( script );
     32                }
     33                else
     34                        document.write(
     35                                '<script type="text/javascript" src="' + src + '"></script>' );
     36        }
     37})();
     38 No newline at end of file
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy