Author: dbiatenia
Date: 2007-08-03 10:08:28 -0400 (Fri, 03 Aug 2007)
New Revision: 2049
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:
js variable will be stored in array now.
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-03
13:53:34 UTC (rev 2048)
+++
trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2007-08-03
14:08:28 UTC (rev 2049)
@@ -209,36 +209,19 @@
public void insertScript(FacesContext context, UIComponent component) throws
IOException{
UIToolTip toolTip = (UIToolTip)component;
- String parentClientId = toolTip.getParent().getClientId(context);
+
StringBuffer ret = new StringBuffer();
ret.append("<script ");
ret.append("type=\"text/javascript\" ");
ret.append("id =\"script" +
component.getClientId(context)+"\">\n");
- String comma = ",";
- String quot = "\"";
StringBuffer script = new StringBuffer();
//
- String event = toolTip.getEvent();
- if(event.startsWith("on")){
- event = event.substring(2);
- }
- String events = "{event:\"" + event + "\",onshow:\""
+ toolTip.getOnshow() +
- "\",oncomplete:\"" + toolTip.getOncomplete() +
"\",onhide:\"" + toolTip.getOnhide() +
- "\",delay:" + toolTip.getDelay() + ",jsVarName:\"" +
getJsVarName(context, component) + "\"}";
- //script.append("var tooltip1 = ").
+ String jsVar = constructJSVariable(context, component);
- script.append(getJsVarName(context, toolTip) + " = ").
- append("new ToolTip(" + events).append(comma).append(quot).append(
toolTip.getClientId(context)).append(quot).append(comma).
- append(quot).append(parentClientId).append(quot).append(comma).
- append(quot).append(toolTip.getMode()).append(quot).append(comma).
- append(toolTip.isDisabled()).append(comma).
- append(quot).append(toolTip.getDirection()).append(quot).append(comma).
- append(toolTip.isFollowMouse()).append(comma).
- append(toolTip.getHorizontalOffset()).append(comma).
- append(toolTip.getVerticalOffset()).append(comma).
- append("\"").append(insertAjaxFunction(context,
component)).append("\");\n");
+ script.append(getJsVarName(context, toolTip) + " =
").append(jsVar).append(";\n");
+
ret.append(script.toString());
-
+ ret.append("Richfaces.tooltips[\"" + toolTip.getClientId(context) +
"\"] = ").append(jsVar).append(";\n");
//
//ret.append("function toolTipAttach(){tooltip1.attachParentEvents() }\n");
@@ -248,6 +231,32 @@
}
+ public String constructJSVariable(FacesContext context, UIComponent component) {
+ UIToolTip toolTip = (UIToolTip)component;
+ String parentClientId = toolTip.getParent().getClientId(context);
+ StringBuffer ret = new StringBuffer();
+ String comma = ",";
+ String quot = "\"";
+ String event = toolTip.getEvent();
+ if(event.startsWith("on")){
+ event = event.substring(2);
+ }
+ String events = "{event:\"" + event + "\",onshow:\""
+ toolTip.getOnshow() +
+ "\",oncomplete:\"" + toolTip.getOncomplete() +
"\",onhide:\"" + toolTip.getOnhide() +
+ "\",delay:" + toolTip.getDelay() + ",jsVarName:\"" +
getJsVarName(context, component) + "\"}";
+
+ ret.append("new ToolTip(" + events).append(comma).append(quot).append(
toolTip.getClientId(context)).append(quot).append(comma).
+ append(quot).append(parentClientId).append(quot).append(comma).
+ append(quot).append(toolTip.getMode()).append(quot).append(comma).
+ append(toolTip.isDisabled()).append(comma).
+ append(quot).append(toolTip.getDirection()).append(quot).append(comma).
+ append(toolTip.isFollowMouse()).append(comma).
+ append(toolTip.getHorizontalOffset()).append(comma).
+ append(toolTip.getVerticalOffset()).append(comma).
+ append("\"").append(insertAjaxFunction(context,
component)).append("\")");
+
+ return ret.toString();
+ }
private String getJsVarName(FacesContext context, UIComponent component){
return "window.tooltip" +
component.getClientId(context).replaceAll("[^A-Za-z0-9_]", "_");
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-03
13:53:34 UTC (rev 2048)
+++
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2007-08-03
14:08:28 UTC (rev 2049)
@@ -1,6 +1,6 @@
-// Detect if the browser is IE or not.
-// If it is not IE, we assume that the browser is NS.
-var IE = document.all?true:false;
+if(!Richfaces.tooltips){
+ Richfaces.tooltips = [];
+}
ToolTip = Class.create();
@@ -13,7 +13,6 @@
this.delay = events.delay;
this.jsVarName = events.jsVarName;
-
this.id = id;
this.parentId = parentId;
this.mode = mode;
@@ -48,7 +47,7 @@
// so, after DOM-element replaced, we should not display it
this.isMouseOvered = false;
- if(IE){
+ if(Richfaces.browser.isIE6){
var toolTipZindex = parseInt(this.toolTip.style.zIndex);
new Insertion.Before(this.toolTip,
"<iframe src=\"javascript:''\" frameborder=\"0\"
scrolling=\"no\" id=\"" + this.id + "iframe\"" +
@@ -105,7 +104,7 @@
doShow: function(e){
- //alert('IE=' + IE);
+
if(this.onshow){
eval(this.onshow);
}
Show replies by date