home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2003 January
/
PCWorld_2003-01_cd.bin
/
Software
/
TemaCD
/
proxomitron
/
prx4-4fcz.exe
/
html
/
jstooltip.js
< prev
next >
Wrap
Text File
|
2002-06-17
|
5KB
|
125 lines
/** jsToolTip
*
* $Id: jstooltip.js,v 1.17 2001/12/07 22:55:07 rainwater Exp $
*
* Copyright (c) 2001 Robert Rainwater
* Distributed Under the Terms of the GNU Lesser General Public License
*/
_ie = document.getElementById&&document.all;
_mz = document.getElementById&&!_ie;
var mrX;
var xfirst;
var yfirst;
var mrY;
jsToolTipHandler = {
mousemove : function(e){
jsToolTip.x = e.clientX;
jsToolTip.y = e.clientY;
},
mouseover : function(e){
var fromEl = jsToolTip.getNode(e.relatedTarget||e.fromElement);
var toEl = jsToolTip.getNode(e.target||e.toElement);
if (!fromEl||!toEl) return;
if (toEl.getAttribute("tooltip") && toEl!=fromEl) jsToolTip.showToolTip(toEl);
},
mouseout : function(e){
var fromEl = jsToolTip.getNode(e.target||e.fromElement);
var toEl = jsToolTip.getNode(e.relatedTarget||e.toElement);
if (!fromEl||!toEl) return;
if (fromEl.getAttribute("tooltip") && toEl!=fromEl) jsToolTip.hideToolTip(fromEl);
}
}
jsToolTip = {
getNode: function(obj) {
if (!obj||_ie) return obj;
while (obj.nodeType!=1) obj=obj.parentNode;
return obj;
},
showToolTip : function(src) {
if (src._timeoutshow) return;
if (src._timeoutfade) { window.clearTimeout(src._timeoutfade); src._timeoutfade=null; }
if (!src._tip) { src._tip = document.createElement("DIV"); document.body.appendChild(src._tip); }
src._cfg = jsToolTipConfig.all[src.getAttribute("tooltip").match(/\|.*\|/)||"|DefaultConfig|"];
src._tip.className = src._cfg.className;
src._tip.innerHTML = src.getAttribute("tooltip").replace(/\|.*\|/,'');
jsToolTip._setOpacity(src._tip,0);
var offsetX = window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft;
var offsetY = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;
if (jsToolTip.x>document.documentElement.offsetWidth - src._tip.offsetWidth)
src._tip.style.left = document.documentElement.offsetWidth - src._tip.offsetWidth + offsetX + "px";
else src._tip.style.left = jsToolTip.x + 12 + offsetX + "px";
src._tip.style.top = jsToolTip.y + 15 + offsetY + "px";
src._tip.style.visibility = "hidden";
xfirst=jsToolTip.x;
yfirst=jsToolTip.y;
timer = window.setTimeout(function () { jsToolTip._showToolTip(src,1) }, src._cfg.showTimeout);
},
_showToolTip : function(src,c) {
mrX=Math.abs(xfirst-jsToolTip.x);
mrY=Math.abs(yfirst-jsToolTip.y);
if((mrX<src._cfg.TipArea)&&(mrY<src._cfg.TipArea)){
src._tip.style.visibility = "visible";
if (c<=src._cfg.showSteps) {
jsToolTip._setOpacity(src._tip,Math.ceil(src._cfg.opacity/src._cfg.showSteps)*c);
src._timeoutshow = window.setTimeout(function () { jsToolTip._showToolTip(src,c+1) }, src._cfg.inTimeout);
return;
}
src._timeoutshow = null;
}
},
hideToolTip : function(src) {
mrX=Math.abs(xfirst-jsToolTip.x);
mrY=Math.abs(yfirst-jsToolTip.y);
if((mrX>src._cfg.TipArea)&&(mrY>src._cfg.TipArea)){
src._timeoutfade = window.setTimeout(function () { jsToolTip._hideToolTip(src,1) }, src._cfg.hideTimeout);
} else {
TimerID = window.setTimeout(function () { jsToolTip.hideToolTip(src) }, 100);
}
},
_hideToolTip : function(s,c) {
if (s._tip) {
if (c<=s._cfg.fadeSteps) {
jsToolTip._setOpacity(s._tip,s._cfg.opacity-(Math.floor(s._cfg.opacity/s._cfg.fadeSteps*c)));
s._timeoutfade = window.setTimeout(function () { jsToolTip._hideToolTip(s,c+1) }, s._cfg.fadeTimeout);
return;
}
s._tip.style.visibility = "hidden";
s._timeoutfade = null;
}
},
_setOpacity : function(s,o) {
if (_ie) s.style.filter = "alpha(opacity="+o+")";
else s.style.MozOpacity = o/100;
}
}
function jsToolTipConfig() {
this.id = arguments[0];
this.hideTimeout= arguments[1]||100;
this.fadeTimeout= arguments[2]||10;
this.showTimeout= arguments[3]||10;
this.inTimeout = arguments[4]||10;
this.fadeSteps = arguments[5]||10;
this.showSteps = arguments[6]||15;
this.opacity = arguments[7]||90;
this.className = arguments[8]||"jstooltip";
this.TipArea = arguments[9]||30;
jsToolTipConfig.all["|"+this.id+"|"] = this;
}
jsToolTipConfig.all = [];
_jsToolTipDefaultConfig = new jsToolTipConfig("DefaultConfig");
if (_ie) {
document.attachEvent("onmousemove",jsToolTipHandler.mousemove);
document.attachEvent("onmouseover",jsToolTipHandler.mouseover);
document.attachEvent("onmouseout",jsToolTipHandler.mouseout);
}
else if (_mz) {
document.addEventListener("mousemove",jsToolTipHandler.mousemove,false);
document.addEventListener("mouseover",jsToolTipHandler.mouseover,false);
document.addEventListener("mouseout",jsToolTipHandler.mouseout,false);
}