From 64aeedfb177fac2d7cee18344f4b7adba4318645 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Thu, 4 Feb 2021 12:10:22 -0800 Subject: [PATCH] Modern Vector should be compatible with ULS Without the following changes the language button shows the wrong label and opens a dialog with zero languages. * Don't apply heading change to modern Vector * Look for the element .mw-portlet-lang as well as #p-lang Bug: T273232 Bug: T273928 Change-Id: Ic201b1983a17cc37fd1ff7c507aab656ea25f370 --- resources/js/ext.uls.compactlinks.js | 10 +++++----- resources/js/ext.uls.interface.js | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/resources/js/ext.uls.compactlinks.js b/resources/js/ext.uls.compactlinks.js index 269bf402..c10e5f26 100644 --- a/resources/js/ext.uls.compactlinks.js +++ b/resources/js/ext.uls.compactlinks.js @@ -236,8 +236,8 @@ getBabelLanguages, getSitePicks, getCommonLanguages, - this.getLangsInText, - this.getLangsWithBadges, + this.getLangsInText.bind( this ), + this.getLangsWithBadges.bind( this ), getExtraCommonLanguages, getFinalFallback ]; @@ -300,7 +300,7 @@ */ CompactInterlanguageList.prototype.getLangsWithBadges = function () { return Array.prototype.map.call( - document.querySelectorAll( '#p-lang [class*="badge"] a.interlanguage-link-target' ), + this.listElement.querySelectorAll( '[class*="badge"] a.interlanguage-link-target' ), function ( el ) { return mw.uls.convertMediaWikiLanguageCodeToULS( el.lang ); } @@ -382,9 +382,9 @@ */ function createCompactList() { var listElement, compactList; - listElement = document.querySelector( '#p-lang ul' ); + listElement = document.querySelector( '.mw-portlet-lang ul, #p-lang ul' ); if ( !listElement ) { - // Not all namespaces/pages/actions have #p-lang. + // Not all namespaces will have a list of languages. return; } compactList = new CompactInterlanguageList( listElement ); diff --git a/resources/js/ext.uls.interface.js b/resources/js/ext.uls.interface.js index 04009a22..3b565de6 100644 --- a/resources/js/ext.uls.interface.js +++ b/resources/js/ext.uls.interface.js @@ -236,6 +236,8 @@ function initInterface() { var $pLang, clickHandler, + // T273928: No change to the heading should be made in modern Vector when the language button is present + changeHeadingAllowed = mw.config.get( 'skin' ) !== 'vector' || $( '#p-lang-btn' ).length > 0, $ulsTrigger = $( '.uls-trigger' ), anonMode = ( mw.user.isAnon() && !mw.config.get( 'wgULSAnonCanChangeLanguage' ) ), @@ -243,7 +245,7 @@ if ( ulsPosition === 'interlanguage' ) { // TODO: Refactor this block - // The interlanguage links section + // The interlanguage links section. $pLang = $( '#p-lang' ); // Add an element near the interlanguage links header $ulsTrigger = $( '