r75490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75489‎ | r75490 | r75491 >
Date:00:04, 27 October 2010
Author:tparscal
Status:resolved
Tags:
Comment:
* Cleaned up comments
* Added mediaWiki.msg back, this time as the return a string version of mediaWiki.message
* Removed use of that variable in mediaWiki.loader, getting ready to make loader a prototyped object.
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -2,7 +2,7 @@
33 * JavaScript backwards-compatibility and support
44 */
55
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
77 if ( typeof String.prototype.trim === 'undefined' ) {
88 // Add removing trailing and leading whitespace functionality cross-browser
99 // See also: http://blog.stevenlevithan.com/archives/faster-trim-javascript
@@ -15,7 +15,6 @@
1616 return this.replace( /^\s\s*/, "" );
1717 };
1818 }
19 -
2019 if ( typeof String.prototype.trimRight === 'undefined' ) {
2120 String.prototype.trimRight = function() {
2221 return this.replace(/\s\s*$/, "");
@@ -225,7 +224,8 @@
226225 * Gets a message object, similar to wfMessage()
227226 *
228227 * @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
230230 */
231231 this.message = function( key, parameters ) {
232232 // Support variadic arguments
@@ -239,13 +239,23 @@
240240 };
241241
242242 /**
 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+ /**
243254 * Client-side module loader which integrates with the MediaWiki ResourceLoader
244255 */
245256 this.loader = new ( function() {
246257
247258 /* Private Members */
248 -
249 - var that = this;
 259+
250260 /**
251261 * Mapping of registered modules
252262 *
@@ -507,7 +517,7 @@
508518 }
509519 }
510520 // Work the queue
511 - that.work();
 521+ mediaWiki.loader.work();
512522 }
513523
514524 function sortQuery(o) {
@@ -612,9 +622,9 @@
613623 if ( typeof module === 'object' ) {
614624 for ( var m = 0; m < module.length; m++ ) {
615625 if ( typeof module[m] === 'string' ) {
616 - that.register( module[m] );
 626+ mediaWiki.loader.register( module[m] );
617627 } else if ( typeof module[m] === 'object' ) {
618 - that.register.apply( that, module[m] );
 628+ mediaWiki.loader.register.apply( mediaWiki.loader, module[m] );
619629 }
620630 }
621631 return;
@@ -649,7 +659,7 @@
650660 this.implement = function( module, script, style, localization ) {
651661 // Automaically register module
652662 if ( typeof registry[module] === 'undefined' ) {
653 - that.register( module );
 663+ mediaWiki.loader.register( module );
654664 }
655665 // Validate input
656666 if ( typeof script !== 'function' ) {
@@ -775,7 +785,7 @@
776786 */
777787 this.go = function() {
778788 suspended = false;
779 - that.work();
 789+ mediaWiki.loader.work();
780790 };
781791
782792 /**
@@ -787,12 +797,12 @@
788798 this.state = function( module, state ) {
789799 if ( typeof module === 'object' ) {
790800 for ( var m in module ) {
791 - that.state( m, module[m] );
 801+ mediaWiki.loader.state( m, module[m] );
792802 }
793803 return;
794804 }
795805 if ( !( module in registry ) ) {
796 - that.register( module );
 806+ mediaWiki.loader.register( module );
797807 }
798808 registry[module].state = state;
799809 };

Status & tagging log