Aleksander Machniak
2012-05-22 041c93ce0bc00cb6417ce2e4bdce2ed84d37f50a
program/js/list.js
@@ -4,7 +4,10 @@
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2006-2009, The Roundcube Dev Team                       |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
 | See the README file for a full license statement.                     |
 |                                                                       |
 +-----------------------------------------------------------------------+
 | Authors: Thomas Bruederli <roundcube@gmail.com>                       |
@@ -12,8 +15,6 @@
 +-----------------------------------------------------------------------+
 | Requires: common.js                                                   |
 +-----------------------------------------------------------------------+
  $Id$
*/
@@ -36,7 +37,7 @@
  this.colcount = 0;
  this.subject_col = -1;
  this.shiftkey = false;
  this.modkey = 0;
  this.multiselect = false;
  this.multiexpand = false;
  this.multi_selecting = false;
@@ -101,7 +102,7 @@
init_row: function(row)
{
  // 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 self = this,
      uid = RegExp.$1;
    row.uid = uid;
@@ -182,8 +183,12 @@
 */
remove_row: function(uid, sel_next)
{
  if (this.rows[uid].obj)
    this.rows[uid].obj.style.display = 'none';
  var obj = this.rows[uid] ? this.rows[uid].obj : null;
  if (!obj)
    return;
  obj.style.display = 'none';
  if (sel_next)
    this.select_next();
@@ -245,7 +250,7 @@
  for (n in this.selection) {
    id = this.selection[n];
    if (this.rows[id] && this.rows[id].obj) {
      $(this.rows[id].obj).removeClass('selected').addClass('unfocused');
      $(this.rows[id].obj).removeClass('selected focused').addClass('unfocused');
    }
  }
},
@@ -350,8 +355,10 @@
  this.in_selection_before = false;
  // row was double clicked
  if (this.rows && dblclicked && this.in_selection(id))
  if (this.rows && dblclicked && this.in_selection(id)) {
    this.triggerEvent('dblclick');
    now = 0;
  }
  else
    this.triggerEvent('click');
@@ -410,7 +417,7 @@
collapse: function(row)
{
  row.expanded = false;
  this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded });
  this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj });
  var depth = row.depth;
  var new_row = row ? row.obj.nextSibling : null;
  var r;
@@ -423,7 +430,7 @@
      $(new_row).css('display', 'none');
      if (r.expanded) {
        r.expanded = false;
        this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded });
        this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded, obj:new_row });
      }
    }
    new_row = new_row.nextSibling;
@@ -441,7 +448,7 @@
    depth = row.depth;
    new_row = row.obj.nextSibling;
    this.update_expando(row.uid, true);
    this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded });
    this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj });
  }
  else {
    var tbody = this.list.tBodies[0];
@@ -464,7 +471,7 @@
              last_expanded_parent_depth = p.depth;
              $(new_row).css('display', '');
              r.expanded = true;
              this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded });
              this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded, obj:new_row });
            }
          }
          else
@@ -489,7 +496,7 @@
    depth = row.depth;
    new_row = row.obj.nextSibling;
    this.update_expando(row.uid);
    this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded });
    this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj });
    // don't collapse sub-root tree in multiexpand mode 
    if (depth && this.multiexpand)
@@ -511,7 +518,7 @@
        if (r.has_children && r.expanded) {
          r.expanded = 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, obj:new_row });
        }
      }
    }
@@ -530,7 +537,7 @@
    depth = row.depth;
    new_row = row.obj.nextSibling;
    this.update_expando(row.uid, true);
    this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded });
    this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded, obj:row.obj });
  }
  else {
    new_row = this.list.tBodies[0].firstChild;
@@ -547,7 +554,7 @@
        if (r.has_children && !r.expanded) {
          r.expanded = true;
          this.update_expando(r.uid, true);
          this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded });
          this.triggerEvent('expandcollapse', { uid:r.uid, expanded:r.expanded, obj:new_row });
        }
      }
    }
@@ -601,8 +608,8 @@
    var i, len, rows = this.list.tBodies[0].rows;
    for (i=0, len=rows.length-1; i<len; i++)
      if (rows[i].id && String(rows[i].id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null)
       return RegExp.$1;
      if (rows[i].id && String(rows[i].id).match(/^rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null)
        return RegExp.$1;
  }
  return null;
@@ -614,7 +621,7 @@
    var i, rows = this.list.tBodies[0].rows;
    for (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;
  }
@@ -648,7 +655,7 @@
      case CONTROL_KEY:
        if (!with_mouse)
          this.highlight_row(id, true);
        break;
        break;
      case CONTROL_SHIFT_KEY:
        this.shift_select(id, true);
@@ -954,7 +961,8 @@
 */
key_press: function(e)
{
  if (this.focused != true)
  var target = e.target || {};
  if (this.focused != true || target.nodeName == 'INPUT' || target.nodeName == 'TEXTAREA' || target.nodeName == 'SELECT')
    return true;
  var keyCode = rcube_event.get_keycode(e),
@@ -962,7 +970,7 @@
  switch (keyCode) {
    case 40:
    case 38:
    case 38:
    case 63233: // "down", in safari keypress
    case 63232: // "up", in safari keypress
      // Stop propagation so that the browser doesn't scroll
@@ -976,7 +984,9 @@
      rcube_event.cancel(e);
      var ret = this.use_plusminus_key(keyCode, mod_key);
      this.key_pressed = keyCode;
      this.modkey = mod_key;
      this.triggerEvent('keypress');
      this.modkey = 0;
      return ret;
    case 36: // Home
      this.select_first(mod_key);
@@ -985,11 +995,10 @@
      this.select_last(mod_key);
      return rcube_event.cancel(e);
    default:
      this.shiftkey = e.shiftKey;
      this.key_pressed = keyCode;
      this.modkey = mod_key;
      this.triggerEvent('keypress');
      // reset shiftkey flag, we need it only for registered events
      this.shiftkey = false;
      this.modkey = 0;
      if (this.key_pressed == this.BACKSPACE_KEY)
        return rcube_event.cancel(e);
@@ -1003,13 +1012,17 @@
 */
key_down: function(e)
{
  var target = e.target || {};
  if (this.focused != true || target.nodeName == 'INPUT' || target.nodeName == 'TEXTAREA' || target.nodeName == 'SELECT')
    return true;
  switch (rcube_event.get_keycode(e)) {
    case 27:
      if (this.drag_active)
       return this.drag_mouse_up(e);
      return this.drag_mouse_up(e);
      if (this.col_drag_active) {
        this.selected_column = null;
       return this.column_drag_mouse_up(e);
        return this.column_drag_mouse_up(e);
      }
    case 40:
@@ -1044,7 +1057,7 @@
    new_row = this.get_prev_row();
  if (new_row) {
    this.select_row(new_row.uid, mod_key, true);
    this.select_row(new_row.uid, mod_key, false);
    this.scrollto(new_row.uid);
  }