From a9e6b480b5a02f55b4974d78b5bbe9778cfa9934 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 2 Apr 2009 16:29:17 -0600 Subject: [PATCH] Optimize thread/flag append. Fixes appending user status flag to a subject with pre-existing thread graphics. --- imp/js/src/DimpBase.js | 41 ++++++++++++++++++++++++++++++----------- imp/themes/screen-dimp.css | 2 +- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/imp/js/src/DimpBase.js b/imp/js/src/DimpBase.js index e7bd95ffe..6226c3263 100644 --- a/imp/js/src/DimpBase.js +++ b/imp/js/src/DimpBase.js @@ -18,6 +18,7 @@ var DimpBase = { pivotrow: -1, ppcache: {}, ppfifo: [], + tcache: {}, sfiltersfolder: $H({ sf_all: 'all', @@ -417,12 +418,17 @@ var DimpBase = { // Add thread graphics if (thread && thread.get(row.imapuid)) { elt = r.down('.msgSubject'); - tmp = elt.cloneNode(false); + tmp = document.createDocumentFragment(); u = thread.get(row.imapuid); $R(0, u.length, true).each(function(i) { - tmp.insert(new Element('SPAN', { className: 'threadImg threadImg' + u.charAt(i) })); - }); - elt.replace(tmp.insert(elt.getText().escapeHTML())); + var c = u.charAt(i); + if (!this.tcache[c]) { + this.tcache[c] = new Element('SPAN', { className: 'threadImg threadImg' + c }); + } + tmp.appendChild(this.tcache[c].cloneNode(false)); + }, this); + elt.select('SPAN.threadImg').invoke('remove'); + elt.insertBefore(tmp, elt.firstChild); } // Add context menu @@ -2196,15 +2202,20 @@ var DimpBase = { updateStatusFlags: function(row) { var bg = null, - f = document.createDocumentFragment(), + pf = document.createDocumentFragment(), r = $(row.domid), - s; + sf = document.createDocumentFragment(), + stat, sub; if (!r) { return; } - s = r.down('.msgStatus'); + stat = r.down('.msgStatus'); + sub = r.down('.msgSubject'); + + /* Clear existing user flags. */ + sub.select('.flagUser').invoke('remove'); row.flag.each(function(a) { var ptr = DIMP.conf.flags[a]; @@ -2214,13 +2225,13 @@ var DimpBase = { // need to truncate label text ourselves. ptr.elt = new Element('SPAN', { className: ptr.c, title: ptr.l }).setStyle({ background: ptr.b }).update(ptr.l.truncate(10)); } - r.down('.msgSubject').insert({ top: ptr.elt.cloneNode(true) }); + pf.appendChild(ptr.elt.cloneNode(true)); } else { if (!ptr.elt) { ptr.elt = new Element('DIV', { className: 'msgflags ' + ptr.c, title: ptr.l }); } r.addClassName(ptr.c); - f.appendChild(ptr.elt.cloneNode(false)); + sf.appendChild(ptr.elt.cloneNode(false)); if (ptr.b) { bg = ptr.b; } @@ -2228,9 +2239,17 @@ var DimpBase = { }); /* Clear existing flags. */ - s.down().nextSiblings().invoke('remove'); + stat.down().nextSiblings().invoke('remove'); + + /* Add flag graphics. */ + if (sf.firstChild) { + stat.appendChild(sf); + } + if (pf.firstChild) { + sub.insertBefore(pf, sub.lastChild); + } - s.appendChild(f); + /* Set (or reset) the background row color. */ r.setStyle({ background: bg }); }, diff --git a/imp/themes/screen-dimp.css b/imp/themes/screen-dimp.css index 3badb8b80..59af663ec 100644 --- a/imp/themes/screen-dimp.css +++ b/imp/themes/screen-dimp.css @@ -1018,7 +1018,7 @@ div.msgRow div.msgSubject span.flagUser { /* Thread images */ span.threadImg { margin-top: -4px; - margin-right: 0; + margin-right: 1px; } /* Other images */ -- 2.11.0