mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-15 19:59:35 +00:00
48b1263533
The language dropdown currently impacts rendering due to making use of visibility: hidden as space must be allocated for it on the page. However when ULS is installed it is never used. As some JS to take that into account so it doesn't impact the rendering of the page. Since ULS may not be installed we have to consider that case and retain the existing behaviour for those wiki (this should only impact 3rd parties) Bug: T340715 Change-Id: Ic83eaa34ffa74a42c7cf6df7c0857dd7a9401aba
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
/**
|
|
* Copies interwiki links to main menu
|
|
*
|
|
* Temporary solution to T287206, can be removed when the new ULS built in Vue.js
|
|
* has been released and contains this
|
|
*/
|
|
function addInterwikiLinkToMainMenu() {
|
|
const editLink = /** @type {HTMLElement|null} */ (
|
|
document.querySelector( '#p-lang-btn .wbc-editpage' )
|
|
);
|
|
|
|
if ( !editLink ) {
|
|
return;
|
|
}
|
|
const title = editLink.getAttribute( 'title' ) || '';
|
|
|
|
const addInterlanguageLink = mw.util.addPortletLink(
|
|
'p-tb',
|
|
editLink.getAttribute( 'href' ) || '#',
|
|
// Original text is "Edit links".
|
|
// Since its taken out of context the title is more descriptive.
|
|
title,
|
|
'wbc-editpage',
|
|
title
|
|
);
|
|
|
|
if ( addInterlanguageLink ) {
|
|
addInterlanguageLink.addEventListener( 'click', function ( /** @type {Event} */ e ) {
|
|
e.preventDefault();
|
|
// redirect to the detached and original edit link
|
|
editLink.click();
|
|
} );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks if ULS is disabled, and makes sure the language dropdown continues
|
|
* to work if it is.
|
|
*/
|
|
function checkIfULSDisabled() {
|
|
const langModuleState = mw.loader.getState( 'ext.uls.interface' );
|
|
if ( langModuleState === null || langModuleState === 'registered' ) {
|
|
document.documentElement.classList.add( 'vector-uls-disabled' );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Initialize the language button.
|
|
*/
|
|
module.exports = function () {
|
|
checkIfULSDisabled();
|
|
addInterwikiLinkToMainMenu();
|
|
};
|