[richfaces-svn-commits] JBoss Rich Faces SVN: r5323 - in branches/3.1.x: samples/tooltip-sample/src/main/webapp/WEB-INF and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Jan 11 21:39:05 EST 2008


Author: nbelaevski
Date: 2008-01-11 21:39:05 -0500 (Fri, 11 Jan 2008)
New Revision: 5323

Modified:
   branches/3.1.x/samples/tooltip-sample/pom.xml
   branches/3.1.x/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml
   branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/demo.jsp
   branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/index.jsp
   branches/3.1.x/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
   branches/3.1.x/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
http://jira.jboss.com/jira/browse/RF-1833
http://jira.jboss.com/jira/browse/RF-1896

Modified: branches/3.1.x/samples/tooltip-sample/pom.xml
===================================================================
--- branches/3.1.x/samples/tooltip-sample/pom.xml	2008-01-12 02:16:54 UTC (rev 5322)
+++ branches/3.1.x/samples/tooltip-sample/pom.xml	2008-01-12 02:39:05 UTC (rev 5323)
@@ -18,6 +18,11 @@
 			<version>3.1.4-SNAPSHOT</version>
 		</dependency>
 		<dependency>
+			<groupId>org.richfaces.ui</groupId>
+			<artifactId>componentControl</artifactId>
+			<version>3.2.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
 			<groupId>org.richfaces.samples</groupId>
 			<artifactId>skins</artifactId>
 			<version>3.1.4-SNAPSHOT</version>

Modified: branches/3.1.x/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- branches/3.1.x/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml	2008-01-12 02:16:54 UTC (rev 5322)
+++ branches/3.1.x/samples/tooltip-sample/src/main/webapp/WEB-INF/faces-config.xml	2008-01-12 02:39:05 UTC (rev 5323)
@@ -12,5 +12,16 @@
         <managed-bean-class>org.richfaces.SkinBean</managed-bean-class>
         <managed-bean-scope>session</managed-bean-scope>
     </managed-bean>
-
+	<navigation-rule>
+		<navigation-case>
+			<from-outcome>demo</from-outcome>
+			<to-view-id>/pages/demo.jsp</to-view-id>
+			<redirect/>
+		</navigation-case>
+		<navigation-case>
+			<from-outcome>index</from-outcome>
+			<to-view-id>/pages/index.jsp</to-view-id>
+			<redirect/>
+		</navigation-case>
+	</navigation-rule>
 </faces-config>

Modified: branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/demo.jsp
===================================================================
--- branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/demo.jsp	2008-01-12 02:16:54 UTC (rev 5322)
+++ branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/demo.jsp	2008-01-12 02:39:05 UTC (rev 5323)
@@ -10,7 +10,9 @@
 	</head>
 	<body>
 		<f:view>
-			<h:outputLink value="pages/index.jsf">index.jsf</h:outputLink>
+			<h:form>
+				<h:commandLink action="index">index.jsf</h:commandLink>
+			</h:form>
 	<h:panelGrid columns="2">
 		<a4j:outputPanel layout="block" style="width:350px;height:75px;cursor:arrow;border-width:2px;text-align:center;border:2px solid red">
 			<f:verbatim>
@@ -36,7 +38,7 @@
 				</p>
 			</f:verbatim>
 		
-		<rich:toolTip followMouse="true" direction="top-right" delay="500" styleClass="tooltip" style="width:250px">
+		<rich:toolTip followMouse="true" direction="top-right" showDelay="500" styleClass="tooltip" style="width:250px">
 			<f:verbatim>
 				<span>
 					This tool-tip content also <strong>pre-rendered</strong> to the page.
@@ -103,7 +105,7 @@
 				</p>
 			</f:verbatim>
 		
-		<rich:toolTip delay="2000" direction="top-right" mode="ajax" styleClass="tooltip" layout="block">
+		<rich:toolTip showDelay="2000" direction="top-right" mode="ajax" styleClass="tooltip" layout="block">
 			<f:facet name="defaultContent">
 				<f:verbatim>
 					<strong>Wait...</strong>

Modified: branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/index.jsp	2008-01-12 02:16:54 UTC (rev 5322)
+++ branches/3.1.x/samples/tooltip-sample/src/main/webapp/pages/index.jsp	2008-01-12 02:39:05 UTC (rev 5323)
@@ -3,6 +3,7 @@
 <%--@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"--%>
 <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
 <%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/tooltip" prefix="rich"%>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/componentControl" prefix="cc"%>
 
 <html>
 	<head>
@@ -10,8 +11,10 @@
 	</head>
 	<body>
 		<f:view>
-			<h:outputLink value="pages/demo.jsf">demo.jsf</h:outputLink>
 			<h:form>
+				<h:commandLink action="demo">demo.jsf</h:commandLink>
+			</h:form>
+			<h:form>
 				<h:selectOneRadio binding="#{skinBean.component}" />
 				<h:commandLink action="#{skinBean.change}" value="set skin" />
 				<f:verbatim>
@@ -46,6 +49,21 @@
 				</h:commandButton--%>
 				
 				<%--a4j:log popup="false" level="ALL"></a4j:log--%>
+			
+				<h:outputText id="text1" value="Text with tooltip">
+					<rich:toolTip id="controlledTooltip" followMouse="false" direction="top-right" value="#{bean.toolTipContent}" horizontalOffset="5" verticalOffset="5" layout="inline">
+					</rich:toolTip>				
+				</h:outputText>
+			
+				<f:verbatim>
+					<br />
+					<span id="controlInput">
+					Mouse down here
+					</span>
+				</f:verbatim>
+
+				<cc:componentControl event="mousedown" operation="show" for="controlledTooltip" attachTo="controlInput" />
+				<cc:componentControl event="mouseup" operation="hide" for="controlledTooltip" attachTo="controlInput" />
 			</h:form>
 			
 		</f:view>

Modified: branches/3.1.x/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
===================================================================
--- branches/3.1.x/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2008-01-12 02:16:54 UTC (rev 5322)
+++ branches/3.1.x/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2008-01-12 02:39:05 UTC (rev 5323)
@@ -137,17 +137,20 @@
 	
 	public Map buildEventOptions(FacesContext context, UIComponent component, String targetId){
         Map eventOptions = AjaxRendererUtils.buildEventOptions(context,	component);
-        String jsVarName = "Richfaces.tooltips[\'" + targetId + "\']";
+        String jsVarName = "_toolTip";
         
         //after element is subsituted in DOM tree, we have to re-create
         //it's JS-reference, cause old one is already invalid
-		String refreshTooltipInDOM = ";" + jsVarName + ".toolTip = $('" + component.getClientId(context) + "');" +
-        	";" + jsVarName + ".toolTipContent = $('" + component.getClientId(context) + "content');";
+		
+        String clientId = component.getClientId(context);
+		String oncompleteTooltip = ";" + "{" + 
+			"var " + jsVarName + " = $('" + clientId + "').component;" +
+        	jsVarName + ".toolTipContent = $('" + clientId + "content');" +
+        	jsVarName + ".displayDiv();" + 
+        	"}";
         
-        String showNewToolTip = ";" + jsVarName + ".displayDiv();";
-        
         // before element will be substituted in DOM tree, we need to hide toolTipe to avoid blinking
-        String fireBeforeUpdateDOM = ";" + jsVarName + ".toolTip.style.display = 'none';";
+        String fireBeforeUpdateDOM = ";" + "{ var " + jsVarName + " = $('" + clientId + "').component;" + jsVarName + ".toolTip.style.display = 'none'; }";
         
        
         //enable ajaxSingle mode, i.e. we do not need to submit all form controls to get tooltip content
@@ -155,14 +158,14 @@
         
         if(eventOptions.containsKey("oncomplete")){
         	JSFunctionDefinition onComplete = (JSFunctionDefinition)eventOptions.get("oncomplete");
-        	onComplete.addToBody(refreshTooltipInDOM + showNewToolTip);
+        	onComplete.addToBody(oncompleteTooltip);
         	eventOptions.put("oncomplete", onComplete);
         } else {
 			JSFunctionDefinition onComplete = new JSFunctionDefinition();
 			onComplete.addParameter("request");
 			onComplete.addParameter("event");
 			onComplete.addParameter("data");
-			onComplete.addToBody(refreshTooltipInDOM + showNewToolTip);
+			onComplete.addToBody(oncompleteTooltip);
 			eventOptions.put("oncomplete", onComplete);
         }
 

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-12 02:16:54 UTC (rev 5322)
+++ branches/3.1.x/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2008-01-12 02:39:05 UTC (rev 5323)
@@ -1,11 +1,13 @@
-if(!Richfaces.tooltips){
-	Richfaces.tooltips = [];
+if (!window.Richfaces) {
+	window.Richfaces = {};
 }
 
 ToolTip = Class.create();
 
 ToolTip.prototype = {
 	initialize:function(events, id, parentId, mode, disabled, direction, followMouse, horizontalOffset, verticalOffset, ajaxFunction, ajaxOptions){
+		this["rich:destructor"] = "destroy";
+		
 		this.event = events.event;
 		this.onshow = new Function('event', events.onshow + ';return true;');
 		this.oncomplete = new Function('event', events.oncomplete + ';return true;');
@@ -27,6 +29,7 @@
 		this.clientAjaxParams = {};
 		
 		this.toolTip = $(id);
+		this.toolTip.component = this;
 		
 		this.toolTipContent = $(id + 'content');
 		this.toolTipDefaultContent = $(id + 'defaultContent');
@@ -71,20 +74,25 @@
 		
 		this.leaveToolTipListner = this.leaveToolTip.bindAsEventListener(this);
 		
-		if (Richfaces.tooltips[parentId])
-		{
-			Richfaces.tooltips[parentId].destroy();
-		}
+//		if (Richfaces.tooltips[parentId])
+//		{
+//			Richfaces.tooltips[parentId].destroy();
+//		}
 
 		if(!this.disabled)	Event.observe(document, "mousemove", this.attachOnLoadEventsListner, true);
 		
 		//it means we have only one tooltip for element
-		Richfaces.tooltips[parentId] = this;
+		//TODO review
+		//Richfaces.tooltips[parentId] = this;
 		
 	},
 	
 	destroy: function()
 	{
+			if (this.toolTip) {
+				this.toolTip.component = null;
+			}
+		
 			if (!this.parentAttached)
 			{
 				if (!this.disabled) Event.stopObserving(document, "mousemove", this.attachOnLoadEventsListner, true);
@@ -164,7 +172,7 @@
 		// Return true if "element" is "leaf" or one of its parents
 		var node = leaf;
 		while (node != null && node != element)
-			node = node.parentNode;
+			node = node.parentNode;				
 		return (node != null);
 	},
 	
@@ -198,10 +206,10 @@
 			}
 			relTarg = relTarg.parentNode;
 		}
+				
+		if(!needToShow) return;
 		
-		if(!needToShow) return;
-
-
+		
 		this.onshow(e);
 		
 		this.isMouseOvered = true;
@@ -265,8 +273,8 @@
 			}
 			relTarg = relTarg.parentNode;
 		}
-	
 		
+		
 		if(!needToHide) return;
 		
 		if (this.activationTimerHandle) {
@@ -280,18 +288,18 @@
 
 		
 		if (!fakeEvent) {
-			this.isMouseOvered = false;
-			this.toolTip.style.visibility = "hidden";
-			this.toolTip.style.display = "none";
-			
-			if(this.iframe){
-				this.iframe.style.display = "none";
-			}
-			this.hintParentElement = null;
-			this.isMouseOvered = false;
-			this.onhide(e);
+		this.isMouseOvered = false;
+		this.toolTip.style.visibility = "hidden";
+		this.toolTip.style.display = "none";
+		
+		if(this.iframe){
+			this.iframe.style.display = "none";
 		}
-
+		this.hintParentElement = null;
+		this.isMouseOvered = false;
+		this.onhide(e);
+		}
+		
 		if (this.hidingTimerHandle) {
 			window.clearTimeout(this.hidingTimerHandle);
 			this.hidingTimerHandle = undefined;
@@ -305,6 +313,22 @@
 		this.disabled = true;
 	},
 	
+	show: function(e) {
+		this.doShow(e);
+	},
+	
+	hide: function(e) {
+		this.doHide(e);
+	},
+	
+	enable: function(e) {
+		this.doEnable(e);
+	},
+	
+	disable: function(e) {
+		this.doDisable(e);
+	},
+
 	/*
 	 * we can pass here not event only, but also object {'clientX':XXX, 'clientY':XXX}
 	 */
@@ -483,4 +507,4 @@
 		}
 		
 	}
-} 
+} 
\ No newline at end of file




More information about the richfaces-svn-commits mailing list