Add new event for initial mouseclick on draggable item.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 16 Mar 2010 06:26:50 +0000 (00:26 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 16 Mar 2010 06:34:58 +0000 (00:34 -0600)
This reverts commit 1761e27b82c75ca1c3e8195dae152c9454958949.

horde/js/dragdrop2.js
imp/js/DimpBase.js

index 7ea6f52..e685b67 100644 (file)
  *   Fired on mousemove.
  *
  * 'DragDrop2:end'
+ *   Fired on mouseup.
+ *
+ * 'DragDrop2:mousedown'
  *   Fired on mousedown.
  *
  * 'DragDrop2:start'
- *   Fired on mouseup.
+ *   Fired when first moved more than 'threshold'.
  *
  *
  * new Drop(element, {
@@ -263,9 +266,11 @@ Drag = Class.create({
         DragDrop.Drags.activate(this);
         this.move = 0;
         this.wasDragged = false;
+        this.wasMoved = false;
         this.lastcaption = null;
+        this.clickEvent = e;
 
-        this.element.fire('DragDrop2:start', e);
+        this.element.fire('DragDrop2:mousedown', e);
 
         if (this.options.ghosting || this.options.caption) {
             if (!DragDrop.Drags.cover) {
@@ -305,6 +310,9 @@ Drag = Class.create({
 
         if (++this.move <= this.options.threshold) {
             return;
+        } else if (!this.wasMoved) {
+            this.element.fire('DragDrop2:start', this.clickEvent);
+            this.wasMoved = true;
         }
 
         this.lastCoord = xy = [ e.pointerX(), e.pointerY() ];
index 2a10dc4..9fbfce3 100644 (file)
@@ -1607,7 +1607,7 @@ var DimpBase = {
         return cnt + ' ' + (cnt == 1 ? DIMP.text.message : DIMP.text.messages);
     },
 
-    onDragStart: function(e)
+    onDragMouseDown: function(e)
     {
         var args,
             elt = e.element(),
@@ -3077,7 +3077,7 @@ DimpBase._folderDropConfig = {
 document.observe('DragDrop2:drag', DimpBase.onDrag.bindAsEventListener(DimpBase));
 document.observe('DragDrop2:drop', DimpBase.folderDropHandler.bindAsEventListener(DimpBase));
 document.observe('DragDrop2:end', DimpBase.onDragEnd.bindAsEventListener(DimpBase));
-document.observe('DragDrop2:start', DimpBase.onDragStart.bindAsEventListener(DimpBase));
+document.observe('DragDrop2:mousedown', DimpBase.onDragMouseDown.bindAsEventListener(DimpBase));
 
 /* Route AJAX responses through ViewPort. */
 DimpCore.onDoActionComplete = function(r) {