Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * JavaScript backwards-compatibility and support |
4 | 4 | */ |
5 | 5 | |
6 | | -// New fallback String trimming functionality, was introduced natively in JavaScript 1.8.1 |
| 6 | +// Implementation of string trimming functionality introduced natively in JavaScript 1.8.1 |
7 | 7 | if ( typeof String.prototype.trim === 'undefined' ) { |
8 | 8 | // Add removing trailing and leading whitespace functionality cross-browser |
9 | 9 | // See also: http://blog.stevenlevithan.com/archives/faster-trim-javascript |
— | — | @@ -15,7 +15,6 @@ |
16 | 16 | return this.replace( /^\s\s*/, "" ); |
17 | 17 | }; |
18 | 18 | } |
19 | | - |
20 | 19 | if ( typeof String.prototype.trimRight === 'undefined' ) { |
21 | 20 | String.prototype.trimRight = function() { |
22 | 21 | return this.replace(/\s\s*$/, ""); |
— | — | @@ -225,7 +224,8 @@ |
226 | 225 | * Gets a message object, similar to wfMessage() |
227 | 226 | * |
228 | 227 | * @param {string} key Key of message to get |
229 | | - * @param {mixed} params First argument in a list of variadic arguments, each a parameter for $ replacement |
| 228 | + * @param {mixed} params First argument in a list of variadic arguments, each a parameter for $ |
| 229 | + * replacement |
230 | 230 | */ |
231 | 231 | this.message = function( key, parameters ) { |
232 | 232 | // Support variadic arguments |
— | — | @@ -239,13 +239,23 @@ |
240 | 240 | }; |
241 | 241 | |
242 | 242 | /** |
| 243 | + * Gets a message string, similar to wfMsg() |
| 244 | + * |
| 245 | + * @param {string} key Key of message to get |
| 246 | + * @param {mixed} params First argument in a list of variadic arguments, each a parameter for $ |
| 247 | + * replacement |
| 248 | + */ |
| 249 | + this.msg = function( key, parameters ) { |
| 250 | + return mediaWiki.message.apply( mediaWiki.message, arguments ); |
| 251 | + }; |
| 252 | + |
| 253 | + /** |
243 | 254 | * Client-side module loader which integrates with the MediaWiki ResourceLoader |
244 | 255 | */ |
245 | 256 | this.loader = new ( function() { |
246 | 257 | |
247 | 258 | /* Private Members */ |
248 | | - |
249 | | - var that = this; |
| 259 | + |
250 | 260 | /** |
251 | 261 | * Mapping of registered modules |
252 | 262 | * |
— | — | @@ -507,7 +517,7 @@ |
508 | 518 | } |
509 | 519 | } |
510 | 520 | // Work the queue |
511 | | - that.work(); |
| 521 | + mediaWiki.loader.work(); |
512 | 522 | } |
513 | 523 | |
514 | 524 | function sortQuery(o) { |
— | — | @@ -612,9 +622,9 @@ |
613 | 623 | if ( typeof module === 'object' ) { |
614 | 624 | for ( var m = 0; m < module.length; m++ ) { |
615 | 625 | if ( typeof module[m] === 'string' ) { |
616 | | - that.register( module[m] ); |
| 626 | + mediaWiki.loader.register( module[m] ); |
617 | 627 | } else if ( typeof module[m] === 'object' ) { |
618 | | - that.register.apply( that, module[m] ); |
| 628 | + mediaWiki.loader.register.apply( mediaWiki.loader, module[m] ); |
619 | 629 | } |
620 | 630 | } |
621 | 631 | return; |
— | — | @@ -649,7 +659,7 @@ |
650 | 660 | this.implement = function( module, script, style, localization ) { |
651 | 661 | // Automaically register module |
652 | 662 | if ( typeof registry[module] === 'undefined' ) { |
653 | | - that.register( module ); |
| 663 | + mediaWiki.loader.register( module ); |
654 | 664 | } |
655 | 665 | // Validate input |
656 | 666 | if ( typeof script !== 'function' ) { |
— | — | @@ -775,7 +785,7 @@ |
776 | 786 | */ |
777 | 787 | this.go = function() { |
778 | 788 | suspended = false; |
779 | | - that.work(); |
| 789 | + mediaWiki.loader.work(); |
780 | 790 | }; |
781 | 791 | |
782 | 792 | /** |
— | — | @@ -787,12 +797,12 @@ |
788 | 798 | this.state = function( module, state ) { |
789 | 799 | if ( typeof module === 'object' ) { |
790 | 800 | for ( var m in module ) { |
791 | | - that.state( m, module[m] ); |
| 801 | + mediaWiki.loader.state( m, module[m] ); |
792 | 802 | } |
793 | 803 | return; |
794 | 804 | } |
795 | 805 | if ( !( module in registry ) ) { |
796 | | - that.register( module ); |
| 806 | + mediaWiki.loader.register( module ); |
797 | 807 | } |
798 | 808 | registry[module].state = state; |
799 | 809 | }; |