From 26f5b0935ef4d8bc01e2b8581f7d7ed3c4508fc2 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 22 Aug 2008 06:37:48 -0400
Subject: [PATCH] Fix keyboard control of the list widgets and prevent Safari from scrolling (#1485279)
---
program/js/list.js | 18 ++++++++++--------
program/js/app.js | 4 ++--
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/program/js/app.js b/program/js/app.js
index df2c839..b5073da 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1189,7 +1189,7 @@
// start timer for message preview (wait for double click)
if (selected && this.env.contentframe && !list.multi_selecting)
- this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, this.dblclick_time + 10);
+ this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, 200);
else if (this.env.contentframe)
this.show_contentframe(false);
};
@@ -2460,7 +2460,7 @@
var id, frame, ref = this;
if (id = list.get_single_selection())
- this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, this.dblclick_time + 10);
+ this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, 200);
else if (this.env.contentframe)
this.show_contentframe(false);
diff --git a/program/js/list.js b/program/js/list.js
index a163f55..a83a8af 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -86,8 +86,10 @@
this.frame = this.list.parentNode;
// set body events
- if (this.keyboard)
- rcube_event.add_listener({element:document, event:'keypress', object:this, method:'key_press'});
+ if (this.keyboard) {
+ rcube_event.add_listener({element:document, event:'keyup', object:this, method:'key_press'});
+ rcube_event.add_listener({element:document, event:'keydown', object:rcube_event, method:'cancel'});
+ }
}
},
@@ -548,20 +550,20 @@
*/
key_press: function(e)
{
- if (this.focused != true)
+ if (this.focused != true)
return true;
- var keyCode = document.layers ? e.which : document.all ? event.keyCode : document.getElementById ? e.keyCode : 0;
+ var keyCode = rcube_event.get_keycode(e);
var mod_key = rcube_event.get_modifier(e);
switch (keyCode)
{
case 40:
case 38:
- case 63233: // "down", in safari keypress
- case 63232: // "up", in safari keypress
+ case 63233: // "down", in safari keypress
+ case 63232: // "up", in safari keypress
+ // Stop propagation so that the browser doesn't scroll
+ rcube_event.cancel(e);
return this.use_arrow_key(keyCode, mod_key);
- break;
-
default:
this.shiftkey = e.shiftKey;
this.key_pressed = keyCode;
--
Gitblit v1.9.1