From: Krinkle Date: Sat, 19 Feb 2011 22:59:44 +0000 (+0000) Subject: Using the mw alias for mediaWiki in core. Saves bandwidth and makes sense (there... X-Git-Tag: 1.31.0-rc.0~31869 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=b2378a694c041d8ae1ef015cb58bdaf452399604;p=lhc%2Fweb%2Fwiklou.git 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. --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index ad82b5a712..a2fe7d3b79 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2554,8 +2554,8 @@ class OutputPage { // Modules requests - let the client calculate dependencies and batch requests as it likes $loader = ''; if ( $this->getModules( true ) ) { - $loader = Xml::encodeJsCall( 'mediaWiki.loader.load', array( $this->getModules( true ) ) ) . - Xml::encodeJsCall( 'mediaWiki.loader.go', array() ); + $loader = Xml::encodeJsCall( 'mw.loader.load', array( $this->getModules( true ) ) ) . + Xml::encodeJsCall( 'mw.loader.go', array() ); } $scripts .= Html::inlineScript( diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index a88ad59a61..354d7f34ab 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -492,7 +492,7 @@ class ResourceLoader { $out .= self::makeMessageSetScript( new XmlJsCode( $messagesBlob ) ); break; default: - // Minify CSS before embedding in mediaWiki.loader.implement call + // Minify CSS before embedding in mw.loader.implement call // (unless in debug mode) if ( !$context->getDebug() ) { foreach ( $styles as $media => $style ) { @@ -544,7 +544,7 @@ class ResourceLoader { /* Static Methods */ /** - * Returns JS code to call to mediaWiki.loader.implement for a module with + * Returns JS code to call to mw.loader.implement for a module with * given properties. * * @param $name Module name @@ -560,7 +560,7 @@ class ResourceLoader { $scripts = implode( $scripts, "\n" ); } return Xml::encodeJsCall( - 'mediaWiki.loader.implement', + 'mw.loader.implement', array( $name, new XmlJsCode( "function( $, mw ) {{$scripts}}" ), @@ -576,7 +576,7 @@ class ResourceLoader { * JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object. */ public static function makeMessageSetScript( $messages ) { - return Xml::encodeJsCall( 'mediaWiki.messages.set', array( (object)$messages ) ); + return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) ); } /** @@ -605,7 +605,7 @@ class ResourceLoader { } /** - * Returns a JS call to mediaWiki.loader.state, which sets the state of a + * Returns a JS call to mw.loader.state, which sets the state of a * module or modules to a given value. Has two calling conventions: * * - ResourceLoader::makeLoaderStateScript( $name, $state ): @@ -616,9 +616,9 @@ class ResourceLoader { */ public static function makeLoaderStateScript( $name, $state = null ) { if ( is_array( $name ) ) { - return Xml::encodeJsCall( 'mediaWiki.loader.state', array( $name ) ); + return Xml::encodeJsCall( 'mw.loader.state', array( $name ) ); } else { - return Xml::encodeJsCall( 'mediaWiki.loader.state', array( $name, $state ) ); + return Xml::encodeJsCall( 'mw.loader.state', array( $name, $state ) ); } } @@ -642,7 +642,7 @@ class ResourceLoader { } /** - * Returns JS code which calls mediaWiki.loader.register with the given + * Returns JS code which calls mw.loader.register with the given * parameters. Has three calling conventions: * * - ResourceLoader::makeLoaderRegisterScript( $name, $version, $dependencies, $group ): @@ -667,10 +667,10 @@ class ResourceLoader { $dependencies = null, $group = null ) { if ( is_array( $name ) ) { - return Xml::encodeJsCall( 'mediaWiki.loader.register', array( $name ) ); + return Xml::encodeJsCall( 'mw.loader.register', array( $name ) ); } else { $version = (int) $version > 1 ? (int) $version : 1; - return Xml::encodeJsCall( 'mediaWiki.loader.register', + return Xml::encodeJsCall( 'mw.loader.register', array( $name, $version, $dependencies, $group ) ); } } @@ -693,7 +693,7 @@ class ResourceLoader { * @param $configuration Array: List of configuration values keyed by variable name */ public static function makeConfigSetScript( array $configuration ) { - return Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ); + return Xml::encodeJsCall( 'mw.config.set', array( $configuration ) ); } /** diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 2837913985..a536a8b01f 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -219,7 +219,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $script = ''; foreach ( $files as $file ) { $path = $this->getRemotePath( $file ); - $script .= "\n\t" . Xml::encodeJsCall( 'mediaWiki.loader.load', array( $path ) ); + $script .= "\n\t" . Xml::encodeJsCall( 'mw.loader.load', array( $path ) ); } return $script; } diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 87c788fd85..87b0cb5fb1 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -127,18 +127,18 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $moduleMtime = wfTimestamp( TS_UNIX, $module->getModifiedTime( $context ) ); $mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $wgCacheEpoch ) ); // Modules without dependencies or a group pass two arguments (name, timestamp) to - // mediaWiki.loader.register() + // mw.loader.register() if ( !count( $module->getDependencies() && $module->getGroup() === null ) ) { $registrations[] = array( $name, $mtime ); } // Modules with dependencies but no group pass three arguments - // (name, timestamp, dependencies) to mediaWiki.loader.register() + // (name, timestamp, dependencies) to mw.loader.register() else if ( $module->getGroup() === null ) { $registrations[] = array( $name, $mtime, $module->getDependencies() ); } // Modules with dependencies pass four arguments (name, timestamp, dependencies, group) - // to mediaWiki.loader.register() + // to mw.loader.register() else { $registrations[] = array( $name, $mtime, $module->getDependencies(), $module->getGroup() ); @@ -178,7 +178,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $registrations = self::getModuleRegistrations( $context ); $out .= "var startUp = function() {\n" . "\t$registrations\n" . - "\t" . Xml::encodeJsCall( 'mediaWiki.config.set', array( $configuration ) ) . + "\t" . Xml::encodeJsCall( 'mw.config.set', array( $configuration ) ) . "};\n"; // Conditional script injection diff --git a/includes/resourceloader/ResourceLoaderUserOptionsModule.php b/includes/resourceloader/ResourceLoaderUserOptionsModule.php index 2dee44dcf5..310101bb56 100644 --- a/includes/resourceloader/ResourceLoaderUserOptionsModule.php +++ b/includes/resourceloader/ResourceLoaderUserOptionsModule.php @@ -67,7 +67,7 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule { } public function getScript( ResourceLoaderContext $context ) { - return Xml::encodeJsCall( 'mediaWiki.user.options.set', + return Xml::encodeJsCall( 'mw.user.options.set', array( $this->contextUserOptions( $context ) ) ); } diff --git a/resources/jquery/jquery.localize.js b/resources/jquery/jquery.localize.js index b913f336e1..27d6584758 100644 --- a/resources/jquery/jquery.localize.js +++ b/resources/jquery/jquery.localize.js @@ -36,8 +36,9 @@ $.fn.localize = function( options ) { return $(this) .find( 'msg,html\\:msg' ) .each( function() { + var $el = $(this); $(this) - .text( mediaWiki.msg( options.prefix + $(this).attr( 'key' ) ) ) + .text( mw.msg( options.prefix + $(this).attr( 'key' ) ) ) .replaceWith( $(this).html() ); } ) .end() diff --git a/resources/mediawiki.action/mediawiki.action.watch.ajax.js b/resources/mediawiki.action/mediawiki.action.watch.ajax.js index 7994cfc465..1fbbe4aa27 100644 --- a/resources/mediawiki.action/mediawiki.action.watch.ajax.js +++ b/resources/mediawiki.action/mediawiki.action.watch.ajax.js @@ -11,17 +11,17 @@ wgAjaxWatch.setLinkText = function( $link, action ) { if ( action == 'watch' || action == 'unwatch' ) { // save the accesskey from the title var keyCommand = $link.attr( 'title' ).match( /\[.*?\]$/ ) ? $link.attr( 'title' ).match( /\[.*?\]$/ )[0] : ''; - $link.attr( 'title', mediaWiki.msg( 'tooltip-ca-' + action ) + ' ' + keyCommand ); + $link.attr( 'title', mw.msg( 'tooltip-ca-' + action ) + ' ' + keyCommand ); } if ( $link.data( 'icon' ) ) { - $link.attr( 'alt', mediaWiki.msg( action ) ); + $link.attr( 'alt', mw.msg( action ) ); if ( action == 'watching' || action == 'unwatching' ) { $link.addClass( 'loading' ); } else { $link.removeClass( 'loading' ); } } else { - $link.html( mediaWiki.msg( action ) ); + $link.html( mw.msg( action ) ); } }; @@ -117,7 +117,7 @@ $( document ).ready( function() { if( $link.closest( 'li' ).attr( 'id' ) == 'ca-' + action ) { $link.closest( 'li' ).attr( 'id', 'ca-' + otheraction ); // update the link text with the new message - $link.text( mediaWiki.msg( otheraction ) ); + $link.text( mw.msg( otheraction ) ); } } diff --git a/resources/mediawiki.special/mediawiki.special.upload.js b/resources/mediawiki.special/mediawiki.special.upload.js index dcaa727257..bfb65a081a 100644 --- a/resources/mediawiki.special/mediawiki.special.upload.js +++ b/resources/mediawiki.special/mediawiki.special.upload.js @@ -128,9 +128,9 @@ jQuery( function( $ ) { $( '#mw-upload-thumbnail .fileinfo' ).text( info ); }; img.src = dataURL; - }, mediaWiki.config.get( 'wgFileCanRotate' ) ? function ( data ) { + }, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) { try { - meta = mediaWiki.util.jpegmeta( data, file.fileName ); + meta = mw.util.jpegmeta( data, file.fileName ); meta._binary_data = null; } catch ( e ) { meta = null; diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js index 6fed126d56..4da1a81dd3 100644 --- a/resources/mediawiki/mediawiki.js +++ b/resources/mediawiki/mediawiki.js @@ -348,7 +348,7 @@ window.mediaWiki = new ( function( $ ) { * This ID is ephemeral for everyone, staying in their browser only until they close * their browser. * - * Do not use this method before the first call to mediaWiki.loader.go(), it depends on + * Do not use this method before the first call to mw.loader.go(), it depends on * jquery.cookie, which is added to the first pay-load just after mediaWiki is defined, but * won't be loaded until the first call to go(). * @@ -370,7 +370,7 @@ window.mediaWiki = new ( function( $ ) { * expiration time is reset each time the ID is queried, so in most cases this ID will * persist until the browser's cookies are cleared or the user doesn't visit for 1 year. * - * Do not use this method before the first call to mediaWiki.loader.go(), it depends on + * Do not use this method before the first call to mw.loader.go(), it depends on * jquery.cookie, which is added to the first pay-load just after mediaWiki is defined, but * won't be loaded until the first call to go(). * @@ -1112,14 +1112,14 @@ window.mediaWiki = new ( function( $ ) { }; /** - * Wrapper object for raw HTML passed to mediaWiki.html.element(). + * Wrapper object for raw HTML passed to mw.html.element(). */ this.Raw = function( value ) { this.value = value; }; /** - * Wrapper object for CDATA element contents passed to mediaWiki.html.element() + * Wrapper object for CDATA element contents passed to mw.html.element() */ this.Cdata = function( value ) { this.value = value; @@ -1139,7 +1139,7 @@ window.mediaWiki = new ( function( $ ) { * See http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.3.2 * * Example: - * var h = mediaWiki.html; + * var h = mw.html; * return h.element( 'div', {}, * new h.Raw( h.element( 'img', {src: '<'} ) ) ); * Returns
diff --git a/resources/mediawiki/mediawiki.log.js b/resources/mediawiki/mediawiki.log.js index d314830c40..d38d4a74ba 100644 --- a/resources/mediawiki/mediawiki.log.js +++ b/resources/mediawiki/mediawiki.log.js @@ -15,7 +15,7 @@ * @author Trevor Parscal * @param {string} string Message to output to console */ - mediaWiki.log = function( string ) { + mw.log = function( string ) { // Allow log messages to use a configured prefix if ( mw.config.exists( 'mw.log.prefix' ) ) { string = mw.config.get( 'mw.log.prefix' ) + '> ' + string; diff --git a/skins/common/metadata.js b/skins/common/metadata.js index 8fafc95581..7123c5f895 100644 --- a/skins/common/metadata.js +++ b/skins/common/metadata.js @@ -49,5 +49,5 @@ window.attachMetadataToggle = function( tableId, showText, hideText ) { }; $( document ).ready( function() { - attachMetadataToggle( 'mw_metadata', mediaWiki.msg( 'metadata-expand' ), mediaWiki.msg( 'metadata-collapse' ) ); + attachMetadataToggle( 'mw_metadata', mw.msg( 'metadata-expand' ), mw.msg( 'metadata-collapse' ) ); } );