mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-28 08:00:32 +00:00
Hygiene: SkinOptions should know what are AMC options
Do not hardcode special handling of Options in other places than SkinOptions. SkinOptions should be only one place that knows all interpedences. Change-Id: I9ad8c1560332665dbcd88ccc7105fb253a2f41b9
This commit is contained in:
parent
d8de612e0c
commit
05cdcc09c8
|
@ -109,4 +109,26 @@ final class SkinOptions {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user enabled any of the options bundled in the AMC mode
|
||||
*
|
||||
* @todo this shouldn't exist, each option should provide it's own logic/styles/js modules
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAnyAMCOptionEnabled() {
|
||||
$keys = [
|
||||
self::AMC_MODE,
|
||||
self::TALK_AT_TOP,
|
||||
self::HISTORY_IN_PAGE_ACTIONS,
|
||||
self::TOOLBAR_SUBMENU,
|
||||
self::TABS_ON_SPECIALS
|
||||
];
|
||||
foreach ( $keys as $key ) {
|
||||
if ( $this->skinOptions[$key] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -938,20 +938,11 @@ class SkinMinerva extends SkinTemplate {
|
|||
$styles[] = 'skins.minerva.icons.loggedin';
|
||||
}
|
||||
|
||||
$keys = [
|
||||
SkinOptions::AMC_MODE,
|
||||
SkinOptions::TALK_AT_TOP,
|
||||
SkinOptions::HISTORY_IN_PAGE_ACTIONS,
|
||||
SkinOptions::TOOLBAR_SUBMENU,
|
||||
SkinOptions::TABS_ON_SPECIALS
|
||||
];
|
||||
$includeAMCStyles = array_reduce( $keys, function ( $val, $key ) {
|
||||
return $val || $this->skinOptions->get( $key );
|
||||
}, false );
|
||||
if ( $includeAMCStyles ) {
|
||||
if ( $this->skinOptions->isAnyAMCOptionEnabled() ) {
|
||||
$styles[] = 'skins.minerva.amc.styles';
|
||||
$styles[] = 'wikimedia.ui';
|
||||
}
|
||||
|
||||
if ( $this->skinOptions->get( SkinOptions::AMC_MODE ) ) {
|
||||
// ToolbarBuilder is reusing the Contributions icon in toolbar @see T224735
|
||||
$styles[] = 'skins.minerva.mainMenu.icons';
|
||||
|
|
Loading…
Reference in a new issue