summaryrefslogtreecommitdiff
path: root/skins/larry/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'skins/larry/ui.js')
-rw-r--r--skins/larry/ui.js60
1 files changed, 47 insertions, 13 deletions
diff --git a/skins/larry/ui.js b/skins/larry/ui.js
index 9183291c5..3c4740df2 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);
+ }
}
/**
@@ -345,8 +373,10 @@ function rcube_mail_ui()
function body_mouseup(e)
{
var config, obj, target = e.target;
+
if (target.className == 'inner')
target = e.target.parentNode;
+
for (var id in popups) {
obj = popups[id];
config = popupconfig[id];
@@ -355,9 +385,10 @@ function rcube_mail_ui()
&& !config.toggle
&& (!config.editable || !target_overlaps(target, obj.get(0)))
&& (!config.sticky || !rcube_mouse_is_over(e, obj.get(0)))
+ && !$(target).is('.folder-selector-link')
) {
var myid = id+'';
- window.setTimeout(function(){ show_popupmenu(myid, false) }, 10);
+ window.setTimeout(function() { show_popupmenu(myid, false); }, 10);
}
}
}
@@ -408,6 +439,9 @@ function rcube_mail_ui()
// show a popup dialog on errors
if (p.type == 'error' && rcmail.env.task != 'login') {
+ // hide original message object, we don't want both
+ rcmail.hide_message(p.object);
+
if (me.message_timer) {
window.clearTimeout(me.message_timer);
}
@@ -416,8 +450,10 @@ function rcube_mail_ui()
}
var msg = p.message,
- pos = $(p.object).offset();
- pos.top -= (rcmail.env.task == 'login' ? 20 : 160);
+ dialog_close = function() {
+ // check if dialog is still displayed, to prevent from js error
+ me.messagedialog.is(':visible') && me.messagedialog.dialog('destroy').hide();
+ };
if (me.messagedialog.is(':visible'))
msg = me.messagedialog.html() + '<p>' + p.message + '</p>';
@@ -428,16 +464,14 @@ function rcube_mail_ui()
closeOnEscape: true,
dialogClass: 'popupmessage ' + p.type,
title: env.errortitle,
- close: function() {
- me.messagedialog.dialog('destroy').hide();
- },
- position: ['center', pos.top],
- hide: { effect:'drop', direction:'right' },
+ close: dialog_close,
+ position: ['center', 'center'],
+ hide: {effect: 'fadeOut'},
width: 420,
minHeight: 90
}).show();
- me.message_timer = window.setTimeout(function(){ me.messagedialog.dialog('close'); }, Math.max(3000, p.timeout / 2));
+ me.message_timer = window.setTimeout(dialog_close, p.timeout);
}
}