From 03d099eddce03610230022c38a17455f89537f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Laxstr=C3=B6m?= Date: Fri, 25 Jun 2021 12:49:20 +0300 Subject: [PATCH] Fix regressions in ULS entry point setup * Link in preferences is again opening ULS * "personal" entry point now works even with compact languages preference disabled I added lots of comments and refactored this code to give things better names to make this code easier to understand and maintain and hopefully reduce the amount of bugs in the future. Bug: T282956 Bug: T286574 Change-Id: I9cd6776ea6664e33fd63c49dfa77c5f004fba799 --- includes/UniversalLanguageSelectorHooks.php | 2 +- resources/js/ext.uls.interface.js | 230 +++++++++++--------- 2 files changed, 125 insertions(+), 107 deletions(-) diff --git a/includes/UniversalLanguageSelectorHooks.php b/includes/UniversalLanguageSelectorHooks.php index 01530889..207f124f 100644 --- a/includes/UniversalLanguageSelectorHooks.php +++ b/includes/UniversalLanguageSelectorHooks.php @@ -424,7 +424,7 @@ class UniversalLanguageSelectorHooks { 'section' => 'personal/i18n', // We use this class to hide this from no-JS users 'cssclass' => 'uls-preferences-link-wrapper', - 'default' => "" . + 'default' => "" . wfMessage( 'ext-uls-language-settings-preferences-link' )->escaped() . "", ]; diff --git a/resources/js/ext.uls.interface.js b/resources/js/ext.uls.interface.js index 75f68583..5b923253 100644 --- a/resources/js/ext.uls.interface.js +++ b/resources/js/ext.uls.interface.js @@ -234,116 +234,108 @@ } ); } - function initInterface() { - var $pLang, - clickHandler, - // T273928: No change to the heading should be made in modern Vector when the language - // button is present - isButton = isUsingStandaloneLanguageButton(), - $trigger = $( '.uls-trigger' ), - anonMode = ( mw.user.isAnon() && - !mw.config.get( 'wgULSAnonCanChangeLanguage' ) ), - configPosition = mw.config.get( 'wgULSPosition' ); + function initSecondaryEntryPoints() { + $( '.uls-settings-trigger' ).one( 'click', function ( e ) { + e.preventDefault(); + mw.loader.using( languageSettingsModules, function () { + $( e.target ).languagesettings(); + $( e.target ).trigger( 'click' ); + } ); + } ); + } - if ( !mw.config.get( 'wgULSisCompactLinksEnabled' ) ) { - // The wgULSisCompactLinksEnabled flag when disabled will not render a language button to the page - // Skins can control where the button is placed, by adding an element with mw-interlanguage-selector to the page, - // the display of which is not impacted by this flag. To signal to these skins that the language button should be - // disabled, the class is removed. - $( '.mw-interlanguage-selector' ).removeClass( 'mw-interlanguage-selector' ); - return; + function initInterlanguageEntryPoint() { + var $pLang = $( '#p-lang' ); + + var $trigger = $( '