Author: jmorliaguet
Date: Sun Apr  2 17:56:51 2006
New Revision: 2761

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

- optimizations, fixes



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 
17:56:51 2006
@@ -694,10 +694,6 @@
     this.dropEvent = this.dropEvent.bindAsEventListener(this);
     this.cancelEvent = new Function("return false");
 
-    this._dropzones = [];
-    this._shiftablezones = [];
-    this._containerzones = [];
-
     // cancel text selection
     document.onmousedown = this.cancelEvent;
     document.onselectstart = this.cancelEvent;
@@ -714,8 +710,6 @@
     var dragEvent = this.dragEvent.bindAsEventListener(
                       Object.extend(this, {'widget': widget}));
     Event.observe(widget, "mousedown", dragEvent);
-    var handle = dragging.handle || dragging.sources || [];
-    this.handle_selector = new Selector(handle);
   },
 
   unregister: function(view) {
@@ -728,22 +722,22 @@
   _setupZones: function() {
     var widget = this.widget;
     var shifting = this.def.shifting;
-    var dropzones = this._dropzones;
-    var shiftablezones = this._shiftablezones;
-    var containerzones = this._containerzones;
-    if (shifting) {
+    if (shifting && !this._shiftablezones) {
+      var shiftablezones = this._shiftablezones = [];
       if (shifting.element) {
         $$(shifting.element).each(function(el) {
           if (el.childOf(widget)) shiftablezones.push(el);
         });
       }
-      if (shifting.container) {
+      if (shifting.container && !this._containerzones) {
+        var containerzones = this._containerzones = [];
         $$(shifting.container).each(function(el) {
           if (el.childOf(widget)) containerzones.push(el);
         });
       }
     }
-    if (this.def.dropping) {
+    if (this.def.dropping && !this._dropzones) {
+      var dropzones = this._dropzones = [];
       (this.def.dropping.targets || []).each(function(d) {
         $$(d).each(function(el) {
           if (el.childOf(widget)) dropzones.push(el);
@@ -753,14 +747,20 @@
   },
 
   _findDraggable: function(e) {
-    var element = Event.element(e);
-    var handle_selector = this.handle_selector;
+    var element = $(Event.element(e));
+    var handle = this.def.dragging.handle || this.def.dragging.sources || [];
     var widget = this.widget;
-    while (element.parentNode && !handle_selector.match(element)) {
-      if (!$(element).childOf(widget)) return null;
-      element = element.parentNode;
-    }
-    return (element != document) ? element : null;
+
+    var draggable = null;
+    $A(handle).each(function(h) {
+      $$(h).each(function(el) {
+        if (el == element || element.childOf(el)) {
+          draggable = el;
+          return;
+        };
+      });
+    });
+    return draggable;
   },
 
   _getVerticalSpeed: function(y) {
@@ -889,7 +889,7 @@
         };
       }.bind(this));
 
-      if (!shifted) {
+      if (!shifted && this._containerzones) {
         this._containerzones.each(function(s) {
           if (Position.within(s, x, y)) {
             s.appendChild(this.dragged);
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to