Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php |
— | — | @@ -166,7 +166,7 @@ |
167 | 167 | * @return {string} JavaScript code for $context |
168 | 168 | */ |
169 | 169 | public function getScript( ResourceLoaderContext $context ) { |
170 | | - global $wgScriptPath; |
| 170 | + global $wgServer, $wgScriptPath; |
171 | 171 | |
172 | 172 | $files = array_merge( |
173 | 173 | $this->scripts, |
— | — | @@ -176,11 +176,12 @@ |
177 | 177 | if ( $context->getDebug() ) { |
178 | 178 | $files = array_merge( $files, $this->debugScripts ); |
179 | 179 | if ( $this->debugRaw ) { |
180 | | - $tags = ''; |
| 180 | + $script = ''; |
181 | 181 | foreach ( $files as $file ) { |
182 | | - $tags .= "<script type=\"text/javascript\" src=\"$wgScriptPath/$file\"></script>"; |
| 182 | + $path = FormatJson::encode( "$wgServer$wgScriptPath/$file" ); |
| 183 | + $script .= "\n\tmediaWiki.loader.load( $path );"; |
183 | 184 | } |
184 | | - return "\n\tdocument.write( " . FormatJson::encode( $tags ) . ' );'; |
| 185 | + return $script; |
185 | 186 | } |
186 | 187 | } |
187 | 188 | return self::readScriptFiles( $files ); |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -673,14 +673,15 @@ |
674 | 674 | // Support adding arbitrary external scripts |
675 | 675 | if ( modules.substr( 0, 7 ) == 'http://' || modules.substr( 0, 8 ) == 'https://' ) { |
676 | 676 | if ( type === 'text/css' ) { |
677 | | - setTimeout( function() { |
678 | | - $( 'head' ).append( '<link rel="stylesheet" type="text/css" />' ).attr( 'href', modules ); |
679 | | - }, 0 ); |
| 677 | + $( 'head' ).append( $( '<link rel="stylesheet" type="text/css" />' ).attr( 'href', modules ) ); |
680 | 678 | return true; |
681 | 679 | } else if ( type === 'text/javascript' || typeof type === 'undefined' ) { |
682 | | - setTimeout( function() { |
683 | | - $( 'body' ).append( '<script type="text/javascript"></script>' ).attr( 'src', modules ) |
684 | | - }, 0 ); |
| 680 | + var script = '<script type="text/javascript" src="' + modules + '"></script>'; |
| 681 | + if ( ready ) { |
| 682 | + $( 'body' ).append( script ); |
| 683 | + } else { |
| 684 | + document.write( script ); |
| 685 | + } |
685 | 686 | return true; |
686 | 687 | } |
687 | 688 | // Unknown type |