Only select childs when a message row is collapsed but also do it when deleting a thread

release-0.6
thomascube 15 years ago
parent 5799531e3f
commit 84a3312f0b

@ -2204,12 +2204,19 @@ function rcube_webmail()
// delete selected messages from the current mailbox // delete selected messages from the current mailbox
this.delete_messages = function() this.delete_messages = function()
{ {
var selection = this.message_list ? this.message_list.get_selection() : new Array(); var selection = this.message_list ? $.merge([], this.message_list.get_selection()) : new Array();
// exit if no mailbox specified or if selection is empty // exit if no mailbox specified or if selection is empty
if (!this.env.uid && !selection.length) if (!this.env.uid && !selection.length)
return; return;
// also select childs of collapsed rows
for (var uid, i=0; i < selection.length; 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 config is set to flag for deletion // if config is set to flag for deletion
if (this.env.flag_for_deletion) { if (this.env.flag_for_deletion) {
this.mark_message('delete'); this.mark_message('delete');
@ -2221,8 +2228,7 @@ function rcube_webmail()
// if there is a trash mailbox defined and we're not currently in it // if there is a trash mailbox defined and we're not currently in it
else { else {
// if shift was pressed delete it immediately // if shift was pressed delete it immediately
if (this.message_list && this.message_list.shiftkey) if (this.message_list && this.message_list.shiftkey) {
{
if (confirm(this.get_label('deletemessagesconfirm'))) if (confirm(this.get_label('deletemessagesconfirm')))
this.permanently_remove_messages(); this.permanently_remove_messages();
} }

@ -658,6 +658,29 @@ select_first: function()
this.select_row(first_row, false, false); this.select_row(first_row, false, false);
}, },
/**
* Add all childs of the given row to selection
*/
select_childs: function(uid)
{
if (!this.rows[uid] || !this.rows[uid].has_children)
return;
var depth = this.rows[uid].depth;
var row = this.rows[uid].obj.nextSibling;
while (row) {
if (row.nodeType == 1) {
if ((r = this.rows[row.uid])) {
if (!r.depth || r.depth <= depth)
break;
if (!this.in_selection(r.uid))
this.select_row(r.uid, CONTROL_KEY);
}
}
row = row.nextSibling;
}
},
/** /**
* Perform selection when shift key is pressed * Perform selection when shift key is pressed
@ -1013,21 +1036,8 @@ drag_mouse_move: function(e)
var depth, row, uid, r; var depth, row, uid, r;
for (var n=0; n < selection.length; n++) { for (var n=0; n < selection.length; n++) {
uid = selection[n]; uid = selection[n];
if (this.rows[uid].has_children /*&& !this.rows[uid].expanded*/) { if (this.rows[uid].has_children && !this.rows[uid].expanded)
depth = this.rows[uid].depth; this.select_childs(uid);
row = this.rows[uid].obj.nextSibling;
while (row) {
if (row.nodeType == 1) {
if ((r = this.rows[row.uid])) {
if (!r.depth || r.depth <= depth)
break;
if (!this.in_selection(r.uid))
this.select_row(r.uid, CONTROL_KEY);
}
}
row = row.nextSibling;
}
}
} }
// get subjects of selected messages // get subjects of selected messages

Loading…
Cancel
Save