diff --git a/includes/SkinVector.php b/includes/SkinVector.php index 4db04502..441ec022 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -291,10 +291,6 @@ class SkinVector extends SkinMustache { $title = $out->getTitle(); $parentData = parent::getTemplateData(); - if ( $this->shouldHideLanguages() ) { - $parentData['data-portlets']['data-languages'] = null; - } - // Naming conventions for Mustache parameters. // // Value type (first segment): @@ -472,6 +468,13 @@ class SkinVector extends SkinMustache { // ext.uls.interface attaches click handler to this selector. ' mw-interlanguage-selector ', ]; + + // Adds class to hide language button + // Temporary solution to T287206, can be removed when ULS dialog includes interwiki links + if ( $this->shouldHideLanguages() ) { + $languageButtonData['class'] = ' mw-portlet-empty'; + } + return array_merge( $portletData, $languageButtonData ); } diff --git a/resources/skins.vector.js/languageButton.js b/resources/skins.vector.js/languageButton.js index 76d40f71..e9f78593 100644 --- a/resources/skins.vector.js/languageButton.js +++ b/resources/skins.vector.js/languageButton.js @@ -1,3 +1,20 @@ +/** + * Copies interwiki links to sidebar + * + * Temporary solution to T287206, can be removed when the new ULS built in Vue.js + * has been released and contains this + */ +function addInterwikiLinkToSidebar() { + // eslint-disable-next-line no-jquery/no-global-selector + var $editLink = $( '#p-lang-btn .wbc-editpage' ); + if ( $editLink.length ) { + // Use title attribute for link text + $editLink.text( $editLink.attr( 'title' ) || '' ); + var $li = $( '
  • ' ).append( $editLink ); + $li.appendTo( '#p-tb ul' ); + } +} + /** * Checks whether ULS is enabled and if so disables the default * drop down behavior of the button. @@ -13,7 +30,8 @@ function disableLanguageDropdown() { return; } if ( !pLangBtn.querySelectorAll( '.mw-interlanguage-selector' ).length ) { - // The ext.uls.interface module removed the selector, because the feature is disabled. Do nothing. + // The ext.uls.interface module removed the selector, + // because the feature is disabled. Do nothing. return; } pLangBtn.classList.add( 'vector-menu--hide-dropdown' ); @@ -35,4 +53,5 @@ function disableLanguageDropdown() { */ module.exports = function () { disableLanguageDropdown(); + addInterwikiLinkToSidebar(); }; diff --git a/resources/skins.vector.styles/components/LanguageButton.less b/resources/skins.vector.styles/components/LanguageButton.less index 5b5cf41b..6380dd17 100644 --- a/resources/skins.vector.styles/components/LanguageButton.less +++ b/resources/skins.vector.styles/components/LanguageButton.less @@ -93,3 +93,9 @@ } } } + +// Hides language button with CSS, ensures language button is in DOM for temporary JS hack for interwiki links +// Temporary solution to T287206, can be removed when ULS dialog includes interwiki links +#p-lang-btn.mw-portlet-empty { + display: none; +}