function DragDrop(oMov, handles, IDLE){ this.moveable = moveable.detectMoveable(oMov); this.moveable._IDLE = IDLE || false; this.elem = this.moveable.elem; this.handles = DragDrop.detectHandles(handles, this.elem); this.currentMouseLeft = null; this.currentMouseTop = null; this.ondragstart = new DOMEvent(this); this.ondrag = DOMEvent.cloneEvent(this.moveable.onmove); this.ondrop = new DOMEvent(this); this.mouse_x = 0; this.mouse_y = 0; this.active_handle = null; this.IS_DRAGGING = false; this.init(); } DragDrop.prototype.init = function(){ this.init_handles(); } DragDrop.prototype.init_handles = function(){ this.handles.each(function(handle){ handle.onselectstart = function(){return false;} handle.onmousedown = function(e, oHandle){ var _handle = oHandle || e; //ev in case of IE var ev = window.event || e; var x = ev.offsetX || ev.layerX; var y = ev.offsetY || ev.layerY; this.active_handle = _handle; this.mouse_x = x; this.mouse_y = y; this.start(ev); }.bind(this, handle); }.bind(this)); } DragDrop.prototype.start = function(e){ var ev = e || window.event; this.IS_DRAGGING = true; this.currentMouseLeft = ev.clientX; this.currentMouseTop = ev.clientY; this.curr_pageXOffset = window.pageXOffset; this.curr_pageYOffset = window.pageYOffset; this.ondragstart.fire(); document.onmousemove = this.move.bind(this); window.onscroll = this.scroll.bind(this); DragDrop.mouseup = this.drop.bind(this); AttachEvent(document, "mouseup", DragDrop.mouseup); document.onselectstart = document.onmousedown = function(){ return false; } return false; } DragDrop.prototype.drop = function(e){ this.IS_DRAGGING = false; document.onmousemove = null; window.onscroll = null; DetachEvent(document, "mouseup", DragDrop.mouseup); document.onselectstart = document.onmousedown = null; this.ondrop.fire(); } DragDrop.prototype.move = function(e){ var ev = window.event || e; var mLeft = ev.clientX; var mTop = ev.clientY; this.moveable.moveBy(mLeft - this.currentMouseLeft, mTop - this.currentMouseTop); this.currentMouseLeft = mLeft; this.currentMouseTop = mTop; } DragDrop.prototype.scroll = function(e){ var deltaX = window.pageXOffset - this.curr_pageXOffset; var deltaY = window.pageYOffset - this.curr_pageYOffset; this.moveable.moveBy(deltaX, deltaY); this.curr_pageXOffset = window.pageXOffset; this.curr_pageYOffset = window.pageYOffset; } DragDrop.prototype.__name = "DragDrop"; DragDrop.prototype.toString = __toString; DragDrop.detectHandles = function(handles, el){ var ret; if(typeof handles == "string"){ ret = $C(handles, el) || [el]; }else if(handles instanceof Array){ ret = handles; }else if(typeof handles == "object" && handles.nodeName){ ret = [handles]; }else if(typeof handles == "undefined" || typeof handles == "boolean"){ ret = [el]; } return ret; } DragDrop.mouseup = null;