mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 06:13:54 +00:00
Merge skin option modules into a single ResourceLoader module and move enabled logic to client
It's presumed that skin options will eventually become the default or be removed from the skin. While they are not the default, it would be helpful to package them in one single module - as ResourceLoader modules are costly bloating the dependency graph in the MediaWiki startup module. In T167713 we talked about grouping our entry points by page rather than feature, which this seems consistent with. A page with special options enabled is different from a page without. Change-Id: Id948f913d4743532ba3442d2059a03c122419ff2
This commit is contained in:
parent
e2b4c024c7
commit
cbad0bd363
|
@ -120,6 +120,19 @@ class SkinMinerva extends SkinTemplate {
|
|||
return $this->skinOptions[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether any of the skin options have been set
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSkinOptions() {
|
||||
foreach ( $this->skinOptions as $key => $val ) {
|
||||
if ( $val ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize various variables and generate the template
|
||||
* @return QuickTemplate
|
||||
|
@ -1245,6 +1258,7 @@ class SkinMinerva extends SkinTemplate {
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of config variables that should be added only to this skin
|
||||
* for use in JavaScript.
|
||||
|
@ -1256,6 +1270,7 @@ class SkinMinerva extends SkinTemplate {
|
|||
$out = $this->getOutput();
|
||||
|
||||
$vars = [
|
||||
'wgMinervaFeatures' => $this->skinOptions,
|
||||
'wgMinervaDownloadNamespaces' => $this->getConfig()->get( 'MinervaDownloadNamespaces' ),
|
||||
'wgMinervaMenuData' => $this->getMenuData(),
|
||||
'wgMFDescription' => $out->getProperty( 'wgMFDescription' ),
|
||||
|
@ -1326,12 +1341,8 @@ class SkinMinerva extends SkinTemplate {
|
|||
$modules[] = 'skins.minerva.talk';
|
||||
}
|
||||
|
||||
if ( $this->hasCategoryLinks() ) {
|
||||
$modules[] = 'skins.minerva.categories';
|
||||
}
|
||||
|
||||
if ( $this->getSkinOption( self::OPTION_BACK_TO_TOP ) ) {
|
||||
$modules[] = 'skins.minerva.backtotop';
|
||||
if ( $this->hasSkinOptions() ) {
|
||||
$modules[] = 'skins.minerva.options';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
OO.mfExtend( BackToTopOverlay, View, {
|
||||
className: 'backtotop',
|
||||
template: mw.template.get( 'skins.minerva.backtotop', 'BackToTopOverlay.hogan' ),
|
||||
template: mw.template.get( 'skins.minerva.options', 'BackToTopOverlay.hogan' ),
|
||||
events: $.extend( {}, View.prototype.events, {
|
||||
click: 'onBackToTopClick'
|
||||
} ),
|
||||
|
@ -47,6 +47,6 @@
|
|||
}
|
||||
} );
|
||||
|
||||
M.define( 'skins.minerva.backtotop/BackToTopOverlay', BackToTopOverlay );
|
||||
M.define( 'skins.minerva.options/BackToTopOverlay', BackToTopOverlay );
|
||||
|
||||
}( mw.mobileFrontend, jQuery ) );
|
|
@ -1,10 +1,11 @@
|
|||
( function ( M, $ ) {
|
||||
var BackToTopOverlay = M.require( 'skins.minerva.backtotop/BackToTopOverlay' ),
|
||||
var BackToTopOverlay = M.require( 'skins.minerva.options/BackToTopOverlay' ),
|
||||
backtotop = new BackToTopOverlay(),
|
||||
features = mw.config.get( 'wgMinervaFeatures', {} ),
|
||||
browser = M.require( 'mobile.startup/Browser' ).getSingleton();
|
||||
|
||||
// check if browser user agent is iOS (T141598)
|
||||
if ( browser.isIos() ) {
|
||||
if ( browser.isIos() || !features.backToTop ) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1,9 +1,15 @@
|
|||
( function ( M, $ ) {
|
||||
|
||||
var loader = M.require( 'mobile.startup/rlModuleLoader' ),
|
||||
features = mw.config.get( 'wgMinervaFeatures', {} ),
|
||||
overlayManager = M.require( 'skins.minerva.scripts/overlayManager' ),
|
||||
user = M.require( 'mobile.startup/user' );
|
||||
|
||||
// check the categories feature has been turned on
|
||||
if ( !features.categories ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// categories overlay
|
||||
overlayManager.add( /^\/categories$/, function () {
|
||||
return loader.loadModule( 'mobile.categories.overlays', true ).then( function ( loadingOverlay ) {
|
33
skin.json
33
skin.json
|
@ -516,37 +516,26 @@
|
|||
"resources/skins.minerva.editor/init.js"
|
||||
]
|
||||
},
|
||||
"skins.minerva.backtotop": {
|
||||
"targets": [
|
||||
"mobile",
|
||||
"desktop"
|
||||
],
|
||||
"dependencies": [
|
||||
"mobile.toggle",
|
||||
"mobile.startup"
|
||||
],
|
||||
"templates": {
|
||||
"BackToTopOverlay.hogan": "resources/skins.minerva.backtotop/BackToTopOverlay.hogan"
|
||||
},
|
||||
"styles": [
|
||||
"resources/skins.minerva.backtotop/backtotop.less"
|
||||
],
|
||||
"scripts": [
|
||||
"resources/skins.minerva.backtotop/BackToTopOverlay.js",
|
||||
"resources/skins.minerva.backtotop/init.js"
|
||||
]
|
||||
},
|
||||
"skins.minerva.categories": {
|
||||
"skins.minerva.options": {
|
||||
"targets": [
|
||||
"mobile",
|
||||
"desktop"
|
||||
],
|
||||
"dependencies": [
|
||||
"skins.minerva.scripts",
|
||||
"mobile.toggle",
|
||||
"mobile.startup"
|
||||
],
|
||||
"templates": {
|
||||
"BackToTopOverlay.hogan": "resources/skins.minerva.options/BackToTopOverlay.hogan"
|
||||
},
|
||||
"styles": [
|
||||
"resources/skins.minerva.options/backtotop.less"
|
||||
],
|
||||
"scripts": [
|
||||
"resources/skins.minerva.categories/init.js"
|
||||
"resources/skins.minerva.options/BackToTopOverlay.js",
|
||||
"resources/skins.minerva.options/backtotop.js",
|
||||
"resources/skins.minerva.options/categories.js"
|
||||
]
|
||||
},
|
||||
"skins.minerva.talk": {
|
||||
|
|
|
@ -39,6 +39,7 @@ class EchoNotifUser {
|
|||
* @group MinervaNeue
|
||||
*/
|
||||
class SkinMinervaTest extends MediaWikiTestCase {
|
||||
const OPTIONS_MODULE = 'skins.minerva.options';
|
||||
|
||||
/**
|
||||
* @covers ::addToBodyAttributes
|
||||
|
@ -190,8 +191,8 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
|||
|
||||
public function provideGetContextSpecificModules() {
|
||||
return [
|
||||
[ true, 'skins.minerva.backtotop', true ],
|
||||
[ false, 'skins.minerva.backtotop', false ],
|
||||
[ true, self::OPTIONS_MODULE, true ],
|
||||
[ false, self::OPTIONS_MODULE, false ],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue