summaryrefslogtreecommitdiff
path: root/program/js/common.js
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2008-09-12 11:12:05 +0000
committerthomascube <thomas@roundcube.net>2008-09-12 11:12:05 +0000
commitf89f03cd6ae4a1b3f98e39c2e01d9e40f8a286b4 (patch)
tree755571136a62931e139bfefa922e386c81344c0f /program/js/common.js
parent55fb73529c5f97fdd79982e546eb15ad870f4438 (diff)
Refactor drag & drop functionality. Don't rely on browser events anymore (#1484453)
Diffstat (limited to 'program/js/common.js')
-rw-r--r--program/js/common.js26
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