Author: akushunin
Date: 2008-01-14 09:23:32 -0500 (Mon, 14 Jan 2008)
New Revision: 5350
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:
http://jira.jboss.com/jira/browse/RF-1897
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 2008-01-14
13:51:05 UTC (rev 5349)
+++
trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2008-01-14
14:23:32 UTC (rev 5350)
@@ -17,6 +17,7 @@
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIToolTip;
import org.richfaces.skin.Skin;
@@ -238,9 +239,6 @@
Map eventsMap = new HashMap();
eventsMap.put(new JSReference("event"), event);
- eventsMap.put(new JSReference("onshow"), toolTip.getOnshow());
- eventsMap.put(new JSReference("oncomplete"), toolTip.getOncomplete());
- eventsMap.put(new JSReference("onhide"), toolTip.getOnhide());
eventsMap.put(new JSReference("delay"), new
Integer(toolTip.getShowDelay()));
eventsMap.put(new JSReference("hideDelay"), new
Integer(toolTip.getHideDelay()));
@@ -248,10 +246,20 @@
JSReference ref = new JSReference("ajaxOptions");
function.addParameter(ref);
String ajaxFunc = function.toScript();
-
+
Map ajaxOptions = buildEventOptions(context, toolTip, targetClientId);
+ JSFunctionDefinition completeFunc = getUtils().getAsEventHandler(context, component,
"oncoplete", "return true;");
+ JSFunctionDefinition hideFunc = getUtils().getAsEventHandler(context,
component,"onhide", "return true;");
+ JSFunctionDefinition showFunc = getUtils().getAsEventHandler(context,
component,"onshow", "return true;");
- ret.append("new ToolTip(" +
ScriptUtils.toScript(eventsMap)).append(comma).append(quot).append(
toolTip.getClientId(context)).append(quot).append(comma).
+ Map funcMap = new HashMap();
+ funcMap.put(new JSReference("oncomplete"), completeFunc);
+ funcMap.put(new JSReference("onhide"), hideFunc);
+ funcMap.put(new JSReference("onshow"), showFunc);
+
+
+ ret.append("new ToolTip(" +
ScriptUtils.toScript(eventsMap)).append(comma).append(ScriptUtils.toScript(funcMap))
+ .append(comma).append(quot).append(
toolTip.getClientId(context)).append(quot).append(comma).
append(quot).append(targetClientId).append(quot).append(comma).
append(quot).append(toolTip.getMode()).append(quot).append(comma).
append(toolTip.isDisabled()).append(comma).
@@ -260,7 +268,7 @@
append(toolTip.getHorizontalOffset()).append(comma).
append(toolTip.getVerticalOffset()).append(comma).
append("\"").append(ajaxFunc).append("\"").append(comma).append(ScriptUtils.toScript(ajaxOptions)).append(");");
-
+
return ret.toString();
}
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 2008-01-14
13:51:05 UTC (rev 5349)
+++
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2008-01-14
14:23:32 UTC (rev 5350)
@@ -5,13 +5,14 @@
ToolTip = Class.create();
ToolTip.prototype = {
- initialize:function(events, id, parentId, mode, disabled, direction, followMouse,
horizontalOffset, verticalOffset, ajaxFunction, ajaxOptions){
+ initialize:function(events,functions, 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;');
- this.onhide = new Function('event', events.onhide + ';return true;');
+ this.event = events.event;
+ this.onshow = functions.onshow;
+ this.oncomplete = functions.oncomplete;
+ this.onhide = functions.onhide;
+
this.delay = events.delay;
this.hideDelay = events.hideDelay;
@@ -256,7 +257,10 @@
} catch (e) {;}
}
- this.onshow(e);
+ if(this.onshow!=null)
+ {
+ this.onshow(e);
+ }
this.isMouseOvered = true;
if (e.target)
@@ -337,7 +341,10 @@
}
this.hintParentElement = null;
this.isMouseOvered = false;
- this.onhide(e);
+ if(this.onhide!=null)
+ {
+ this.onhide(e);
+ }
if (this.hidingTimerHandle) {
window.clearTimeout(this.hidingTimerHandle);
@@ -565,7 +572,11 @@
}
if(runOnComplete){
- this.oncomplete(window.event);
+ if(this.oncomplete!=null)
+ {
+ this.oncomplete(window.event);
+ }
+
}
}