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