Author: dbiatenia
Date: 2007-07-24 14:19:02 -0400 (Tue, 24 Jul 2007)
New Revision: 1832
Modified:
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
positioning bugfix
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-07-24
18:04:01 UTC (rev 1831)
+++
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2007-07-24
18:19:02 UTC (rev 1832)
@@ -10,7 +10,10 @@
this.onshow = events.onshow;
this.oncomplete = events.oncomplete;
this.onhide = events.onhide;
+ this.delay = events.delay;
+ this.jsVarName = events.jsVarName;
+
this.id = id;
this.parentId = parentId;
this.mode = mode;
@@ -101,10 +104,8 @@
},
-
-
doShow: function(e){
-
+ //alert('IE=' + IE);
if(this.onshow){
eval(this.onshow);
}
@@ -124,10 +125,8 @@
var event = e;
eval(this.ajaxExecuteString);
}
- this.displayDiv(e);
- if(this.mode != 'ajax' && this.oncomplete){
- eval(this.oncomplete);
- }
+
+ setTimeout(this.jsVarName + '.displayDiv()', this.delay);
},
doHide: function(e){
@@ -144,10 +143,10 @@
}
this.hintParentElement = null;
this.isMouseOvered = false;
+ if(this.onhide){
+ eval(this.onhide);
+ }
}
- if(this.onhide){
- eval(this.onhide);
- }
},
doEnable: function(){
@@ -167,23 +166,75 @@
this.toolTipH = this.toolTip.getHeight();
this.toolTipW = this.toolTip.getWidth();
}
+/*
+ this.toolTip.style.display = 'block';
+
+ this.toolTip.style.top = cursorY;
+ this.toolTip.style.left = cursorX;
+*/
+ //var offsets = Position.cumulativeOffset(this.toolTip.parentNode);
+ var offsets = Position.cumulativeOffset(this.toolTip.parentNode);
- var offsets = Position.cumulativeOffset(this.parent);
+
+
+// offsets[0] -= this.toolTip.parentNode.offsetLeft || 0;
+// offsets[1] -= this.toolTip.parentNode.offsetTop || 0;
+//
+//
+ var toolTipX=0;
+ var toolTipY=0;
+ var p = Element.getStyle(this.toolTip.parentNode, 'position');
+
+ if (p == 'relative'){
+ toolTipX = cursorX - offsets[0];
+ toolTipY = cursorY - offsets[1];
+ //Element.setStyle(this.toolTip, {"left": - offsets[0] + cursorX +
"px", "top": - offsets[1] + cursorY + "px"});
+ } else {
+ if(IE){
+
+ var cumOffset = this.cumCumOffset(this.toolTip.parentNode);
+ //Element.setStyle(this.toolTip, {"left": - cumOffset[0] + cursorX +
"px", "top": - cumOffset[1] + cursorY + "px"});
+ toolTipX = cursorX - cumOffset[0];
+ toolTipY = cursorY - cumOffset[1];
+
+
+ //Element.setStyle(this.toolTip, {"left": Event.pointerX(e) +
"px", "top": Event.pointerY(e) + "px"});
+ //Element.setStyle(this.toolTip, {"left": - offsets[0] + Event.pointerX(e)
+ "px", "top": - offsets[1] + Event.pointerY(e) + "px"});
+ } else {
+ toolTipX = cursorX;
+ toolTipY = cursorY;
+
+// this.toolTip.style.top = cursorY;
+// this.toolTip.style.left = cursorX;
+ }
+ }
+ //Element.setStyle(this.toolTip, {"left": toolTipX + "px",
"top": toolTipY + "px"});
+
+//
+ //Element.setStyle(this.toolTip, {"left": offsets[0] + "px",
"top": offsets[1] + "px"});
+/*
+ this.toolTip.style.top = cursorY;
+ this.toolTip.style.left = cursorX;
+
cursorX -= offsets[0];
cursorY -= offsets[1];
+
+ this.toolTip.style.top = cursorY;
+ this.toolTip.style.left = cursorX;
+
cursorX += this.parent.offsetLeft;
cursorY += this.parent.offsetTop;
this.toolTip.style.top = cursorY;
this.toolTip.style.left = cursorX;
-
+*/
if(this.direction == "top-left"){
- this.toolTip.style.top = cursorY - this.verticalOffset - this.toolTipH;
- this.toolTip.style.left = cursorX - this.horizontalOffset - this.toolTipW;
+ this.toolTip.style.top = toolTipY - this.verticalOffset - this.toolTipH;
+ this.toolTip.style.left = toolTipX - this.horizontalOffset - this.toolTipW;
/*
if(cursorY - this.verticalOffset - this.toolTipH < 0){
this.toolTip.style.top = cursorY + this.verticalOffset - this.toolTipH;
@@ -197,8 +248,8 @@
}
*/
} else if(this.direction == "bottom-left"){
- this.toolTip.style.top = cursorY + this.verticalOffset;
- this.toolTip.style.left = cursorX - this.horizontalOffset - this.toolTipW;
+ this.toolTip.style.top = toolTipY + this.verticalOffset;
+ this.toolTip.style.left = toolTipX - this.horizontalOffset - this.toolTipW;
/*
if(cursorY + this.verticalOffset + this.toolTipH > windowDim[1]){
this.toolTip.style.top = cursorY - this.verticalOffset - this.toolTipH;
@@ -212,8 +263,8 @@
}
*/
} else if(this.direction == "top-right"){
- this.toolTip.style.top = cursorY - this.verticalOffset - this.toolTipH;
- this.toolTip.style.left = cursorX + this.horizontalOffset;
+ this.toolTip.style.top = toolTipY - this.verticalOffset - this.toolTipH;
+ this.toolTip.style.left = toolTipX + this.horizontalOffset;
/*
if(cursorY - this.verticalOffset - this.toolTipH < 0){
this.toolTip.style.top = cursorY + this.verticalOffset;
@@ -228,8 +279,8 @@
*/
} else {
// bottom-right is default
- this.toolTip.style.top = cursorY + this.verticalOffset;
- this.toolTip.style.left = cursorX + this.horizontalOffset;
+ this.toolTip.style.top = toolTipY + this.verticalOffset;
+ this.toolTip.style.left = toolTipX + this.horizontalOffset;
/*
if(cursorY + this.verticalOffset - this.toolTip.clientHeight > windowDim[1]){
this.toolTip.style.top = cursorY - this.verticalOffset - this.toolTipH;
@@ -264,7 +315,7 @@
return [wWidth,wHeight];
},
- displayDiv: function(e){
+ displayDiv: function(){
if(this.isMouseOvered){
this.toolTip.style.display = "block";
if(this.iframe){
@@ -272,6 +323,21 @@
this.iframe.style.left = parseInt(this.toolTip.style.left) -
this.toolTipBorderWidth;
this.iframe.style.display = "block";
}
+ if(this.mode != 'ajax' && this.oncomplete){
+ eval(this.oncomplete);
+ }
}
- }
+ },
+ cumCumOffset: function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ var p = Element.getStyle(element, 'position');
+ if (p == 'relative'){
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+ }
+ element = element.offsetParent;
+ } while (element);
+ return [valueL, valueT];
+ }
}
\ No newline at end of file
Show replies by date