diff options
-rw-r--r-- | program/js/common.js | 5 | ||||
-rw-r--r-- | program/js/list.js | 55 |
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); |