Author: pyaschenko
Date: 2008-01-29 12:11:48 -0500 (Tue, 29 Jan 2008)
New Revision: 5710
Modified:
trunk/samples/tooltip-sample/src/main/webapp/pages/demo.jsp
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
RF-2007
Modified: trunk/samples/tooltip-sample/src/main/webapp/pages/demo.jsp
===================================================================
--- trunk/samples/tooltip-sample/src/main/webapp/pages/demo.jsp 2008-01-29 16:21:54 UTC
(rev 5709)
+++ trunk/samples/tooltip-sample/src/main/webapp/pages/demo.jsp 2008-01-29 17:11:48 UTC
(rev 5710)
@@ -34,11 +34,11 @@
<a4j:outputPanel layout="block"
style="width:350px;height:75px;cursor:arrow;border-width:2px;text-align:center;border:2px
solid red">
<f:verbatim>
<p>
- This tool-tip will <b>follow mouse</b>. Also this tool-tip has a
<b>delay 0.5 sec</b>, so be patient!
+ This tool-tip will <b>follow mouse</b>. Also this tool-tip has a
<b>delay 0.5 sec</b> and <b>hide delay 0.5 sec</b>, so be
patient!
</p>
</f:verbatim>
- <rich:toolTip followMouse="true" direction="top-right"
showDelay="500" styleClass="tooltip"
style="width:250px">
+ <rich:toolTip followMouse="true" direction="top-right"
showDelay="500" hideDelay="500" styleClass="tooltip"
style="width:250px">
<f:verbatim>
<span>
This tool-tip content also <strong>pre-rendered</strong> to the page.
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-29
16:21:54 UTC (rev 5709)
+++
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2008-01-29
17:11:48 UTC (rev 5710)
@@ -68,12 +68,6 @@
this.attachOnLoadEventsListner = this.attachOnLoadEvents.bindAsEventListener(this);
this.setToolTipPositionListner = this.setToolTipPosition.bindAsEventListener(this);
- if (this.hideDelay > 0) {
- this.doHideListner = this.customHideHandler.bindAsEventListener(this);
- } else {
- this.doHideListner = this.doHide.bindAsEventListener(this);
- }
-
this.leaveToolTipListner = this.leaveToolTip.bindAsEventListener(this);
// if (Richfaces.tooltips[parentId])
@@ -103,7 +97,7 @@
{
if (this.followMouse) Event.stopObserving(this.parent, 'mousemove',
this.setToolTipPositionListner, false);
- Event.stopObserving(this.parent, this.event, this.customEventHandlerListner, false);
+ Event.stopObserving(this.parent, this.event, this.doShowListner, false);
if (this.showEvent != "focus") {
if(this.hideEvent != null){
@@ -145,43 +139,15 @@
}
},
- customEventHandler: function(event) {
- if (this.activationTimerHandle) {
- return ;
- }
-
- this.eventCopy = A4J.AJAX.CloneObject(event, false);
-
- this.activationTimerHandle = window.setTimeout(function() {
- this.doShow(this.eventCopy);
- }.bindAsEventListener(this), this.delay);
- },
-
- customHideHandler: function(event) {
- if (this.hidingTimerHandle) {
- return ;
- }
-
- this.eventCopy = A4J.AJAX.CloneObject(event, false);
-
- this.hidingTimerHandle = window.setTimeout(function() {
- this.doHide(this.eventCopy);
- }.bindAsEventListener(this), this.hideDelay);
- },
-
attachParentEvents: function(){
if(this.followMouse){
Event.observe(this.parent, 'mousemove', this.setToolTipPositionListner,
false);
}
- var eventHandler;
- if (this.delay > 0) {
- this.customEventHandlerListner = this.customEventHandler.bindAsEventListener(this);
- } else {
- this.customEventHandlerListner = this.doShow.bindAsEventListener(this);
- }
+ this.doShowListner = this.doShow.bindAsEventListener(this);
+ this.doHideListner = this.doHide.bindAsEventListener(this);
- Event.observe(this.parent, this.showEvent, this.customEventHandlerListner, false);
+ Event.observe(this.parent, this.showEvent, this.doShowListner, false);
//TODO handle onfocus and onblur show/hide events
if (this.showEvent != "focus") {
if(this.hideEvent != null){
@@ -260,6 +226,8 @@
},
doShow: function(e){
+ if (this.activationTimerHandle) return;
+
this.setScrollDelta();
var obj;
@@ -279,11 +247,6 @@
} catch (e) {;}
}
- if(this.onshow!=null)
- {
- this.onshow(e);
- }
-
this.isMouseOvered = true;
if (e.target)
this.hintParentElement = e.target;
@@ -319,7 +282,19 @@
eval(this.ajaxExecuteString);
} else {
this.setToolTipPosition(e);
- this.displayDiv();
+ if (this.hidingTimerHandle)
+ {
+ window.clearTimeout(this.hidingTimerHandle);
+ this.hidingTimerHandle = undefined;
+ }
+ if (this.delay>0)
+ {
+ this.activationTimerHandle = window.setTimeout(function()
+ {
+ this.displayDiv();
+ }.bindAsEventListener(this), this.delay);
+ }
+ else this.displayDiv();
}
// if(this.delay > 0){
@@ -329,8 +304,30 @@
// }
//
},
-
+
+ hideDiv:function(e)
+ {
+ this.isMouseOvered = false;
+ this.toolTip.style.visibility = "hidden";
+ this.toolTip.style.display = "none";
+
+ if(this.iframe){
+ this.iframe.style.display = "none";
+ }
+ this.hintParentElement = null;
+ this.isMouseOvered = false;
+ if(this.onhide!=null)
+ {
+ this.onhide(e);
+ }
+
+
+ this.scrollDelta = undefined;
+ },
+
doHide: function(e){
+ if (this.hidingTimerHandle) return;
+
this.eventCopy = null;
if (!e) var e = window.event;
@@ -353,27 +350,21 @@
if (this.detectAncestorNode(relTarg,this.toolTip)) return;
} catch (e) {;}
}
-
- this.isMouseOvered = false;
- this.toolTip.style.visibility = "hidden";
- this.toolTip.style.display = "none";
-
- if(this.iframe){
- this.iframe.style.display = "none";
+
+ if (this.activationTimerHandle)
+ {
+ window.clearTimeout(this.activationTimerHandle);
+ this.activationTimerHandle = undefined;
}
- this.hintParentElement = null;
- this.isMouseOvered = false;
- if(this.onhide!=null)
+ if (this.hideDelay>0)
{
- this.onhide(e);
+ var event = A4J.AJAX.CloneObject(e, false);
+ this.hidingTimerHandle = window.setTimeout(function()
+ {
+ this.hideDiv(event);
+ }.bindAsEventListener(this), this.hideDelay);
}
-
- if (this.hidingTimerHandle) {
- window.clearTimeout(this.hidingTimerHandle);
- this.hidingTimerHandle = undefined;
- }
-
- this.scrollDelta = undefined;
+ else this.hideDiv();
},
doEnable: function(){
@@ -579,6 +570,11 @@
this.setToolTipPosition((this.eventCopy ? this.eventCopy : obj));
}
}
+
+ if(this.onshow!=null)
+ {
+ this.onshow(this.eventCopy);
+ }
this.setToolTipVisible(true);