Jdlrobson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/362456 )
Change subject: Vector should operate in responsive mode when the mobile skin ...................................................................... Vector should operate in responsive mode when the mobile skin With MobileFrontend installed applying ?useskin=vector&useformat=mobile will ensure that responsive vector mode is invoked. I'm keen to do this, as it would help to have more examples of skins that are MobileFrontend aware as part of the work I am doing in T166748 Change-Id: I81edd855a5e96400d1179fb10907fcc30ea43ef7 --- A Hooks.php M SkinVector.php M skin.json 3 files changed, 45 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/Vector refs/changes/56/362456/1 diff --git a/Hooks.php b/Hooks.php new file mode 100644 index 0000000..80458a4 --- /dev/null +++ b/Hooks.php @@ -0,0 +1,29 @@ +<?php +/** + * Hooks.php + */ + +/** + * Hook handlers for Vector skin. + * + * Hook handler method names should be in the form of: + * on<HookName>() + */ + +class VectorHooks { + /** + * BeforePageDisplayMobile hook handler + * + * Make Vector responsive when operating in mobile mode (useformat=mobile) + * + * @see https://www.mediawiki.org/wiki/Extension:MobileFrontend/BeforePageDisplayMobile + * @param array &$lessVars Variables already added + */ + public static function onBeforePageDisplayMobile( OutputPage $out, $sk ) { + + // This makes Vector behave in responsive mode when MobileFrontend is installed + if ( $sk instanceof SkinVector ) { + $sk->enableResponsiveMode(); + } + } +} diff --git a/SkinVector.php b/SkinVector.php index 8af200f..6da20d4 100644 --- a/SkinVector.php +++ b/SkinVector.php @@ -40,6 +40,15 @@ } /** + * Enables the responsive mode + */ + public function enableResponsiveMode() { + $out = $this->getOutput(); + $out->addMeta( 'viewport', 'width=device-width, initial-scale=1' ); + $out->addModuleStyles( 'skins.vector.styles.responsive' ); + } + + /** * Initializes output page and sets up skin-specific parameters * @param OutputPage $out Object to initialize */ @@ -47,8 +56,7 @@ parent::initPage( $out ); if ( $this->vectorConfig->get( 'VectorResponsive' ) ) { - $out->addMeta( 'viewport', 'width=device-width, initial-scale=1' ); - $out->addModuleStyles( 'skins.vector.styles.responsive' ); + $this->enableResponsiveMode(); } $out->addModules( 'skins.vector.js' ); diff --git a/skin.json b/skin.json index 6eba1ab..3f016a7 100644 --- a/skin.json +++ b/skin.json @@ -25,9 +25,15 @@ ] }, "AutoloadClasses": { + "VectorHooks": "Hooks.php", "SkinVector": "SkinVector.php", "VectorTemplate": "VectorTemplate.php" }, + "Hooks": { + "BeforePageDisplayMobile": [ + "VectorHooks::onBeforePageDisplayMobile" + ] + }, "@note": "When modifying skins.vector.styles definition, make sure the installer still works", "ResourceModules": { "skins.vector.styles": { -- To view, visit https://gerrit.wikimedia.org/r/362456 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81edd855a5e96400d1179fb10907fcc30ea43ef7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/skins/Vector Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits