summaryrefslogtreecommitdiff
path: root/includes/js/dojox/gfx/Mover.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/gfx/Mover.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/gfx/Mover.js')
-rw-r--r--includes/js/dojox/gfx/Mover.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/includes/js/dojox/gfx/Mover.js b/includes/js/dojox/gfx/Mover.js
new file mode 100644
index 0000000..6a5d456
--- /dev/null
+++ b/includes/js/dojox/gfx/Mover.js
@@ -0,0 +1,62 @@
+if(!dojo._hasResource["dojox.gfx.Mover"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gfx.Mover"] = true;
+dojo.provide("dojox.gfx.Mover");
+
+dojo.declare("dojox.gfx.Mover", null, {
+ constructor: function(shape, e, host){
+ // summary: an object, which makes a shape follow the mouse,
+ // used as a default mover, and as a base class for custom movers
+ // shape: dojox.gfx.Shape: a shape object to be moved
+ // e: Event: a mouse event, which started the move;
+ // only clientX and clientY properties are used
+ // host: Object?: object which implements the functionality of the move,
+ // and defines proper events (onMoveStart and onMoveStop)
+ this.shape = shape;
+ this.lastX = e.clientX
+ this.lastY = e.clientY;
+ var h = this.host = host, d = document,
+ firstEvent = dojo.connect(d, "onmousemove", this, "onFirstMove");
+ this.events = [
+ dojo.connect(d, "onmousemove", this, "onMouseMove"),
+ dojo.connect(d, "onmouseup", this, "destroy"),
+ // cancel text selection and text dragging
+ dojo.connect(d, "ondragstart", dojo, "stopEvent"),
+ dojo.connect(d, "onselectstart", dojo, "stopEvent"),
+ firstEvent
+ ];
+ // notify that the move has started
+ if(h && h.onMoveStart){
+ h.onMoveStart(this);
+ }
+ },
+ // mouse event processors
+ onMouseMove: function(e){
+ // summary: event processor for onmousemove
+ // e: Event: mouse event
+ var x = e.clientX;
+ var y = e.clientY;
+ this.host.onMove(this, {dx: x - this.lastX, dy: y - this.lastY});
+ this.lastX = x;
+ this.lastY = y;
+ dojo.stopEvent(e);
+ },
+ // utilities
+ onFirstMove: function(){
+ // summary: it is meant to be called only once
+ this.host.onFirstMove(this);
+ dojo.disconnect(this.events.pop());
+ },
+ destroy: function(){
+ // summary: stops the move, deletes all references, so the object can be garbage-collected
+ dojo.forEach(this.events, dojo.disconnect);
+ // undo global settings
+ var h = this.host;
+ if(h && h.onMoveStop){
+ h.onMoveStop(this);
+ }
+ // destroy objects
+ this.events = this.shape = null;
+ }
+});
+
+}