alecpl
2008-10-07 2727053c61cac4a37a76b9e58e607acff7fc8dfb
program/js/list.js
@@ -51,7 +51,7 @@
  this.drag_mouse_start = null;
  this.dblclick_time = 600;
  this.row_init = function(){};
  this.events = { click:[], dblclick:[], select:[], keypress:[], dragstart:[], dragend:[] };
  this.events = { click:[], dblclick:[], select:[], keypress:[], dragstart:[], dragmove:[], dragend:[] };
  
  // overwrite default paramaters
  if (p && typeof(p)=='object')
@@ -173,7 +173,7 @@
/**
 * Set focur to the list
 * Set focus to the list
 */
focus: function(e)
{
@@ -221,7 +221,11 @@
  var evtarget = rcube_event.get_target(e);
  if (this.dont_select || (evtarget && (evtarget.tagName == 'INPUT' || evtarget.tagName == 'IMG')))
    return false;
  // accept right-clicks
  if (rcube_event.get_button(e) == 2)
    return true;
  this.in_selection_before = this.in_selection(id) ? id : false;
  // selects currently unselected row
@@ -286,7 +290,7 @@
/**
 * get next and previous rows that are not hidden
 * get next/previous/last rows that are not hidden
 */
get_next_row: function()
{
@@ -314,8 +318,24 @@
  return new_row;
},
get_last_row: function()
{
  if (this.rowcount)
    {
    var rows = this.list.tBodies[0].rows;
// selects or unselects the proper row depending on the modifier key pressed
    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)
   return RegExp.$1;
    }
  return null;
},
/**
 * selects or unselects the proper row depending on the modifier key pressed
 */
select_row: function(id, mod_key, with_mouse)
{
  var select_before = this.selection.join(',');
@@ -478,21 +498,36 @@
/**
 * Unselect all selected rows
 * Unselect selected row(s)
 */
clear_selection: function()
clear_selection: function(id)
{
  var num_select = this.selection.length;
  for (var n=0; n<this.selection.length; n++)
    if (this.rows[this.selection[n]])
  // one row
  if (id)
    {
      this.set_classname(this.rows[this.selection[n]].obj, 'selected', false);
      this.set_classname(this.rows[this.selection[n]].obj, 'unfocused', false);
    for (var n=0; n<this.selection.length; n++)
      if (this.selection[n] == id)
        {
   this.selection.splice(n,1);
       break;
   }
    }
  // all rows
  else
    {
    for (var n=0; n<this.selection.length; n++)
      if (this.rows[this.selection[n]])
        {
        this.set_classname(this.rows[this.selection[n]].obj, 'selected', false);
        this.set_classname(this.rows[this.selection[n]].obj, 'unfocused', false);
        }
    this.selection = new Array();
    }
  this.selection = new Array();
  if (num_select)
  if (num_select && !this.selection.length)
    this.trigger_event('select');
},
@@ -576,7 +611,7 @@
      this.key_pressed = keyCode;
      this.trigger_event('keypress');
      
      if (this.key_pressed == list.BACKSPACE_KEY)
      if (this.key_pressed == this.BACKSPACE_KEY)
        return rcube_event.cancel(e);
  }
  
@@ -658,7 +693,7 @@
      return false;
  
    if (!this.draglayer)
      this.draglayer = new rcube_layer('rcmdraglayer', {x:0, y:0, width:300, vis:0, zindex:2000});
      this.draglayer = new rcube_layer('rcmdraglayer', {x:0, y:0, vis:0, zindex:2000});
  
    // get subjects of selectedd messages
    var names = '';
@@ -704,6 +739,7 @@
  {
    var pos = rcube_event.get_mouse_pos(e);
    this.draglayer.move(pos.x+20, pos.y-5);
    this.trigger_event('dragmove', e);
  }
  this.drag_start = false;
@@ -784,12 +820,12 @@
 * This will execute all registered event handlers
 * @private
 */
trigger_event: function(evt)
trigger_event: function(evt, p)
{
  if (this.events[evt] && this.events[evt].length) {
    for (var i=0; i<this.events[evt].length; i++)
      if (typeof(this.events[evt][i]) == 'function')
        this.events[evt][i](this);
        this.events[evt][i](this, p);
  }
}