source: trunk/www.guidonia.net/wp/wp-content/plugins/ferdinand-wordbook/common/tooltip.js@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 2.3 KB
Line 
1var offsetxpoint=-60 //Customize x offset of tooltip
2var offsetypoint=20 //Customize y offset of tooltip
3var ie=document.all
4var ns6=document.getElementById && !document.all
5var enabletip=false
6if (ie||ns6)
7var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
8
9function ietruebody(){
10return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
11}
12
13function ddrivetip(thetext, thecolor, thewidth){
14if (ns6||ie){
15if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
16if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
17tipobj.innerHTML=thetext
18enabletip=true
19return false
20}
21}
22
23function positiontip(e){
24if (enabletip){
25var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
26var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
27//Find out how close the mouse is to the corner of the window
28var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
29var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
30
31var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
32
33//if the horizontal distance isn't enough to accomodate the width of the context menu
34if (rightedge<tipobj.offsetWidth)
35//move the horizontal position of the menu to the left by it's width
36tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
37else if (curX<leftedge)
38tipobj.style.left="5px"
39else
40//position the horizontal position of the menu where the mouse is positioned
41tipobj.style.left=curX+offsetxpoint+"px"
42
43//same concept with the vertical position
44if (bottomedge<tipobj.offsetHeight)
45tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
46else
47tipobj.style.top=curY+offsetypoint+"px"
48tipobj.style.visibility="visible"
49}
50}
51
52function hideddrivetip(){
53if (ns6||ie){
54enabletip=false
55tipobj.style.visibility="hidden"
56tipobj.style.left="-1000px"
57tipobj.style.backgroundColor=''
58tipobj.style.width=''
59}
60}
61
62document.onmousemove=positiontip
Note: See TracBrowser for help on using the repository browser.