Author: jmorliaguet
Date: Wed Jan  4 12:57:43 2006
New Revision: 2134

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

- don't show the tooltip if a mouseout event occurs before the show delay has
  elapsed



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 Wed Jan  4 
12:57:43 2006
@@ -287,7 +287,8 @@
     this.onComplete = options.onComplete || function() {};
     this.duration = options.duration || 300;
 
-    this.start()
+    this.started = false;
+    this.start();
   },
 
   start: function() {
@@ -303,6 +304,7 @@
       this.stop();
     } else {
       this.action((1-Math.cos(pos*Math.PI))/2);
+      this.started = true;
     }
   },
 
@@ -649,34 +651,27 @@
     this.hint = null;
     this.effect = null;
 
-    this.setupEvent = this.setup.bindAsEventListener(this);
-    this.hideEvent = this.hide.bindAsEventListener(this);
-    Event.observe(this.area || document, "mouseover", this.setupEvent);
+    this.showEvent = this.showEvent.bindAsEventListener(this);
+    this.hideEvent = this.hideEvent.bindAsEventListener(this);
+    Event.observe(this.area || document, "mouseover", this.showEvent);
+    Event.observe(this.area || document, "mouseout", this.hideEvent);
   },
 
-  setup: function(e) {
+  showEvent: function(e) {
     var selected = Event.element(e);
     var data = Canvas.getNodeData(selected);
     if (!data) return;
-    this.hint = {
-      selected: selected,
-      text: data["hint"],
-      x: Event.pointerX(e),
-      y: Event.pointerY(e)
-    }
-    this.show();
-  },
 
-  show: function() {
     var widget = this.widget;
-    widget.style.top = this.hint.y + 20 + "px";
-    widget.style.left = this.hint.x + "px";
-    widget.innerHTML = this.hint.text;
+    widget.style.top = Event.pointerY(e) + 20 + "px";
+    widget.style.left = Event.pointerX(e) + "px";
+    widget.innerHTML = data["hint"]
 
     if (this.effect) {
       this.effect.stop();
     }
 
+    Element.hide(widget);
     this.effect = new CPSSkins.Scheduler(widget, {
       delay: this.options.showdelay,
       action: function(value) {
@@ -684,19 +679,27 @@
         },
       onComplete: function() {
         Element.show(widget);
-      }.bind(this)
+      }
     });
 
-    Event.observe(this.hint.selected, "mouseout", this.hideEvent);
+    this.selected = selected;
   },
 
-  hide: function(e) {
+  hideEvent: function(e) {
+    var selected = Event.element(e);
+    if (selected != this.selected) return;
+
     var widget = this.widget;
 
     if (this.effect) {
       this.effect.stop();
     }
 
+    if (this.effect && !this.effect.started) {
+      Element.hide(widget);
+      return;
+    }
+
     this.effect = new CPSSkins.Scheduler(widget, {
       delay: this.options.hidedelay,
       action: function(value) {
@@ -704,9 +707,6 @@
         },
       onComplete: function() {
         Element.hide(widget);
-        if (this.hint) {
-          Event.stopObserving(this.hint.selected, "mouseout", this.hideEvent);
-        }
       }.bind(this)
     });
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to