Author: jmorliaguet
Date: Mon Dec 26 18:12:27 2005
New Revision: 2083

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

- fixed race condition in the tooltip



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 Mon Dec 26 
18:12:27 2005
@@ -150,7 +150,7 @@
     var area = node.getAttribute('area');
     var options = {
       delay: node.getAttribute('delay') || 1000,
-      label: node.getAttribute('label') || 'hint'
+      text: node.getAttribute('text') || 'hint'
     }
     new CPSSkins.Tooltip(tooltip, area, options);
   }
@@ -313,37 +313,37 @@
     this.area = $(area);
     this.options = options;
 
+    this.hint = null;
+
     this.setupEvent = this.setup.bindAsEventListener(this);
     this.hideEvent = this.hide.bindAsEventListener(this);
 
     var area = area || document;
-    Event.observe(document, 'mouseover', this.setupEvent);
-    Event.observe(document, 'mouseout', this.hideEvent);
+    Event.observe(area, 'mouseover', this.setupEvent);
+    Event.observe(area, 'mouseout', this.hideEvent);
   },
 
   setup: function(e) {
-    if (this.active) return;
-    var x = Event.pointerX(e);
-    var y = Event.pointerY(e);
-    if (!Position.within(this.area, x, y)) return;
-    var node = this.node;
-    var hint = Event.element(e).getAttribute(this.options.label);
-    if (!hint) { return; }
-    node.innerHTML = hint;
-    setTimeout((function() {this.show(x, y)}).bind(this), 1000);
-    this.active = true;
+    this.hint = {
+      text: Event.element(e).getAttribute(this.options.text) || '',
+      x: Event.pointerX(e),
+      y: Event.pointerY(e)
+    }
+    setTimeout((function() {this.show()}).bind(this), this.options.delay);
   },
 
-  show: function(x, y) {
+  show: function() {
     var node = this.node;
-    node.style.top = y + 20 + 'px';
-    node.style.left = x + 'px';
+    if (!this.hint) return;
+    node.style.top = this.hint['y'] + 20 + 'px';
+    node.style.left = this.hint['x'] + 'px';
+    node.innerHTML = this.hint['text'];
     Element.show(node);
   },
 
   hide: function(e) {
+    this.hint = null;
     Element.hide(this.node);
-    this.active = false;
   }
 }
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to