2021-03-01 21:32:25 +00:00
|
|
|
/**
|
|
|
|
* Checks whether ULS is enabled and if so disables the default
|
|
|
|
* drop down behavior of the button.
|
|
|
|
*/
|
|
|
|
function disableLanguageDropdown() {
|
|
|
|
var ulsModuleStatus = mw.loader.getState( 'ext.uls.interface' ),
|
|
|
|
pLangBtnLabel;
|
|
|
|
|
|
|
|
if ( ulsModuleStatus && ulsModuleStatus !== 'registered' ) {
|
|
|
|
mw.loader.using( 'ext.uls.interface' ).then( function () {
|
|
|
|
var pLangBtn = document.getElementById( 'p-lang-btn' );
|
|
|
|
if ( !pLangBtn ) {
|
|
|
|
return;
|
|
|
|
}
|
2021-05-14 15:04:28 +00:00
|
|
|
if ( !pLangBtn.querySelectorAll( '.mw-interlanguage-selector' ).length ) {
|
|
|
|
// The ext.uls.interface module removed the selector, because the feature is disabled. Do nothing.
|
|
|
|
return;
|
|
|
|
}
|
2021-03-01 21:32:25 +00:00
|
|
|
pLangBtn.classList.add( 'vector-menu--hide-dropdown' );
|
|
|
|
} );
|
|
|
|
} else {
|
|
|
|
pLangBtnLabel = document.getElementById( 'p-lang-btn-label' );
|
|
|
|
if ( !pLangBtnLabel ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove .mw-interlanguage-selector to show the dropdown arrow since evidently
|
|
|
|
// ULS is not used.
|
|
|
|
pLangBtnLabel.classList.remove( 'mw-interlanguage-selector' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the language button.
|
|
|
|
*/
|
|
|
|
module.exports = function () {
|
|
|
|
disableLanguageDropdown();
|
|
|
|
};
|