jenkins-bot has submitted this change and it was merged. Change subject: Refactor showULSTooltip ......................................................................
Refactor showULSTooltip Makes the code easier to understand and fixes T52743 Bug: T52743 Change-Id: If508f26b5133284f3059b50d420066a8b4fefb07 --- M resources/js/ext.uls.interface.js 1 file changed, 18 insertions(+), 18 deletions(-) Approvals: KartikMistry: Looks good to me, approved Santhosh: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/js/ext.uls.interface.js b/resources/js/ext.uls.interface.js index 5056920..96aaa2e 100644 --- a/resources/js/ext.uls.interface.js +++ b/resources/js/ext.uls.interface.js @@ -189,37 +189,37 @@ * It also allows to undo the language selection. */ function showULSTooltip() { - var ulsPosition = mw.config.get( 'wgULSPosition' ), + var previousLang, $ulsTrigger, anonMode, showUndo, newLanguage, previousLanguages, + ulsPosition = mw.config.get( 'wgULSPosition' ), currentLang = mw.config.get( 'wgUserLanguage' ), - previousLang, - $ulsTrigger, - anonMode, rtlPage = $( 'body' ).hasClass( 'rtl' ), tipsyGravity = { personal: 'n', interlanguage: rtlPage ? 'e' : 'w' - }, - previousLanguages = mw.uls.getPreviousLanguages() || []; - - previousLang = previousLanguages.slice( -1 )[0]; + }; $ulsTrigger = ( ulsPosition === 'interlanguage' ) ? $( '.uls-settings-trigger' ) : $( '.uls-trigger' ); - if ( previousLang === currentLang ) { - $ulsTrigger.tipsy( { gravity: rtlPage ? 'e' : 'w' } ); + previousLanguages = mw.uls.getPreviousLanguages() || []; + previousLang = previousLanguages.slice( -1 )[0]; - return; + // Whether we see current language for the first time + newLanguage = currentLang !== previousLang; + // Whether user is able to change language + anonMode = ( mw.user.isAnon() && !mw.config.get( 'wgULSAnonCanChangeLanguage' ) ); + // Whether user is able to change language, and just did so + showUndo = !anonMode && newLanguage && previousLang !== undefined; + + if ( newLanguage ) { + previousLanguages.push( currentLang ); + mw.uls.setPreviousLanguages( previousLanguages ); } - previousLanguages.push( currentLang ); - mw.uls.setPreviousLanguages( previousLanguages ); - - anonMode = ( mw.user.isAnon() && !mw.config.get( 'wgULSAnonCanChangeLanguage' ) ); - - if ( anonMode || !previousLang ) { - // Do not show tooltip + if ( !showUndo ) { + // In interlanguage mode, we will have normal tooltip, make it look same using tipsy + $ulsTrigger.tipsy( { gravity: tipsyGravity[ulsPosition] } ); return; } -- To view, visit https://gerrit.wikimedia.org/r/199875 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If508f26b5133284f3059b50d420066a8b4fefb07 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector Gerrit-Branch: master Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: KartikMistry <kartik.mis...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits