Author: jmorliaguet
Date: Mon Feb 20 01:33:38 2006
New Revision: 2434

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- added a basic drag-and-drop controller



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Mon Feb 20 
01:33:38 2006
@@ -404,6 +404,10 @@
 
   'focus observer': function(node, def) {
     return new CPSSkins.FocusObserver(node, def);
+  },
+
+  'drag-and-drop': function(node, def) {
+    return new CPSSkins.DragAndDropController(node, def);
   }
 
 });
@@ -490,7 +494,6 @@
     });
 
     model.setData(form_data);
-
     return false;
   }
 
@@ -525,6 +528,40 @@
 
 });
 
+CPSSkins.DragAndDropController = Class.create();
+CPSSkins.DragAndDropController.prototype = Object.extend(
+  new CPSSkins.Controller(), {
+
+  register: function(view) {
+    var widget = view.widget;
+
+    this.dragEvent = this.dragEvent.bindAsEventListener(this);
+    this.moveEvent = this.moveEvent.bindAsEventListener(this);
+    this.dropEvent = this.dropEvent.bindAsEventListener(this);
+    Event.observe(widget, "mousedown", this.dragEvent);
+  },
+
+  dragEvent: function(e) {
+    var widget = this.view.widget;
+    Event.observe(document, "mousemove", this.moveEvent);
+    Event.observe(document, "mouseup", this.dropEvent);
+  },
+
+  moveEvent: function(e) {
+    var widget = this.view.widget;
+    var mouseX = Event.pointerX(e);
+    var mouseY = Event.pointerY(e);
+    CPSSkins.Canvas.moveTo(widget, parseInt(mouseX)-20, parseInt(mouseY-20));
+  },
+
+  dropEvent: function(e) {
+    var widget = this.view.widget;
+    Event.stopObserving(document, "mousemove", this.moveEvent);
+    Event.stopObserving(document, "mouseup", this.dropEvent);
+  }
+
+});
+
 // Identifiable DOM elements.
 if (!CPSSkins.Identifiable) { CPSSkins.Identifiable = new Object() }
 Object.extend(CPSSkins.Identifiable, {
@@ -1697,8 +1734,8 @@
 
 // Contextual actions
 CPSSkins.ContextualActions = Class.create();
-Object.extend(CPSSkins.ContextualActions.prototype, new CPSSkins.View());
-Object.extend(CPSSkins.ContextualActions.prototype, 
CPSSkins.ContextualMenu.prototype);
+Object.extend(CPSSkins.ContextualActions.prototype,
+              CPSSkins.ContextualMenu.prototype);
 Object.extend(CPSSkins.ContextualActions.prototype, {
 
   prepare: function() {
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to