Use localstorage instead of cookie for previous language autonym

Change-Id: I1025a8bbb9fad0cfd326547a09c982925a55e55d
This commit is contained in:
Santhosh Thottingal
2016-04-12 11:33:36 +05:30
committed by Niklas Laxström
parent 4ff9e44529
commit 7d90ecef1d
2 changed files with 14 additions and 10 deletions

View File

@@ -24,7 +24,6 @@
mw.uls = mw.uls || {}; mw.uls = mw.uls || {};
mw.uls.previousLanguagesStorageKey = 'uls-previous-languages'; mw.uls.previousLanguagesStorageKey = 'uls-previous-languages';
mw.uls.previousLanguageAutonymCookie = 'uls-previous-language-autonym';
mw.uls.languageSettingsModules = [ 'ext.uls.inputsettings', 'ext.uls.displaysettings' ]; mw.uls.languageSettingsModules = [ 'ext.uls.inputsettings', 'ext.uls.displaysettings' ];
/** /**

View File

@@ -20,6 +20,8 @@
( function ( $, mw ) { ( function ( $, mw ) {
'use strict'; 'use strict';
var previousLanguageAutonymStorageKey = 'uls-previous-language-autonym';
/** /**
* Construct the display settings link * Construct the display settings link
* *
@@ -176,9 +178,12 @@
* @return {jQuery.Promise} * @return {jQuery.Promise}
*/ */
function getUndoAutonym( code ) { function getUndoAutonym( code ) {
var var autonym,
deferred = $.Deferred(), deferred = $.Deferred();
autonym = $.cookie( mw.uls.previousLanguageAutonymCookie );
try {
autonym = localStorage.getItem( previousLanguageAutonymStorageKey );
} catch ( e ) {}
if ( autonym ) { if ( autonym ) {
mw.loader.using( 'jquery.tipsy', function () { mw.loader.using( 'jquery.tipsy', function () {
@@ -313,14 +318,14 @@
} ); } );
// 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 store the previous autonym.
// TODO: Refactor this, because it doesn't directly belong // TODO: Refactor this, because it doesn't directly belong
// to the tooltip. // to the tooltip.
$.cookie( mw.uls.previousLanguageAutonymCookie, try {
mw.config.get( 'wgULSCurrentAutonym' ), { localStorage.setItem(
path: '/' previousLanguageAutonymStorageKey, mw.config.get( 'wgULSCurrentAutonym' )
}
); );
} catch ( e ) {}
} }
function initInterface() { function initInterface() {