Author: abelevich
Date: 2011-02-18 14:22:55 -0500 (Fri, 18 Feb 2011)
New Revision: 21784
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml
Log:
https://issues.jboss.org/browse/RF-10463 richfaces-showcase: tooltip sample throws JS
exception in ajax mode (MyFaces)
https://issues.jboss.org/browse/RF-10529 Tooltip is rerendered when mouse enters
tooltip's div
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2011-02-18
19:15:04 UTC (rev 21783)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2011-02-18
19:22:55 UTC (rev 21784)
@@ -105,13 +105,18 @@
writer.startElement(getMarkupElement(tooltip), component);
writer.writeAttribute(ID_ATTRIBUTE, component.getClientId(context),
"clientId");
+
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, "display: none;",
null);
+ writer.startElement(getMarkupElement(tooltip), component);
+ writer.writeAttribute(ID_ATTRIBUTE, component.getClientId(context) +
":wrp", null);
writer.writeAttribute(CLASS_ATTRIBUTE, getStyleClass(component), null);
+
int zindex = tooltip.getZindex();
if (zindex == Integer.MIN_VALUE) {
zindex = DEFAULT_ZINDEX_VALUE;
}
+
String style = concatStyles("z-index:"+zindex, getStyle(component));
-
if (style != null && style.trim().length() > 0) {
writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, style, null);
}
@@ -231,6 +236,8 @@
writer.endElement(getMarkupElement((AbstractTooltip) component));
+ writer.endElement(getMarkupElement((AbstractTooltip) component));
+
writeJavaScript(writer, context, component);
writer.endElement(getMarkupElement((AbstractTooltip) component));
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js 2011-02-18
19:15:04 UTC (rev 21783)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js 2011-02-18
19:22:55 UTC (rev 21784)
@@ -117,8 +117,8 @@
this.__addUserEventHandler("show");
this.__addUserEventHandler("beforehide");
this.__addUserEventHandler("beforeshow");
-
- this.popup = new rf.ui.Popup(this.id, {
+ this.popupId = this.id+':wrp';
+ this.popup = new rf.ui.Popup(this.popupId, {
attachTo: this.target,
attachToBody: true,
positionType: "TOOLTIP",
@@ -133,10 +133,8 @@
rf.Event.bindById(this.target, handlers, this);
-
-
if (this.options.hideEvent == 'mouseleave') {
- rf.Event.bindById(this.id, this.options.hideEvent + this.namespace,
this.__hideHandler, this);
+ rf.Event.bindById(this.popupId, this.options.hideEvent + this.namespace,
this.__hideHandler, this);
}
},
@@ -150,21 +148,22 @@
* @return {void} TODO ...
*/
hide: function () {
- var continueProcess = this.__fireBeforeHide();
- if (!continueProcess) {
- return false;
+
+ var tooltip = this;
+ if (tooltip.hidingTimerHandle) {
+ window.clearTimeout(tooltip.hidingTimerHandle);
+ tooltip.hidingTimerHandle = undefined;
}
-
- this.__hide();
-
- return this.__fireHide()
+ if (this.shown) {
+ this.__hide();
+ }
},
__hideHandler: function(event) {
if (event.type == 'mouseleave' &&
this.__isInside(event.relatedTarget)) {
return;
}
-
+
this.hide();
if (this.options.followMouse) {
@@ -180,8 +179,10 @@
__hide: function () {
var tooltip = this;
this.__delay(this.options.hideDelay, function () {
+ tooltip.__fireBeforeHide();
tooltip.popup.hide();
tooltip.shown = false;
+ tooltip.__fireHide();
});
},
@@ -210,12 +211,16 @@
* @return {void} TODO ...
*/
show: function (event) {
- var continueProcess = this.__fireBeforeShow();
- if (!continueProcess) {
- return false;
+ var tooltip = this;
+ if (tooltip.hidingTimerHandle) {
+ window.clearTimeout(tooltip.hidingTimerHandle);
+ tooltip.hidingTimerHandle = undefined;
}
- SHOW_ACTION.exec(this, event);
+ if (!this.shown) {
+ SHOW_ACTION.exec(this, event);
+ }
+
},
onCompleteHandler : function () {
@@ -233,12 +238,13 @@
var tooltip = this;
this.__delay(this.options.showDelay, function () {
if (!tooltip.options.followMouse) {
- tooltip.popup.show(event);
- } else if (!tooltip.shown) {
- {
- tooltip.popup.show(tooltip.saveShowEvent);
- }
+ tooltip.saveShowEvent = event;
}
+ if (!tooltip.shown) {
+ tooltip.__fireBeforeShow();
+ tooltip.popup.show(tooltip.saveShowEvent);
+ }
+ //for showing tooltip in followMouse mode
tooltip.shown = true;
});
},
@@ -246,10 +252,7 @@
/***************************** Private Methods
****************************************************************/
__delay : function (delay, action) {
var tooltip = this;
- if (tooltip.hidingTimerHandle) {
- window.clearTimeout(tooltip.hidingTimerHandle);
- tooltip.hidingTimerHandle = undefined;
- }
+
if (delay > 0) {
tooltip.hidingTimerHandle = window.setTimeout(function() {
action();
@@ -297,8 +300,6 @@
return rf.Event.fireById(this.id, "beforeshow", { id: this.id });
},
-
-
/**
* @private
* */
@@ -317,16 +318,15 @@
elt = elt.parentNode;
}
-
return false;
},
__isInside: function(elt) {
- return this.__contains(this.target, elt) || this.__contains(this.id, elt);
+ return this.__contains(this.target, elt) || this.__contains(this.popupId, elt);
},
destroy: function () {
- rf.Event.unbindById(this.id, this.namespace);
+ rf.Event.unbindById(this.popupId, this.namespace);
rf.Event.unbindById(this.target, this.namespace);
this.popup.destroy();
this.popup = null;
@@ -336,4 +336,4 @@
// define super class link
var $super = rf.ui.Tooltip.$super;
-})(jQuery, RichFaces);
+})(jQuery, RichFaces);
\ No newline at end of file
Modified:
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml
===================================================================
---
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml 2011-02-18
19:15:04 UTC (rev 21783)
+++
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml 2011-02-18
19:22:55 UTC (rev 21784)
@@ -1,6 +1,8 @@
-<span id="f:tooltip" class="rf-tt"
style="z-index:1000">
- <span id="f:tooltip:cntr" class="rf-tt-cntr">
- <span id="f:tooltip:content"
class="rf-tt-cnt"></span>
+<span id="f:tooltip" style="display: none;">
+ <span id="f:tooltip:wrp" class="rf-tt"
style="z-index:1000">
+ <span id="f:tooltip:cntr" class="rf-tt-cntr">
+ <span id="f:tooltip:content"
class="rf-tt-cnt"></span>
+ </span>
</span>
<script type="text/javascript">
// Text