r82496 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82495‎ | r82496 | r82497 >
Date:22:59, 19 February 2011
Author:krinkle
Status:ok
Tags:
Comment:
Using the mw alias for mediaWiki in core. Saves bandwidth and makes sense (there's no point in a wrapper function for ($,mw) if we use jQuery and mediaWiki inside of it).

TODO: Since the alias is globally available from the start, the 'mw' argument in the wrapper is redundant, so that should be removed at some point as well.
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.localize.js (modified) (history)
  • /trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js (modified) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.upload.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.log.js (modified) (history)
  • /trunk/phase3/skins/common/metadata.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/metadata.js
@@ -49,5 +49,5 @@
5050 };
5151
5252 $( document ).ready( function() {
53 - attachMetadataToggle( 'mw_metadata', mediaWiki.msg( 'metadata-expand' ), mediaWiki.msg( 'metadata-collapse' ) );
 53+ attachMetadataToggle( 'mw_metadata', mw.msg( 'metadata-expand' ), mw.msg( 'metadata-collapse' ) );
5454 } );
Index: trunk/phase3/includes/OutputPage.php
@@ -2554,8 +2554,8 @@
25552555 // Modules requests - let the client calculate dependencies and batch requests as it likes
25562556 $loader = '';
25572557 if ( $this->getModules( true ) ) {
2558 - $loader = Xml::encodeJsCall( 'mediaWiki.loader.load', array( $this->getModules( true ) ) ) .
2559 - Xml::encodeJsCall( 'mediaWiki.loader.go', array() );
 2558+ $loader = Xml::encodeJsCall( 'mw.loader.load', array( $this->getModules( true ) ) ) .
 2559+ Xml::encodeJsCall( 'mw.loader.go', array() );
25602560 }
25612561
25622562 $scripts .= Html::inlineScript(
Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -492,7 +492,7 @@
493493 $out .= self::makeMessageSetScript( new XmlJsCode( $messagesBlob ) );
494494 break;
495495 default:
496 - // Minify CSS before embedding in mediaWiki.loader.implement call
 496+ // Minify CSS before embedding in mw.loader.implement call
497497 // (unless in debug mode)
498498 if ( !$context->getDebug() ) {
499499 foreach ( $styles as $media => $style ) {
@@ -544,7 +544,7 @@
545545 /* Static Methods */
546546
547547 /**
548 - * Returns JS code to call to mediaWiki.loader.implement for a module with
 548+ * Returns JS code to call to mw.loader.implement for a module with
549549 * given properties.
550550 *
551551 * @param $name Module name
@@ -560,7 +560,7 @@
561561 $scripts = implode( $scripts, "\n" );
562562 }
563563 return Xml::encodeJsCall(
564 - 'mediaWiki.loader.implement',
 564+ 'mw.loader.implement',
565565 array(
566566 $name,
567567 new XmlJsCode( "function( $, mw ) {{$scripts}}" ),
@@ -576,7 +576,7 @@
577577 * JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object.
578578 */
579579 public static function makeMessageSetScript( $messages ) {
580 - return Xml::encodeJsCall( 'mediaWiki.messages.set', array( (object)$messages ) );
 580+ return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) );
581581 }
582582
583583 /**
@@ -605,7 +605,7 @@
606606 }
607607
608608 /**
609 - * Returns a JS call to mediaWiki.loader.state, which sets the state of a
 609+ * Returns a JS call to mw.loader.state, which sets the state of a
610610 * module or modules to a given value. Has two calling conventions:
611611 *
612612 * - ResourceLoader::makeLoaderStateScript( $name, $state ):
@@ -616,9 +616,9 @@
617617 */
618618 public static function makeLoaderStateScript( $name, $state = null ) {
619619 if ( is_array( $name ) ) {
620 - return Xml::encodeJsCall( 'mediaWiki.loader.state', array( $name ) );
 620+ return Xml::encodeJsCall( 'mw.loader.state', array( $name ) );
621621 } else {
622 - return Xml::encodeJsCall( 'mediaWiki.loader.state', array( $name, $state ) );
 622+ return Xml::encodeJsCall( 'mw.loader.state', array( $name, $state ) );
623623 }
624624 }
625625
@@ -642,7 +642,7 @@
643643 }
644644
645645 /**
646 - * Returns JS code which calls mediaWiki.loader.register with the given
 646+ * Returns JS code which calls mw.loader.register with the given
647647 * parameters. Has three calling conventions:
648648 *
649649 * - ResourceLoader::makeLoaderRegisterScript( $name, $version, $dependencies, $group ):
@@ -667,10 +667,10 @@
668668 $dependencies = null, $group = null )
669669 {
670670 if ( is_array( $name ) ) {
671 - return Xml::encodeJsCall( 'mediaWiki.loader.register', array( $name ) );
 671+ return Xml::encodeJsCall( 'mw.loader.register', array( $name ) );
672672 } else {
673673 $version = (int) $version > 1 ? (int) $version : 1;
674 - return Xml::encodeJsCall( 'mediaWiki.loader.register',
 674+ return Xml::encodeJsCall( 'mw.loader.register',
675675 array( $name, $version, $dependencies, $group ) );
676676 }
677677 }
@@ -693,7 +693,7 @@
694694 * @param $configuration Array: List of configuration values keyed by variable name
695695 */
696696 public static function makeConfigSetScript( array $configuration ) {
697 - return Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) );
 697+ return Xml::encodeJsCall( 'mw.config.set', array( $configuration ) );
698698 }
699699
700700 /**
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php
@@ -67,7 +67,7 @@
6868 }
6969
7070 public function getScript( ResourceLoaderContext $context ) {
71 - return Xml::encodeJsCall( 'mediaWiki.user.options.set',
 71+ return Xml::encodeJsCall( 'mw.user.options.set',
7272 array( $this->contextUserOptions( $context ) ) );
7373 }
7474
Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -219,7 +219,7 @@
220220 $script = '';
221221 foreach ( $files as $file ) {
222222 $path = $this->getRemotePath( $file );
223 - $script .= "\n\t" . Xml::encodeJsCall( 'mediaWiki.loader.load', array( $path ) );
 223+ $script .= "\n\t" . Xml::encodeJsCall( 'mw.loader.load', array( $path ) );
224224 }
225225 return $script;
226226 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -127,18 +127,18 @@
128128 $moduleMtime = wfTimestamp( TS_UNIX, $module->getModifiedTime( $context ) );
129129 $mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
130130 // Modules without dependencies or a group pass two arguments (name, timestamp) to
131 - // mediaWiki.loader.register()
 131+ // mw.loader.register()
132132 if ( !count( $module->getDependencies() && $module->getGroup() === null ) ) {
133133 $registrations[] = array( $name, $mtime );
134134 }
135135 // Modules with dependencies but no group pass three arguments
136 - // (name, timestamp, dependencies) to mediaWiki.loader.register()
 136+ // (name, timestamp, dependencies) to mw.loader.register()
137137 else if ( $module->getGroup() === null ) {
138138 $registrations[] = array(
139139 $name, $mtime, $module->getDependencies() );
140140 }
141141 // Modules with dependencies pass four arguments (name, timestamp, dependencies, group)
142 - // to mediaWiki.loader.register()
 142+ // to mw.loader.register()
143143 else {
144144 $registrations[] = array(
145145 $name, $mtime, $module->getDependencies(), $module->getGroup() );
@@ -178,7 +178,7 @@
179179 $registrations = self::getModuleRegistrations( $context );
180180 $out .= "var startUp = function() {\n" .
181181 "\t$registrations\n" .
182 - "\t" . Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ) .
 182+ "\t" . Xml::encodeJsCall( 'mw.config.set', array( $configuration ) ) .
183183 "};\n";
184184
185185 // Conditional script injection
Index: trunk/phase3/resources/jquery/jquery.localize.js
@@ -36,8 +36,9 @@
3737 return $(this)
3838 .find( 'msg,html\\:msg' )
3939 .each( function() {
 40+ var $el = $(this);
4041 $(this)
41 - .text( mediaWiki.msg( options.prefix + $(this).attr( 'key' ) ) )
 42+ .text( mw.msg( options.prefix + $(this).attr( 'key' ) ) )
4243 .replaceWith( $(this).html() );
4344 } )
4445 .end()
Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js
@@ -11,17 +11,17 @@
1212 if ( action == 'watch' || action == 'unwatch' ) {
1313 // save the accesskey from the title
1414 var keyCommand = $link.attr( 'title' ).match( /\[.*?\]$/ ) ? $link.attr( 'title' ).match( /\[.*?\]$/ )[0] : '';
15 - $link.attr( 'title', mediaWiki.msg( 'tooltip-ca-' + action ) + ' ' + keyCommand );
 15+ $link.attr( 'title', mw.msg( 'tooltip-ca-' + action ) + ' ' + keyCommand );
1616 }
1717 if ( $link.data( 'icon' ) ) {
18 - $link.attr( 'alt', mediaWiki.msg( action ) );
 18+ $link.attr( 'alt', mw.msg( action ) );
1919 if ( action == 'watching' || action == 'unwatching' ) {
2020 $link.addClass( 'loading' );
2121 } else {
2222 $link.removeClass( 'loading' );
2323 }
2424 } else {
25 - $link.html( mediaWiki.msg( action ) );
 25+ $link.html( mw.msg( action ) );
2626 }
2727 };
2828
@@ -117,7 +117,7 @@
118118 if( $link.closest( 'li' ).attr( 'id' ) == 'ca-' + action ) {
119119 $link.closest( 'li' ).attr( 'id', 'ca-' + otheraction );
120120 // update the link text with the new message
121 - $link.text( mediaWiki.msg( otheraction ) );
 121+ $link.text( mw.msg( otheraction ) );
122122 }
123123 }
124124
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.upload.js
@@ -128,9 +128,9 @@
129129 $( '#mw-upload-thumbnail .fileinfo' ).text( info );
130130 };
131131 img.src = dataURL;
132 - }, mediaWiki.config.get( 'wgFileCanRotate' ) ? function ( data ) {
 132+ }, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) {
133133 try {
134 - meta = mediaWiki.util.jpegmeta( data, file.fileName );
 134+ meta = mw.util.jpegmeta( data, file.fileName );
135135 meta._binary_data = null;
136136 } catch ( e ) {
137137 meta = null;
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -348,7 +348,7 @@
349349 * This ID is ephemeral for everyone, staying in their browser only until they close
350350 * their browser.
351351 *
352 - * Do not use this method before the first call to mediaWiki.loader.go(), it depends on
 352+ * Do not use this method before the first call to mw.loader.go(), it depends on
353353 * jquery.cookie, which is added to the first pay-load just after mediaWiki is defined, but
354354 * won't be loaded until the first call to go().
355355 *
@@ -370,7 +370,7 @@
371371 * expiration time is reset each time the ID is queried, so in most cases this ID will
372372 * persist until the browser's cookies are cleared or the user doesn't visit for 1 year.
373373 *
374 - * Do not use this method before the first call to mediaWiki.loader.go(), it depends on
 374+ * Do not use this method before the first call to mw.loader.go(), it depends on
375375 * jquery.cookie, which is added to the first pay-load just after mediaWiki is defined, but
376376 * won't be loaded until the first call to go().
377377 *
@@ -1112,14 +1112,14 @@
11131113 };
11141114
11151115 /**
1116 - * Wrapper object for raw HTML passed to mediaWiki.html.element().
 1116+ * Wrapper object for raw HTML passed to mw.html.element().
11171117 */
11181118 this.Raw = function( value ) {
11191119 this.value = value;
11201120 };
11211121
11221122 /**
1123 - * Wrapper object for CDATA element contents passed to mediaWiki.html.element()
 1123+ * Wrapper object for CDATA element contents passed to mw.html.element()
11241124 */
11251125 this.Cdata = function( value ) {
11261126 this.value = value;
@@ -1139,7 +1139,7 @@
11401140 * See http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.3.2
11411141 *
11421142 * Example:
1143 - * var h = mediaWiki.html;
 1143+ * var h = mw.html;
11441144 * return h.element( 'div', {},
11451145 * new h.Raw( h.element( 'img', {src: '<'} ) ) );
11461146 * Returns <div><img src="&lt;"/></div>
Index: trunk/phase3/resources/mediawiki/mediawiki.log.js
@@ -15,7 +15,7 @@
1616 * @author Trevor Parscal <tparscal@wikimedia.org>
1717 * @param {string} string Message to output to console
1818 */
19 - mediaWiki.log = function( string ) {
 19+ mw.log = function( string ) {
2020 // Allow log messages to use a configured prefix
2121 if ( mw.config.exists( 'mw.log.prefix' ) ) {
2222 string = mw.config.get( 'mw.log.prefix' ) + '> ' + string;

Follow-up revisions

RevisionCommit summaryAuthorDate
r82497mw.loader.implement now calls script without setting mw to mediaWiki since th...krinkle23:52, 19 February 2011

Status & tagging log