Author: jmorliaguet
Date: Sun Apr  2 20:44:30 2006
New Revision: 2764

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html
Log:

- fixed the drag handle.

- interaction zones are computed when the controller is registered (this is
  done fast now).



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 Sun Apr  2 
20:44:30 2006
@@ -698,9 +698,6 @@
     document.onmousedown = this.cancelEvent;
     document.onselectstart = this.cancelEvent;
 
-    this._shiftablezones = [];
-    this._containerzones = [];
-    this._dropzones = [];
     this._last_updated = 0;
   },
 
@@ -710,44 +707,45 @@
       return;
     }
     var widget = view.widget;
-    var dragEvent = this.dragEvent.bindAsEventListener(
-                      Object.extend(this, {'widget': widget}));
-    Event.observe(widget, "mousedown", dragEvent);
-  },
 
-  unregister: function(view) {
-    var widget = view.widget;
-    var dragEvent = this.dragEvent.bindAsEventListener(
-                      Object.extend(this, {'widget': widget}));
-    Event.stopObserving(widget, "mousedown", dragEvent);
-  },
-
-  _setupZones: function() {
-    var widget = this.widget;
     var shifting = this.def.shifting;
     if (shifting) {
       if (shifting.element) {
         this._shiftablezones = document.getElementsByClassName(
-                                    shifting.element)
+                               shifting.element, widget)
       }
       if (shifting.container) {
         this._containerzones = document.getElementsByClassName(
-                                    shifting.container, widget)
+                               shifting.container, widget)
       }
     }
     if (this.def.dropping) {
       this._dropzones = document.getElementsByClassName(
-                                    this.def.dropping.target)
+                        this.def.dropping.target, widget)
     }
+
+    var dragEvent = this.dragEvent.bindAsEventListener(
+                      Object.extend(this, {'widget': widget}));
+    Event.observe(widget, "mousedown", dragEvent);
+  },
+
+  unregister: function(view) {
+    var widget = view.widget;
+    var dragEvent = this.dragEvent.bindAsEventListener(
+                      Object.extend(this, {'widget': widget}));
+    Event.stopObserving(widget, "mousedown", dragEvent);
   },
 
   _findDraggable: function(e) {
     var element = $(Event.element(e));
-    var handle = this.def.dragging.handle || this.def.dragging.source || '';
+    var source = this.def.dragging.source || '';
+    var handle = this.def.dragging.handle || '';
     var widget = this.widget;
-
+    if (handle && !element.hasClassName(handle)) {
+      return null;
+    }
     while($(element).parentNode) {
-      if (element.hasClassName(handle)) {
+      if (element.hasClassName(source)) {
         return element;
       }
       if (!element.childOf(widget)) {
@@ -786,8 +784,6 @@
       return false;
     }
 
-    this._setupZones();
-
     this.target = $(draggable);
     var pos = Position.cumulativeOffset(draggable);
 

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html
    Sun Apr  2 20:44:30 2006
@@ -240,8 +240,8 @@
   {"id": "drag",
    "type": "drag-and-drop",
    "dragging": {
-     "sources": ["div.window"],
-     "handle": ["div.window .title"]
+     "source": "window",
+     "handle": "title"
    },
    "dropping": {}
   }
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to