mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-11 05:46:09 +00:00
Merge "Remove onBeforePageDisplay for Minerva"
This commit is contained in:
commit
395f4617fc
|
@ -26,7 +26,6 @@ use Config;
|
||||||
use ExtensionRegistry;
|
use ExtensionRegistry;
|
||||||
use Hooks as MWHooks;
|
use Hooks as MWHooks;
|
||||||
use Html;
|
use Html;
|
||||||
use MediaWiki\Hook\BeforePageDisplayHook;
|
|
||||||
use MediaWiki\Hook\FetchChangesListHook;
|
use MediaWiki\Hook\FetchChangesListHook;
|
||||||
use MediaWiki\Hook\OutputPageBodyAttributesHook;
|
use MediaWiki\Hook\OutputPageBodyAttributesHook;
|
||||||
use MediaWiki\Hook\UserLogoutCompleteHook;
|
use MediaWiki\Hook\UserLogoutCompleteHook;
|
||||||
|
@ -58,7 +57,6 @@ use Wikimedia\Services\NoSuchServiceException;
|
||||||
* on<HookName>()
|
* on<HookName>()
|
||||||
*/
|
*/
|
||||||
class Hooks implements
|
class Hooks implements
|
||||||
BeforePageDisplayHook,
|
|
||||||
FetchChangesListHook,
|
FetchChangesListHook,
|
||||||
OutputPageBodyAttributesHook,
|
OutputPageBodyAttributesHook,
|
||||||
ResourceLoaderGetConfigVarsHook,
|
ResourceLoaderGetConfigVarsHook,
|
||||||
|
@ -401,53 +399,6 @@ class Hooks implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The Minerva skin loads message box styles differently from core, to
|
|
||||||
* reduce the amount of styles on the critical path.
|
|
||||||
* This adds message box styles to pages that need it, to avoid loading them
|
|
||||||
* on pages where they are not.
|
|
||||||
*
|
|
||||||
* @param OutputPage $out
|
|
||||||
* @param Skin $skin
|
|
||||||
*/
|
|
||||||
public function onBeforePageDisplay( $out, $skin ): void {
|
|
||||||
if ( $skin->getSkinName() === 'minerva' ) {
|
|
||||||
self::addMessageBoxStylesToPage( $out );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Minerva skin loads message box styles differently from core, to
|
|
||||||
* reduce the amount of styles on the critical path.
|
|
||||||
* This adds message box styles to pages that need it, to avoid loading them
|
|
||||||
* on pages where they are not.
|
|
||||||
* The pages where they are needed are:
|
|
||||||
* - special pages
|
|
||||||
* - edit workflow (action=edit and action=submit)
|
|
||||||
* - when viewing old revisions
|
|
||||||
* - non-main namespaces for anon talk page messages
|
|
||||||
*
|
|
||||||
* @param OutputPage $out
|
|
||||||
*/
|
|
||||||
private static function addMessageBoxStylesToPage( OutputPage $out ) {
|
|
||||||
$request = $out->getRequest();
|
|
||||||
$title = $out->getTitle();
|
|
||||||
// Warning box styles are needed when reviewing old revisions
|
|
||||||
// and inside the fallback editor styles to action=edit page.
|
|
||||||
$requestAction = $request->getVal( 'action' );
|
|
||||||
$viewAction = $requestAction === null || $requestAction === 'view';
|
|
||||||
|
|
||||||
if (
|
|
||||||
$title->getNamespace() !== NS_MAIN ||
|
|
||||||
$request->getText( 'oldid' ) ||
|
|
||||||
!$viewAction
|
|
||||||
) {
|
|
||||||
$out->addModuleStyles( [
|
|
||||||
'skins.minerva.messageBox.styles'
|
|
||||||
] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies the `<body>` element's attributes.
|
* Modifies the `<body>` element's attributes.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1026,6 +1026,9 @@ class SkinMinerva extends SkinMustache {
|
||||||
protected function getSkinStyles(): array {
|
protected function getSkinStyles(): array {
|
||||||
$title = $this->getTitle();
|
$title = $this->getTitle();
|
||||||
$skinOptions = $this->getSkinOptions();
|
$skinOptions = $this->getSkinOptions();
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$requestAction = $request->getVal( 'action' );
|
||||||
|
$viewAction = $requestAction === null || $requestAction === 'view';
|
||||||
$styles = [
|
$styles = [
|
||||||
'skins.minerva.base.styles',
|
'skins.minerva.base.styles',
|
||||||
'skins.minerva.content.styles.images',
|
'skins.minerva.content.styles.images',
|
||||||
|
@ -1036,6 +1039,17 @@ class SkinMinerva extends SkinMustache {
|
||||||
'skins.minerva.mainMenu.icons',
|
'skins.minerva.mainMenu.icons',
|
||||||
'skins.minerva.mainMenu.styles',
|
'skins.minerva.mainMenu.styles',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Warning box styles are needed when reviewing old revisions
|
||||||
|
// and inside the fallback editor styles to action=edit page.
|
||||||
|
if (
|
||||||
|
$title->getNamespace() !== NS_MAIN ||
|
||||||
|
$request->getText( 'oldid' ) ||
|
||||||
|
!$viewAction
|
||||||
|
) {
|
||||||
|
$styles[] = 'skins.minerva.messageBox.styles';
|
||||||
|
}
|
||||||
|
|
||||||
if ( $title->isMainPage() ) {
|
if ( $title->isMainPage() ) {
|
||||||
$styles[] = 'skins.minerva.mainPage.styles';
|
$styles[] = 'skins.minerva.mainPage.styles';
|
||||||
} elseif ( $this->getUserPageHelper()->isUserPage() ) {
|
} elseif ( $this->getUserPageHelper()->isUserPage() ) {
|
||||||
|
|
|
@ -136,7 +136,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Hooks": {
|
"Hooks": {
|
||||||
"BeforePageDisplay": "main",
|
|
||||||
"ResourceLoaderRegisterModules": "main",
|
"ResourceLoaderRegisterModules": "main",
|
||||||
"SkinPageReadyConfig": "main",
|
"SkinPageReadyConfig": "main",
|
||||||
"UserLogoutComplete": "main",
|
"UserLogoutComplete": "main",
|
||||||
|
|
Loading…
Reference in a new issue