Forum Moderators: open
// Coded by Travis Beckham, modified by RMcGirr83
tooltip = {
name : "tooltip",
offsetX : -25,
offsetY : 25,
tip : null
};
tooltip.move = function (evt) {
var x=0, y=0;
if (document.all) {// IE
x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
x += window.event.clientX;
y += window.event.clientY;
} else {// Mozilla
x = evt.pageX;
y = evt.pageY;
}
this.tip.style.left = (x + this.offsetX) + "px";
this.tip.style.top = (y + this.offsetY) + "px";
};
tooltip.show = function (text) {
if (!this.tip) return;
text = text.replace(/\n/g, "<br />");
this.tip.innerHTML = text;
this.tip.style.visibility = "visible";
this.tip.style.display = "block";
if (this.tip.offsetWidth > 400)
this.tip.style.width = "400px";
};
tooltip.hide = function () {
if (!this.tip) return;
this.tip.style.visibility = "hidden";
this.tip.style.display = "none";
this.tip.innerHTML = "";
this.tip.style.width = null;
};
tooltip.init = function () {
var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
if(!tipContainerID){ var tipContainerID = "tooltip";}
var tipContainer = document.getElementById(tipContainerID);
if(!tipContainer){
tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
tipContainer.setAttribute("id", tipContainerID);
tipContainer.style.display = "none";
document.getElementsByTagName("body").item(0).appendChild(tipContainer);
}
if (!document.getElementById) return;
this.tip = document.getElementById (this.name);
if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};
var a, sTitle;
var anchors = document.getElementsByTagName ("a");
for (var i = 0; i < anchors.length; i ++) {
a = anchors[i];
sTitle = a.getAttribute("title");
if(sTitle) {
a.setAttribute("tooltip", sTitle);
a.removeAttribute("title");
a.removeAttribute("alt");
a.onmouseover = function() {tooltip.show(this.getAttribute('tooltip'))};
a.onmouseout = function() {tooltip.hide()};
}
}
};
// this is used instead in a non-prosilver based template
//window.onload = function () {
//tooltip.init ();
//}
onload_functions.push('tooltip.init();'); // prosilver based template only <script type="text/javascript">
// <![CDATA[
// show the popup
function show_popup(UserID) {
if(http_getuser) {
close_popup(); sendRequest(UserID);
}
}
// hide the popup
function close_popup() {
document.getElementById('popup').style.display='none';
}
// Make the request
function createRequestObject() {
if(window.XMLHttpRequest){
ro = new XMLHttpRequest();
} else if(window.ActiveXObject) {
ro = new ActiveXObject("Msxml2.XMLHTTP");
if(!ro) {
ro = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return ro;
}
var http_getuser = createRequestObject();
function sendRequest(UserID) {
var userinfo_url = '{AJAX_USERINFO_PATH}';
http_getuser.open('get', userinfo_url.replace('USERID', UserID));
http_getuser.onreadystatechange = handleResponse;
http_getuser.send(null);
}
// fill in the response
function handleResponse() {
if(http_getuser.readyState == 4 ){
var xmlDoc = http_getuser.responseXML;
if(xmlDoc.hasChildNodes()) {
document.getElementById('ajax_username').innerHTML = xmlDoc.getElementsByTagName('username')[0].firstChild.nodeValue;
document.getElementById('ajax_registert').innerHTML = xmlDoc.getElementsByTagName('regdate')[0].firstChild.nodeValue;
document.getElementById('ajax_posts').innerHTML = xmlDoc.getElementsByTagName('posts')[0].firstChild.nodeValue;
document.getElementById('ajax_website').innerHTML = xmlDoc.getElementsByTagName('website')[0].firstChild.nodeValue;
document.getElementById('ajax_from').innerHTML = xmlDoc.getElementsByTagName('from')[0].firstChild.nodeValue;
document.getElementById('ajax_last_visit').innerHTML = xmlDoc.getElementsByTagName('lastvisit')[0].firstChild.nodeValue;
document.getElementById('ajax_rank').innerHTML = xmlDoc.getElementsByTagName('rank')[0].firstChild.nodeValue;
document.getElementById('ajax_avatar').innerHTML = xmlDoc.getElementsByTagName('avatar')[0].firstChild.nodeValue;
document.getElementById('popup').style.display='block';
}
}
}
// set popup to mouse possition
function set_div_to_mouse(e) {
var docX, docY;
if(e) {
if(typeof(e.pageX) == 'number') { docX = e.pageX; docY = e.pageY;}
else {docX = e.clientX; docY = e.clientY;}
} else {
e = window.event;
docX = e.clientX; docY = e.clientY;
if(document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
docX += document.documentElement.scrollLeft; docY += document.documentElement.scrollTop;
}
else if(document.body && (document.body.scrollTop || document.body.scrollLeft)) {
docX += document.body.scrollLeft; docY += document.body.scrollTop;
}
}
if (docX > document.body.offsetWidth - 400) {
document.getElementById('popup').style.left = (docX - 350) + "px";
} else {
document.getElementById('popup').style.left = (docX - 5) + "px";
}
document.getElementById('popup').style.top = (docY + 30) + "px";
}
document.onmousemove = set_div_to_mouse;
// ]]>
</script>
<div class="forabg" id="popup" style="display: none;">
<div class="inner">
<span class="corners-top"><span></span></span>
<ul class="topiclist fullwidth">
<li class="header"><dl><dt>{L_READ_PROFILE}</dt></dl></li>
</ul>
<ul class="topiclist forums">
<li><dl>
<dd style="width:100%">
<div id="ajax_avatar"></div>
<strong>{L_USERNAME}:</strong> <span id="ajax_username"></span><br />
<strong>{L_TOTAL_POSTS}:</strong> <span id="ajax_posts"></span><br />
<strong>{L_SORT_RANK}:</strong> <span id="ajax_rank"></span><br />
<strong>{L_JOINED}:</strong> <span id="ajax_registert"></span><br />
<strong>{L_LAST_VISIT}:</strong> <span id="ajax_last_visit"></span><br />
<strong>{L_LOCATION}:</strong> <span id="ajax_from"></span><br />
<strong>{L_WEBSITE}:</strong> <span id="ajax_website"></span>
<br style="clear: both;" />
</dd>
</dl></li>
</ul>
<span class="corners-bottom"><span></span></span>
</div>
</div>