Merge "When changing language first time, language code was shown"
This commit is contained in:
@@ -163,6 +163,27 @@
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the previously active language
|
||||||
|
* @param {string} code Language code of previously selected language.
|
||||||
|
* @return {jQuery.Promise}
|
||||||
|
*/
|
||||||
|
function getUndoAutonym( code ) {
|
||||||
|
var
|
||||||
|
deferred = $.Deferred(),
|
||||||
|
autonym = $.cookie( mw.uls.previousLanguageAutonymCookie );
|
||||||
|
|
||||||
|
if ( autonym ) {
|
||||||
|
deferred.resolve( autonym );
|
||||||
|
} else {
|
||||||
|
mw.loader.using( 'jquery.uls.data', function () {
|
||||||
|
deferred.resolve( $.uls.data.getAutonym( code ) );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
return deferred.promise();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* It also allows to undo the language selection.
|
||||||
@@ -171,7 +192,6 @@
|
|||||||
var ulsPosition = mw.config.get( 'wgULSPosition' ),
|
var ulsPosition = mw.config.get( 'wgULSPosition' ),
|
||||||
currentLang = mw.config.get( 'wgUserLanguage' ),
|
currentLang = mw.config.get( 'wgUserLanguage' ),
|
||||||
previousLang,
|
previousLang,
|
||||||
previousLanguageAutonym,
|
|
||||||
$ulsTrigger,
|
$ulsTrigger,
|
||||||
anonMode,
|
anonMode,
|
||||||
rtlPage = $( 'body' ).hasClass( 'rtl' ),
|
rtlPage = $( 'body' ).hasClass( 'rtl' ),
|
||||||
@@ -203,9 +223,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
previousLanguageAutonym = $.cookie( mw.uls.previousLanguageAutonymCookie ) ||
|
getUndoAutonym( previousLang ).done( function( autonym ) {
|
||||||
previousLang;
|
|
||||||
|
|
||||||
// Attach a tipsy tooltip to the trigger
|
// Attach a tipsy tooltip to the trigger
|
||||||
$ulsTrigger.tipsy( {
|
$ulsTrigger.tipsy( {
|
||||||
gravity: tipsyGravity[ulsPosition],
|
gravity: tipsyGravity[ulsPosition],
|
||||||
@@ -216,7 +234,7 @@
|
|||||||
title: function () {
|
title: function () {
|
||||||
var link;
|
var link;
|
||||||
|
|
||||||
link = $( '<a>' ).text( previousLanguageAutonym )
|
link = $( '<a>' ).text( autonym )
|
||||||
.attr( {
|
.attr( {
|
||||||
href: '#',
|
href: '#',
|
||||||
'class': 'uls-prevlang-link',
|
'class': 'uls-prevlang-link',
|
||||||
@@ -233,6 +251,7 @@
|
|||||||
return mw.message( 'ext-uls-undo-language-tooltip-text', '$1' ).escaped().replace( '$1', link );
|
return mw.message( 'ext-uls-undo-language-tooltip-text', '$1' ).escaped().replace( '$1', link );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
} );
|
||||||
|
|
||||||
// Now that we set the previous languages,
|
// Now that we set the previous languages,
|
||||||
// we can set the cookie of the previous autonym.
|
// we can set the cookie of the previous autonym.
|
||||||
|
|||||||
Reference in New Issue
Block a user