mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-14 19:26:42 +00:00
0b024a4a4d
Depends-On: I726c61d4c6895a28b999781752535e0ddc961744 Bug: T282149 Change-Id: I436554d9d51470d277d59c2c71e08124735e12fd
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
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;
|
|
}
|
|
if ( !pLangBtn.querySelectorAll( '.mw-interlanguage-selector' ).length ) {
|
|
// The ext.uls.interface module removed the selector, because the feature is disabled. Do nothing.
|
|
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();
|
|
};
|