Index: branches/resourceloader/phase3/includes/ResourceLoader.php |
— | — | @@ -253,6 +253,7 @@ |
254 | 254 | foreach ( $modules as $module ) { |
255 | 255 | if ( static::$modules[$module]['raw'] ) { |
256 | 256 | readfile( static::$modules[$module]['script'] ); |
| 257 | + echo "\n"; |
257 | 258 | } |
258 | 259 | } |
259 | 260 | // Special meta-information for the 'mw' module |
— | — | @@ -267,7 +268,12 @@ |
268 | 269 | // Include each loader once |
269 | 270 | foreach ( array_unique( $loaders ) as $loader ) { |
270 | 271 | readfile( $loader ); |
| 272 | + echo "\n"; |
271 | 273 | } |
| 274 | + // Configure debug mode on server |
| 275 | + if ( $parameters['debug'] ) { |
| 276 | + echo "mw.debug = true;\n"; |
| 277 | + } |
272 | 278 | /* |
273 | 279 | * Skin::makeGlobalVariablesScript needs to be modified so that we still output the globals for now, but also |
274 | 280 | * put them into the initial payload like this: |
— | — | @@ -300,7 +306,7 @@ |
301 | 307 | // Messages |
302 | 308 | $messages = isset( $blobs[$module] ) ? $blobs[$module] : '{}'; |
303 | 309 | // Output |
304 | | - echo "mw.loader.implement(\n'{$module}', function() { {$script} }, '{$style}', {$messages}\n);\n"; |
| 310 | + echo "mw.loader.implement( '{$module}', function() {\n{$script}\n}, '{$style}', {$messages} );\n"; |
305 | 311 | } |
306 | 312 | } |
307 | 313 | // Set headers -- when we support CSS only mode, this might change! |
Index: branches/resourceloader/phase3/resources/test/index.html |
— | — | @@ -8,8 +8,8 @@ |
9 | 9 | color: white; |
10 | 10 | } |
11 | 11 | </style> |
12 | | - <script type="text/javascript" src="../../load.php?modules=jquery|mw"></script> |
13 | | - <script type="text/javascript" src="../../load.php?modules=mw.util|test"></script> |
| 12 | + <script type="text/javascript" src="../../load.php?modules=jquery|mw&debug=1"></script> |
| 13 | + <script type="text/javascript" src="../../load.php?modules=mw.util|test&debug=1"></script> |
14 | 14 | <script> |
15 | 15 | mw.config.set( 'wgScriptPath', '../..' ); |
16 | 16 | </script> |
Index: branches/resourceloader/phase3/resources/Resources.php |
— | — | @@ -13,11 +13,6 @@ |
14 | 14 | 'script' => 'resources/base/mw/mw.util.js', |
15 | 15 | 'raw' => true, |
16 | 16 | ), |
17 | | - 'mw.debug' => array( |
18 | | - 'script' => 'resources/base/mw/mw.debug.js', |
19 | | - 'raw' => true, |
20 | | - 'debug' => true |
21 | | - ), |
22 | 17 | 'test' => array( |
23 | 18 | 'script' => 'resources/test/test.js', |
24 | 19 | 'loader' => 'resources/test/loader.js', |
Index: branches/resourceloader/phase3/resources/base/mw/mw.debug.js |
— | — | @@ -1,56 +0,0 @@ |
2 | | -/** |
3 | | - * Debug system |
4 | | - */ |
5 | | - |
6 | | -window.mw.debug = true; |
7 | | -/** |
8 | | -* Log a string msg to the console |
9 | | -* |
10 | | -* All mw.log statements will be removed on minification so lots of mw.log calls will not impact performance in non-debug |
11 | | -* mode. This is done using simple regular expressions, so the input of this function needs to not contain things like a |
12 | | -* self-executing closure. In the case that the browser does not have a console available, one is created by appending a |
13 | | -* <div> element to the bottom of the body and then appending a <div> element to that for each message. In the case that |
14 | | -* the browser does have a console available |
15 | | -* |
16 | | -* @author Michael Dale <mdale@wikimedia.org>, Trevor Parscal <tparscal@wikimedia.org> |
17 | | -* @param {String} string String to output to console |
18 | | -*/ |
19 | | -window.mw.log = function( string ) { |
20 | | - // Allow log messages to use a configured prefix |
21 | | - if ( mw.config.exists( 'mw.log.prefix' ) ) { |
22 | | - string = mw.config.get( 'mw.log.prefix' ) + string; |
23 | | - } |
24 | | - // Try to use an existing console |
25 | | - if ( typeof window.console !== 'undefined' && typeof window.console.log == 'function' ) { |
26 | | - window.console.log( string ); |
27 | | - } else { |
28 | | - // Show a log box for console-less browsers |
29 | | - var $log = $( '#mw_log_console' ); |
30 | | - if ( !$log.length ) { |
31 | | - $log = $( '<div id="mw_log_console"></div>' ) |
32 | | - .css( { |
33 | | - 'position': 'absolute', |
34 | | - 'overflow': 'auto', |
35 | | - 'z-index': 500, |
36 | | - 'bottom': '0px', |
37 | | - 'left': '0px', |
38 | | - 'right': '0px', |
39 | | - 'height': '150px', |
40 | | - 'background-color': 'white', |
41 | | - 'border-top': 'solid 1px #DDDDDD' |
42 | | - } ) |
43 | | - .appendTo( $( 'body' ) ); |
44 | | - } |
45 | | - if ( $log.length ) { |
46 | | - $log.append( |
47 | | - $( '<div>' + string + '</div>' ) |
48 | | - .css( { |
49 | | - 'border-bottom': 'solid 1px #DDDDDD', |
50 | | - 'font-size': 'small', |
51 | | - 'font-family': 'monospace', |
52 | | - 'padding': '0.125em 0.25em' |
53 | | - } ) |
54 | | - ); |
55 | | - } |
56 | | - } |
57 | | -}; |
\ No newline at end of file |
Index: branches/resourceloader/phase3/resources/base/mw.js |
— | — | @@ -437,7 +437,7 @@ |
438 | 438 | } |
439 | 439 | } ); |
440 | 440 | /* |
441 | | - * Read-write access to site and user configurations |
| 441 | + * Site and user configurations |
442 | 442 | */ |
443 | 443 | mw.config = new mw.prototypes.Collection(); |
444 | 444 | /* |
— | — | @@ -445,6 +445,60 @@ |
446 | 446 | */ |
447 | 447 | mw.loader = new mw.prototypes.ResourceLoader(); |
448 | 448 | /* |
449 | | - * Provides read-write access to localizations |
| 449 | + * Localization system |
450 | 450 | */ |
451 | | -mw.msg = new mw.prototypes.Language(); |
\ No newline at end of file |
| 451 | +mw.msg = new mw.prototypes.Language(); |
| 452 | +/* |
| 453 | + * Debug logging |
| 454 | + */ |
| 455 | +/** |
| 456 | +* Log a string msg to the console |
| 457 | +* |
| 458 | +* All mw.log statements will be removed on minification so lots of mw.log calls will not impact performance in non-debug |
| 459 | +* mode. This is done using simple regular expressions, so the input of this function needs to not contain things like a |
| 460 | +* self-executing closure. In the case that the browser does not have a console available, one is created by appending a |
| 461 | +* <div> element to the bottom of the body and then appending a <div> element to that for each message. In the case that |
| 462 | +* the browser does have a console available |
| 463 | +* |
| 464 | +* @author Michael Dale <mdale@wikimedia.org>, Trevor Parscal <tparscal@wikimedia.org> |
| 465 | +* @param {String} string String to output to console |
| 466 | +*/ |
| 467 | +window.mw.log = function( string ) { |
| 468 | + // Allow log messages to use a configured prefix |
| 469 | + if ( mw.config.exists( 'mw.log.prefix' ) ) { |
| 470 | + string = mw.config.get( 'mw.log.prefix' ) + string; |
| 471 | + } |
| 472 | + // Try to use an existing console |
| 473 | + if ( typeof window.console !== 'undefined' && typeof window.console.log == 'function' ) { |
| 474 | + window.console.log( string ); |
| 475 | + } else { |
| 476 | + // Show a log box for console-less browsers |
| 477 | + var $log = $( '#mw_log_console' ); |
| 478 | + if ( !$log.length ) { |
| 479 | + $log = $( '<div id="mw_log_console"></div>' ) |
| 480 | + .css( { |
| 481 | + 'position': 'absolute', |
| 482 | + 'overflow': 'auto', |
| 483 | + 'z-index': 500, |
| 484 | + 'bottom': '0px', |
| 485 | + 'left': '0px', |
| 486 | + 'right': '0px', |
| 487 | + 'height': '150px', |
| 488 | + 'background-color': 'white', |
| 489 | + 'border-top': 'solid 1px #DDDDDD' |
| 490 | + } ) |
| 491 | + .appendTo( $( 'body' ) ); |
| 492 | + } |
| 493 | + if ( $log.length ) { |
| 494 | + $log.append( |
| 495 | + $( '<div>' + string + '</div>' ) |
| 496 | + .css( { |
| 497 | + 'border-bottom': 'solid 1px #DDDDDD', |
| 498 | + 'font-size': 'small', |
| 499 | + 'font-family': 'monospace', |
| 500 | + 'padding': '0.125em 0.25em' |
| 501 | + } ) |
| 502 | + ); |
| 503 | + } |
| 504 | + } |
| 505 | +}; |
\ No newline at end of file |