Blame | Last modification | View Log | RSS feed
if(!dojo._hasResource["dojo.dnd.Mover"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dojo.dnd.Mover"] = true;dojo.provide("dojo.dnd.Mover");dojo.require("dojo.dnd.common");dojo.require("dojo.dnd.autoscroll");dojo.declare("dojo.dnd.Mover", null, {constructor: function(node, e, host){// summary: an object, which makes a node follow the mouse,// used as a default mover, and as a base class for custom movers// node: Node: a node (or node's id) to be moved// e: Event: a mouse event, which started the move;// only pageX and pageY properties are used// host: Object?: object which implements the functionality of the move,// and defines proper events (onMoveStart and onMoveStop)this.node = dojo.byId(node);this.marginBox = {l: e.pageX, t: e.pageY};this.mouseButton = e.button;var h = this.host = host, d = node.ownerDocument,firstEvent = dojo.connect(d, "onmousemove", this, "onFirstMove");this.events = [dojo.connect(d, "onmousemove", this, "onMouseMove"),dojo.connect(d, "onmouseup", this, "onMouseUp"),// cancel text selection and text draggingdojo.connect(d, "ondragstart", dojo, "stopEvent"),dojo.connect(d, "onselectstart", dojo, "stopEvent"),firstEvent];// notify that the move has startedif(h && h.onMoveStart){h.onMoveStart(this);}},// mouse event processorsonMouseMove: function(e){// summary: event processor for onmousemove// e: Event: mouse eventdojo.dnd.autoScroll(e);var m = this.marginBox;this.host.onMove(this, {l: m.l + e.pageX, t: m.t + e.pageY});},onMouseUp: function(e){if(this.mouseButton == e.button){this.destroy();}},// utilitiesonFirstMove: function(){// summary: makes the node absolute; it is meant to be called only oncethis.node.style.position = "absolute"; // enforcing the absolute modevar m = dojo.marginBox(this.node);m.l -= this.marginBox.l;m.t -= this.marginBox.t;this.marginBox = m;this.host.onFirstMove(this);dojo.disconnect(this.events.pop());},destroy: function(){// summary: stops the move, deletes all references, so the object can be garbage-collecteddojo.forEach(this.events, dojo.disconnect);// undo global settingsvar h = this.host;if(h && h.onMoveStop){h.onMoveStop(this);}// destroy objectsthis.events = this.node = null;}});}