From f89f03cd6ae4a1b3f98e39c2e01d9e40f8a286b4 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 12 Sep 2008 07:12:05 -0400
Subject: [PATCH] Refactor drag & drop functionality. Don't rely on browser events anymore (#1484453)

---
 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 6e4c643..209ce10 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -114,6 +114,15 @@
 },
 
 /**
+ * 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 @@
     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

--
Gitblit v1.9.1