var rgForceHover = new Array(),
rgRestorePointerEvents = new Array(),
cssmenu,
vtTimeoutClearForceHover,
vtTimeoutRestorePointerEvents,
vtThumbnail,
vtTimeoutThumbnail,
vtHoverA;
function disablePointerEvents(c, e)
{
if (c)
for (var i = 0, p; i < c.length; i++)
{
p = c[i];
if (e != p)
if (rgRestorePointerEvents.indexOf(p) < 0)
{
p.style.pointerEvents = "none";
//p.style.outline = "1px solid #808080";
rgRestorePointerEvents.push(p);
}
}
}
function restorePointerEvents()
{
while (rgRestorePointerEvents.length)
rgRestorePointerEvents.pop().style.pointerEvents = "";
}
function hasThumbnailOf(a)
{
return getThumbnailImageOf(a) || getThumbnailTextOf(a);
}
function getThumbnailImageOf(a)
{
return a.getAttribute("user-thumbnail");
}
function getThumbnailWidthOf(a)
{
var vtThumbnailImageWidth = a.getAttribute("user-thumbnail-width");
if (vtThumbnailImageWidth)
return parseInt(vtThumbnailImageWidth);
return 128;
}
function getThumbnailHeightOf(a)
{
var vtThumbnailImageHeight = a.getAttribute("user-thumbnail-height");
if (vtThumbnailImageHeight)
return parseInt(vtThumbnailImageHeight);
return 128;
}
function getThumbnailTextOf(a)
{
var vtThumbnailText = a.getElementsByClassName("tooltiptext");
if (vtThumbnailText)
if (vtThumbnailText.length)
return vtThumbnailText[0];
return null;
}
function getThumbnailOf(a)
{
var r = "";
if (a) {
var vtThumbnailImage = getThumbnailImageOf(a);
if (vtThumbnailImage)
r += "
";
var vtThumbnailText = getThumbnailTextOf(a);
if (vtThumbnailText)
r += "
";
}
return r;
}
function onHoverAnchor(a, io)
{
if (vtThumbnail)
{
if (io)
{
vtHoverA = a;
if (vtHoverA)
{
vtThumbnail.style.opacity = 0;
vtThumbnail.style.position = "fixed";
var rtBound = vtHoverA.parentElement.getBoundingClientRect();
vtThumbnail.style.left = rtBound.left + "px";
vtThumbnail.style.top = rtBound.top + "px";
vtThumbnail.style.width = rtBound.width + "px";
vtThumbnail.style.height = rtBound.height + "px";
vtThumbnail.innerHTML = getThumbnailOf(vtHoverA);
vtTimeoutThumbnail = setTimeout(function ()
{
if (vtHoverA)
{
var vtThumbnailWidth = getThumbnailWidthOf(vtHoverA),
vtThumbnailHeight = getThumbnailHeightOf(vtHoverA),
vtParentLI,
rtBound,
vtThumbnailTop;
vtThumbnail.style.opacity = 1;
vtThumbnail.style.display = "block";
vtThumbnail.style.visibility = getThumbnailImageOf(vtHoverA) ? "visible" : "hidden";
vtParentLI = vtHoverA.parentElement;
rtBound = vtParentLI.getBoundingClientRect();
/*
vtThumbnail.style.left = Math.max( rtBound.left - (12 + vtThumbnailWidth), 8 ) + "px";
vtThumbnail.style.top = Math.max( rtBound.top + (rtBound.height - vtThumbnailHeight)/2, 8 ) + "px";
*/
vtThumbnail.style.left = Math.max(rtBound.left - 16, 4) + "px";
vtThumbnailTop = Math.max(rtBound.top - (vtThumbnailHeight + 16), 4);
vtThumbnail.style.top = vtThumbnailTop + "px";
if (!((vtThumbnailTop + (vtThumbnailHeight + 16)) <= rtBound.top))
if (vtParentLI.parentElement)
{
var rtBoundParent = vtParentLI.parentElement.getBoundingClientRect();
vtThumbnail.style.left = (rtBoundParent.right + 12) + "px";
vtThumbnail.style.top = Math.max(rtBound.bottom - vtThumbnailHeight - 12, 4) + "px";
}
vtThumbnail.style.width = vtThumbnailWidth + "px";
vtThumbnail.style.height = vtThumbnailHeight + "px";
setTimeout(function ()
{
if (vtHoverA)
{
var vtTextThumbnail = vtThumbnail.getElementsByClassName("cssmenu-thumbnail-text");
if (vtTextThumbnail) {
var rtHoverThumbnailBound = vtHoverA.getBoundingClientRect();
for (var i = 0; i < vtTextThumbnail.length; i++) {
var vtText = vtTextThumbnail[i];
vtText.style.visibility = "visible";
vtText.style.position = "fixed";
vtText.style.left = (rtHoverThumbnailBound.left - 16) + "px";
vtText.style.top = (rtHoverThumbnailBound.bottom + 6) + "px";
vtText.style.opacity = 1;
}
}
}
}, 50);
}
}, 500);
}
}
else {
vtHoverA = null;
vtThumbnail.style.opacity = 0;
vtThumbnail.style.display = "none";
vtThumbnail.style.visibility = "hidden";
clearTimeout(vtTimeoutThumbnail);
vtTimeoutThumbnail = null;
}
}
}
window.addEventListener("load", function ()
{
if (cssmenu = this.document.getElementById("cssmenu"))
{
var rgLI = cssmenu.getElementsByTagName("LI");
for (var i = 0, vtLI; i < rgLI.length; i++)
{
vtLI = rgLI[i];
// delays closing the menu being visible...
vtLI.onmousemove = function (event)
{
var e = event.target;
if (e)
{
var vteLI = e;
while (vteLI && vteLI.tagName != "LI")
vteLI = vteLI.parentElement;
while (rgForceHover.length)
rgForceHover.pop().className = "";
var vteP = e;
while (vteP)
{
if (vteP.tagName == "LI")
if (vteP.parentElement.className.indexOf("AsTable") < 0)
if (vteP.getElementsByTagName("UL").length) {
vteP.className = "force-hover";
rgForceHover.push(vteP);
}
vteP = vteP.parentElement;
}
vtTimeoutClearForceHover && clearTimeout(vtTimeoutClearForceHover);
vtTimeoutClearForceHover = setTimeout(function ()
{
while (rgForceHover.length)
rgForceHover.pop().className = "";
}, 500);
}
}
}
if (document.getElementsByClassName)
{
var rgTooltip = document.getElementsByClassName("tooltip");
if (rgTooltip)
if (rgTooltip.length)
{
if (document.getElementById("thumbnail") == null)
{
vtThumbnail = document.createElement("DIV");
vtThumbnail.id = "thumbnail";
vtThumbnail.className = "cssmenu-thumbnail";
vtThumbnail.style.pointerEvents = "none";
document.body.appendChild(vtThumbnail);
}
for (var i = 0, vtA; i < rgTooltip.length; i++)
{
vtA = rgTooltip[i];
if (vtA.tagName == "A")
if (hasThumbnailOf(vtA))
{
vtA.onmouseenter = function (event)
{
onHoverAnchor(event.target, true);
}
vtA.onmouseleave = function (event)
{
onHoverAnchor(event.target, false);
}
}
}
}
}
}
})