From 1c7b97e81bea919c26bfe878312c5118c02ac0a9 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Tue, 13 Mar 2007 19:17:20 -0400 Subject: [PATCH] Fixed flag for deletion bug #1484264 + code style --- program/js/app.js | 84 +++++++++++++++++++++++++++++------------- 1 files changed, 58 insertions(+), 26 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 434f1f4..c19a3e1 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -671,7 +671,7 @@ if (this.env.uid && props.mimetype && find_in_array(props.mimetype, this.mimetypes)>=0) { if (props.mimetype == 'text/html') - qstring += '&safe=1'; + qstring += '&_safe=1'; this.attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment'); if (this.attachment_win) { @@ -1091,13 +1091,13 @@ { this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected); this.enable_command('delete', 'moveto', list.selection.length>0 ? true : false); - - // start timer for message preview (wait for double click) - if (selected && this.env.contentframe) - this.preview_timer = setTimeout(function(){ ref.msglist_get_preview(); }, this.dblclick_time + 10); - else if (this.env.contentframe) - this.show_messageframe(false); } + + // start timer for message preview (wait for double click) + if (selected && this.env.contentframe) + this.preview_timer = setTimeout(function(){ ref.msglist_get_preview(); }, this.dblclick_time + 10); + else if (this.env.contentframe) + this.show_messageframe(false); }; @@ -1226,7 +1226,8 @@ page = 1; add_url += '&_refresh=1'; this.env.current_page = page; - this.message_list.clear_selection(); + if (this.message_list) + this.message_list.clear_selection(); this.show_messageframe(false); } @@ -1354,15 +1355,14 @@ // delete selected messages from the current mailbox this.delete_messages = function() { + var selection = this.message_list ? this.message_list.get_selection() : new Array(); + // exit if no mailbox specified or if selection is empty - if (!this.env.uid) - { - if (!this.message_list || !this.message_list.get_selection().length) + if (!this.env.uid && !selection.length) return; - } // if there is a trash mailbox defined and we're not currently in it: - if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase()!=String(this.env.trash_mailbox).toLowerCase()) + if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() != String(this.env.trash_mailbox).toLowerCase()) { // if shift was pressed delete it immediately if (this.message_list && this.message_list.shiftkey) @@ -1379,8 +1379,7 @@ // if there isn't a defined trash mailbox and the config is set to flag for deletion else if (!this.env.trash_mailbox && this.env.flag_for_deletion) { - flag = 'delete'; - this.mark_message(flag); + this.mark_message('delete'); if(this.env.action=="show") this.command('nextmessage','',this); else if (selection.length == 1) @@ -1398,7 +1397,7 @@ // exit if no mailbox specified or if selection is empty if (!this.env.uid && (!this.message_list || !this.message_list.get_selection().length)) return; - + this.show_messageframe(false); this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : '')); }; @@ -1443,13 +1442,13 @@ a_uids[0] = uid; else if (this.env.uid) a_uids[0] = this.env.uid; - else + else if (this.message_list) { - var id; - for (var n=0; n<selection.length; n++) + for (var id, n=0; n<selection.length; n++) { id = selection[n]; - if ((flag=='read' && this.message_list.rows[id].unread) || (flag=='unread' && !this.message_list.rows[id].unread)) + if ((flag=='read' && this.message_list.rows[id].unread) || (flag=='unread' && !this.message_list.rows[id].unread) + || (flag=='delete' && !this.message_list.rows[id].deleted) || (flag=='undelete' && this.message_list.rows[id].deleted)) a_uids[a_uids.length] = id; } } @@ -1522,7 +1521,8 @@ return false; var rows = this.message_list.rows; - if (a_uids.length==1) { + if (a_uids.length==1) + { if (rows[a_uids[0]] && rows[a_uids[0]].classname.indexOf('deleted') < 0) this.flag_as_deleted(a_uids); else @@ -1532,10 +1532,12 @@ } var all_deleted = true; - for (var i=0; i<a_uids.length; i++) { + for (var i=0; i<a_uids.length; i++) + { uid = a_uids[i]; if (rows[uid]) { - if (rows[uid].classname.indexOf('deleted')<0) { + if (rows[uid].classname.indexOf('deleted')<0) + { all_deleted = false; break; } @@ -1560,12 +1562,14 @@ var icn_src; var rows = this.message_list.rows; - for (var i=0; i<a_uids.length; i++) { + for (var i=0; i<a_uids.length; i++) + { uid = a_uids[i]; if (rows[uid]) { rows[uid].deleted = false; - if (rows[uid].classname.indexOf('deleted') > 0) { + if (rows[uid].classname.indexOf('deleted') > 0) + { rows[uid].classname = rows[uid].classname.replace(/\s*deleted/, ''); this.set_classname(rows[uid].obj, 'deleted', false); } @@ -1592,7 +1596,8 @@ return false; var rows = this.message_list.rows; - for (var i=0; i<a_uids.length; i++) { + for (var i=0; i<a_uids.length; i++) + { uid = a_uids[i]; if (rows[uid]) { rows[uid].deleted = true; @@ -2584,6 +2589,7 @@ form.elements['_folder_name'].value = ''; } + this.sort_subscription_list(); }; @@ -2732,6 +2738,32 @@ return new_row; }; + // sort subscription folder list + this.sort_subscription_list = function() + { + var index = new Array(); + var tbody = this.gui_objects.subscriptionlist.tBodies[0]; + var swapped = false; + for (var i = 0; i<(tbody.childNodes.length-1); i++) + if (this.env.subscriptionrows[tbody.childNodes[i].id]!=null) + index.push(i); + for (i = 0; i<(index.length-1); i++) + { + if (this.env.subscriptionrows[tbody.childNodes[index[i]].id][0]> + this.env.subscriptionrows[tbody.childNodes[index[i+1]].id][0]) + { + var swap = tbody.replaceChild(tbody.childNodes[index[i]], tbody.childNodes[index[i+1]]); + if (typeof(tbody.childNodes[index[i]]) != 'undefined') + tbody.insertBefore(swap, tbody.childNodes[index[i]]) + else + tbody.appendChild(swap); + swapped = true; + } + } + if (swapped) + this.sort_subscription_list(); + }; + /*********************************************************/ /********* GUI functionality *********/ -- Gitblit v1.9.1