mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-11 16:59:09 +00:00
Drop wgVectorResponsive support from modern Vector
Move the body of enableResponsiveMode method into the onBeforePageDisplayMobile hook. Replace BeforePageDisplayMobile hook with BeforePageDisplay hook. Bug: T254378 Change-Id: I63da1b67bf2b85c644e4af196bf894efc4797433
This commit is contained in:
parent
13ba8ebe6a
commit
1874e40d87
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -44,3 +44,4 @@ Thumbs.db
|
|||
# storybook
|
||||
/.storybook/resolve-less-imports/
|
||||
/.storybook/integration.less
|
||||
.vscode
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Vector;
|
||||
|
||||
use ExtensionRegistry;
|
||||
use HTMLForm;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use OutputPage;
|
||||
|
@ -21,16 +22,33 @@ class Hooks {
|
|||
/**
|
||||
* BeforePageDisplayMobile hook handler
|
||||
*
|
||||
* Make Vector responsive when operating in mobile mode (useformat=mobile)
|
||||
* Make Legacy Vector responsive when $wgVectorResponsive = true
|
||||
*
|
||||
* @see https://www.mediawiki.org/wiki/Extension:MobileFrontend/BeforePageDisplayMobile
|
||||
* @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
|
||||
* @param OutputPage $out
|
||||
* @param SkinTemplate $sk
|
||||
*/
|
||||
public static function onBeforePageDisplayMobile( OutputPage $out, $sk ) {
|
||||
// This makes Vector behave in responsive mode when MobileFrontend is installed
|
||||
if ( $sk instanceof SkinVector ) {
|
||||
$sk->enableResponsiveMode();
|
||||
public static function onBeforePageDisplay( OutputPage $out, $sk ) {
|
||||
if ( !$sk instanceof SkinVector ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$skinVersionLookup = new SkinVersionLookup(
|
||||
$out->getRequest(), $sk->getUser(), self::getServiceConfig()
|
||||
);
|
||||
|
||||
$mobile = false;
|
||||
if ( ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
|
||||
|
||||
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
|
||||
$mobile = $mobFrontContext->shouldDisplayMobileView();
|
||||
}
|
||||
|
||||
if ( $skinVersionLookup->isLegacy()
|
||||
&& ( $mobile || $sk->getConfig()->get( 'VectorResponsive' ) )
|
||||
) {
|
||||
$out->addMeta( 'viewport', 'width=device-width, initial-scale=1' );
|
||||
$out->addModuleStyles( 'skins.vector.styles.responsive' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,32 +37,6 @@ class SkinVector extends SkinTemplate {
|
|||
public $stylename = 'Vector';
|
||||
public $template = 'VectorTemplate';
|
||||
|
||||
private $responsiveMode = false;
|
||||
|
||||
/**
|
||||
* Enables the responsive mode
|
||||
*/
|
||||
public function enableResponsiveMode() {
|
||||
if ( !$this->responsiveMode ) {
|
||||
$out = $this->getOutput();
|
||||
$out->addMeta( 'viewport', 'width=device-width, initial-scale=1' );
|
||||
$out->addModuleStyles( 'skins.vector.styles.responsive' );
|
||||
$this->responsiveMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes output page and sets up skin-specific parameters
|
||||
* @param OutputPage $out Object to initialize
|
||||
*/
|
||||
public function initPage( OutputPage $out ) {
|
||||
parent::initPage( $out );
|
||||
|
||||
if ( $this->getConfig()->get( 'VectorResponsive' ) ) {
|
||||
$this->enableResponsiveMode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return array
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"vector": "GlobalVarConfig::newInstance"
|
||||
},
|
||||
"Hooks": {
|
||||
"BeforePageDisplayMobile": "Vector\\Hooks::onBeforePageDisplayMobile",
|
||||
"BeforePageDisplay": "Vector\\Hooks::onBeforePageDisplay",
|
||||
"GetPreferences": "Vector\\Hooks::onGetPreferences",
|
||||
"PreferencesFormPreSave": "Vector\\Hooks::onPreferencesFormPreSave",
|
||||
"SkinTemplateNavigation": "Vector\\Hooks::onSkinTemplateNavigation",
|
||||
|
|
Loading…
Reference in a new issue