Remove the dependency on uls.data

Change-Id: I9fa103ee7d338ed8ea2032c82249a47d022d2c90
This commit is contained in:
Amir E. Aharoni
2013-11-06 12:55:09 +02:00
committed by Amire80
parent f5ce066c80
commit b23f937cb7
4 changed files with 30 additions and 7 deletions

View File

@@ -165,13 +165,14 @@
}
/**
* The tooltip to be shown when language changed using ULS
* The tooltip to be shown when language changed using ULS.
* It also allows to undo the language selection.
*/
function showULSTooltip() {
var ulsPosition = mw.config.get( 'wgULSPosition' ),
currentLang = mw.config.get( 'wgUserLanguage' ),
previousLang,
previousLanguageAutonym,
$ulsTrigger,
anonMode,
rtlPage = $( 'body' ).hasClass( 'rtl' ),
@@ -198,11 +199,14 @@
anonMode = ( mw.user.isAnon() && !mw.config.get( 'wgULSAnonCanChangeLanguage' ) );
if ( anonMode || !previousLang || !$.uls.data.languages[previousLang] ) {
if ( anonMode || !previousLang ) {
// Do not show tooltip
return;
}
previousLanguageAutonym = $.cookie( mw.uls.previousLanguageAutonymCookie ) ||
previousLang;
// Attach a tipsy tooltip to the trigger
$ulsTrigger.tipsy( {
gravity: tipsyGravity[ulsPosition],
@@ -213,12 +217,15 @@
title: function () {
var link;
link = $( '<a>' ).text( $.uls.data.getAutonym( previousLang ) )
link = $( '<a>' ).text( previousLanguageAutonym )
.attr( {
href: '#',
'class': 'uls-prevlang-link',
lang: previousLang,
dir: $.uls.data.getDir( previousLang )
// We could get dir from uls.data,
// but we are trying to avoid loading it
// and 'auto' is safe enough in this context
dir: 'auto'
} );
// Get the html of the link by wrapping it in div first
@@ -228,6 +235,15 @@
}
} );
// Now that we set the previous languages,
// we can set the cookie of the previous autonym.
// TODO: Refactor this, because it doesn't directly belong
// to the tooltip.
$.cookie( mw.uls.previousLanguageAutonymCookie,
mw.config.get( 'wgULSCurrentAutonym' ),
{ path: '/' }
);
function showTipsy( timeout ) {
var tipsyTimer = 0;