Remove ResourceLoaderRegisterModules hook handler

We should endeavour to define Resource Loader modules in one place,
extension.json. Adding them to the output, however...

Changes:
* Remove ResourceLoaderRegisterModules hook handler.
* Move all dependencies, messages, templates, and styles into "empty" RL
  module definitions in extension.json so that they don't have to be
  looked up later.

Change-Id: I7ec963e3296de8f411e90079ab13b97c6eba4916
This commit is contained in:
Sam Smith 2016-11-08 07:57:30 +00:00 committed by jhobs
parent 046d12f51b
commit 3bf0f8ab8b
2 changed files with 30 additions and 128 deletions

View file

@ -52,79 +52,6 @@ class PopupsHooks {
return $config; return $config;
} }
/**
* @param ResourceLoader $rl
* @return bool
*/
public static function onResourceLoaderRegisterModules( ResourceLoader $rl ) {
$moduleDependencies = array(
'mediawiki.jqueryMsg',
'mediawiki.ui.button',
'mediawiki.ui.icon',
'moment',
'jquery.hidpi',
'ext.popups.targets.desktopTarget',
'ext.popups.images',
);
// Create a schema module and add it as a dependency of `ext.popups.desktop`.
$schemaPopups = [
'remoteExtPath' => 'Popups',
'localBasePath' => __DIR__,
'targets' => [ 'desktop' ],
];
if ( class_exists( 'EventLogging' ) ) {
$schemaPopups += [
'dependencies' => [
'schema.Popups',
'ext.popups.schemaPopups.utils',
],
'scripts' => [
'resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js',
]
];
}
$rl->register('ext.popups.schemaPopups', $schemaPopups );
$moduleDependencies[] = 'ext.popups.schemaPopups';
$rl->register( "ext.popups.desktop", array(
'scripts' => array(
'resources/ext.popups.desktop/ext.popups.renderer.article.js',
'resources/ext.popups.desktop/ext.popups.settings.js',
),
'templates' => array(
'popup.mustache' => 'resources/ext.popups.desktop/popup.mustache',
'settings.mustache' => 'resources/ext.popups.desktop/settings.mustache',
),
'styles' => array(
'resources/ext.popups.desktop/ext.popups.animation.less',
'resources/ext.popups.desktop/ext.popups.settings.less',
),
'dependencies' => $moduleDependencies,
'messages' => array(
'popups-last-edited',
"popups-settings-title",
"popups-settings-description",
"popups-settings-option-simple",
"popups-settings-option-simple-description",
"popups-settings-option-advanced",
"popups-settings-option-advanced-description",
"popups-settings-option-off",
"popups-settings-save",
"popups-settings-cancel",
"popups-settings-enable",
"popups-settings-help",
"popups-settings-help-ok",
"popups-send-feedback",
),
'remoteExtPath' => 'Popups',
'localBasePath' => __DIR__,
) );
return true;
}
public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin) { public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin) {
// Enable only if the user has turned it on in Beta Preferences, or BetaFeatures is not installed. // Enable only if the user has turned it on in Beta Preferences, or BetaFeatures is not installed.
// Will only be loaded if PageImages & TextExtracts extensions are installed. // Will only be loaded if PageImages & TextExtracts extensions are installed.
@ -156,7 +83,7 @@ class PopupsHooks {
} }
} }
$out->addModules( array( 'ext.popups.desktop' ) ); $out->addModules( array( 'ext.popups' ) );
return true; return true;
} }

View file

@ -24,9 +24,6 @@
"ResourceLoaderTestModules": [ "ResourceLoaderTestModules": [
"PopupsHooks::onResourceLoaderTestModules" "PopupsHooks::onResourceLoaderTestModules"
], ],
"ResourceLoaderRegisterModules": [
"PopupsHooks::onResourceLoaderRegisterModules"
],
"ResourceLoaderGetConfigVars": [ "ResourceLoaderGetConfigVars": [
"PopupsHooks::onResourceLoaderGetConfigVars" "PopupsHooks::onResourceLoaderGetConfigVars"
], ],
@ -52,38 +49,6 @@
"PopupsExperiment": false "PopupsExperiment": false
}, },
"ResourceModules": { "ResourceModules": {
"ext.popups.core": {
"scripts": [
"resources/ext.popups.core/ext.popups.core.js"
],
"dependencies": [
"mediawiki.api",
"mediawiki.Title",
"mediawiki.Uri",
"mediawiki.RegExp",
"mediawiki.storage",
"mediawiki.user",
"mediawiki.experiments"
],
"targets": [
"desktop"
],
"styles": [
"resources/ext.popups.core/ext.popups.core.less"
]
},
"ext.popups.targets.desktopTarget": {
"scripts": [
"resources/ext.popups.targets.desktopTarget/desktopTarget.js"
],
"dependencies": [
"mediawiki.storage",
"jquery.client",
"ext.popups.core",
"ext.popups.renderer.desktopRenderer"
],
"targets": [ "desktop" ]
},
"ext.popups.images": { "ext.popups.images": {
"selector": ".mw-ui-icon-{name}:before", "selector": ".mw-ui-icon-{name}:before",
"class": "ResourceLoaderImageModule", "class": "ResourceLoaderImageModule",
@ -92,27 +57,37 @@
"popups-close": "resources/ext.popups.images/close.svg" "popups-close": "resources/ext.popups.images/close.svg"
} }
}, },
"ext.popups.renderer.desktopRenderer": { "ext.popups": {
"scripts": [ "templates": {
"resources/ext.popups.renderer.desktopRenderer/desktopRenderer.js" "popup.mustache": "resources/ext.popups.desktop/popup.mustache",
"settings.mustache": "resources/ext.popups.desktop/settings.mustache"
},
"styles": [
"resources/ext.popups.desktop/ext.popups.animation.less",
"resources/ext.popups.desktop/ext.popups.settings.less"
],
"messages": [
"popups-last-edited",
"popups-settings-title",
"popups-settings-description",
"popups-settings-option-simple",
"popups-settings-option-simple-description",
"popups-settings-option-advanced",
"popups-settings-option-advanced-description",
"popups-settings-option-off",
"popups-settings-save",
"popups-settings-cancel",
"popups-settings-enable",
"popups-settings-help",
"popups-settings-help-ok",
"popups-send-feedback"
], ],
"dependencies": [ "dependencies": [
"ext.popups.core" "mediawiki.jqueryMsg",
] "mediawiki.ui.button",
}, "mediawiki.ui.icon",
"ext.popups.schemaPopups.utils": { "moment",
"scripts": [ "jquery.hidpi"
"resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js"
],
"dependencies": [
"mediawiki.experiments",
"mediawiki.Title",
"mediawiki.user",
"ext.popups.core",
"ext.popups.renderer.desktopRenderer"
],
"targets": [
"desktop"
] ]
} }
}, },