diff options
Diffstat (limited to 'program/js/common.js')
-rw-r--r-- | program/js/common.js | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/program/js/common.js b/program/js/common.js index 6e4c643fa..209ce1070 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -114,6 +114,15 @@ get_keycode: function(e) }, /** + * returns the event key code + */ +get_button: function(e) +{ + e = e || window.event; + return e && (typeof e.button != 'undefined') ? e.button : (e && e.which ? e.which : 0); +}, + +/** * returns modifier key (constants defined at top of file) */ get_modifier: function(e) @@ -502,18 +511,25 @@ function rcube_get_object_pos(obj) var elm = obj.offsetParent; while(elm && elm!=null) { - iX += elm.offsetLeft; - iY += elm.offsetTop; + iX += elm.offsetLeft - (elm.parentNode && elm.parentNode.scrollLeft ? elm.parentNode.scrollLeft : 0); + iY += elm.offsetTop - (elm.parentNode && elm.parentNode.scrollTop ? elm.parentNode.scrollTop : 0); elm = elm.offsetParent; } } - //if(bw.mac && bw.ie5) iX += document.body.leftMargin; - //if(bw.mac && bw.ie5) iY += document.body.topMargin; - return {x:iX, y:iY}; } +// determine whether the mouse is over the given object or not +function rcube_mouse_is_over(ev, obj) +{ + var mouse = rcube_event.get_mouse_pos(ev); + var pos = rcube_get_object_pos(obj); + + return ((mouse.x >= pos.x) && (mouse.x < (pos.x + obj.offsetWidth)) && + (mouse.y >= pos.y) && (mouse.y < (pos.y + obj.offsetHeight))); +} + /** * Return the currently applied value of a css property |