|
|
f2e824 |
/*
|
|
|
f2e824 |
javascript for Bubble Tooltips by Alessandro Fulciniti
|
|
|
f2e824 |
- http://pro.html.it - http://web-graphics.com
|
|
|
f2e824 |
obtained from: http://web-graphics.com/mtarchive/001717.php
|
|
|
f2e824 |
|
|
|
f2e824 |
phpBB Development Team:
|
|
|
f2e824 |
- modified to adhere to our coding guidelines
|
|
|
f2e824 |
- integration into our design
|
|
|
f2e824 |
- added ability to perform tooltips on select elements
|
|
|
f2e824 |
- further adjustements
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
|
|
|
f2e824 |
var head_text, tooltip_mode;
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Enable tooltip replacements for links
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function enable_tooltips_link(id, headline, sub_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
var links, i, hold;
|
|
|
f2e824 |
|
|
|
f2e824 |
head_text = headline;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!document.getElementById || !document.getElementsByTagName)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
hold = document.createElement('span');
|
|
|
f2e824 |
hold.id = '_tooltip_container';
|
|
|
f2e824 |
hold.setAttribute('id', '_tooltip_container');
|
|
|
f2e824 |
hold.style.position = 'absolute';
|
|
|
f2e824 |
|
|
|
f2e824 |
document.getElementsByTagName('body')[0].appendChild(hold);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (id == null)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
links = document.getElementsByTagName('a');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
links = document.getElementById(id).getElementsByTagName('a');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
for (i = 0; i < links.length; i++)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (sub_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (links[i].id.substr(0, sub_id.length) == sub_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
prepare(links[i]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
prepare(links[i]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
tooltip_mode = 'link';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Enable tooltip replacements for selects
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function enable_tooltips_select(id, headline, sub_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
var links, i, hold;
|
|
|
f2e824 |
|
|
|
f2e824 |
head_text = headline;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!document.getElementById || !document.getElementsByTagName)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
hold = document.createElement('span');
|
|
|
f2e824 |
hold.id = '_tooltip_container';
|
|
|
f2e824 |
hold.setAttribute('id', '_tooltip_container');
|
|
|
f2e824 |
hold.style.position = 'absolute';
|
|
|
f2e824 |
|
|
|
f2e824 |
document.getElementsByTagName('body')[0].appendChild(hold);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (id == null)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
links = document.getElementsByTagName('option');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
links = document.getElementById(id).getElementsByTagName('option');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
for (i = 0; i < links.length; i++)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (sub_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (links[i].parentNode.id.substr(0, sub_id.length) == sub_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
prepare(links[i]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
prepare(links[i]);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
tooltip_mode = 'select';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Prepare elements to replace
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function prepare(element)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
var tooltip, text, desc, title;
|
|
|
f2e824 |
|
|
|
f2e824 |
text = element.getAttribute('title');
|
|
|
f2e824 |
|
|
|
f2e824 |
if (text == null || text.length == 0)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
return;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
element.removeAttribute('title');
|
|
|
f2e824 |
tooltip = create_element('span', 'tooltip');
|
|
|
f2e824 |
|
|
|
f2e824 |
title = create_element('span', 'top');
|
|
|
f2e824 |
title.appendChild(document.createTextNode(head_text));
|
|
|
f2e824 |
tooltip.appendChild(title);
|
|
|
f2e824 |
|
|
|
f2e824 |
desc = create_element('span', 'bottom');
|
|
|
f2e824 |
desc.innerHTML = text;
|
|
|
f2e824 |
tooltip.appendChild(desc);
|
|
|
f2e824 |
|
|
|
f2e824 |
set_opacity(tooltip);
|
|
|
f2e824 |
|
|
|
f2e824 |
element.tooltip = tooltip;
|
|
|
f2e824 |
element.onmouseover = show_tooltip;
|
|
|
f2e824 |
element.onmouseout = hide_tooltip;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (tooltip_mode == 'link')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
element.onmousemove = locate;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Show tooltip
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function show_tooltip(e)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
document.getElementById('_tooltip_container').appendChild(this.tooltip);
|
|
|
f2e824 |
locate(this);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Hide tooltip
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function hide_tooltip(e)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
var d = document.getElementById('_tooltip_container');
|
|
|
f2e824 |
if (d.childNodes.length > 0)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
d.removeChild(d.firstChild);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Set opacity on tooltip element
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function set_opacity(element)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
element.style.filter = 'alpha(opacity:95)';
|
|
|
f2e824 |
element.style.KHTMLOpacity = '0.95';
|
|
|
f2e824 |
element.style.MozOpacity = '0.95';
|
|
|
f2e824 |
element.style.opacity = '0.95';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Create new element
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function create_element(tag, c)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
var x = document.createElement(tag);
|
|
|
f2e824 |
x.className = c;
|
|
|
f2e824 |
x.style.display = 'block';
|
|
|
f2e824 |
return x;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* Correct positioning of tooltip container
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
function locate(e)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
var posx = 0;
|
|
|
f2e824 |
var posy = 0;
|
|
|
f2e824 |
|
|
|
f2e824 |
e = e.parentNode;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (e.offsetParent)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
for (var posx = 0, posy = 0; e.offsetParent; e = e.offsetParent)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
posx += e.offsetLeft;
|
|
|
f2e824 |
posy += e.offsetTop;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
posx = e.offsetLeft;
|
|
|
f2e824 |
posy = e.offsetTop;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (tooltip_mode == 'link')
|
|
|
f2e824 |
{
|
|
|
f2e824 |
document.getElementById('_tooltip_container').style.top=(posy+20) + 'px';
|
|
|
f2e824 |
document.getElementById('_tooltip_container').style.left=(posx-20) + 'px';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
document.getElementById('_tooltip_container').style.top=(posy+30) + 'px';
|
|
|
f2e824 |
document.getElementById('_tooltip_container').style.left=(posx-205) + 'px';
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
/*
|
|
|
f2e824 |
if (e == null)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
e = window.event;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (e.pageX || e.pageY)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
posx = e.pageX;
|
|
|
f2e824 |
posy = e.pageY;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else if (e.clientX || e.clientY)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (document.documentElement.scrollTop)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
posx = e.clientX+document.documentElement.scrollLeft;
|
|
|
f2e824 |
posy = e.clientY+document.documentElement.scrollTop;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
else
|
|
|
f2e824 |
{
|
|
|
f2e824 |
posx = e.clientX+document.body.scrollLeft;
|
|
|
f2e824 |
posy = e.clientY+document.body.scrollTop;
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
}
|