String eventShow = (toolTip.isAttached()) ? toolTip.getShowEvent() : "";
if (eventShow.startsWith("on")) {
eventShow = eventShow.substring(2);
}
eventsMap.put(new JSReference("showEvent"), eventShow);
String eventHide = (toolTip.isAttached()) ? toolTip.getHideEvent() : "";
if (eventHide.startsWith("on")) {
eventHide = eventHide.substring(2);
}
eventsMap.put(new JSReference("hideEvent"), eventHide);
eventsMap.put(new JSReference("delay"), new Integer(toolTip.getShowDelay()));
eventsMap.put(new JSReference("hideDelay"), new Integer(toolTip.getHideDelay()));
JSFunctionDefinition ajaxFunc = null;
if (AJAX_MODE.equalsIgnoreCase(toolTip.getMode())) {
ajaxFunc = new JSFunctionDefinition("event", "ajaxOptions");
JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context);
JSReference ref = new JSReference("ajaxOptions");
function.addParameter(ref);
ajaxFunc.addToBody(function);
}
Map<String, Object> ajaxOptions = buildEventOptions(context, toolTip, targetClientId);
ajaxOptions.putAll(getParamsMap(context, toolTip));
Map<JSReference, Object> funcMap = new HashMap<JSReference, Object>();
JSFunctionDefinition completeFunc = getUtils().getAsEventHandler(
context, component, "oncomplete", "; return true;");
funcMap.put(new JSReference("oncomplete"), completeFunc);
JSFunctionDefinition hideFunc = getUtils().getAsEventHandler(
context, component, "onhide", "; return true;");
funcMap.put(new JSReference("onhide"), hideFunc);
JSFunctionDefinition showFunc = getUtils().getAsEventHandler(
context, component, "onshow", "; return true;");
funcMap.put(new JSReference("onshow"), showFunc);
StringBuffer ret = new StringBuffer();
ret.append("new ToolTip(").append(ScriptUtils.toScript(eventsMap)).append(COMMA)
.append(ScriptUtils.toScript(funcMap)).append(COMMA)
.append(QUOT).append(toolTip.getClientId(context)).append(QUOT_COMMA)