summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-12-14 19:00:09 +0000
committeralecpl <alec@alec.pl>2008-12-14 19:00:09 +0000
commitcf6bc5d5fac6d7fe0db54ead2cc10436f8aeaa9a (patch)
tree445f27c5a7c6b150c7e9a736765763d64e045451 /program
parent2b5c123aadfa50f09a60b3d05c240932f9e5907a (diff)
#1485444: fix drag layer over an iframe
Diffstat (limited to 'program')
-rw-r--r--program/js/common.js5
-rw-r--r--program/js/list.js55
2 files changed, 60 insertions, 0 deletions
diff --git a/program/js/common.js b/program/js/common.js
index 4b877bac3..5923989ec 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -158,6 +158,11 @@ get_mouse_pos: function(e)
mY += document.body.scrollTop;
}
+ if (e._offset) {
+ mX += e._offset.x;
+ mY += e._offset.y;
+ }
+
return { x:mX, y:mY };
},
diff --git a/program/js/list.js b/program/js/list.js
index 62d473260..66694ce9f 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -241,6 +241,36 @@ drag_row: function(e, id)
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 @@ drag_mouse_move: function(e)
{
// 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 @@ drag_mouse_up: function(e)
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);