1 // Copyright (C) 2009, 2012 Rod Roark <rod@sunsetsystems.com>
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // See interface/reports/players_report.php for an example of
9 // implementing tooltips with this module.
12 function ttGetX(elem) {
16 elem = elem.offsetParent;
20 function ttGetY(elem) {
24 elem = elem.offsetParent;
33 var ttWantContent = false;
35 function ttClearTimer() {
37 clearTimeout(ttTimerId);
42 ttWantContent = false;
45 // timer completion handler
49 $.get(ttUrl, function(data) {
50 if (!ttWantContent) return;
51 ttobject = document.getElementById("tooltipdiv");
52 ttobject.innerHTML = data;
53 var x = ttGetX(ttElem);
54 var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth;
55 if (dw && dw < (x + ttobject.offsetWidth)) {
56 x = dw - ttobject.offsetWidth;
59 var dh = window.innerHeight ? window.innerHeight : document.body.clientHeight;
60 var y = ttGetY(ttElem) + ttElem.offsetHeight;
61 ttobject.style.left = x;
62 ttobject.style.top = y;
63 ttobject.style.visibility='visible';
64 ttWantContent = false;
70 // onmouseover handler
71 function ttMouseOver(elem, url) {
75 ttTimerId = setTimeout("ttMake()", 250);
79 // onmouseout handler.
80 function ttMouseOut() {
82 var ttobject = document.getElementById("tooltipdiv");
83 ttobject.style.visibility='hidden';
84 ttobject.style.left = '-1000px';