Merge "[refactor] Clean up responsive handling"

This commit is contained in:
jenkins-bot 2021-08-25 16:17:20 +00:00 committed by Gerrit Code Review
commit 92e034fbe7
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",