|
|
@ -22,18 +22,18 @@
|
|
|
|
* @contructor
|
|
|
|
* @contructor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function rcube_list_widget(list, p)
|
|
|
|
function rcube_list_widget(list, p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// static contants
|
|
|
|
// static contants
|
|
|
|
this.ENTER_KEY = 13;
|
|
|
|
this.ENTER_KEY = 13;
|
|
|
|
this.DELETE_KEY = 46;
|
|
|
|
this.DELETE_KEY = 46;
|
|
|
|
this.BACKSPACE_KEY = 8;
|
|
|
|
this.BACKSPACE_KEY = 8;
|
|
|
|
|
|
|
|
|
|
|
|
this.list = list ? list : null;
|
|
|
|
this.list = list ? list : null;
|
|
|
|
this.frame = null;
|
|
|
|
this.frame = null;
|
|
|
|
this.rows = [];
|
|
|
|
this.rows = [];
|
|
|
|
this.selection = [];
|
|
|
|
this.selection = [];
|
|
|
|
this.rowcount = 0;
|
|
|
|
this.rowcount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
this.subject_col = -1;
|
|
|
|
this.subject_col = -1;
|
|
|
|
this.shiftkey = false;
|
|
|
|
this.shiftkey = false;
|
|
|
|
this.multiselect = false;
|
|
|
|
this.multiselect = false;
|
|
|
@ -42,7 +42,7 @@ function rcube_list_widget(list, p)
|
|
|
|
this.draggable = false;
|
|
|
|
this.draggable = false;
|
|
|
|
this.keyboard = false;
|
|
|
|
this.keyboard = false;
|
|
|
|
this.toggleselect = false;
|
|
|
|
this.toggleselect = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.dont_select = false;
|
|
|
|
this.dont_select = false;
|
|
|
|
this.drag_active = false;
|
|
|
|
this.drag_active = false;
|
|
|
|
this.last_selected = 0;
|
|
|
|
this.last_selected = 0;
|
|
|
@ -52,12 +52,12 @@ function rcube_list_widget(list, p)
|
|
|
|
this.drag_mouse_start = null;
|
|
|
|
this.drag_mouse_start = null;
|
|
|
|
this.dblclick_time = 600;
|
|
|
|
this.dblclick_time = 600;
|
|
|
|
this.row_init = function(){};
|
|
|
|
this.row_init = function(){};
|
|
|
|
|
|
|
|
|
|
|
|
// overwrite default paramaters
|
|
|
|
// overwrite default paramaters
|
|
|
|
if (p && typeof(p)=='object')
|
|
|
|
if (p && typeof(p) == 'object')
|
|
|
|
for (var n in p)
|
|
|
|
for (var n in p)
|
|
|
|
this[n] = p[n];
|
|
|
|
this[n] = p[n];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rcube_list_widget.prototype = {
|
|
|
|
rcube_list_widget.prototype = {
|
|
|
@ -68,17 +68,14 @@ rcube_list_widget.prototype = {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
init: function()
|
|
|
|
init: function()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (this.list && this.list.tBodies[0])
|
|
|
|
if (this.list && this.list.tBodies[0]) {
|
|
|
|
{
|
|
|
|
this.rows = [];
|
|
|
|
this.rows = new Array();
|
|
|
|
|
|
|
|
this.rowcount = 0;
|
|
|
|
this.rowcount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
var row;
|
|
|
|
var row;
|
|
|
|
for(var r=0; r<this.list.tBodies[0].childNodes.length; r++)
|
|
|
|
for(var r=0; r<this.list.tBodies[0].childNodes.length; r++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
row = this.list.tBodies[0].childNodes[r];
|
|
|
|
row = this.list.tBodies[0].childNodes[r];
|
|
|
|
while (row && row.nodeType != 1)
|
|
|
|
while (row && row.nodeType != 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
row = row.nextSibling;
|
|
|
|
row = row.nextSibling;
|
|
|
|
r++;
|
|
|
|
r++;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -104,8 +101,7 @@ init: function()
|
|
|
|
init_row: function(row)
|
|
|
|
init_row: function(row)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// make references in internal array and set event handlers
|
|
|
|
// make references in internal array and set event handlers
|
|
|
|
if (row && String(row.id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i))
|
|
|
|
if (row && String(row.id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
var p = this;
|
|
|
|
var p = this;
|
|
|
|
var uid = RegExp.$1;
|
|
|
|
var uid = RegExp.$1;
|
|
|
|
row.uid = uid;
|
|
|
|
row.uid = uid;
|
|
|
@ -131,10 +127,11 @@ 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 = new Array();
|
|
|
|
this.rows = [];
|
|
|
|
this.rowcount = 0;
|
|
|
|
this.rowcount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (sel) this.clear_selection();
|
|
|
|
if (sel)
|
|
|
|
|
|
|
|
this.clear_selection();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,8 +178,7 @@ insert_row: function(row, attop)
|
|
|
|
focus: function(e)
|
|
|
|
focus: function(e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.focused = true;
|
|
|
|
this.focused = true;
|
|
|
|
for (var n=0; n<this.selection.length; n++)
|
|
|
|
for (var n=0; n<this.selection.length; n++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
id = this.selection[n];
|
|
|
|
id = this.selection[n];
|
|
|
|
if (this.rows[id] && this.rows[id].obj) {
|
|
|
|
if (this.rows[id] && this.rows[id].obj) {
|
|
|
|
$(this.rows[id].obj).addClass('selected').removeClass('unfocused');
|
|
|
|
$(this.rows[id].obj).addClass('selected').removeClass('unfocused');
|
|
|
@ -201,8 +197,7 @@ blur: function()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var id;
|
|
|
|
var id;
|
|
|
|
this.focused = false;
|
|
|
|
this.focused = false;
|
|
|
|
for (var n=0; n<this.selection.length; n++)
|
|
|
|
for (var n=0; n<this.selection.length; n++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
id = this.selection[n];
|
|
|
|
id = this.selection[n];
|
|
|
|
if (this.rows[id] && this.rows[id].obj) {
|
|
|
|
if (this.rows[id] && this.rows[id].obj) {
|
|
|
|
$(this.rows[id].obj).removeClass('selected').addClass('unfocused');
|
|
|
|
$(this.rows[id].obj).removeClass('selected').addClass('unfocused');
|
|
|
@ -221,22 +216,20 @@ drag_row: function(e, id)
|
|
|
|
var tagname = evtarget.tagName.toLowerCase();
|
|
|
|
var 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;
|
|
|
|
|
|
|
|
|
|
|
|
// accept right-clicks
|
|
|
|
// accept right-clicks
|
|
|
|
if (rcube_event.get_button(e) == 2)
|
|
|
|
if (rcube_event.get_button(e) == 2)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
this.in_selection_before = this.in_selection(id) ? id : false;
|
|
|
|
this.in_selection_before = this.in_selection(id) ? id : false;
|
|
|
|
|
|
|
|
|
|
|
|
// selects currently unselected row
|
|
|
|
// selects currently unselected row
|
|
|
|
if (!this.in_selection_before)
|
|
|
|
if (!this.in_selection_before) {
|
|
|
|
{
|
|
|
|
|
|
|
|
var mod_key = rcube_event.get_modifier(e);
|
|
|
|
var mod_key = rcube_event.get_modifier(e);
|
|
|
|
this.select_row(id, mod_key, false);
|
|
|
|
this.select_row(id, mod_key, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.draggable && this.selection.length)
|
|
|
|
if (this.draggable && this.selection.length) {
|
|
|
|
{
|
|
|
|
|
|
|
|
this.drag_start = true;
|
|
|
|
this.drag_start = true;
|
|
|
|
this.drag_mouse_start = rcube_event.get_mouse_pos(e);
|
|
|
|
this.drag_mouse_start = rcube_event.get_mouse_pos(e);
|
|
|
|
rcube_event.add_listener({event:'mousemove', object:this, method:'drag_mouse_move'});
|
|
|
|
rcube_event.add_listener({event:'mousemove', object:this, method:'drag_mouse_move'});
|
|
|
@ -272,12 +265,11 @@ click_row: function(e, id)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
// don't do anything (another action processed before)
|
|
|
|
// don't do anything (another action processed before)
|
|
|
|
if (this.dont_select)
|
|
|
|
if (this.dont_select) {
|
|
|
|
{
|
|
|
|
|
|
|
|
this.dont_select = false;
|
|
|
|
this.dont_select = false;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var dblclicked = now - this.rows[id].clicked < this.dblclick_time;
|
|
|
|
var dblclicked = now - this.rows[id].clicked < this.dblclick_time;
|
|
|
|
|
|
|
|
|
|
|
|
// unselects currently selected row
|
|
|
|
// unselects currently selected row
|
|
|
@ -425,7 +417,7 @@ collapse_all: function(row)
|
|
|
|
new_row = row.obj.nextSibling;
|
|
|
|
new_row = row.obj.nextSibling;
|
|
|
|
this.update_expando(row.uid);
|
|
|
|
this.update_expando(row.uid);
|
|
|
|
this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded });
|
|
|
|
this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded });
|
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
@ -535,28 +527,28 @@ get_prev_row: function()
|
|
|
|
|
|
|
|
|
|
|
|
get_first_row: function()
|
|
|
|
get_first_row: function()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (this.rowcount)
|
|
|
|
if (this.rowcount) {
|
|
|
|
{
|
|
|
|
|
|
|
|
var rows = this.list.tBodies[0].rows;
|
|
|
|
var rows = this.list.tBodies[0].rows;
|
|
|
|
|
|
|
|
|
|
|
|
for(var i=0; i<rows.length-1; i++)
|
|
|
|
for(var i=0; i<rows.length-1; i++)
|
|
|
|
if(rows[i].id && String(rows[i].id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null)
|
|
|
|
if(rows[i].id && String(rows[i].id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null)
|
|
|
|
|
|
|
|
|
|
|
|
return RegExp.$1;
|
|
|
|
return RegExp.$1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
get_last_row: function()
|
|
|
|
get_last_row: function()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (this.rowcount)
|
|
|
|
if (this.rowcount) {
|
|
|
|
{
|
|
|
|
|
|
|
|
var rows = this.list.tBodies[0].rows;
|
|
|
|
var rows = this.list.tBodies[0].rows;
|
|
|
|
|
|
|
|
|
|
|
|
for(var i=rows.length-1; i>=0; i--)
|
|
|
|
for(var i=rows.length-1; i>=0; i--)
|
|
|
|
if(rows[i].id && String(rows[i].id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null)
|
|
|
|
if(rows[i].id && String(rows[i].id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null)
|
|
|
|
|
|
|
|
|
|
|
|
return RegExp.$1;
|
|
|
|
return RegExp.$1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -570,20 +562,17 @@ select_row: function(id, mod_key, with_mouse)
|
|
|
|
var select_before = this.selection.join(',');
|
|
|
|
var select_before = this.selection.join(',');
|
|
|
|
if (!this.multiselect)
|
|
|
|
if (!this.multiselect)
|
|
|
|
mod_key = 0;
|
|
|
|
mod_key = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.shift_start)
|
|
|
|
if (!this.shift_start)
|
|
|
|
this.shift_start = id
|
|
|
|
this.shift_start = id
|
|
|
|
|
|
|
|
|
|
|
|
if (!mod_key)
|
|
|
|
if (!mod_key) {
|
|
|
|
{
|
|
|
|
|
|
|
|
this.shift_start = id;
|
|
|
|
this.shift_start = id;
|
|
|
|
this.highlight_row(id, false);
|
|
|
|
this.highlight_row(id, false);
|
|
|
|
this.multi_selecting = false;
|
|
|
|
this.multi_selecting = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else {
|
|
|
|
{
|
|
|
|
switch (mod_key) {
|
|
|
|
switch (mod_key)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case SHIFT_KEY:
|
|
|
|
case SHIFT_KEY:
|
|
|
|
this.shift_select(id, false);
|
|
|
|
this.shift_select(id, false);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -612,8 +601,7 @@ select_row: function(id, mod_key, with_mouse)
|
|
|
|
$(this.rows[this.last_selected].obj).removeClass('focused');
|
|
|
|
$(this.rows[this.last_selected].obj).removeClass('focused');
|
|
|
|
|
|
|
|
|
|
|
|
// unselect if toggleselect is active and the same row was clicked again
|
|
|
|
// unselect if toggleselect is active and the same row was clicked again
|
|
|
|
if (this.toggleselect && this.last_selected == id)
|
|
|
|
if (this.toggleselect && this.last_selected == id) {
|
|
|
|
{
|
|
|
|
|
|
|
|
this.clear_selection();
|
|
|
|
this.clear_selection();
|
|
|
|
id = null;
|
|
|
|
id = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -690,7 +678,7 @@ select_childs: function(uid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!this.rows[uid] || !this.rows[uid].has_children)
|
|
|
|
if (!this.rows[uid] || !this.rows[uid].has_children)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
var depth = this.rows[uid].depth;
|
|
|
|
var depth = this.rows[uid].depth;
|
|
|
|
var row = this.rows[uid].obj.nextSibling;
|
|
|
|
var row = this.rows[uid].obj.nextSibling;
|
|
|
|
while (row) {
|
|
|
|
while (row) {
|
|
|
@ -722,16 +710,13 @@ shift_select: function(id, control)
|
|
|
|
var j = ((from_rowIndex > to_rowIndex)? from_rowIndex : to_rowIndex);
|
|
|
|
var j = ((from_rowIndex > to_rowIndex)? from_rowIndex : to_rowIndex);
|
|
|
|
|
|
|
|
|
|
|
|
// iterate through the entire message list
|
|
|
|
// iterate through the entire message list
|
|
|
|
for (var n in this.rows)
|
|
|
|
for (var n in this.rows) {
|
|
|
|
{
|
|
|
|
if ((this.rows[n].obj.rowIndex >= i) && (this.rows[n].obj.rowIndex <= j)) {
|
|
|
|
if ((this.rows[n].obj.rowIndex >= i) && (this.rows[n].obj.rowIndex <= j))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!this.in_selection(n)) {
|
|
|
|
if (!this.in_selection(n)) {
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this.in_selection(n) && !control) {
|
|
|
|
if (this.in_selection(n) && !control) {
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -763,17 +748,14 @@ select_all: function(filter)
|
|
|
|
|
|
|
|
|
|
|
|
// reset but remember selection first
|
|
|
|
// reset but remember selection first
|
|
|
|
var select_before = this.selection.join(',');
|
|
|
|
var select_before = this.selection.join(',');
|
|
|
|
this.selection = new Array();
|
|
|
|
this.selection = [];
|
|
|
|
|
|
|
|
|
|
|
|
for (var n in this.rows)
|
|
|
|
for (var n in this.rows) {
|
|
|
|
{
|
|
|
|
if (!filter || (this.rows[n] && this.rows[n][filter] == true)) {
|
|
|
|
if (!filter || (this.rows[n] && this.rows[n][filter] == true))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.last_selected = n;
|
|
|
|
this.last_selected = n;
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (this.rows[n])
|
|
|
|
else if (this.rows[n]) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$(this.rows[n].obj).removeClass('selected').removeClass('unfocused');
|
|
|
|
$(this.rows[n].obj).removeClass('selected').removeClass('unfocused');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -798,7 +780,7 @@ invert_selection: function()
|
|
|
|
|
|
|
|
|
|
|
|
// remember old selection
|
|
|
|
// remember old selection
|
|
|
|
var select_before = this.selection.join(',');
|
|
|
|
var select_before = this.selection.join(',');
|
|
|
|
|
|
|
|
|
|
|
|
for (var n in this.rows)
|
|
|
|
for (var n in this.rows)
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
this.highlight_row(n, true);
|
|
|
|
|
|
|
|
|
|
|
@ -820,24 +802,22 @@ clear_selection: function(id)
|
|
|
|
var num_select = this.selection.length;
|
|
|
|
var num_select = this.selection.length;
|
|
|
|
|
|
|
|
|
|
|
|
// one row
|
|
|
|
// one row
|
|
|
|
if (id)
|
|
|
|
if (id) {
|
|
|
|
{
|
|
|
|
|
|
|
|
for (var n=0; n<this.selection.length; n++)
|
|
|
|
for (var n=0; n<this.selection.length; n++)
|
|
|
|
if (this.selection[n] == id) {
|
|
|
|
if (this.selection[n] == id) {
|
|
|
|
this.selection.splice(n,1);
|
|
|
|
this.selection.splice(n,1);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// all rows
|
|
|
|
// all rows
|
|
|
|
else
|
|
|
|
else {
|
|
|
|
{
|
|
|
|
|
|
|
|
for (var n=0; n<this.selection.length; n++)
|
|
|
|
for (var n=0; n<this.selection.length; n++)
|
|
|
|
if (this.rows[this.selection[n]]) {
|
|
|
|
if (this.rows[this.selection[n]]) {
|
|
|
|
$(this.rows[this.selection[n]].obj).removeClass('selected').removeClass('unfocused');
|
|
|
|
$(this.rows[this.selection[n]].obj).removeClass('selected').removeClass('unfocused');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.selection = new Array();
|
|
|
|
this.selection = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (num_select && !this.selection.length)
|
|
|
|
if (num_select && !this.selection.length)
|
|
|
|
this.triggerEvent('select');
|
|
|
|
this.triggerEvent('select');
|
|
|
@ -870,25 +850,20 @@ get_single_selection: function()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
highlight_row: function(id, multiple)
|
|
|
|
highlight_row: function(id, multiple)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (this.rows[id] && !multiple)
|
|
|
|
if (this.rows[id] && !multiple) {
|
|
|
|
{
|
|
|
|
if (this.selection.length > 1 || !this.in_selection(id)) {
|
|
|
|
if (this.selection.length > 1 || !this.in_selection(id))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.clear_selection();
|
|
|
|
this.clear_selection();
|
|
|
|
this.selection[0] = id;
|
|
|
|
this.selection[0] = id;
|
|
|
|
$(this.rows[id].obj).addClass('selected');
|
|
|
|
$(this.rows[id].obj).addClass('selected');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (this.rows[id])
|
|
|
|
else if (this.rows[id]) {
|
|
|
|
{
|
|
|
|
if (!this.in_selection(id)) { // select row
|
|
|
|
if (!this.in_selection(id)) // select row
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.selection[this.selection.length] = id;
|
|
|
|
this.selection[this.selection.length] = id;
|
|
|
|
$(this.rows[id].obj).addClass('selected');
|
|
|
|
$(this.rows[id].obj).addClass('selected');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // unselect row
|
|
|
|
else { // unselect row
|
|
|
|
{
|
|
|
|
var p = $.inArray(id, this.selection);
|
|
|
|
var p = jQuery.inArray(id, this.selection);
|
|
|
|
|
|
|
|
var a_pre = this.selection.slice(0, p);
|
|
|
|
var a_pre = this.selection.slice(0, p);
|
|
|
|
var a_post = this.selection.slice(p+1, this.selection.length);
|
|
|
|
var a_post = this.selection.slice(p+1, this.selection.length);
|
|
|
|
this.selection = a_pre.concat(a_post);
|
|
|
|
this.selection = a_pre.concat(a_post);
|
|
|
@ -909,8 +884,7 @@ key_press: function(e)
|
|
|
|
var keyCode = rcube_event.get_keycode(e);
|
|
|
|
var keyCode = rcube_event.get_keycode(e);
|
|
|
|
var mod_key = rcube_event.get_modifier(e);
|
|
|
|
var mod_key = rcube_event.get_modifier(e);
|
|
|
|
|
|
|
|
|
|
|
|
switch (keyCode)
|
|
|
|
switch (keyCode) {
|
|
|
|
{
|
|
|
|
|
|
|
|
case 40:
|
|
|
|
case 40:
|
|
|
|
case 38:
|
|
|
|
case 38:
|
|
|
|
case 63233: // "down", in safari keypress
|
|
|
|
case 63233: // "down", in safari keypress
|
|
|
@ -938,11 +912,11 @@ key_press: function(e)
|
|
|
|
this.shiftkey = e.shiftKey;
|
|
|
|
this.shiftkey = e.shiftKey;
|
|
|
|
this.key_pressed = keyCode;
|
|
|
|
this.key_pressed = keyCode;
|
|
|
|
this.triggerEvent('keypress');
|
|
|
|
this.triggerEvent('keypress');
|
|
|
|
|
|
|
|
|
|
|
|
if (this.key_pressed == this.BACKSPACE_KEY)
|
|
|
|
if (this.key_pressed == this.BACKSPACE_KEY)
|
|
|
|
return rcube_event.cancel(e);
|
|
|
|
return rcube_event.cancel(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -951,12 +925,11 @@ key_press: function(e)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
key_down: function(e)
|
|
|
|
key_down: function(e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (rcube_event.get_keycode(e))
|
|
|
|
switch (rcube_event.get_keycode(e)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
case 27:
|
|
|
|
case 27:
|
|
|
|
if (this.drag_active)
|
|
|
|
if (this.drag_active)
|
|
|
|
return this.drag_mouse_up(e);
|
|
|
|
return this.drag_mouse_up(e);
|
|
|
|
|
|
|
|
|
|
|
|
case 40:
|
|
|
|
case 40:
|
|
|
|
case 38:
|
|
|
|
case 38:
|
|
|
|
case 63233:
|
|
|
|
case 63233:
|
|
|
@ -967,10 +940,10 @@ key_down: function(e)
|
|
|
|
case 32:
|
|
|
|
case 32:
|
|
|
|
if (!rcube_event.get_modifier(e) && this.focused)
|
|
|
|
if (!rcube_event.get_modifier(e) && this.focused)
|
|
|
|
return rcube_event.cancel(e);
|
|
|
|
return rcube_event.cancel(e);
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -988,8 +961,7 @@ use_arrow_key: function(keyCode, mod_key)
|
|
|
|
else if (keyCode == 38 || keyCode == 63232) // up arrow key pressed
|
|
|
|
else if (keyCode == 38 || keyCode == 63232) // up arrow key pressed
|
|
|
|
new_row = this.get_prev_row();
|
|
|
|
new_row = this.get_prev_row();
|
|
|
|
|
|
|
|
|
|
|
|
if (new_row)
|
|
|
|
if (new_row) {
|
|
|
|
{
|
|
|
|
|
|
|
|
this.select_row(new_row.uid, mod_key, true);
|
|
|
|
this.select_row(new_row.uid, mod_key, true);
|
|
|
|
this.scrollto(new_row.uid);
|
|
|
|
this.scrollto(new_row.uid);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1034,8 +1006,7 @@ use_plusminus_key: function(keyCode, mod_key)
|
|
|
|
scrollto: function(id)
|
|
|
|
scrollto: function(id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var row = this.rows[id].obj;
|
|
|
|
var row = this.rows[id].obj;
|
|
|
|
if (row && this.frame)
|
|
|
|
if (row && this.frame) {
|
|
|
|
{
|
|
|
|
|
|
|
|
var scroll_to = Number(row.offsetTop);
|
|
|
|
var scroll_to = Number(row.offsetTop);
|
|
|
|
|
|
|
|
|
|
|
|
// expand thread if target row is hidden (collapsed)
|
|
|
|
// expand thread if target row is hidden (collapsed)
|
|
|
@ -1058,17 +1029,16 @@ scrollto: function(id)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
drag_mouse_move: function(e)
|
|
|
|
drag_mouse_move: function(e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (this.drag_start)
|
|
|
|
if (this.drag_start) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// check mouse movement, of less than 3 pixels, don't start dragging
|
|
|
|
// check mouse movement, of less than 3 pixels, don't start dragging
|
|
|
|
var m = rcube_event.get_mouse_pos(e);
|
|
|
|
var m = rcube_event.get_mouse_pos(e);
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.drag_mouse_start || (Math.abs(m.x - this.drag_mouse_start.x) < 3 && Math.abs(m.y - this.drag_mouse_start.y) < 3))
|
|
|
|
if (!this.drag_mouse_start || (Math.abs(m.x - this.drag_mouse_start.x) < 3 && Math.abs(m.y - this.drag_mouse_start.y) < 3))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.draglayer)
|
|
|
|
if (!this.draglayer)
|
|
|
|
this.draglayer = $('<div>').attr('id', 'rcmdraglayer').css({ position:'absolute', display:'none', 'z-index':2000 }).appendTo(document.body);
|
|
|
|
this.draglayer = $('<div>').attr('id', 'rcmdraglayer').css({ position:'absolute', display:'none', 'z-index':2000 }).appendTo(document.body);
|
|
|
|
|
|
|
|
|
|
|
|
// also select childs of (collapsed) threads for dragging
|
|
|
|
// also select childs of (collapsed) threads for dragging
|
|
|
|
var selection = $.merge([], this.selection);
|
|
|
|
var selection = $.merge([], this.selection);
|
|
|
|
var depth, row, uid, r;
|
|
|
|
var depth, row, uid, r;
|
|
|
@ -1081,42 +1051,37 @@ drag_mouse_move: function(e)
|
|
|
|
// get subjects of selected messages
|
|
|
|
// get subjects of selected messages
|
|
|
|
var names = '';
|
|
|
|
var names = '';
|
|
|
|
var c, i, subject, obj;
|
|
|
|
var c, i, subject, obj;
|
|
|
|
for(var n=0; n<this.selection.length; n++)
|
|
|
|
for(var n=0; n<this.selection.length; n++) {
|
|
|
|
{
|
|
|
|
// only show 12 lines
|
|
|
|
if (n>12) // only show 12 lines
|
|
|
|
if (n>12) {
|
|
|
|
{
|
|
|
|
|
|
|
|
names += '...';
|
|
|
|
names += '...';
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (obj = this.rows[this.selection[n]].obj)
|
|
|
|
if (obj = this.rows[this.selection[n]].obj) {
|
|
|
|
{
|
|
|
|
|
|
|
|
subject = '';
|
|
|
|
subject = '';
|
|
|
|
|
|
|
|
|
|
|
|
for (c=0, i=0; i<obj.childNodes.length; i++)
|
|
|
|
for (c=0, i=0; i<obj.childNodes.length; i++) {
|
|
|
|
{
|
|
|
|
if (obj.childNodes[i].nodeName == 'TD') {
|
|
|
|
if (obj.childNodes[i].nodeName == 'TD')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
if (n == 0)
|
|
|
|
this.drag_start_pos = $(obj.childNodes[i]).offset();
|
|
|
|
this.drag_start_pos = $(obj.childNodes[i]).offset();
|
|
|
|
|
|
|
|
|
|
|
|
if (this.subject_col < 0 || (this.subject_col >= 0 && this.subject_col == c))
|
|
|
|
if (this.subject_col < 0 || (this.subject_col >= 0 && this.subject_col == c)) {
|
|
|
|
{
|
|
|
|
var node, tmp_node, nodes = obj.childNodes[i].childNodes;
|
|
|
|
var node, tmp_node, nodes = obj.childNodes[i].childNodes;
|
|
|
|
// find text node
|
|
|
|
// find text node
|
|
|
|
for (m=0; m<nodes.length; m++) {
|
|
|
|
for (m=0; m<nodes.length; m++) {
|
|
|
|
if ((tmp_node = obj.childNodes[i].childNodes[m]) && (tmp_node.nodeType==3 || tmp_node.nodeName=='A'))
|
|
|
|
if ((tmp_node = obj.childNodes[i].childNodes[m]) && (tmp_node.nodeType==3 || tmp_node.nodeName=='A'))
|
|
|
|
node = tmp_node;
|
|
|
|
node = tmp_node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!node)
|
|
|
|
if (!node)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subject = node.nodeType==3 ? node.data : node.innerHTML;
|
|
|
|
subject = node.nodeType==3 ? node.data : node.innerHTML;
|
|
|
|
// remove leading spaces
|
|
|
|
// remove leading spaces
|
|
|
|
subject = subject.replace(/^\s+/i, '');
|
|
|
|
subject = subject.replace(/^\s+/i, '');
|
|
|
|
// truncate line to 50 characters
|
|
|
|
// truncate line to 50 characters
|
|
|
|
names += (subject.length > 50 ? subject.substring(0, 50)+'...' : subject) + '<br />';
|
|
|
|
names += (subject.length > 50 ? subject.substring(0, 50)+'...' : subject) + '<br />';
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c++;
|
|
|
|
c++;
|
|
|
@ -1132,8 +1097,7 @@ drag_mouse_move: function(e)
|
|
|
|
this.triggerEvent('dragstart');
|
|
|
|
this.triggerEvent('dragstart');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.drag_active && this.draglayer)
|
|
|
|
if (this.drag_active && this.draglayer) {
|
|
|
|
{
|
|
|
|
|
|
|
|
var pos = rcube_event.get_mouse_pos(e);
|
|
|
|
var pos = rcube_event.get_mouse_pos(e);
|
|
|
|
this.draglayer.css({ left:(pos.x+20)+'px', top:(pos.y-5 + (bw.ie ? document.documentElement.scrollTop : 0))+'px' });
|
|
|
|
this.draglayer.css({ left:(pos.x+20)+'px', top:(pos.y-5 + (bw.ie ? document.documentElement.scrollTop : 0))+'px' });
|
|
|
|
this.triggerEvent('dragmove', e?e:window.event);
|
|
|
|
this.triggerEvent('dragmove', e?e:window.event);
|
|
|
|