From 25c35c81e1648c49291218fdf0162d82b7e692ca Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 19 Sep 2008 16:14:10 +0000 Subject: - added set_message, set_message_icon and set_message_status functions - icon setting more unified + some small fixes/typos - get rid of *_from_preview() functions (Thomas, don't be mad, it was truly tested ;)) --- program/js/app.js | 265 +++++++++++++++++--------------------------- program/js/list.js | 2 +- program/steps/mail/show.inc | 4 +- 3 files changed, 106 insertions(+), 165 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 0aceb3008..d1341c7c6 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -758,7 +758,6 @@ function rcube_webmail() if (props._row.uid) { uid = props._row.uid; - this.message_list.dont_select = true; // toggle flagged/unflagged if (this.message_list.rows[uid].flagged) flag = 'unflagged'; @@ -1345,7 +1344,6 @@ function rcube_webmail() /********* (message) list functionality *********/ /*********************************************************/ - // when user doble-clicks on a row this.show_message = function(id, safe, preview) { @@ -1540,6 +1538,98 @@ function rcube_webmail() || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter)))); }; + // set message icon + this.set_message_icon = function(uid) + { + var icn_src; + var rows = this.message_list.rows; + + if (!rows[uid]) + return false; + + if (rows[uid].deleted && this.env.deletedicon) + icn_src = this.env.deletedicon; + else if (rows[uid].replied && this.env.repliedicon) + { + if (rows[uid].forwarded && this.env.forwardedrepliedicon) + icn_src = this.env.forwardedrepliedicon; + else + icn_src = this.env.repliedicon; + } + else if (rows[uid].forwarded && this.env.forwardedicon) + icn_src = this.env.forwardedicon; + else if (rows[uid].unread && this.env.unreadicon) + icn_src = this.env.unreadicon; + else if (this.env.messageicon) + icn_src = this.env.messageicon; + + if (icn_src && rows[uid].icon) + rows[uid].icon.src = icn_src; + + icn_src = ''; + + if (rows[uid].flagged && this.env.flaggedicon) + icn_src = this.env.flaggedicon; + else if (this.env.unflaggedicon) + icn_src = this.env.unflaggedicon; + + if (rows[uid].flagged_icon && icn_src) + rows[uid].flagged_icon.src = icn_src; + } + + // set message status + this.set_message_status = function(uid, flag, status) + { + var rows = this.message_list.rows; + + if (!rows[uid]) return false; + + if (flag == 'unread') + rows[uid].unread = status; + else if(flag == 'deleted') + rows[uid].deleted = status; + else if (flag == 'replied') + rows[uid].replied = status; + else if (flag == 'forwarded') + rows[uid].forwarded = status; + else if (flag == 'flagged') + rows[uid].flagged = status; + } + + // set message row status, class and icon + this.set_message = function(uid, flag, status) + { + var rows = this.message_list.rows; + + if (!rows[uid]) return false; + + if (flag) + this.set_message_status(uid, flag, status); + + if (rows[uid].unread && rows[uid].classname.indexOf('unread')<0) + { + rows[uid].classname += ' unread'; + this.set_classname(rows[uid].obj, 'unread', true); + } + else if (!rows[uid].unread && rows[uid].classname.indexOf('unread')>=0) + { + rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); + this.set_classname(rows[uid].obj, 'unread', false); + } + + if (rows[uid].deleted && rows[uid].classname.indexOf('deleted')<0) + { + rows[uid].classname += ' deleted'; + this.set_classname(rows[uid].obj, 'deleted', true); + } + else if (!rows[uid].deleted && rows[uid].classname.indexOf('deleted')>=0) + { + rows[uid].classname = rows[uid].classname.replace(/\s*deleted/, ''); + this.set_classname(rows[uid].obj, 'deleted', false); + } + + this.set_message_icon(uid); + } // move selected messages to the specified mailbox this.move_messages = function(mbox) @@ -1639,20 +1729,9 @@ function rcube_webmail() else { rows[id].deleted = true; - - if (rows[id].classname.indexOf('deleted')<0) - { - rows[id].classname += ' deleted'; - this.set_classname(rows[id].obj, 'deleted', true); - } if (this.env.read_when_deleted) - { - rows[id].classname = rows[id].classname.replace(/\s*unread/, ''); - this.set_classname(rows[id].obj, 'unread', false); - } - - if (rows[id].icon && this.env.deletedicon) - rows[id].icon.src = this.env.deletedicon; + rows[id].unread = false; + this.set_message(id); } } } @@ -1727,96 +1806,18 @@ function rcube_webmail() this.toggle_read_status = function(flag, a_uids) { // mark all message rows as read/unread - var icn_src; - var rows = this.message_list.rows; for (var i=0; i 0) - { - rows[uid].classname = rows[uid].classname.replace(/\s*deleted/, ''); - this.set_classname(rows[uid].obj, 'deleted', false); - } - - if (rows[uid].unread && this.env.unreadicon) - icn_src = this.env.unreadicon; - else if (rows[uid].replied && this.env.repliedicon) - { - if (rows[uid].forwarded && this.env.forwardedrepliedicon) - icn_src = this.env.forwardedrepliedicon; - else - icn_src = this.env.repliedicon; - } - else if (rows[uid].forwarded && this.env.forwardedicon) - icn_src = this.env.forwardedicon; - else if (this.env.messageicon) - icn_src = this.env.messageicon; - - if (rows[uid].icon && icn_src) - rows[uid].icon.src = icn_src; - } - } + this.set_message(a_uids[i], 'deleted', false); this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=undelete'); return true; @@ -1910,22 +1880,7 @@ function rcube_webmail() uid = a_uids[i]; if (rows[uid]) { - rows[uid].deleted = true; - - if (rows[uid].classname.indexOf('deleted')<0) - { - rows[uid].classname += ' deleted'; - this.set_classname(rows[uid].obj, 'deleted', true); - } - if (this.env.read_when_deleted) - { - rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); - this.set_classname(rows[uid].obj, 'unread', false); - } - - if (rows[uid].icon && this.env.deletedicon) - rows[uid].icon.src = this.env.deletedicon; - + this.set_message(uid, 'deleted', true); if (rows[uid].unread) r_uids[r_uids.length] = uid; } @@ -1957,12 +1912,7 @@ function rcube_webmail() { rows[uid].unread = false; rows[uid].read = true; - - rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); - this.set_classname(rows[uid].obj, 'unread', false); - - if (rows[uid].icon) - rows[uid].icon.src = this.env.deletedicon; + this.set_message(uid); } } }; @@ -2360,7 +2310,6 @@ function rcube_webmail() /********* keyboard live-search methods *********/ /*********************************************************/ - // handler for keyboard events on address-fields this.ksearch_keypress = function(e, obj) { @@ -2581,7 +2530,6 @@ function rcube_webmail() /********* address book methods *********/ /*********************************************************/ - this.contactlist_keypress = function(list) { if (list.key_pressed == list.DELETE_KEY) @@ -3510,8 +3458,6 @@ function rcube_webmail() var icon = this.env.messageicon; if (flags.deleted && this.env.deletedicon) icon = this.env.deletedicon; - else if(flags.unread && this.env.unreadicon) - icon = this.env.unreadicon; else if (flags.replied && this.env.repliedicon) { if (flags.forwarded && this.env.forwardedrepliedicon) @@ -3521,6 +3467,8 @@ function rcube_webmail() } else if (flags.forwarded && this.env.forwardedicon) icon = this.env.forwardedicon; + else if(flags.unread && this.env.unreadicon) + icon = this.env.unreadicon; var col = document.createElement('TD'); col.className = 'icon'; @@ -3656,12 +3604,6 @@ function rcube_webmail() } }; - // update parent's mailboxlist (from preview) - this.set_unread_count_from_preview = function(mbox, count, set_title) - { - parent.rcmail.set_unread_count(mbox, count, set_title); - } - // add row to contacts list this.add_contact_row = function(cid, cols, select) { @@ -4233,4 +4175,3 @@ function call_init(o) window.setTimeout('if (window[\''+o+'\'] && window[\''+o+'\'].init) { '+o+'.init(); }', bw.win ? 500 : 200); } - diff --git a/program/js/list.js b/program/js/list.js index 5da2bb15b..62d473260 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -173,7 +173,7 @@ insert_row: function(row, attop) /** - * Set focur to the list + * Set focus to the list */ focus: function(e) { diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 0b15c98d9..e5ea85791 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -71,8 +71,8 @@ if ($_GET['_uid']) { $marked = $IMAP->set_flag($MESSAGE->uid, 'SEEN'); if($RCMAIL->action == 'preview' && $marked != -1) { - $OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); - $OUTPUT->command('mark_as_read_from_preview', $MESSAGE->uid); + $OUTPUT->command('parent.set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); + $OUTPUT->command('parent.set_message', $MESSAGE->uid, 'unread', false); } } -- cgit v1.2.3