| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
function addInterwikiLinkToMainMenu() { |
| 8 |
const editLink = ( |
| 9 |
document.querySelector( '#p-lang-btn .wbc-editpage' ) |
| 10 |
); |
| 11 |
|
| 12 |
if ( !editLink ) { |
| 13 |
return; |
| 14 |
} |
| 15 |
const title = editLink.getAttribute( 'title' ) || ''; |
| 16 |
|
| 17 |
const addInterlanguageLink = mw.util.addPortletLink( |
| 18 |
'p-tb', |
| 19 |
editLink.getAttribute( 'href' ) || '#', |
| 20 |
|
| 21 |
|
| 22 |
title, |
| 23 |
'wbc-editpage', |
| 24 |
title |
| 25 |
); |
| 26 |
|
| 27 |
if ( addInterlanguageLink ) { |
| 28 |
addInterlanguageLink.addEventListener( 'click', ( e ) => { |
| 29 |
e.preventDefault(); |
| 30 |
|
| 31 |
editLink.click(); |
| 32 |
} ); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
function checkIfULSDisabled() { |
| 41 |
const langModuleState = mw.loader.getState( 'ext.uls.interface' ); |
| 42 |
if ( langModuleState === null || langModuleState === 'registered' ) { |
| 43 |
document.documentElement.classList.add( 'vector-uls-disabled' ); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
module.exports = function () { |
| 51 |
checkIfULSDisabled(); |
| 52 |
addInterwikiLinkToMainMenu(); |
| 53 |
}; |