Author: jmorliaguet
Date: Fri May 26 20:38:52 2006
New Revision: 3230

Modified:
   cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js

Log:

- context menu / drag-and-drop improvements



Modified: cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js
==============================================================================
--- cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js    
(original)
+++ cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js    Fri May 
26 20:38:52 2006
@@ -814,6 +814,7 @@
 
     var dragEvent = this.dragEvent.bindAsEventListener(
                       Object.extend(this, {widget: widget}));
+    widget.setStyle({cursor: 'default'});
     Event.observe(widget, "mousedown", dragEvent);
   },
 
@@ -1031,7 +1032,7 @@
     }
 
     var dropping = this.def.dropping;
-    if (dropping) {
+    if (dropping && this.dragged) {
       var action_id = dropping.action;
       if (action_id) {
         var action_handler = CPSSkins.getAction(action_id);
@@ -1044,12 +1045,11 @@
     }
 
     if (this.def.dragging.feedback) {
-      if (zoomback) {
+      if (zoomback && this.moved) {
         this.moved.moveTo({
           'x': this.x0,
           'y': this.y0,
           'duration': zoomback.duration || 400,
-          'onComplete': function() { this.parentNode.removeChild(this); }
         });
       }
     }
@@ -1075,16 +1075,16 @@
       }
     }
 
-    if (this.def.dragging.feedback && !zoomback && !zoomto) {
+    if (this.def.dragging.feedback && !zoomback && !zoomto && this.moved) {
       var parent = this.moved.parentNode;
       if (parent) {
         parent.removeChild(this.moved);
       }
     }
 
-    this.moved.setStyle({cursor: ''});
+    if (this.moved) this.moved.setStyle({cursor: ''});
 
-    this.dragged.setOpacity(1);
+    if (this.dragged) this.dragged.setOpacity(1);
     Event.stop(e);
   }
 
@@ -1482,6 +1482,7 @@
 
   deactivate: function(node, options) {
     var bg = node._saved_bg_color;
+    if (!bg) return;
     Object.extend(options, {
       action: function(value) {
         node.setBackgroundColor({r: bg.r, g: bg.g, b: bg.b-(1-value)});
@@ -2219,12 +2220,13 @@
     Event.observe(this.widget, "mouseover", this.mouseOverEvent);
     Event.observe(document, "mousedown", this.hideEvent);
 
-    var area = $(this.def.area);
+    var area = this.area = $(this.def.area);
     if (area) {
       Event.observe(area, "mouseup", this.showEvent);
       area.oncontextmenu = new Function("return false");
     }
     this._displayed = false;
+    this.wait = true;
   },
 
   render: function(data) {
@@ -2389,6 +2391,7 @@
 
   /* Event handlers */
   showEvent: function(e) {
+    if (this.wait) return;
     var element = Event.element(e);
     var selected = CPSSkins.Identifiable.getIdentifiable(element);
     if (!selected) return;
@@ -2402,9 +2405,14 @@
     this._displayed = true;
     this.focus();
     this.show();
+    return false;
   },
 
   hideEvent: function(e) {
+    var x = Event.pointerX(e);
+    var y = Event.pointerY(e);
+    this.wait = !this.wait;
+    if (!Position.within(this.area, x, y)) this.wait = true;
     this._displayed = false;
     this.defocus();
     this.hide();
@@ -2430,6 +2438,7 @@
     }
     CPSSkins.notify("command", info);
     Event.stop(e);
+    this.wait = true;
   },
 
   mouseOverEvent: function(e) {
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to