summaryrefslogtreecommitdiff
path: root/includes/js/dojo/dnd/TimedMoveable.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/dojo/dnd/TimedMoveable.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/dojo/dnd/TimedMoveable.js')
-rw-r--r--includes/js/dojo/dnd/TimedMoveable.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/includes/js/dojo/dnd/TimedMoveable.js b/includes/js/dojo/dnd/TimedMoveable.js
new file mode 100644
index 0000000..4f4fb0b
--- /dev/null
+++ b/includes/js/dojo/dnd/TimedMoveable.js
@@ -0,0 +1,66 @@
+if(!dojo._hasResource["dojo.dnd.TimedMoveable"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojo.dnd.TimedMoveable"] = true;
+dojo.provide("dojo.dnd.TimedMoveable");
+
+dojo.require("dojo.dnd.Moveable");
+
+(function(){
+ // precalculate long expressions
+ var oldOnMove = dojo.dnd.Moveable.prototype.onMove;
+
+ dojo.declare("dojo.dnd.TimedMoveable", dojo.dnd.Moveable, {
+ // summary:
+ // A specialized version of Moveable to support an FPS throttling.
+ // This class puts an upper restriction on FPS, which may reduce
+ // the CPU load. The additional parameter "timeout" regulates
+ // the delay before actually moving the moveable object.
+
+ // object attributes (for markup)
+ timeout: 40, // in ms, 40ms corresponds to 25 fps
+
+ constructor: function(node, params){
+ // summary: an object, which makes a node moveable with a timer
+ // node: Node: a node (or node's id) to be moved
+ // params: Object: an optional object with additional parameters.
+ // See dojo.dnd.Moveable for details on general parameters.
+ // Following parameters are specific for this class:
+ // timeout: Number: delay move by this number of ms
+ // accumulating position changes during the timeout
+
+ // sanitize parameters
+ if(!params){ params = {}; }
+ if(params.timeout && typeof params.timeout == "number" && params.timeout >= 0){
+ this.timeout = params.timeout;
+ }
+ },
+
+ // markup methods
+ markupFactory: function(params, node){
+ return new dojo.dnd.TimedMoveable(node, params);
+ },
+
+ onMoveStop: function(/* dojo.dnd.Mover */ mover){
+ if(mover._timer){
+ // stop timer
+ clearTimeout(mover._timer)
+ // reflect the last received position
+ oldOnMove.call(this, mover, mover._leftTop)
+ }
+ dojo.dnd.Moveable.prototype.onMoveStop.apply(this, arguments);
+ },
+ onMove: function(/* dojo.dnd.Mover */ mover, /* Object */ leftTop){
+ mover._leftTop = leftTop;
+ if(!mover._timer){
+ var _t = this; // to avoid using dojo.hitch()
+ mover._timer = setTimeout(function(){
+ // we don't have any pending requests
+ mover._timer = null;
+ // reflect the last received position
+ oldOnMove.call(_t, mover, mover._leftTop);
+ }, this.timeout);
+ }
+ }
+ });
+})();
+
+}