Using the mw alias for mediaWiki in core. Saves bandwidth and makes sense (there...
authorKrinkle <krinkle@users.mediawiki.org>
Sat, 19 Feb 2011 22:59:44 +0000 (22:59 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sat, 19 Feb 2011 22:59:44 +0000 (22:59 +0000)
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.

includes/OutputPage.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/resourceloader/ResourceLoaderUserOptionsModule.php
resources/jquery/jquery.localize.js
resources/mediawiki.action/mediawiki.action.watch.ajax.js
resources/mediawiki.special/mediawiki.special.upload.js
resources/mediawiki/mediawiki.js
resources/mediawiki/mediawiki.log.js
skins/common/metadata.js

index ad82b5a..a2fe7d3 100644 (file)
@@ -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(
index a88ad59..354d7f3 100644 (file)
@@ -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 ) );
        }
        
        /**
index 2837913..a536a8b 100644 (file)
@@ -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;
                        }
index 87c788f..87b0cb5 100644 (file)
@@ -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
index 2dee44d..310101b 100644 (file)
@@ -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 ) ) );
        }
 
index b913f33..27d6584 100644 (file)
@@ -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()
index 7994cfc..1fbbe4a 100644 (file)
@@ -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 ) );
                        }
                }
 
index dcaa727..bfb65a0 100644 (file)
@@ -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;
index 6fed126..4da1a81 100644 (file)
@@ -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 <div><img src="&lt;"/></div>
index d314830..d38d4a7 100644 (file)
@@ -15,7 +15,7 @@
         * @author Trevor Parscal <tparscal@wikimedia.org>
         * @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;
index 8fafc95..7123c5f 100644 (file)
@@ -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' ) );
 } );