Author: nbelaevski
Date: 2008-01-11 20:46:01 -0500 (Fri, 11 Jan 2008)
New Revision: 5319
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-1833
http://jira.jboss.com/jira/browse/RF-1896
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-12
00:45:38 UTC (rev 5318)
+++
trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2008-01-12
01:46:01 UTC (rev 5319)
@@ -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:
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-12
00:45:38 UTC (rev 5318)
+++
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2008-01-12
01:46:01 UTC (rev 5319)
@@ -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);
@@ -330,6 +338,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);
+ },
+
setScrollDelta: function() {
if (!this.scrollDelta) {
this.scrollDelta = [0, 0];