From a0ce2f0fa1873e45359d58e8c64e49fd80d9a692 Mon Sep 17 00:00:00 2001 From: thomascube Date: Tue, 12 Feb 2008 19:54:16 +0000 Subject: Make script cross browser compatible --- program/js/common.js | 25 +++++++++++++++++-------- program/js/list.js | 6 ++++-- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'program/js') diff --git a/program/js/common.js b/program/js/common.js index 6435f3b77..860ca3e07 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -95,14 +95,23 @@ 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 the event target element + */ +get_target: function(e) +{ + e = e || window.event; + return e && e.target ? e.target : e.srcElement; +}, + +/** + * 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) diff --git a/program/js/list.js b/program/js/list.js index ad5763365..3255c1a3f 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -210,7 +210,8 @@ drag_row: function(e, id) this.in_selection_before = this.in_selection(id) ? id : false; // don't do anything (another action processed before) - if (this.dont_select || (e.target && (e.target.tagName == 'INPUT' || e.target.tagName == 'IMG'))) + var evtarget = rcube_event.get_target(e); + if (this.dont_select || (evtarget && (evtarget.tagName == 'INPUT' || evtarget.tagName == 'IMG'))) return false; // selects currently unselected row @@ -239,8 +240,9 @@ click_row: function(e, id) { var now = new Date().getTime(); var mod_key = rcube_event.get_modifier(e); + var evtarget = rcube_event.get_target(e); - if ((e.target && (e.target.tagName == 'INPUT' || e.target.tagName == 'IMG'))) + if ((evtarget && (evtarget.tagName == 'INPUT' || evtarget.tagName == 'IMG'))) return false; // don't do anything (another action processed before) -- cgit v1.2.3