[Svn] r2150 - trunk/roundcubemail/program/js

trac at roundcube.net trac at roundcube.net
Sun Dec 14 20:00:09 CET 2008


Author: alec
Date: 2008-12-14 13:00:09 -0600 (Sun, 14 Dec 2008)
New Revision: 2150

Modified:
   trunk/roundcubemail/program/js/common.js
   trunk/roundcubemail/program/js/list.js
Log:
#1485444: fix drag layer over an iframe


Modified: trunk/roundcubemail/program/js/common.js
===================================================================
--- trunk/roundcubemail/program/js/common.js	2008-12-12 11:57:20 UTC (rev 2149)
+++ trunk/roundcubemail/program/js/common.js	2008-12-14 19:00:09 UTC (rev 2150)
@@ -158,6 +158,11 @@
     mY += document.body.scrollTop;
   }
 
+  if (e._offset) {
+    mX += e._offset.x;
+    mY += e._offset.y;
+  }
+
   return { x:mX, y:mY };
 },
 

Modified: trunk/roundcubemail/program/js/list.js
===================================================================
--- trunk/roundcubemail/program/js/list.js	2008-12-12 11:57:20 UTC (rev 2149)
+++ trunk/roundcubemail/program/js/list.js	2008-12-14 19:00:09 UTC (rev 2150)
@@ -241,6 +241,36 @@
     this.drag_mouse_start = rcube_event.get_mouse_pos(e);
     rcube_event.add_listener({element:document, event:'mousemove', object:this, method:'drag_mouse_move'});
     rcube_event.add_listener({element:document, event:'mouseup', object:this, method:'drag_mouse_up'});
+
+    // add listener for iframes
+    var iframes = document.getElementsByTagName('IFRAME');
+    this.iframe_events = Object();
+    for (var n in iframes)
+    {
+      var iframedoc = null;
+      if (iframes[n].contentDocument)
+        iframedoc = iframes[n].contentDocument;
+      else if (iframes[n].contentWindow)
+	iframedoc = iframes[n].contentWindow.document;
+      else if (iframes[n].document)
+        iframedoc = iframes[n].document;
+
+      if (iframedoc)
+      {
+	var list = this;
+	var pos = rcube_get_object_pos(document.getElementById(iframes[n].id));
+	this.iframe_events[n] = function(e) { e._offset = pos; return list.drag_mouse_move(e); }
+	
+	if (iframedoc.addEventListener)
+	  iframedoc.addEventListener('mousemove', this.iframe_events[n], false);
+	else if (iframes[n].attachEvent)
+	  iframedoc.attachEvent('onmousemove', this.iframe_events[n]);
+	else
+	  iframedoc['onmousemove'] = this.iframe_events[n];
+
+        rcube_event.add_listener({element:iframedoc, event:'mouseup', object:this, method:'drag_mouse_up'});
+      }
+    }								  
   }
 
   return false;
@@ -689,6 +719,7 @@
   {
     // check mouse movement, of less than 3 pixels, don't start dragging
     var m = rcube_event.get_mouse_pos(e);
+
     if (!this.drag_mouse_start || (Math.abs(m.x - this.drag_mouse_start.x) < 3 && Math.abs(m.y - this.drag_mouse_start.y) < 3))
       return false;
   
@@ -764,6 +795,30 @@
   rcube_event.remove_listener({element:document, event:'mousemove', object:this, method:'drag_mouse_move'});
   rcube_event.remove_listener({element:document, event:'mouseup', object:this, method:'drag_mouse_up'});
 
+  var iframes = document.getElementsByTagName('IFRAME');
+  for (var n in iframes) {
+    var iframedoc;
+    
+    if (iframes[n].contentDocument)
+      iframedoc = iframes[n].contentDocument;
+    else if (iframes[n].contentWindow)
+      iframedoc = iframes[n].contentWindow.document;
+    else if (iframes[n].document)
+      iframedoc = iframes[n].document;
+
+    if (iframedoc) {
+      if (this.iframe_events[n]) {
+	if (iframedoc.removeEventListener)
+	  iframedoc.removeEventListener('mousemove', this.iframe_events[n], false);
+	else if (iframedoc.detachEvent)
+	  iframedoc.detachEvent('onmousemove', this.iframe_events[n]);
+	else
+	  iframedoc['onmousemove'] = null;
+	}
+      rcube_event.remove_listener({element:iframedoc, event:'mouseup', object:this, method:'drag_mouse_up'});
+      }
+    }
+
   this.focus();
   
   return rcube_event.cancel(e);

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list