Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php |
— | — | @@ -79,6 +79,8 @@ |
80 | 80 | * @format array( [message-key], [message-key], ... ) |
81 | 81 | */ |
82 | 82 | protected $group; |
| 83 | + /** @var {boolean} Link to raw files in debug mode */ |
| 84 | + protected $debugRaw = true; |
83 | 85 | /** |
84 | 86 | * @var {array} Cache for mtime |
85 | 87 | * @format array( [hash] => [mtime], [hash] => [mtime], ... ) |
— | — | @@ -147,8 +149,12 @@ |
148 | 150 | break; |
149 | 151 | // Single strings |
150 | 152 | case 'group': |
151 | | - $this->group = (string) $option; |
| 153 | + $this->{$member} = (string) $option; |
152 | 154 | break; |
| 155 | + // Single booleans |
| 156 | + case 'debugRaw': |
| 157 | + $this->{$member} = (bool) $option; |
| 158 | + break; |
153 | 159 | } |
154 | 160 | } |
155 | 161 | } |
— | — | @@ -160,13 +166,24 @@ |
161 | 167 | * @return {string} JavaScript code for $context |
162 | 168 | */ |
163 | 169 | public function getScript( ResourceLoaderContext $context ) { |
164 | | - $script = self::readScriptFiles( $this->scripts ) . "\n" . |
165 | | - self::readScriptFiles( self::tryForKey( $this->languageScripts, $context->getLanguage() ) ) . "\n" . |
166 | | - self::readScriptFiles( self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' ) ) . "\n"; |
| 170 | + global $wgScriptPath; |
| 171 | + |
| 172 | + $files = array_merge( |
| 173 | + $this->scripts, |
| 174 | + self::tryForKey( $this->languageScripts, $context->getLanguage() ), |
| 175 | + self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' ) |
| 176 | + ); |
167 | 177 | if ( $context->getDebug() ) { |
168 | | - $script .= "\n" . self::readScriptFiles( $this->debugScripts ); |
| 178 | + $files = array_merge( $files, $this->debugScripts ); |
| 179 | + if ( $this->debugRaw ) { |
| 180 | + $tags = ''; |
| 181 | + foreach ( $files as $file ) { |
| 182 | + $tags .= "<script type=\"text/javascript\" src=\"$wgScriptPath/$file\"></script>"; |
| 183 | + } |
| 184 | + return "\n\tdocument.write( " . FormatJson::encode( $tags ) . ' );'; |
| 185 | + } |
169 | 186 | } |
170 | | - return $script; |
| 187 | + return self::readScriptFiles( $files ); |
171 | 188 | } |
172 | 189 | |
173 | 190 | /** |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | |
27 | 27 | /* jQuery */ |
28 | 28 | |
29 | | - 'jquery' => new ResourceLoaderFileModule( array( 'scripts' => 'resources/jquery/jquery.js' ) ), |
| 29 | + 'jquery' => new ResourceLoaderFileModule( array( 'scripts' => 'resources/jquery/jquery.js', 'debugRaw' => false ) ), |
30 | 30 | |
31 | 31 | /* jQuery Plugins */ |
32 | 32 | |
— | — | @@ -314,6 +314,7 @@ |
315 | 315 | 'mediawiki' => new ResourceLoaderFileModule( array( |
316 | 316 | 'scripts' => 'resources/mediawiki/mediawiki.js', |
317 | 317 | 'debugScripts' => 'resources/mediawiki/mediawiki.log.js', |
| 318 | + 'debugRaw' => false |
318 | 319 | ) ), |
319 | 320 | 'mediawiki.specials.preferences' => new ResourceLoaderFileModule( array( |
320 | 321 | 'scripts' => 'resources/mediawiki/mediawiki.specials.preferences.js', |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -495,34 +495,26 @@ |
496 | 496 | }; |
497 | 497 | // Extend request parameters with a list of modules in the batch |
498 | 498 | var requests = []; |
499 | | - if ( base.debug == '1' ) { |
500 | | - for ( var b = 0; b < batch.length; b++ ) { |
501 | | - requests[requests.length] = $.extend( |
502 | | - { 'modules': batch[b], 'version': registry[batch[b]].version }, base |
503 | | - ); |
| 499 | + // Split into groups |
| 500 | + var groups = {}; |
| 501 | + for ( var b = 0; b < batch.length; b++ ) { |
| 502 | + var group = registry[batch[b]].group; |
| 503 | + if ( !( group in groups ) ) { |
| 504 | + groups[group] = []; |
504 | 505 | } |
505 | | - } else { |
506 | | - // Split into groups |
507 | | - var groups = {}; |
508 | | - for ( var b = 0; b < batch.length; b++ ) { |
509 | | - var group = registry[batch[b]].group; |
510 | | - if ( !( group in groups ) ) { |
511 | | - groups[group] = []; |
| 506 | + groups[group][groups[group].length] = batch[b]; |
| 507 | + } |
| 508 | + for ( var group in groups ) { |
| 509 | + // Calculate the highest timestamp |
| 510 | + var version = 0; |
| 511 | + for ( var g = 0; g < groups[group].length; g++ ) { |
| 512 | + if ( registry[groups[group][g]].version > version ) { |
| 513 | + version = registry[groups[group][g]].version; |
512 | 514 | } |
513 | | - groups[group][groups[group].length] = batch[b]; |
514 | 515 | } |
515 | | - for ( var group in groups ) { |
516 | | - // Calculate the highest timestamp |
517 | | - var version = 0; |
518 | | - for ( var g = 0; g < groups[group].length; g++ ) { |
519 | | - if ( registry[groups[group][g]].version > version ) { |
520 | | - version = registry[groups[group][g]].version; |
521 | | - } |
522 | | - } |
523 | | - requests[requests.length] = $.extend( |
524 | | - { 'modules': groups[group].join( '|' ), 'version': formatVersionNumber( version ) }, base |
525 | | - ); |
526 | | - } |
| 516 | + requests[requests.length] = $.extend( |
| 517 | + { 'modules': groups[group].join( '|' ), 'version': formatVersionNumber( version ) }, base |
| 518 | + ); |
527 | 519 | } |
528 | 520 | // Clear the batch - this MUST happen before we append the script element to the body or it's |
529 | 521 | // possible that the script will be locally cached, instantly load, and work the batch again, |