[richfaces-svn-commits] JBoss Rich Faces SVN: r2418 - in trunk/ui/tooltip/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Aug 22 16:00:52 EDT 2007


Author: dbiatenia
Date: 2007-08-22 16:00:52 -0400 (Wed, 22 Aug 2007)
New Revision: 2418

Modified:
   trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
   trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
avoid toolTip blinking when positioned 'left' of 'top'

Modified: trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
===================================================================
--- trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2007-08-22 19:59:16 UTC (rev 2417)
+++ trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2007-08-22 20:00:52 UTC (rev 2418)
@@ -155,10 +155,10 @@
         
         String showNewToolTip = ";" + getJsVarName(context, component) + ".displayDiv();";
         
-        String fireOnComplete = null;
-        if(((UIToolTip)component).getOncomplete() != null){
-        	
-        }
+        // before element will be substituted in DOM tree, we need to hide toolTipe to avoid blinking
+        String fireBeforeUpdateDOM = ";" + getJsVarName(context, component) + ".toolTip.style.display = 'none';";
+        
+       
         //enable ajaxSingle mode, i.e. we do not need to submit all form controls to get tooltip content
         eventOptions.put("control", JSReference.THIS);
         
@@ -174,7 +174,22 @@
 			onComplete.addToBody(refreshTooltipInDOM + showNewToolTip);
 			eventOptions.put("oncomplete", onComplete);
         }
+
+        if(eventOptions.containsKey("beforeupdate")){
+        	JSFunctionDefinition beforeUpdate = (JSFunctionDefinition)eventOptions.get("beforeupdate");
+        	beforeUpdate.addToBody(fireBeforeUpdateDOM);
+        	eventOptions.put("beforeupdate", beforeUpdate);
+        } else {
+			JSFunctionDefinition beforeUpdate = new JSFunctionDefinition();
+			beforeUpdate.addParameter("request");
+			beforeUpdate.addParameter("event");
+			beforeUpdate.addParameter("data");
+			beforeUpdate.addToBody(fireBeforeUpdateDOM);
+			eventOptions.put("oncomplete", beforeUpdate);
+        }
         
+        
+        
         return eventOptions;
 	}
 	

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-22 19:59:16 UTC (rev 2417)
+++ trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2007-08-22 20:00:52 UTC (rev 2418)
@@ -113,13 +113,7 @@
 		var obj;
 		if (!e) var e = window.event;
 		var relTarg = e.relatedTarget || e.fromElement;
-		
-//		if(e.srcElement){
-//			obj = e.srcElement;
-//		} else {
-//			obj = e.explicitOriginalTarget;
-//		}
-//		
+
 		while(relTarg){
 			if(relTarg == this.parent){
 				needToShow = false;
@@ -143,11 +137,13 @@
 		if(this.mode == 'ajax'){
 			if(this.toolTipDefaultContent){
 				this.toolTipContent.innerHTML = this.toolTipDefaultContent.innerHTML;
-				/*
+				
 				this.toolTip.style.visibility = "hidden";
 				this.toolTip.style.display = 'block';
-				*/
+				
 				this.setToolTipPosition(e); 
+				this.setToolTipVisible(false);
+				
 			}
 			var event = e;
 			var ajaxOptions = this.ajaxOptions;
@@ -166,24 +162,19 @@
 			eval(this.ajaxExecuteString);
 		} else {
 			this.setToolTipPosition(e);
-		}
-		
-		if(this.delay > 0){
-			setTimeout('Richfaces.tooltips[\'' + this.parentId + '\'].displayDiv()', this.delay);	
-		} else {
 			this.displayDiv();
 		}
 		
+//		if(this.delay > 0){
+//			setTimeout('Richfaces.tooltips[\'' + this.parentId + '\'].displayDiv()', this.delay);	
+//		} else {
+//			this.displayDiv();
+//		}
+//		
 	},
 
 	doHide: function(e){
 		var needToHide = true;
-//		var obj;
-//		if(e.srcElement){
-//			obj = e.srcElement;
-//		} else {
-//			obj = e.explicitOriginalTarget;
-//		}
 
 		if (!e) var e = window.event;
 		var relTarg = e.relatedTarget || e.toElement;
@@ -262,63 +253,6 @@
 		
 		var coords = this.fitToolTip(e.clientX, e.clientY, {'x':toolTipX , 'y':toolTipY},elementDim, horizontalDirection, verticalDirection, {'x':this.horizontalOffset, 'y':this.verticalOffset});
 		
-		
-//		if(this.direction == "top-left"){
-//			
-//			if(e.clientY - this.verticalOffset - this.toolTipH < 0){
-//				toolTipY = toolTipY + this.verticalOffset;
-//			} else {
-//				toolTipY = toolTipY - this.verticalOffset - this.toolTipH;
-//			}
-//			
-//			if(e.clientX - this.horizontalOffset - this.toolTipW < 0){
-//				toolTipX = toolTipX + this.horizontalOffset;
-//			} else {
-//				toolTipX = toolTipX - this.horizontalOffset - this.toolTipW;
-//			}
-//
-//		} else if(this.direction == "bottom-left"){
-//
-//			if(e.clientY + this.verticalOffset + this.toolTipH > windowDim[1]){
-//				toolTipY = toolTipY - this.verticalOffset - this.toolTipH;
-//			} else {
-//				toolTipY = toolTipY + this.verticalOffset;
-//			}
-//
-//			if(e.clientX - this.horizontalOffset - this.toolTipW < 0){
-//				toolTipX = toolTipX + this.horizontalOffset;
-//			} else {
-//				toolTipX = toolTipX - this.horizontalOffset - this.toolTipW;
-//			}
-//			
-//		} else if(this.direction == "top-right"){
-//			
-//			if(e.clientY - this.verticalOffset - this.toolTipH < 0){
-//				toolTipY = toolTipY + this.verticalOffset;
-//			} else {
-//				toolTipY = toolTipY - this.verticalOffset - this.toolTipH;
-//			}
-//			if(e.clientX + this.horizontalOffset + this.toolTipW > windowDim[0]){
-//				toolTipX = toolTipX - this.horizontalOffset - this.toolTipW;
-//			} else {
-//				toolTipX = toolTipX + this.horizontalOffset;
-//			}
-//			
-//		} else {
-//
-//			if(e.clientY + this.verticalOffset + this.toolTipH > windowDim[1]){
-//				toolTipY = toolTipY - this.verticalOffset - this.toolTipH;
-//			} else {
-//				toolTipY = toolTipY + this.verticalOffset;
-//			}
-//
-//			if(e.clientX + this.horizontalOffset + this.toolTipW > windowDim[0]){
-//				toolTipX = toolTipX - this.horizontalOffset - this.toolTipW;
-//			} else {
-//				toolTipX = toolTipX + this.horizontalOffset;
-//			}
-//		}
-//		Element.setStyle(this.toolTip, {"left": toolTipX + "px", "top": toolTipY + "px"});
 		Element.setStyle(this.toolTip, {"left": coords.x + "px", "top": coords.y + "px"});
 	},
 	
@@ -386,30 +320,12 @@
 			return coords;
 	},
 	
-	
-	windowSize: function() {
-	  var wWidth = 0, wHeight = 0;
-	  if( typeof( window.innerWidth ) == 'number' ) {
-	    //Non-IE
-	    wWidth = window.innerWidth;
-	    wHeight = window.innerHeight;
-	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
-	    //IE 6+ in 'standards compliant mode'
-	    wWidth = document.documentElement.clientWidth;
-	    wHeight = document.documentElement.clientHeight;
-	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
-	    //IE 4 compatible
-	    wWidth = document.body.clientWidth;
-	    wHeight = document.body.clientHeight;
-	  }
-	  return [wWidth,wHeight];
-	},
-	
 	displayDiv: function(){
 		//this.toolTip.style.display = 'block';
 		if(this.isMouseOvered){
 			
 			if(this.mode == 'ajax'){
+				this.toolTip.style.display = 'none';
 				if(this.clientAjaxParams){
 					/*
 					if(this.toolTipDefaultContent){
@@ -435,20 +351,36 @@
 					obj[yVarName] = this.clientAjaxParams[yVarName];
 					//var xValue = this.clientAjaxParams[xVarName];
 					//var yValue = this.clientAjaxParams[yVarName];
+					this.toolTip.style.visibility = "hidden";
+					this.toolTip.style.display = 'block';
+
 					this.setToolTipPosition(obj);
 				}
 			}
-			
-			this.toolTip.style.display = "block";
-			this.toolTip.style.visibility = "visible";
-			if(this.iframe){
-				this.iframe.style.top = parseInt(this.toolTip.style.top) - this.toolTipBorderHeight;
-				this.iframe.style.left = parseInt(this.toolTip.style.left) - this.toolTipBorderWidth;
-				this.iframe.style.display = "block"; 
+			if(this.delay > 0){
+				setTimeout('Richfaces.tooltips[\'' + this.parentId + '\'].setToolTipVisible(true)', this.delay);	
+			} else {
+				this.setToolTipVisible(true);
 			}
-			if(this.mode != 'ajax'){
-				this.oncomplete(window.event);
-			}
+
+			
+//			if(this.mode != 'ajax'){
+//				this.oncomplete(window.event);
+//			}
 		}
+	},
+	
+	setToolTipVisible: function(runOnComplete){
+		this.toolTip.style.display = "block";
+		this.toolTip.style.visibility = "visible";
+		if(this.iframe){
+			this.iframe.style.top = parseInt(this.toolTip.style.top) - this.toolTipBorderHeight;
+			this.iframe.style.left = parseInt(this.toolTip.style.left) - this.toolTipBorderWidth;
+			this.iframe.style.display = "block"; 
+		}
+		if(runOnComplete){
+			this.oncomplete(window.event);	
+		}
+		
 	}
 } 
\ No newline at end of file




More information about the richfaces-svn-commits mailing list