Author: pyaschenko
Date: 2007-09-13 13:03:40 -0400 (Thu, 13 Sep 2007)
New Revision: 2932
Modified:
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
RF-910
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-09-13
15:42:22 UTC (rev 2931)
+++
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2007-09-13
17:03:40 UTC (rev 2932)
@@ -60,11 +60,41 @@
}
this.attachOnLoadEventsListner = this.attachOnLoadEvents.bindAsEventListener(this);
+ this.setToolTipPositionListner = this.setToolTipPosition.bindAsEventListener(this);
+ this.doHideListner = this.doHide.bindAsEventListener(this);
+ this.leaveToolTipListner = this.leaveToolTip.bindAsEventListener(this);
+ 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;
+
},
+
+ destroy: function()
+ {
+ if (!this.parentAttached) Event.stopObserving(document, "mousemove",
this.attachOnLoadEventsListner, true);
+ else if (this.followMouse) Event.stopObserving(this.parent, 'mousemove',
this.setToolTipPositionListner, false);
+
+ Event.stopObserving(this.parent, this.event, this.customEventHandlerListner, false);
+ Event.stopObserving(this.parent, "mouseout", this.doHideListner, false);
+ Event.stopObserving(this.toolTip, 'mouseout', this.leaveToolTipListner,
false);
+
+ this.hintParentElement = null;
+ this.parent = null;
+ this.toolTip = null;
+ this.toolTipContent = null;
+ this.toolTipDefaultContent = null;
+ this.iframe = null;
+ this.eventCopy = null;
+ this.event = null;
+ },
+
attachOnLoadEvents: function(){
if(!this.parentAttached){
this.parent = $(this.parentId);
@@ -75,32 +105,34 @@
Event.stopObserving(document, "mousemove", this.attachOnLoadEventsListner,
true);
}
},
+
+ customEventHandler: function(event) {
+ if (this.activationTimerHandle) {
+ return ;
+ }
+
+ this.eventCopy = A4J.AJAX.CloneObject(event, false);
+
+ this.activationTimerHandle = setTimeout(function() {
+ this.doShow(this.eventCopy);
+ }.bind(this), this.delay);
+ },
+
attachParentEvents: function(){
if(this.followMouse){
- Event.observe(this.parent, 'mousemove',
this.setToolTipPosition.bindAsEventListener(this), false);
+ Event.observe(this.parent, 'mousemove', this.setToolTipPositionListner,
false);
}
var eventHandler;
if (this.delay > 0) {
- eventHandler = function(event) {
- if (this.activationTimerHandle) {
- return ;
- }
-
- this.eventCopy = A4J.AJAX.CloneObject(event, false);
-
- this.activationTimerHandle = setTimeout(function() {
- this.doShow(this.eventCopy);
- }.bind(this), this.delay);
- }.bindAsEventListener(this);
+ this.customEventHandlerListner = this.customEventHandler.bindAsEventListener(this);
} else {
- eventHandler = this.doShow.bindAsEventListener(this);
+ this.customEventHandlerListner = this.doShow.bindAsEventListener(this);
}
- Event.observe(this.parent, this.event, eventHandler, false);
- Event.observe(this.parent, "mouseout", this.doHide.bindAsEventListener(this),
false);
-
- Event.observe(this.toolTip, 'mouseout',
this.leaveToolTip.bindAsEventListener(this), false)
+ Event.observe(this.parent, this.event, this.customEventHandlerListner, false);
+ Event.observe(this.parent, "mouseout", this.doHideListner, false);
+ Event.observe(this.toolTip, 'mouseout', this.leaveToolTipListner, false);
},
detectAncestorNode: function(leaf, element) {
@@ -128,6 +160,7 @@
},
doShow: function(e){
+
var needToShow = true;
var obj;
if (!e) var e = window.event;
@@ -193,6 +226,8 @@
},
doHide: function(e){
+ this.eventCopy = null;
+
var needToHide = true;
if (!e) var e = window.event;
@@ -284,11 +319,7 @@
this.iframe.style.left = (coords.x - this.toolTipBorderWidth) + 'px';
}
- this.eventCopy = null;
- if (this.delay>0)
- {
- this.eventCopy = A4J.AJAX.CloneObject(e, false);
- }
+ this.eventCopy = A4J.AJAX.CloneObject(e, false);
},
prePosition: function(basePoint, elementDim, horizontalDirection, verticalDirection,
offset){
@@ -389,7 +420,7 @@
this.toolTip.style.visibility = "hidden";
this.toolTip.style.display = 'block';
- this.setToolTipPosition(obj);
+ this.setToolTipPosition((this.eventCopy ? this.eventCopy : obj));
}
}