ResourceLoaderFileModule now uses mediaWiki.loader.load to load scripts in debug...
authorTrevor Parscal <tparscal@users.mediawiki.org>
Thu, 21 Oct 2010 21:25:27 +0000 (21:25 +0000)
committerTrevor Parscal <tparscal@users.mediawiki.org>
Thu, 21 Oct 2010 21:25:27 +0000 (21:25 +0000)
includes/resourceloader/ResourceLoaderFileModule.php
resources/mediawiki/mediawiki.js

index 4439124..cd950e8 100644 (file)
@@ -166,7 +166,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @return {string} JavaScript code for $context
         */
        public function getScript( ResourceLoaderContext $context ) {
-               global $wgScriptPath;
+               global $wgServer, $wgScriptPath;
                
                $files = array_merge(
                        $this->scripts,
@@ -176,11 +176,12 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                if ( $context->getDebug() ) {
                        $files = array_merge( $files, $this->debugScripts );
                        if ( $this->debugRaw ) {
-                               $tags = '';
+                               $script = '';
                                foreach ( $files as $file ) {
-                                       $tags .= "<script type=\"text/javascript\" src=\"$wgScriptPath/$file\"></script>";
+                                       $path = FormatJson::encode( "$wgServer$wgScriptPath/$file" );
+                                       $script .= "\n\tmediaWiki.loader.load( $path );";
                                }
-                               return "\n\tdocument.write( " . FormatJson::encode( $tags ) . ' );';
+                               return $script;
                        }
                }
                return self::readScriptFiles( $files );
index 69e00ce..0eef7d7 100644 (file)
@@ -673,14 +673,15 @@ window.mediaWiki = new ( function( $ ) {
                                // Support adding arbitrary external scripts
                                if ( modules.substr( 0, 7 ) == 'http://' || modules.substr( 0, 8 ) == 'https://' ) {
                                        if ( type === 'text/css' ) {
-                                               setTimeout(  function() {
-                                                       $( 'head' ).append( '<link rel="stylesheet" type="text/css" />' ).attr( 'href', modules );
-                                               }, 0 );
+                                               $( 'head' ).append( $( '<link rel="stylesheet" type="text/css" />' ).attr( 'href', modules ) );
                                                return true;
                                        } else if ( type === 'text/javascript' || typeof type === 'undefined' ) {
-                                               setTimeout(  function() {
-                                                       $( 'body' ).append( '<script type="text/javascript"></script>'  ).attr( 'src', modules )
-                                               }, 0 );
+                                               var script = '<script type="text/javascript" src="' + modules + '"></script>';
+                                               if ( ready ) {
+                                                       $( 'body' ).append( script );
+                                               } else {
+                                                       document.write( script );
+                                               }
                                                return true;
                                        }
                                        // Unknown type