Author: jmorliaguet
Date: Tue Mar 14 23:40:51 2006
New Revision: 2640

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
   cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
Log:

- don't apply the drag-and-drop controller to elements outside the view / widget
  that the controller is supposed to manage.



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 Tue Mar 14 
23:40:51 2006
@@ -596,12 +596,7 @@
     this.dropEvent = this.dropEvent.bindAsEventListener(this);
     this.cancelEvent = new Function("return false");
 
-    var dropzones = this._dropzones = [];
-    if (this.def.dropping) {
-      (this.def.dropping.targets || []).each(function(d) {
-        $$(d).each(function(el) { dropzones.push(el); });
-      });
-    }
+    this._dropzones = [];
 
     // cancel text selection
     document.onmousedown = this.cancelEvent;
@@ -616,17 +611,33 @@
     }
     var handle = dragging.handle;
     var sources = dragging.sources || [];
+    var dropzones = this._dropzones;
+    var widget = view.widget;
 
     if (!handle) { handle = sources; }
     handle.each(function(h) {
       $$(h).each(function(el) {
-        Event.observe(el, "mousedown", dragEvent);
-        el.setStyle({'cursor': 'move'});
+        if (el.childOf(widget)) {
+          Event.observe(el, "mousedown", dragEvent);
+          el.setStyle({'cursor': 'move'});
+        }
       });
     });
+
     sources.each(function(d) {
-      $$(d).each(function(el) { el._cpsskins_draggable = true; });
+      $$(d).each(function(el) {
+        if (el.childOf(widget)) el._cpsskins_draggable = true;
+      });
     });
+
+    if (this.def.dropping) {
+      (this.def.dropping.targets || []).each(function(d) {
+        $$(d).each(function(el) {
+          if (el.childOf(widget)) dropzones.push(el);
+        });
+      });
+    }
+
   },
 
   _findDraggable: function(e) {

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
        (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
        Tue Mar 14 23:40:51 2006
@@ -157,10 +157,11 @@
        "template": "draggable.html"
      },
      "model": "dummy",
-     "controllers": ["dnd", "dnd2", "dnd3", "dnd4"]
+     "controllers": ["dnd"]
     }
     </ins>
 
+
   </div>
 
   <div style="width: 200px; float: left">

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    Tue Mar 14 23:40:51 2006
@@ -324,6 +324,15 @@
       assertEqual(e0, CPSSkins.Identifiable.getIdentifiable(e1.parentNode));
     }},
 
+    testGetParent: function() { with(this) {
+      assertEqual(e0, CPSSkins.Identifiable.getParent(e1));
+      assertEqual(e0, CPSSkins.Identifiable.getParent(e2));
+      assertEqual(e0, CPSSkins.Identifiable.getParent(e3));
+      assertEqual(e0, CPSSkins.Identifiable.getParent(e4));
+      assertEqual(e4, CPSSkins.Identifiable.getParent(e5));
+      assertEqual(e0, CPSSkins.Identifiable.getParent(e6));
+    }},
+
     /* CPSSkins.Canvas */
 
     testCreateNode: function() { with(this) {
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to