diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2013-11-23 16:59:41 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2013-11-23 16:59:41 +0100 |
commit | f52efbd5cde3bdd7733d1318de06cce3386b62b2 (patch) | |
tree | 189de08125a9b18b5f9342067f5c5cbc67db6d42 /skins/larry/ui.js | |
parent | 078679843852e8531f907bafbab275a521dbb5e5 (diff) |
Save Larry skin UI settings in local storage instead of cookies
Diffstat (limited to 'skins/larry/ui.js')
-rw-r--r-- | skins/larry/ui.js | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/skins/larry/ui.js b/skins/larry/ui.js index ae8ae5c55..a3c64b437 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -31,6 +31,7 @@ function rcube_mail_ui() var me = this; var mailviewsplit; var compose_headers = {}; + var prefs; // export public methods this.set = setenv; @@ -74,7 +75,25 @@ function rcube_mail_ui() */ function get_pref(key) { - return rcmail.get_cookie(key); + if (!prefs) { + prefs = window.localStorage ? rcmail.local_storage_get_item('prefs.larry', {}) : {}; + } + + // fall-back to cookies + if (prefs[key] == null) { + var cookie = rcmail.get_cookie(key); + if (cookie != null) { + prefs[key] = cookie; + + // copy value to local storage and remove cookie + if (window.localStorage) { + rcmail.local_storage_set_item('prefs.larry', prefs); + rcmail.set_cookie(key, cookie, new Date()); // expire cookie + } + } + } + + return prefs[key]; } /** @@ -82,9 +101,18 @@ function rcube_mail_ui() */ function save_pref(key, val) { - var exp = new Date(); - exp.setYear(exp.getFullYear() + 1); - rcmail.set_cookie(key, val, exp); + prefs[key] = val; + + // write prefs to local storage + if (window.localStorage) { + rcmail.local_storage_set_item('prefs.larry', prefs); + } + else { + // store value in cookie + var exp = new Date(); + exp.setYear(exp.getFullYear() + 1); + rcmail.set_cookie(key, val, exp); + } } /** |