From 4764079c6af092a6dfa18306601e1b33482fb756 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 05 May 2011 03:26:50 -0400
Subject: [PATCH] - Fix bug where messages were deleted instead moved to trash folder after Shift key was used (#1487902), small code improvements
---
program/js/list.js | 2 ++
CHANGELOG | 1 +
program/js/app.js | 47 +++++++++++++++++++++++------------------------
3 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 73a04da..f6a671d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix bug where messages were deleted instead moved to trash folder after Shift key was used (#1487902)
- Enable multiselection for attachments uploading in capable browsers (#1485969)
- Add possibility to change HTML editor configuration by skin
- Fix a bug where selecting too many contacts would produce too large URI request (#1487892)
diff --git a/program/js/app.js b/program/js/app.js
index 3da2eca..99446d6 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -657,13 +657,13 @@
case 'delete':
// mail task
- if (this.task=='mail')
+ if (this.task == 'mail')
this.delete_messages();
// addressbook task
- else if (this.task=='addressbook')
+ else if (this.task == 'addressbook')
this.delete_contacts();
// user settings task
- else if (this.task=='settings')
+ else if (this.task == 'settings')
this.delete_identity();
break;
@@ -1364,22 +1364,20 @@
this.doc_mouse_up = function(e)
{
- var model, list, li;
+ var model, list, li, id;
- if (this.message_list) {
- if (!rcube_mouse_is_over(e, this.message_list.list.parentNode))
- this.message_list.blur();
+ if (list = this.message_list) {
+ if (!rcube_mouse_is_over(e, list.list.parentNode))
+ list.blur();
else
- this.message_list.focus();
- list = this.message_list;
+ list.focus();
model = this.env.mailboxes;
}
- else if (this.contact_list) {
- if (!rcube_mouse_is_over(e, this.contact_list.list.parentNode))
- this.contact_list.blur();
+ else if (list = this.contact_list) {
+ if (!rcube_mouse_is_over(e, list.list.parentNode))
+ list.blur();
else
- this.contact_list.focus();
- list = this.contact_list;
+ list.focus();
model = this.env.contactfolders;
}
else if (this.ksearch_value) {
@@ -1400,7 +1398,7 @@
// reset 'pressed' buttons
if (this.buttons_sel) {
- for (var id in this.buttons_sel)
+ for (id in this.buttons_sel)
if (typeof id !== 'function')
this.button_out(this.buttons_sel[id], id);
this.buttons_sel = {};
@@ -1499,8 +1497,6 @@
this.command('previouspage');
else if (list.key_pressed == 34)
this.command('nextpage');
- else
- list.shiftkey = false;
};
this.msglist_get_preview = function()
@@ -2426,17 +2422,19 @@
// delete selected messages from the current mailbox
this.delete_messages = function()
{
- var selection = this.message_list ? $.merge([], this.message_list.get_selection()) : [];
+ var uid, i, len, trash = this.env.trash_mailbox,
+ list = this.message_list,
+ selection = list ? $.merge([], list.get_selection()) : [];
// exit if no mailbox specified or if selection is empty
if (!this.env.uid && !selection.length)
return;
// also select childs of collapsed rows
- for (var uid, i=0, len=selection.length; i<len; i++) {
+ for (i=0, len=selection.length; i<len; i++) {
uid = selection[i];
- if (this.message_list.rows[uid].has_children && !this.message_list.rows[uid].expanded)
- this.message_list.select_childs(uid);
+ if (list.rows[uid].has_children && !list.rows[uid].expanded)
+ list.select_childs(uid);
}
// if config is set to flag for deletion
@@ -2445,17 +2443,18 @@
return false;
}
// if there isn't a defined trash mailbox or we are in it
- else if (!this.env.trash_mailbox || this.env.mailbox == this.env.trash_mailbox)
+ // @TODO: we should check if defined trash mailbox exists
+ else if (!trash || this.env.mailbox == trash)
this.permanently_remove_messages();
// if there is a trash mailbox defined and we're not currently in it
else {
// if shift was pressed delete it immediately
- if (this.message_list && this.message_list.shiftkey) {
+ if (list && list.shiftkey) {
if (confirm(this.get_label('deletemessagesconfirm')))
this.permanently_remove_messages();
}
else
- this.move_messages(this.env.trash_mailbox);
+ this.move_messages(trash);
}
return true;
diff --git a/program/js/list.js b/program/js/list.js
index 3f25d4d..eb73bbb 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -988,6 +988,8 @@
this.shiftkey = e.shiftKey;
this.key_pressed = keyCode;
this.triggerEvent('keypress');
+ // reset shiftkey flag, we need it only for registered events
+ this.shiftkey = false;
if (this.key_pressed == this.BACKSPACE_KEY)
return rcube_event.cancel(e);
--
Gitblit v1.9.1