Always load init CSS when tools are available for a title

Also, make init CSS available on mobile.

Bug: T274311
Change-Id: I8f63fdb249cdd8ccdc6d1c4944d2622ac7d668cc
This commit is contained in:
Ed Sanders 2021-03-06 12:08:50 +00:00
parent 9403fb961c
commit 6224c11ff1
2 changed files with 11 additions and 3 deletions

View file

@ -26,7 +26,11 @@
},
"ResourceModules": {
"ext.discussionTools.init.styles": {
"styles": "dt.init.less"
"styles": "dt.init.less",
"targets": [
"desktop",
"mobile"
]
},
"ext.discussionTools.init": {
"packageFiles": [

View file

@ -32,11 +32,15 @@ class PageHooks implements
*/
public function onBeforePageDisplay( $output, $skin ) : void {
$user = $output->getUser();
// Load modules if any DT feature is enabled for this user
if ( HookUtils::isFeatureEnabledForOutput( $output ) ) {
// Load style modules if the tools can be available for the title
// as this means the DOM may have been modified in the parser cache.
if ( HookUtils::isAvailableForTitle( $output->getTitle() ) ) {
$output->addModuleStyles( [
'ext.discussionTools.init.styles'
] );
}
// Load modules if any DT feature is enabled for this user
if ( HookUtils::isFeatureEnabledForOutput( $output ) ) {
$output->addModules( [
'ext.discussionTools.init'
] );