[refactor] Clean up responsive handling

There is no need for this to be in the constructor. Separate into
its own function that inherits from parent class and existing parent
method isResponsive.

Change-Id: I60d155ec9db99ccfe0b74271dee76275a8a6986c
This commit is contained in:
jdlrobson 2021-08-13 11:21:52 -07:00 committed by Jdlrobson
parent d6778948da
commit 391d9ba509
2 changed files with 19 additions and 12 deletions

View File

@ -87,18 +87,6 @@ class SkinVector extends SkinMustache {
$options['styles'] = [ 'skins.vector.styles.legacy' ];
$options['template'] = 'skin-legacy';
} else {
// For historic reasons, the viewport is added when Vector is loaded on the mobile
// domain. This is only possible for 3rd parties or by useskin parameter as there is
// no preference for changing mobile skin.
$responsive = $this->getConfig()->get( 'VectorResponsive' );
if ( ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
if ( $mobFrontContext->shouldDisplayMobileView() ) {
$responsive = true;
}
}
$options['responsive'] = $responsive;
if ( $this->shouldConsolidateUserLinks() ) {
$options['link'] = [ 'text-wrapper' => [ 'tag' => 'span' ] ];
}
@ -435,6 +423,24 @@ class SkinVector extends SkinMustache {
return Constants::SEARCH_BOX_INPUT_LOCATION_MOVED;
}
/**
* @inheritDoc
*/
public function isResponsive() {
// Check it's enabled by user preference and configuration
$responsive = parent::isResponsive() && $this->getConfig()->get( 'VectorResponsive' );
// For historic reasons, the viewport is added when Vector is loaded on the mobile
// domain. This is only possible for 3rd parties or by useskin parameter as there is
// no preference for changing mobile skin. Only need to check if $responsive is falsey.
if ( !$responsive && ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
if ( $mobFrontContext->shouldDisplayMobileView() ) {
return true;
}
}
return $responsive;
}
/**
* Determines whether or not the search input should expand when focused
* before WVUI search is loaded. In WVUI, the search input expands to

View File

@ -24,6 +24,7 @@
"scripts": [
"skins.vector.js"
],
"responsive": true,
"styles": [
"mediawiki.ui.button",
"skins.vector.styles",