]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/js/list.js.src
Imported Upstream version 0.7
[roundcube.git] / program / js / list.js.src
index 78cf994a8c5c4dc45686aa6c43dd4f47e55ad48b..c8864c31897f815afcfdff63d065eb23059683ee 100644 (file)
@@ -3,7 +3,7 @@
  | Roundcube List Widget                                                 |
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2006-2009, Roundcube Dev, - Switzerland                 |
+ | Copyright (C) 2006-2009, The Roundcube Dev Team                       |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  +-----------------------------------------------------------------------+
@@ -13,7 +13,7 @@
  | Requires: common.js                                                   |
  +-----------------------------------------------------------------------+
 
-  $Id: list.js 4666 2011-04-17 09:34:02Z alec $
+  $Id: list.js 5271 2011-09-22 20:51:42Z thomasb $
 */
 
 
@@ -36,7 +36,7 @@ function rcube_list_widget(list, p)
   this.colcount = 0;
 
   this.subject_col = -1;
-  this.shiftkey = false;
+  this.modkey = 0;
   this.multiselect = false;
   this.multiexpand = false;
   this.multi_selecting = false;
@@ -58,7 +58,7 @@ function rcube_list_widget(list, p)
   this.row_init = function(){};
 
   // overwrite default paramaters
-  if (p && typeof(p) == 'object')
+  if (p && typeof p === 'object')
     for (var n in p)
       this[n] = p[n];
 };
@@ -101,7 +101,7 @@ init: function()
 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;
@@ -601,7 +601,7 @@ get_first_row: function()
     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)
+      if (rows[i].id && String(rows[i].id).match(/^rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null)
            return RegExp.$1;
   }
 
@@ -614,7 +614,7 @@ get_last_row: function()
     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 +648,7 @@ select_row: function(id, mod_key, with_mouse)
       case CONTROL_KEY:
         if (!with_mouse)
           this.highlight_row(id, true);
-        break; 
+        break;
 
       case CONTROL_SHIFT_KEY:
         this.shift_select(id, true);
@@ -954,7 +954,8 @@ highlight_row: function(id, multiple)
  */
 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 +963,7 @@ key_press: function(e)
 
   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 +977,9 @@ key_press: function(e)
       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,9 +988,10 @@ key_press: function(e)
       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');
+      this.modkey = 0;
 
       if (this.key_pressed == this.BACKSPACE_KEY)
         return rcube_event.cancel(e);
@@ -1001,13 +1005,17 @@ key_press: function(e)
  */
 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:
@@ -1042,7 +1050,7 @@ use_arrow_key: function(keyCode, mod_key)
     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);
   }