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.
// 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(
$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 ) {
/* 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
$scripts = implode( $scripts, "\n" );
}
return Xml::encodeJsCall(
- 'mediaWiki.loader.implement',
+ 'mw.loader.implement',
array(
$name,
new XmlJsCode( "function( $, mw ) {{$scripts}}" ),
* 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 ) );
}
/**
}
/**
- * 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 ):
*/
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 ) );
}
}
}
/**
- * 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 ):
$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 ) );
}
}
* @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 ) );
}
/**
$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;
}
$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() );
$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
}
public function getScript( ResourceLoaderContext $context ) {
- return Xml::encodeJsCall( 'mediaWiki.user.options.set',
+ return Xml::encodeJsCall( 'mw.user.options.set',
array( $this->contextUserOptions( $context ) ) );
}
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()
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 ) );
}
};
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 ) );
}
}
$( '#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;
* 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().
*
* 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().
*
};
/**
- * 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;
* 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="<"/></div>
* @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;
};
$( 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' ) );
} );