mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-14 19:26:42 +00:00
1d01f70e32
Having this outside the init function makes the code more easy to understand. Change-Id: I6bdcb385738ceb986e21075b006db40567386e7b
36 lines
915 B
JavaScript
36 lines
915 B
JavaScript
/**
|
|
* 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;
|
|
}
|
|
|
|
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();
|
|
};
|