diff options
Diffstat (limited to 'program/js')
-rw-r--r-- | program/js/app.js | 45 | ||||
-rw-r--r-- | program/js/list.js | 29 |
2 files changed, 45 insertions, 29 deletions
diff --git a/program/js/app.js b/program/js/app.js index 5eae82351..2401e1e0c 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -217,6 +217,7 @@ function rcube_webmail() this.gui_objects.messagelist.parentNode.onmousedown = function(e){ return p.click_on_list(e); }; this.enable_command('toggle_status', 'toggle_flag', 'sort', true); + this.enable_command('set-listmode', this.env.threads && !this.env.search_request); // load messages this.command('list'); @@ -709,6 +710,10 @@ function rcube_webmail() this.list_contacts(props); break; + case 'set-listmode': + this.set_list_options(null, undefined, undefined, props == 'threads' ? 1 : 0); + break; + case 'sort': var sort_order = this.env.sort_order, sort_col = !this.env.disabled_sort_col ? props : this.env.sort_col; @@ -1753,7 +1758,7 @@ function rcube_webmail() this.init_message_row = function(row) { var i, fn = {}, self = this, uid = row.uid, - status_icon = (this.env.status_col != null ? 'status' : 'msg') + 'icn' + row.uid; + status_icon = (this.env.status_col != null ? 'status' : 'msg') + 'icn' + row.id; if (uid && this.env.messages[uid]) $.extend(row, this.env.messages[uid]); @@ -1765,17 +1770,17 @@ function rcube_webmail() // save message icon position too if (this.env.status_col != null) - row.msgicon = document.getElementById('msgicn'+row.uid); + row.msgicon = document.getElementById('msgicn'+row.id); else row.msgicon = row.icon; // set eventhandler to flag icon - if (this.env.flagged_col != null && (row.flagicon = document.getElementById('flagicn'+row.uid))) { + if (this.env.flagged_col != null && (row.flagicon = document.getElementById('flagicn'+row.id))) { fn.flagicon = function(e) { self.command('toggle_flag', uid); }; } // set event handler to thread expand/collapse icon - if (!row.depth && row.has_children && (row.expando = document.getElementById('rcmexpando'+row.uid))) { + if (!row.depth && row.has_children && (row.expando = document.getElementById('rcmexpando'+row.id))) { fn.expando = function(e) { self.expand_message_row(e, uid); }; } @@ -1837,7 +1842,7 @@ function rcube_webmail() + (flags.deleted ? ' deleted' : '') + (flags.flagged ? ' flagged' : '') + (message.selected ? ' selected' : ''), - row = { cols:[], style:{}, id:'rcmrow'+uid }; + row = { cols:[], style:{}, id:'rcmrow'+this.html_identifier(uid,true), uid:uid }; // message status icons css_class = 'msgicon'; @@ -1863,7 +1868,7 @@ function rcube_webmail() if (this.env.threading) { if (message.depth) { // This assumes that div width is hardcoded to 15px, - tree += '<span id="rcmtab' + uid + '" class="branch" style="width:' + (message.depth * 15) + 'px;"> </span>'; + tree += '<span id="rcmtab' + row.id + '" class="branch" style="width:' + (message.depth * 15) + 'px;"> </span>'; if ((rows[message.parent_uid] && rows[message.parent_uid].expanded === false) || ((this.env.autoexpand_threads == 0 || this.env.autoexpand_threads == 2) && @@ -1882,7 +1887,7 @@ function rcube_webmail() message.expanded = true; } - expando = '<div id="rcmexpando' + uid + '" class="' + (message.expanded ? 'expanded' : 'collapsed') + '"> </div>'; + expando = '<div id="rcmexpando' + row.id + '" class="' + (message.expanded ? 'expanded' : 'collapsed') + '"> </div>'; row_class += ' thread' + (message.expanded? ' expanded' : ''); } @@ -1890,14 +1895,14 @@ function rcube_webmail() row_class += ' unroot'; } - tree += '<span id="msgicn'+uid+'" class="'+css_class+'"> </span>'; + tree += '<span id="msgicn'+row.id+'" class="'+css_class+'"> </span>'; row.className = row_class; // build subject link if (!bw.ie && cols.subject) { var action = flags.mbox == this.env.drafts_mailbox ? 'compose' : 'show'; var uid_param = flags.mbox == this.env.drafts_mailbox ? '_draft_uid' : '_uid'; - cols.subject = '<a href="./?_task=mail&_action='+action+'&_mbox='+urlencode(flags.mbox)+'&'+uid_param+'='+uid+'"'+ + cols.subject = '<a href="./?_task=mail&_action='+action+'&_mbox='+urlencode(flags.mbox)+'&'+uid_param+'='+urlencode(uid)+'"'+ ' onclick="return rcube_event.cancel(event)" onmouseover="rcube_webmail.long_subject_title(this,'+(message.depth+1)+')">'+cols.subject+'</a>'; } @@ -1908,7 +1913,7 @@ function rcube_webmail() if (c == 'flag') { css_class = (flags.flagged ? 'flagged' : 'unflagged'); - html = '<span id="flagicn'+uid+'" class="'+css_class+'"> </span>'; + html = '<span id="flagicn'+row.id+'" class="'+css_class+'"> </span>'; } else if (c == 'attachment') { if (/application\/|multipart\/(m|signed)/.test(flags.ctype)) @@ -1927,7 +1932,7 @@ function rcube_webmail() css_class = 'unreadchildren'; else css_class = 'msgicon'; - html = '<span id="statusicn'+uid+'" class="'+css_class+'"> </span>'; + html = '<span id="statusicn'+row.id+'" class="'+css_class+'"> </span>'; } else if (c == 'threads') html = expando; @@ -2390,7 +2395,7 @@ function rcube_webmail() } if (html) - $('#rcmtab'+uid).html(html); + $('#rcmtab'+this.html_identifier(uid, true)).html(html); }; // update parent in a thread @@ -2454,14 +2459,14 @@ function rcube_webmail() r.depth--; // move left // reset width and clear the content of a tab, icons will be added later - $('#rcmtab'+r.uid).width(r.depth * 15).html(''); + $('#rcmtab'+r.id).width(r.depth * 15).html(''); if (!r.depth) { // a new root count++; // increase roots count r.parent_uid = 0; if (r.has_children) { // replace 'leaf' with 'collapsed' - $('#rcmrow'+r.uid+' '+'.leaf:first') - .attr('id', 'rcmexpando' + r.uid) + $('#'+r.id+' .leaf:first') + .attr('id', 'rcmexpando' + r.id) .attr('class', (r.obj.style.display != 'none' ? 'expanded' : 'collapsed')) .bind('mousedown', {uid:r.uid, p:this}, function(e) { return e.data.p.expand_message_row(e, e.data.uid); }); @@ -4118,6 +4123,7 @@ function rcube_webmail() r = this.http_request(action, url, lock); this.env.qsearch = {lock: lock, request: r}; + this.enable_command('set-listmode', this.env.threads && (this.env.search_scope || 'base') == 'base'); } }; @@ -4126,7 +4132,8 @@ function rcube_webmail() { var n, url = {}, mods_arr = [], mods = this.env.search_mods, - mbox = this.env.mailbox; + mbox = this.env.mailbox, + scope = this.env.search_scope || 'base'; if (!filter && this.gui_objects.search_filter) filter = this.gui_objects.search_filter.value; @@ -4150,7 +4157,9 @@ function rcube_webmail() } } - if (mbox) + if (scope) + url._scope = scope; + if (mbox && scope != 'all') url._mbox = mbox; return url; @@ -4168,6 +4177,8 @@ function rcube_webmail() this.env.qsearch = null; this.env.search_request = null; this.env.search_id = null; + + this.enable_command('set-listmode', this.env.threads); }; this.sent_successfully = function(type, msg, folders) diff --git a/program/js/list.js b/program/js/list.js index 319807eae..c026ccb4a 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -107,11 +107,15 @@ init: function() */ init_row: function(row) { - // make references in internal array and set event handlers - if (row && String(row.id).match(this.id_regexp)) { - var self = this, - uid = RegExp.$1; + var uid; + if (row && (uid = $(row).data('uid'))) row.uid = uid; + else if (row && String(row.id).match(this.id_regexp)) + row.uid = RegExp.$1; + + // make references in internal array and set event handlers + if (row && row.uid) { + var self = this, uid = row.uid; this.rows[uid] = {uid:uid, id:row.id, obj:row}; // set eventhandlers to table row @@ -291,6 +295,7 @@ insert_row: function(row, before) if (row.id) domrow.id = row.id; if (row.className) domrow.className = row.className; if (row.style) $.extend(domrow.style, row.style); + if (row.uid) $(domrow).data('uid', row.uid); for (var domcell, col, i=0; row.cols && i < row.cols.length; i++) { col = row.cols[i]; @@ -589,7 +594,7 @@ expand: function(row) row.expanded = true; depth = row.depth; new_row = row.obj.nextSibling; - this.update_expando(row.uid, true); + this.update_expando(row.id, true); this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj }); } else { @@ -639,7 +644,7 @@ collapse_all: function(row) row.expanded = false; depth = row.depth; new_row = row.obj.nextSibling; - this.update_expando(row.uid); + this.update_expando(row.id); this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj }); // don't collapse sub-root tree in multiexpand mode @@ -661,7 +666,7 @@ collapse_all: function(row) $(new_row).css('display', 'none'); if (r.has_children && r.expanded) { r.expanded = false; - this.update_expando(r.uid, false); + this.update_expando(r.id, false); this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded, obj:new_row }); } } @@ -683,7 +688,7 @@ expand_all: function(row) row.expanded = true; depth = row.depth; new_row = row.obj.nextSibling; - this.update_expando(row.uid, true); + this.update_expando(row.id, true); this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj }); } else { @@ -700,7 +705,7 @@ expand_all: function(row) $(new_row).css('display', ''); if (r.has_children && !r.expanded) { r.expanded = true; - this.update_expando(r.uid, true); + this.update_expando(r.id, true); this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded, obj:new_row }); } } @@ -714,9 +719,9 @@ expand_all: function(row) }, -update_expando: function(uid, expanded) +update_expando: function(id, expanded) { - var expando = document.getElementById('rcmexpando' + uid); + var expando = document.getElementById('rcmexpando' + id); if (expando) expando.className = expanded ? 'expanded' : 'collapsed'; }, @@ -1267,7 +1272,7 @@ use_arrow_key: function(keyCode, mod_key) this.collapse(selected_row); } - this.update_expando(selected_row.uid, selected_row.expanded); + this.update_expando(selected_row.id, selected_row.expanded); return false; } |