[richfaces-svn-commits] JBoss Rich Faces SVN: r5498 - branches/3.1.x/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Jan 21 12:04:36 EST 2008


Author: sergeyhalipov
Date: 2008-01-21 12:04:36 -0500 (Mon, 21 Jan 2008)
New Revision: 5498

Modified:
   branches/3.1.x/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
http://jira.jboss.com/jira/browse/RF-1485

Modified: branches/3.1.x/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
===================================================================
--- branches/3.1.x/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2008-01-21 16:30:20 UTC (rev 5497)
+++ branches/3.1.x/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2008-01-21 17:04:36 UTC (rev 5498)
@@ -193,6 +193,7 @@
 	},
 	
 	doShow: function(e){
+		this.setScrollDelta();
 		
 		var needToShow = true;
 		var obj;
@@ -304,6 +305,8 @@
 			window.clearTimeout(this.hidingTimerHandle);
 			this.hidingTimerHandle = undefined;
 		}
+		
+		this.scrollDelta = undefined;
 	},
 	
 	doEnable: function(){
@@ -329,6 +332,24 @@
 		this.doDisable(e);
 	},
 
+	setScrollDelta: function() {
+		if (!this.scrollDelta) {
+			this.scrollDelta = [0, 0];
+		}
+		var parentNode = this.parent;
+		while (parentNode && !/^body$/i.test(parentNode.tagName)) {
+			if (/^absolute$/i.test(Richfaces.getComputedStyle(parentNode, "position"))) {
+				if (parentNode.scrollLeft) {
+					this.scrollDelta[0] = parentNode.scrollLeft;
+				}
+				if (parentNode.scrollTop) {
+					this.scrollDelta[1] = parentNode.scrollTop;
+				}
+			}
+			parentNode = parentNode.parentNode;
+		}
+	},
+	
 	/*
 	 * we can pass here not event only, but also object {'clientX':XXX, 'clientY':XXX}
 	 */
@@ -345,9 +366,20 @@
 //		this.toolTipH = toolTipDim.height;
 	
 		var elementDim = Richfaces.Position.getOffsetDimensions(this.toolTip);
+
+		// RF-1485, fix for FF
+		var _display = this.toolTip.style.display;
+		var _visibility = this.toolTip.style.visibility;
+		this.toolTip.style.visibility = "hidden";
+		this.toolTip.style.display = "block";
+		this.toolTip.style.top = "0px";
+		this.toolTip.style.left = "0px";
 		
 		var offsets = Position.cumulativeOffset(this.toolTip);
 		
+		this.toolTip.style.visibility = _visibility;
+		this.toolTip.style.display = _display;
+		
 		offsets[0] -= this.toolTip.offsetLeft || 0;
 		offsets[1] -= this.toolTip.offsetTop || 0;
 	
@@ -366,6 +398,10 @@
 		
 		var coords = this.fitToolTip(e.clientX, e.clientY, {'x':toolTipX , 'y':toolTipY},elementDim, horizontalDirection, verticalDirection, {'x':this.horizontalOffset, 'y':this.verticalOffset});
 		
+		if (this.scrollDelta) {
+			coords.x += this.scrollDelta[0];
+			coords.y += this.scrollDelta[1];
+		}
 		Element.setStyle(this.toolTip, {"left": coords.x + "px", "top": coords.y + "px"});
 		if(this.iframe)
 		{
@@ -507,4 +543,4 @@
 		}
 		
 	}
-} 
\ No newline at end of file
+} 




More information about the richfaces-svn-commits mailing list