http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72259
Revision: 72259
Author: tparscal
Date: 2010-09-03 03:56:16 +0000 (Fri, 03 Sep 2010)
Log Message:
-----------
Removed the notion of "pre-loaded" modules, in favor of once again updating the
client's module registry for script loaded as only=scripts. Special casing is
used for the startup module.
Modified Paths:
--------------
branches/resourceloader/phase3/includes/ResourceLoader.php
branches/resourceloader/phase3/resources/Resources.php
branches/resourceloader/phase3/resources/mediawiki/mediawiki.js
Modified: branches/resourceloader/phase3/includes/ResourceLoader.php
===================================================================
--- branches/resourceloader/phase3/includes/ResourceLoader.php 2010-09-03
03:02:23 UTC (rev 72258)
+++ branches/resourceloader/phase3/includes/ResourceLoader.php 2010-09-03
03:56:16 UTC (rev 72259)
@@ -68,8 +68,6 @@
// @var array list of module name/ResourceLoaderModule object pairs
protected static $modules = array();
- // @var array list of modules which should not be registered, as they
are already registered in mediawiki.js
- protected static $preRegisteredModules = array( 'jquery', 'mediawiki' );
/* Protected Static Methods */
@@ -185,24 +183,20 @@
$scripts = '';
$registrations = array();
foreach ( self::$modules as $name => $module ) {
- if ( in_array( $name, self::$preRegisteredModules ) ) {
- $registrations[] = array( $name,
$module->getModifiedTime( $lang, $skin, $debug ), array(), 'ready' );
- } else {
- // Support module loader scripts
- if ( ( $loader = $module->getLoaderScript() )
!== false ) {
- $scripts .= $loader;
+ // Support module loader scripts
+ if ( ( $loader = $module->getLoaderScript() ) !== false
) {
+ $scripts .= $loader;
+ }
+ // Automatically register module
+ else {
+ // Modules without dependencies pass one
argument (name) to mediaWiki.loader.register()
+ if ( !count( $module->getDependencies() ) ) {
+ $registrations[] = array( $name,
$module->getModifiedTime( $lang, $skin, $debug ) );
}
- // Automatically register module
+ // Modules with dependencies pass two arguments
(name, dependencies) to mediaWiki.loader.register()
else {
- // Modules without dependencies pass
one argument (name) to mediaWiki.loader.register()
- if ( !count( $module->getDependencies()
) ) {
- $registrations[] = array(
$name, $module->getModifiedTime( $lang, $skin, $debug ) );
- }
- // Modules with dependencies pass two
arguments (name, dependencies) to mediaWiki.loader.register()
- else {
- $registrations[] = array(
$name, $module->getModifiedTime( $lang, $skin, $debug ),
-
$module->getDependencies() );
- }
+ $registrations[] = array( $name,
$module->getModifiedTime( $lang, $skin, $debug ),
+ $module->getDependencies() );
}
}
}
@@ -383,13 +377,21 @@
echo "mediaWiki.loader.implement( '{$name}',
function() {{$scripts}},\n'{$styles}',\n{$messages} );\n";
}
}
-
+ // Update the status of script-only modules
+ if ( $parameters['only'] === 'scripts' && !in_array( 'startup',
$modules ) ) {
+ $statuses = array();
+ foreach ( $modules as $name ) {
+ $statuses[$name] = 'ready';
+ }
+ $statuses = FormatJson::encode( $statuses );
+ echo "mediaWiki.loader.state( {$statuses} );";
+ }
// Register missing modules
foreach ( $missing as $name ) {
echo "mediaWiki.loader.register( '{$name}', null,
'missing' );\n";
}
- if ( $parameters['only'] == 'styles' ) {
+ if ( $parameters['only'] === 'styles' ) {
header( 'Content-Type: text/css' );
} else {
header( 'Content-Type: text/javascript' );
Modified: branches/resourceloader/phase3/resources/Resources.php
===================================================================
--- branches/resourceloader/phase3/resources/Resources.php 2010-09-03
03:02:23 UTC (rev 72258)
+++ branches/resourceloader/phase3/resources/Resources.php 2010-09-03
03:56:16 UTC (rev 72259)
@@ -358,7 +358,6 @@
) ),
'mediawiki.legacy.wikibits' => new ResourceLoaderFileModule( array(
'scripts' => 'skins/common/wikibits.js',
- 'dependencies' => 'mediawiki',
'messages' => array( 'showtoc', 'hidetoc' ),
) ),
) );
Modified: branches/resourceloader/phase3/resources/mediawiki/mediawiki.js
===================================================================
--- branches/resourceloader/phase3/resources/mediawiki/mediawiki.js
2010-09-03 03:02:23 UTC (rev 72258)
+++ branches/resourceloader/phase3/resources/mediawiki/mediawiki.js
2010-09-03 03:56:16 UTC (rev 72259)
@@ -483,11 +483,11 @@
this.register = function( module, version, dependencies, status
) {
// Allow multiple registration
if ( typeof module === 'object' ) {
- for ( var n = 0; n < module.length; n++ ) {
- if ( typeof module[n] === 'string' ) {
- that.register( module[n] );
- } else if ( typeof module[n] ===
'object' ) {
- that.register.apply( that,
module[n] );
+ for ( var m = 0; m < module.length; m++ ) {
+ if ( typeof module[m] === 'string' ) {
+ that.register( module[m] );
+ } else if ( typeof module[m] ===
'object' ) {
+ that.register.apply( that,
module[m] );
}
}
return;
@@ -617,12 +617,29 @@
}
};
/**
- * Flush the request queue and begin executing load requests on
demand
+ * Flushes the request queue and begin executing load requests
on demand
*/
this.go = function() {
suspended = false;
that.work();
- }
+ };
+ /**
+ * Changes the state of a module
+ *
+ * @param mixed module string module name or object of module
name/state pairs
+ * @param string state string state name
+ */
+ this.state = function( module, state ) {
+ if ( typeof module === 'object' ) {
+ for ( var m in module ) {
+ that.state( m, module[m] );
+ }
+ return;
+ }
+ if ( module in registry ) {
+ registry[module].state = state;
+ }
+ };
/* Cache document ready status */
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs