mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-04 20:18:57 +00:00
8457b64a83
For pages with interlanguage links, this link has no event listener and only functions as a plain link to the corresponding Wikidata page. Bug: T336931 Change-Id: I8c1456b3c524824ccc59aee5f999c8017c59fc0b
42 lines
1,000 B
JavaScript
42 lines
1,000 B
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();
|
|
} );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Initialize the language button.
|
|
*/
|
|
module.exports = function () {
|
|
addInterwikiLinkToMainMenu();
|
|
};
|