- small improvements

release-0.6
alecpl 15 years ago
parent b00ba6e6de
commit 54531f1d7f

@ -1969,8 +1969,8 @@ function rcube_webmail()
this.init_threads = function(roots) this.init_threads = function(roots)
{ {
for (var n=0, len=roots.length; n<len; n++) for (var n=0, len=roots.length; n<len; n++)
setTimeout(function() { rcmail.add_tree_icons(roots[n]);}, 1); this.add_tree_icons(roots[n]);
setTimeout(function() { rcmail.expand_threads();}, 1); this.expand_threads();
}; };
// adds threads tree icons to the list (or specified thread) // adds threads tree icons to the list (or specified thread)

@ -148,6 +148,7 @@ init_header: function()
clear: function(sel) clear: function(sel)
{ {
var tbody = document.createElement('tbody'); var tbody = document.createElement('tbody');
this.list.insertBefore(tbody, this.list.tBodies[0]); this.list.insertBefore(tbody, this.list.tBodies[0]);
this.list.removeChild(this.list.tBodies[1]); this.list.removeChild(this.list.tBodies[1]);
this.rows = []; this.rows = [];
@ -261,8 +262,9 @@ drag_column: function(e, col)
drag_row: function(e, id) drag_row: function(e, id)
{ {
// don't do anything (another action processed before) // don't do anything (another action processed before)
var evtarget = rcube_event.get_target(e); var evtarget = rcube_event.get_target(e),
var tagname = evtarget.tagName.toLowerCase(); tagname = evtarget.tagName.toLowerCase();
if (this.dont_select || (evtarget && (tagname == 'input' || tagname == 'img'))) if (this.dont_select || (evtarget && (tagname == 'input' || tagname == 'img')))
return true; return true;
@ -297,10 +299,10 @@ drag_row: function(e, id)
*/ */
click_row: function(e, id) click_row: function(e, id)
{ {
var now = new Date().getTime(); var now = new Date().getTime(),
var mod_key = rcube_event.get_modifier(e); mod_key = rcube_event.get_modifier(e),
var evtarget = rcube_event.get_target(e); evtarget = rcube_event.get_target(e),
var tagname = evtarget.tagName.toLowerCase(); tagname = evtarget.tagName.toLowerCase();
if ((evtarget && (tagname == 'input' || tagname == 'img'))) if ((evtarget && (tagname == 'input' || tagname == 'img')))
return true; return true;
@ -353,9 +355,9 @@ find_root: function(uid)
expand_row: function(e, id) expand_row: function(e, id)
{ {
var row = this.rows[id]; var row = this.rows[id],
var evtarget = rcube_event.get_target(e); evtarget = rcube_event.get_target(e),
var mod_key = rcube_event.get_modifier(e); mod_key = rcube_event.get_modifier(e);
// Don't select this message // Don't select this message
this.dont_select = true; this.dont_select = true;
@ -363,14 +365,14 @@ expand_row: function(e, id)
row.clicked = 0; row.clicked = 0;
if (row.expanded) { if (row.expanded) {
evtarget.className = "collapsed"; evtarget.className = 'collapsed';
if (mod_key == CONTROL_KEY || this.multiexpand) if (mod_key == CONTROL_KEY || this.multiexpand)
this.collapse_all(row); this.collapse_all(row);
else else
this.collapse(row); this.collapse(row);
} }
else { else {
evtarget.className = "expanded"; evtarget.className = 'expanded';
if (mod_key == CONTROL_KEY || this.multiexpand) if (mod_key == CONTROL_KEY || this.multiexpand)
this.expand_all(row); this.expand_all(row);
else else
@ -392,8 +394,10 @@ collapse: function(row)
if (r && r.depth <= depth) if (r && r.depth <= depth)
break; break;
$(new_row).hide(); $(new_row).hide();
r.expanded = false; if (r.expanded) {
this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded }); r.expanded = false;
this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded });
}
} }
new_row = new_row.nextSibling; new_row = new_row.nextSibling;
} }
@ -452,8 +456,7 @@ expand: function(row)
collapse_all: function(row) collapse_all: function(row)
{ {
var depth, new_row; var depth, new_row, r;
var r;
if (row) { if (row) {
row.expanded = false; row.expanded = false;
@ -464,27 +467,24 @@ collapse_all: function(row)
// don't collapse sub-root tree in multiexpand mode // don't collapse sub-root tree in multiexpand mode
if (depth && this.multiexpand) if (depth && this.multiexpand)
return false; return false;
} }
else { else {
var tbody = this.list.tBodies[0]; new_row = this.list.tBodies[0].firstChild;
new_row = tbody.firstChild;
depth = 0; depth = 0;
} }
while (new_row) { while (new_row) {
if (new_row.nodeType == 1) { if (new_row.nodeType == 1) {
var r = this.rows[new_row.uid]; if (r = this.rows[new_row.uid]) {
if (r) {
if (row && (!r.depth || r.depth <= depth)) if (row && (!r.depth || r.depth <= depth))
break; break;
if (row || r.depth) if (row || r.depth)
$(new_row).hide(); $(new_row).hide();
if (r.has_children) { if (r.has_children && r.expanded) {
r.expanded = false; r.expanded = false;
if (!r.depth || !this.multiexpand) this.update_expando(r.uid, false);
this.update_expando(r.uid, false);
this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded }); this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded });
} }
} }
@ -497,8 +497,7 @@ collapse_all: function(row)
expand_all: function(row) expand_all: function(row)
{ {
var depth, new_row; var depth, new_row, r;
var r;
if (row) { if (row) {
row.expanded = true; row.expanded = true;
@ -508,27 +507,20 @@ expand_all: function(row)
this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded }); this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded });
} }
else { else {
var tbody = this.list.tBodies[0]; new_row = this.list.tBodies[0].firstChild;
new_row = tbody.firstChild;
depth = 0; depth = 0;
} }
while (new_row) { while (new_row) {
if (new_row.nodeType == 1) { if (new_row.nodeType == 1) {
var r = this.rows[new_row.uid]; if (r = this.rows[new_row.uid]) {
if (r) {
if (row && r.depth <= depth) if (row && r.depth <= depth)
break; break;
$(new_row).show(); $(new_row).show();
if (r.has_children) { if (r.has_children && !r.expanded) {
r.expanded = true; r.expanded = true;
// in multiexpand mode only root has expando icon this.update_expando(r.uid, true);
// so we don't need to set it for children, this
// improves performance because getElementById()
// is relatively slow on IE
if (!r.depth || !this.multiexpand)
this.update_expando(r.uid, true);
this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded }); this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded });
} }
} }
@ -554,8 +546,9 @@ get_next_row: function()
if (!this.rows) if (!this.rows)
return false; return false;
var last_selected_row = this.rows[this.last_selected]; var last_selected_row = this.rows[this.last_selected],
var new_row = last_selected_row ? last_selected_row.obj.nextSibling : null; new_row = last_selected_row ? last_selected_row.obj.nextSibling : null;
while (new_row && (new_row.nodeType != 1 || new_row.style.display == 'none')) while (new_row && (new_row.nodeType != 1 || new_row.style.display == 'none'))
new_row = new_row.nextSibling; new_row = new_row.nextSibling;
@ -567,8 +560,9 @@ get_prev_row: function()
if (!this.rows) if (!this.rows)
return false; return false;
var last_selected_row = this.rows[this.last_selected]; var last_selected_row = this.rows[this.last_selected],
var new_row = last_selected_row ? last_selected_row.obj.previousSibling : null; new_row = last_selected_row ? last_selected_row.obj.previousSibling : null;
while (new_row && (new_row.nodeType != 1 || new_row.style.display == 'none')) while (new_row && (new_row.nodeType != 1 || new_row.style.display == 'none'))
new_row = new_row.previousSibling; new_row = new_row.previousSibling;

Loading…
Cancel
Save