Add 'collapsible-headings-collapsed' body class

Used by MobileFrontend in I78cfb22fbe7d to prevent sections from
auto-expanding.

Bug: T321618
Bug: T322628
Change-Id: I6dafd5b9cb170bfa57f185849db6450162173399
This commit is contained in:
Ed Sanders 2022-12-07 16:51:22 +00:00
parent 529e83fce6
commit c2dc05b085

View file

@ -60,6 +60,14 @@ class PageHooks implements
$this->userOptionsLookup = $userOptionsLookup;
}
private function isMobile(): bool {
if ( ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
return $mobFrontContext->shouldDisplayMobileView();
}
return false;
}
/**
* Adds DiscussionTools JS to the output.
*
@ -79,6 +87,10 @@ class PageHooks implements
}
}
if ( $this->isMobile() && HookUtils::isFeatureEnabledForOutput( $output, HookUtils::VISUALENHANCEMENTS ) ) {
$output->addBodyClasses( 'collapsible-headings-collapsed' );
}
// Load style modules if the tools can be available for the title
// to selectively hide DT features, depending on the body classes added above.
$availableForTitle = HookUtils::isAvailableForTitle( $output->getTitle() );
@ -240,11 +252,7 @@ class PageHooks implements
// This hook can be executed more than once per page view if the page content is composed from
// multiple sources!
$isMobile = false;
if ( ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
$isMobile = $mobFrontContext->shouldDisplayMobileView();
}
$isMobile = $this->isMobile();
$lang = $output->getLanguage();
if ( HookUtils::isFeatureEnabledForOutput( $output, HookUtils::TOPICSUBSCRIPTION ) ) {