cmcnulty
2013-10-30 a8876fba93a1e52dd0daab6fa3b7b74fedbdc252
program/js/list.js
@@ -35,7 +35,7 @@
  this.tbody;
  this.fixed_header;
  this.frame = null;
  this.rows = [];
  this.rows = {};
  this.selection = [];
  this.rowcount = 0;
  this.colcount = 0;
@@ -50,7 +50,6 @@
  this.keyboard = false;
  this.toggleselect = false;
  this.dont_select = false;
  this.drag_active = false;
  this.col_drag_active = false;
  this.column_fixed = null;
@@ -86,7 +85,7 @@
  }
  if (this.tbody) {
    this.rows = [];
    this.rows = {};
    this.rowcount = 0;
    var r, len, rows = this.tbody.childNodes;
@@ -240,7 +239,7 @@
    $(this.row_tagname() + ':not(.thead)', this.tbody).remove();
  }
  this.rows = [];
  this.rows = {};
  this.rowcount = 0;
  if (sel)
@@ -409,14 +408,14 @@
  var evtarget = rcube_event.get_target(e),
    tagname = evtarget.tagName.toLowerCase();
  if (this.dont_select || (evtarget && (tagname == 'input' || tagname == 'img')))
  if (evtarget && (tagname == 'input' || tagname == 'img' || (tagname != 'a' && evtarget.onclick)))
    return true;
  // accept right-clicks
  if (rcube_event.get_button(e) == 2)
    return true;
  this.in_selection_before = e.istouch || this.in_selection(id) ? id : false;
  this.in_selection_before = e && e.istouch || this.in_selection(id) ? id : false;
  // selects currently unselected row
  if (!this.in_selection_before) {
@@ -455,23 +454,17 @@
  if ((evtarget && (tagname == 'input' || tagname == 'img')))
    return true;
  // don't do anything (another action processed before)
  if (this.dont_select) {
    this.dont_select = false;
    return false;
  }
  var dblclicked = now - this.rows[id].clicked < this.dblclick_time;
  // unselects currently selected row
  // selects/unselects currently selected row
  if (!this.drag_active && this.in_selection_before == id && !dblclicked)
    this.select_row(id, mod_key, false);
    this.select_row(id, mod_key, true);
  this.drag_start = false;
  this.in_selection_before = false;
  // row was double clicked
  if (this.rows && dblclicked && this.in_selection(id)) {
  if (this.rowcount && dblclicked && this.in_selection(id)) {
    this.triggerEvent('dblclick');
    now = 0;
  }
@@ -509,8 +502,6 @@
    evtarget = rcube_event.get_target(e),
    mod_key = rcube_event.get_modifier(e);
  // Don't select this message
  this.dont_select = true;
  // Don't treat double click on the expando as double click on the message.
  row.clicked = 0;
@@ -703,7 +694,7 @@
 */
get_next_row: function()
{
  if (!this.rows)
  if (!this.rowcount)
    return false;
  var last_selected_row = this.rows[this.last_selected],
@@ -717,7 +708,7 @@
get_prev_row: function()
{
  if (!this.rows)
  if (!this.rowcount)
    return false;
  var last_selected_row = this.rows[this.last_selected],
@@ -796,7 +787,7 @@
        break;
      case CONTROL_KEY:
        if (!with_mouse)
        if (with_mouse)
          this.highlight_row(id, true);
        break;
@@ -921,7 +912,8 @@
    from_rowIndex = this._rowIndex(this.rows[this.shift_start].obj),
    to_rowIndex = this._rowIndex(to_row.obj);
  if (!to_row.expanded && to_row.has_children)
  // if we're going down the list, and we hit a thread, and it's closed, select the whole thread
  if (from_rowIndex < to_rowIndex && !to_row.expanded && to_row.has_children)
    if (to_row = this.rows[(this.row_children(id)).pop()])
      to_rowIndex = this._rowIndex(to_row.obj);
@@ -942,6 +934,7 @@
    }
  }
},
/**
 * Helper method to emulate the rowIndex property of non-tr elements
@@ -969,7 +962,7 @@
 */
select_all: function(filter)
{
  if (!this.rows || !this.rows.length)
  if (!this.rowcount)
    return false;
  // reset but remember selection first
@@ -1001,7 +994,7 @@
 */
invert_selection: function()
{
  if (!this.rows || !this.rows.length)
  if (!this.rowcount)
    return false;
  // remember old selection
@@ -1143,10 +1136,13 @@
      // Stop propagation so that the browser doesn't scroll
      rcube_event.cancel(e);
      return this.use_arrow_key(keyCode, mod_key);
    case 61:
    case 107: // Plus sign on a numeric keypad (fc11 + firefox 3.5.2)
    case 109:
    case 32:
      rcube_event.cancel(e);
      return this.select_row(this.last_selected, mod_key, true);
    case 37: // Left arrow key
    case 39: // Right arrow key
    case 107: // Plus sign on a numeric keypad
    case 109: // Minus sign on a numeric keypad
      // Stop propagation
      rcube_event.cancel(e);
      var ret = this.use_plusminus_key(keyCode, mod_key);
@@ -1211,21 +1207,30 @@
use_plusminus_key: function(keyCode, mod_key)
{
  var selected_row = this.rows[this.last_selected];
  if (!selected_row)
  if (!selected_row || !selected_row.has_children)
    return;
  if (keyCode == 32)
    keyCode = selected_row.expanded ? 109 : 61;
  if (keyCode == 61 || keyCode == 107)
  // expand
  if (keyCode == 39 || keyCode == 107) {
    if (selected_row.expanded)
      return;
    if (mod_key == CONTROL_KEY || this.multiexpand)
      this.expand_all(selected_row);
    else
     this.expand(selected_row);
  else
      this.expand(selected_row);
  }
  // collapse
  else {
    if (!selected_row.expanded)
      return;
    if (mod_key == CONTROL_KEY || this.multiexpand)
      this.collapse_all(selected_row);
    else
      this.collapse(selected_row);
  }
  this.update_expando(selected_row.uid, selected_row.expanded);