[richfaces-svn-commits] JBoss Rich Faces SVN: r14556 - in branches/community/3.3.X: ui/tooltip/src/main/java/org/richfaces/renderkit/html and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Jun 8 11:56:13 EDT 2009


Author: konstantin.mishin
Date: 2009-06-08 11:56:13 -0400 (Mon, 08 Jun 2009)
New Revision: 14556

Modified:
   branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
   branches/community/3.3.X/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
   branches/community/3.3.X/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
RF-7327

Modified: branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java	2009-06-08 15:26:15 UTC (rev 14555)
+++ branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java	2009-06-08 15:56:13 UTC (rev 14556)
@@ -651,6 +651,40 @@
 	}
 	
 	/**
+	 * Puts value into map under specified key if the value is not empty and not default. 
+	 * Performs optional value wrapping.
+	 * 
+	 * @param hash
+	 * @param name
+	 * @param value
+	 * @param defaultValue
+	 * 
+	 * @since 3.3.2
+	 */
+	public void addToScriptHash(Map<String, Object> hash, 
+			String name, 
+			Object value, 
+			String defaultValue) {
+		addToScriptHash(hash, name, value, defaultValue, null);
+	}
+
+	/**
+	 * Puts value into map under specified key if the value is not empty and not default. 
+	 * Performs optional value wrapping.
+	 * 
+	 * @param hash
+	 * @param name
+	 * @param value
+	 * 
+	 * @since 3.3.2
+	 */
+	public void addToScriptHash(Map<String, Object> hash, 
+			String name, 
+			Object value) {
+		addToScriptHash(hash, name, value, null, null);
+	}
+
+	/**
 	 * Convert HTML attribute name to component property name.
 	 * 
 	 * @param key

Modified: branches/community/3.3.X/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
===================================================================
--- branches/community/3.3.X/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2009-06-08 15:26:15 UTC (rev 14555)
+++ branches/community/3.3.X/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java	2009-06-08 15:56:13 UTC (rev 14556)
@@ -42,6 +42,7 @@
 import org.ajax4jsf.javascript.ScriptUtils;
 import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
 import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
 import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
 import org.ajax4jsf.resource.InternetResource;
 import org.richfaces.component.UIToolTip;
@@ -154,22 +155,13 @@
             UIComponent component) {
         Map<String, Object> eventOptions = AjaxRendererUtils.buildEventOptions(
                 context, component);
-        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 clientId = component.getClientId(context);
-        String oncompleteTooltip = ";" + "{" + "var " + jsVarName + " = $('"
-                + clientId + "').component;" + jsVarName
-                + ".toolTipContent = $('" + clientId + "content');" + jsVarName
-                + ".displayDiv();" + "}";
+        String oncompleteTooltip = "; request.options.control.displayDiv();";
         
         // before element will be substituted in DOM tree, we need to hide
         // toolTipe to avoid blinking
-        String fireBeforeUpdateDOM = ";" + "{ var " + jsVarName + " = $('"
-                + clientId + "').component;" + jsVarName
-                + ".toolTip.style.display = 'none'; }";
+        String fireBeforeUpdateDOM = "; request.options.control.toolTip.style.display = 'none';";
         
         // enable ajaxSingle mode, i.e. we do not need to submit all form
         // controls to get tooltip content
@@ -197,7 +189,7 @@
         } else {
             JSFunctionDefinition beforeUpdate = new JSFunctionDefinition();
             beforeUpdate.addParameter("request");
-            beforeUpdate.addParameter("showEvent");
+            beforeUpdate.addParameter("event");
             beforeUpdate.addParameter("data");
             beforeUpdate.addToBody(fireBeforeUpdateDOM);
             eventOptions.put(AjaxRendererUtils.ONBEFOREDOMUPDATE_ATTR_NAME, beforeUpdate);
@@ -213,7 +205,7 @@
         ret.append("<script ");
         ret.append("type=\"text/javascript\" ");
         ret.append("id =\"script").append(component.getClientId(context)).append("\">\n");
-        ret.append(constructJSVariable(context, component)).append(";\n\n");
+        ret.append(constructJSVariable(context, component)).append("\n");
         ret.append("</script>");
 
         context.getResponseWriter().write(ret.toString());
@@ -256,52 +248,45 @@
         String targetClientId = getTargetId(context, component);
         
         Map<String, Object> options = new HashMap<String, Object>();
-        //Map<JSReference, Object> eventsMap = new HashMap<JSReference, Object>();
         
         String eventShow = (toolTip.isAttached()) ? toolTip.getShowEvent() : "";
         if (eventShow.startsWith("on")) {
             eventShow = eventShow.substring(2);
         }
-        getUtils().addToScriptHash(options, "showEvent", eventShow, "mouseover", ScriptHashVariableWrapper.DEFAULT); 
+        RendererUtils utils = getUtils();
+		utils.addToScriptHash(options, "showEvent", eventShow); 
         String eventHide = (toolTip.isAttached()) ? toolTip.getHideEvent() : "";
         if (eventHide.startsWith("on")) {
             eventHide = eventHide.substring(2);
         }
-        getUtils().addToScriptHash(options, "hideEvent", eventHide, null, ScriptHashVariableWrapper.DEFAULT); 
+        utils.addToScriptHash(options, "hideEvent", eventHide); 
 
-        getUtils().addToScriptHash(options, "delay", toolTip.getShowDelay(), "0", ScriptHashVariableWrapper.DEFAULT); 
-        getUtils().addToScriptHash(options, "hideDelay", toolTip.getHideDelay(), "0", ScriptHashVariableWrapper.DEFAULT); 
+        utils.addToScriptHash(options, "delay", toolTip.getShowDelay(), "0"); 
+        utils.addToScriptHash(options, "hideDelay", toolTip.getHideDelay(), "0"); 
         
         if (AJAX_MODE.equalsIgnoreCase(toolTip.getMode())) {
-        	JSFunctionDefinition ajaxFunc = new JSFunctionDefinition("event", "ajaxOptions");
+        	JSFunctionDefinition ajaxFunc = new JSFunctionDefinition("event");
             JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context);
-            JSReference ref = new JSReference("ajaxOptions");
-            function.addParameter(ref);
-            ajaxFunc.addToBody(function);
-            getUtils().addToScriptHash(options, "ajaxFunction", ajaxFunc, null, ScriptHashVariableWrapper.DEFAULT); 
             Map<String, Object> ajaxOptions = buildEventOptions(context, toolTip);
             ajaxOptions.putAll(getParamsMap(context, toolTip));
-            getUtils().addToScriptHash(options, "ajaxOptions", ajaxOptions, null, ScriptHashVariableWrapper.DEFAULT); 
+            function.addParameter(ajaxOptions);
+            ajaxFunc.addToBody(function);
+            utils.addToScriptHash(options, "ajaxFunction", ajaxFunc); 
        } 
         
-        
-        JSFunctionDefinition completeFunc = getUtils().getAsEventHandler(
-                context, component, "oncomplete", "; return true;");
-        getUtils().addToScriptHash(options, "oncomplete", completeFunc, null, ScriptHashVariableWrapper.DEFAULT); 
-
-        JSFunctionDefinition hideFunc = getUtils().getAsEventHandler(
+        JSFunctionDefinition hideFunc = utils.getAsEventHandler(
                 context, component, "onhide", "; return true;");
-        getUtils().addToScriptHash(options, "onhide", hideFunc, null, ScriptHashVariableWrapper.DEFAULT); 
+        utils.addToScriptHash(options, "onhide", hideFunc); 
 
-        JSFunctionDefinition showFunc = getUtils().getAsEventHandler(
+        JSFunctionDefinition showFunc = utils.getAsEventHandler(
                 context, component, "onshow", "; return true;");
-        getUtils().addToScriptHash(options, "onshow", showFunc, null, ScriptHashVariableWrapper.DEFAULT); 
+        utils.addToScriptHash(options, "onshow", showFunc); 
         
-        getUtils().addToScriptHash(options, "disabled", toolTip.isDisabled(), "false", ScriptHashVariableWrapper.DEFAULT); 
-        getUtils().addToScriptHash(options, "direction", toolTip.getDirection(), "bottom-right", ScriptHashVariableWrapper.DEFAULT); 
-        getUtils().addToScriptHash(options, "followMouse", toolTip.isFollowMouse(), "false", ScriptHashVariableWrapper.DEFAULT); 
-        getUtils().addToScriptHash(options, "horizontalOffset", toolTip.getHorizontalOffset(), "10", ScriptHashVariableWrapper.DEFAULT); 
-        getUtils().addToScriptHash(options, "verticalOffset", toolTip.getVerticalOffset(), "10", ScriptHashVariableWrapper.DEFAULT); 
+        utils.addToScriptHash(options, "disabled", toolTip.isDisabled(), "false");
+        utils.addToScriptHash(options, "direction", toolTip.getDirection(), "bottom-right");
+        utils.addToScriptHash(options, "followMouse", toolTip.isFollowMouse(), "false");
+        utils.addToScriptHash(options, "horizontalOffset", toolTip.getHorizontalOffset(), "10");
+        utils.addToScriptHash(options, "verticalOffset", toolTip.getVerticalOffset(), "10");
 
         StringBuffer ret = new StringBuffer();
         ret.append("new ToolTip(").append(QUOT).append(toolTip.getClientId(context)).append(QUOT_COMMA)

Modified: branches/community/3.3.X/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
===================================================================
--- branches/community/3.3.X/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2009-06-08 15:26:15 UTC (rev 14555)
+++ branches/community/3.3.X/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js	2009-06-08 15:56:13 UTC (rev 14556)
@@ -9,13 +9,11 @@
 ToolTip.prototype = {
 		
 	//default values of options
-	showEvent: "mouseover",
+	showEvent: null,
 	hideEvent: null,
 	delay: 0,
 	hideDelay: 0,
 	ajaxFunction: null,
-	ajaxOptions: null,
-	oncomplete: null,
 	onhide: null,
 	onshow: null,
 	disabled: false,
@@ -254,19 +252,15 @@
 				this.setToolTipPosition(e);
 			}
 			var event = A4J.AJAX.CloneObject(e, false);
-			var ajaxOptions = this.ajaxOptions;
-			if(this.clientAjaxParams){
-				if(e.clientX){
-					this.clientAjaxParams['clientX'] = e.clientX;
-					this.clientAjaxParams['clientY'] = e.clientY;	
-				} else {
-					this.clientAjaxParams['event.pageX'] = e.pageX;
-					this.clientAjaxParams['event.pageY'] = e.pageY;	
-					
-				}
+			if(e.clientX){
+				this.clientAjaxParams['clientX'] = e.clientX;
+				this.clientAjaxParams['clientY'] = e.clientY;	
+			} else {
+				this.clientAjaxParams['event.pageX'] = e.pageX;
+				this.clientAjaxParams['event.pageY'] = e.pageY;	
 				
-				Object.extend(ajaxOptions['parameters'], this.clientAjaxParams);
 			}
+			
 			if (this.delay>0)
 			{
 				this.setToolTipPosition(e);
@@ -274,15 +268,15 @@
 				{
 					if (this.toolTipDefaultContent)
 					{
-						this.setToolTipVisible(false);
+						this.setToolTipVisible();
 					}
-					this.ajaxFunction(event, ajaxOptions);
+					this.ajaxFunction(event);
 				}.bind(this), this.delay);
 			}
 			else
 			{
-				this.setToolTipVisible(false);			
-				this.ajaxFunction(event, ajaxOptions);
+				this.setToolTipVisible();			
+				this.ajaxFunction(event);
 			}
 		} else {
 			this.setToolTipPosition(e);
@@ -613,37 +607,17 @@
 				this.onshow(this.eventCopy); 
 			}
 
-			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);
-//			}
+			this.setToolTipVisible();			
 		}
 	},
 	
-	setToolTipVisible: function(runOnComplete){
+	setToolTipVisible: function(){
 		this.activationTimerHandle = undefined;
 		this.toolTip.style.display = "block";
 		this.toolTip.style.visibility = "visible";
 		if(this.iframe)
 		{
 			this.iframe.style.display = "block";
-		} 
-		
-		if(runOnComplete){
-			if(this.oncomplete!=null)
-			{
-			 this.oncomplete(window.event); 
-			}
-			 	
-		}
-		
+		} 		
 	}
 } 




More information about the richfaces-svn-commits mailing list