summaryrefslogtreecommitdiff
path: root/program/js
diff options
context:
space:
mode:
Diffstat (limited to 'program/js')
-rw-r--r--program/js/app.js19
-rw-r--r--program/js/common.js9
2 files changed, 17 insertions, 11 deletions
diff --git a/program/js/app.js b/program/js/app.js
index e166d07da..7406df2ff 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1638,14 +1638,13 @@ function rcube_webmail()
// handler for keyboard events on the _user field
this.login_user_keypress = function(e)
{
- if (!e)
- e = window.event;
- var key = e.keyCode ? e.keyCode : e.which;
+ var key = rcube_event.get_keycode(e);
+ var elm;
// enter
- if ((key==13) && (document.form._pass))
+ if ((key==13) && (elm = rcube_find_object('_pass')))
{
- rcube_find_object('_pass').focus();
+ elm.focus();
return false;
}
};
@@ -1986,11 +1985,9 @@ function rcube_webmail()
if (this.ksearch_timer)
clearTimeout(this.ksearch_timer);
- if (!e)
- e = window.event;
-
var highlight;
- var key = e.keyCode ? e.keyCode : e.which;
+ var key = rcube_event.get_keycode(e);
+ var mod = rcube_event.get_modifier(e);
switch (key)
{
@@ -2022,7 +2019,7 @@ function rcube_webmail()
return rcube_event.cancel(e);
case 9: // tab
- if(e.shiftKey)
+ if(mod == SHIFT_KEY)
break;
case 13: // enter
@@ -2531,7 +2528,7 @@ function rcube_webmail()
// handler for keyboard events on the input field
this.name_input_keypress = function(e)
{
- var key = document.all ? event.keyCode : document.getElementById ? e.keyCode : 0;
+ var key = rcube_event.get_keycode(e);
// enter
if (key==13)
diff --git a/program/js/common.js b/program/js/common.js
index 82d7ed17c..be9a131c2 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -103,6 +103,15 @@ function roundcube_browser()
// static functions for event handling
var rcube_event = {
+ /**
+ * returns the event key code
+ */
+ get_keycode: function(e)
+ {
+ e = e || window.event;
+ return e && e.keyCode ? e.keyCode : (e && e.which ? e.which : 0);
+ },
+
/**
* returns modifier key (constants defined at top of file)
*/