[richfaces-svn-commits] JBoss Rich Faces SVN: r2624 - trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Aug 30 12:41:35 EDT 2007


Author: nbelaevski
Date: 2007-08-30 12:41:35 -0400 (Thu, 30 Aug 2007)
New Revision: 2624

Modified:
   trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
http://jira.jboss.com/jira/browse/RF-766

Modified: trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
===================================================================
--- trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2007-08-30 16:41:30 UTC (rev 2623)
+++ trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2007-08-30 16:41:35 UTC (rev 2624)
@@ -59,7 +59,7 @@
 			this.iframe = $(this.id + 'iframe');	
 		}		
 		
-		if(!this.disabled)	Event.observe(document.getElementsByTagName("body")[0], "mousemove", this.attachOnLoadEvents.bindAsEventListener(this), true);
+		if(!this.disabled)	Event.observe(document, "mousemove", this.attachOnLoadEvents.bindAsEventListener(this), true);
 		//it means we have only one tooltip for elements
 		Richfaces.tooltips[parentId] = this;
 	},
@@ -70,14 +70,32 @@
 				this.attachParentEvents();
 				this.parentAttached = true;
 			}
-			Event.stopObserving(document.getElementsByTagName("body")[0], "mousemove", this.attachOnLoadEvents.bindAsEventListener(this), false);
+			Event.stopObserving(document, "mousemove", this.attachOnLoadEvents.bindAsEventListener(this), false);
 		}
 	},
 	attachParentEvents: function(){
 		if(this.followMouse){
 			Event.observe(this.parent, 'mousemove', this.setToolTipPosition.bindAsEventListener(this), false);	
 		}
-		Event.observe(this.parent, this.event, this.doShow.bindAsEventListener(this), false);
+		
+		var eventHandler;
+		if (this.delay > 0) {
+			eventHandler = function(event) {
+				if (this.activationTimerHandle) {
+					return ;
+				}
+				
+				var eventCopy = A4J.AJAX.CloneObject(event, false);
+				
+				this.activationTimerHandle = setTimeout(function() {
+					this.doShow(eventCopy);
+				}.bind(this), this.delay);
+			}.bindAsEventListener(this);
+		} else {
+			eventHandler = this.doShow.bindAsEventListener(this);
+		}
+
+		Event.observe(this.parent, this.event, eventHandler, false);
 		Event.observe(this.parent, "mouseout", this.doHide.bindAsEventListener(this), false);
 		
 		Event.observe(this.toolTip, 'mouseout', this.leaveToolTip.bindAsEventListener(this), false)
@@ -107,7 +125,6 @@
 		}
 	},
 	
-	
 	doShow: function(e){
 		var needToShow = true;
 		var obj;
@@ -190,9 +207,9 @@
 		
 		if(!needToHide) return;
 		
-		if (this.queuedToolTip) {
-			clearTimeout(this.queuedToolTip);
-			this.queuedToolTip = undefined;
+		if (this.activationTimerHandle) {
+			clearTimeout(this.activationTimerHandle);
+			this.activationTimerHandle = undefined;
 		}
 		
 		var fakeEvent = false;
@@ -362,12 +379,15 @@
 					this.setToolTipPosition(obj);
 				}
 			}
-			if(this.delay > 0){
-				this.queuedToolTip = setTimeout('Richfaces.tooltips[\'' + this.parentId + '\'].setToolTipVisible(true)', this.delay);	
-			} else {
-				this.setToolTipVisible(true);
-			}
 
+			this.setToolTipVisible(true);
+
+//			if(this.delay > 0) {
+//				this.queuedToolTip = setTimeout('Richfaces.tooltips[\'' + this.parentId + '\'].setToolTipVisible(true)', this.delay);	
+//			} else {
+//				this.setToolTipVisible(true);
+//			}
+
 			
 //			if(this.mode != 'ajax'){
 //				this.oncomplete(window.event);
@@ -376,7 +396,7 @@
 	},
 	
 	setToolTipVisible: function(runOnComplete){
-		this.queuedToolTip = undefined;
+		this.activationTimerHandle = undefined;
 		this.toolTip.style.display = "block";
 		this.toolTip.style.visibility = "visible";
 		if(this.iframe){




More information about the richfaces-svn-commits mailing list