User:Eleazaros/quicktooltip.js

From Lotro-Wiki.com
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// from ttp://www.wowwiki.com/User:Pcj/quicktooltip.js
/*
<pre>
*/

function showTemplateTip_Eleazaros(i) {
if (tooltipsOn) {
var tip = document.getElementById('templatetfb');
var Span = document.getElementById( "tttc" + i );
tooltip = ttHTMLStart + Span.innerHTML + '</div>';
tip.innerHTML = tooltip;
tip.style.position = "absolute";
tip.style.visibility = "hidden";
tip.style.display = "block";
tip.style.zIndex = "999";
moveTemplateTip();
tip.style.visibility = "visible";
}
}

function hideTemplateTip_Eleazaros() {
var tip = document.getElementById('templatetfb');
tip.innerHTML = "";
tip.style.display = "none";
}

// This function moves the tool-tips when our mouse moves
function moveTemplateTip() {
if (document.documentElement && document.documentElement.scrollTop) {
// IE6 +4.01 and user has scrolled
dbSleft = document.documentElement.scrollLeft;
dbStop = document.documentElement.scrollTop;
} else {
// IE5 or DTD 3.2
dbSleft = document.body.scrollLeft;
dbStop = document.body.scrollTop;
}
var tip = document.getElementById('templatetfb');
var newTop = mousePos.y - (tip.clientHeight + 40);
var newLeft = mousePos.x - ( tip.clientWidth / 2 );
if( newTop < dbStop ) { 
newTop = mousePos.y + 1;
if ( newTop + tip.clientHeight > winSize.y ) newTop = dbStop; 
}
if( newLeft < dbSleft ) newLeft = dbSleft;
if( ( mousePos.x + ( tip.clientWidth / 2 ) ) >= winSize.x - 150 ) newLeft = mousePos.x - ( 1.75 * tip.clientWidth );
tip.style.top = newTop + "px";
tip.style.left = newLeft + "px";
}


function ttTemplateMouseOver() {
ttfdiv = document.createElement("div");
ttfdiv.setAttribute("id", "templatetfb");
contentstart = document.getElementById("content");
contentstart.insertBefore(ttfdiv , contentstart.childNodes[0]);
var Spans = document.getElementsByTagName( "span" );
for ( var i = 0; i < Spans.length; i++ ) {
if ( hasClass( Spans[i], "tttemplatelink" ) ) {
Spans[i].nextSibling.setAttribute("id", "tttc" + i);
Spans[i].onmouseover = showTemplateTip_Eleazaros.bind(Spans[i],i);
Spans[i].onmouseout = hideTemplateTip_Eleazaros;
Spans[i].onmousemove = moveTemplateTip;
}
}
}
ttTemplateMouseOver();

/*
</pre>
*/