From 0be05950af9af9aa7a94d69eff19ff24bcc3a420 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Fri, 29 Mar 2019 14:31:09 -0700 Subject: [PATCH] Desktop should use AMC mode To help us test special pages prior to moving them on mobile it would be useful to make AMC the default on desktop where the special page override does not exist This is also probably what editors on desktop using the Minerva skin want out of the skin. On top of this, add an amc class to the body tag so we can target styles at AMC and/or non-AMC users Change-Id: I7f3141bae71181131ae4878fd21fb6ff4322c8ca --- includes/skins/SkinMinerva.php | 8 +++++++- tests/phpunit/skins/SkinMinervaTest.php | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index fc59f67..3af454b 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -95,7 +95,8 @@ class SkinMinerva extends SkinTemplate { /** @var array skin specific options */ protected $skinOptions = [ - self::OPTION_AMC => false, + // Defaults to true for desktop mode. + self::OPTION_AMC => true, self::OPTIONS_MOBILE_BETA => false, /** * Whether the main menu should include a link to @@ -1445,6 +1446,11 @@ class SkinMinerva extends SkinTemplate { */ public function addToBodyAttributes( $out, &$bodyAttrs ) { $classes = $out->getProperty( 'bodyClassName' ); + if ( $this->getSkinOption( self::OPTION_AMC ) ) { + $classes .= ' minerva--amc-enabled'; + } else { + $classes .= ' minerva--amc-disabled'; + } $bodyAttrs[ 'class' ] .= ' ' . $classes; } diff --git a/tests/phpunit/skins/SkinMinervaTest.php b/tests/phpunit/skins/SkinMinervaTest.php index 8e47a48..2267e4d 100644 --- a/tests/phpunit/skins/SkinMinervaTest.php +++ b/tests/phpunit/skins/SkinMinervaTest.php @@ -173,6 +173,9 @@ class SkinMinervaTest extends MediaWikiTestCase { $moduleName, $expected ) { $skin = new SkinMinerva(); + $skin->setSkinOptions( [ + SkinMinerva::OPTION_AMC => false, + ] ); $title = Title::newFromText( 'Test' ); $testContext = RequestContext::getMain(); $testContext->setTitle( $title );