windows-nt/Source/XPSP1/NT/shell/ext/taskui/nusrmgr/html/popup.htc
2020-09-26 16:20:57 +08:00

104 lines
2.4 KiB
Plaintext

<PUBLIC:COMPONENT lightweight >
<PUBLIC:PROPERTY name=ttText />
<PUBLIC:PROPERTY name=ttWidth />
<PUBLIC:PROPERTY name=ttDelay />
<PUBLIC:METHOD name=ShowPopup />
<PUBLIC:ATTACH event=onmousemove onevent="onMouseMove();" />
<PUBLIC:ATTACH event=onmouseout onevent="onMouseOut();" />
<PUBLIC:ATTACH event=onclick onevent="onClick();" />
<PUBLIC:ATTACH event=onkeydown onevent="onKeyDown();" />
</PUBLIC:COMPONENT lightweight >
<SCRIPT language="JavaScript">
if (!ttWidth) ttWidth = 300;
if (!ttDelay) ttDelay = 750;
if (top.window.popup == null)
{
top.window.popup = window.createPopup();
if (top.window.popup)
top.window.popup.document.body.style.cssText =
"{ font:menu; border:'1px solid'; margin:0; padding:2px; color:infotext; background:infobackground; overflow:hidden; }";
}
var _popup = top.window.popup;
var _tidDelay = null;
var _posX;
var _posY;
function onMouseMove()
{
KillDelay();
if (_popup && (false == _popup.isOpen) && window.document.hasFocus())
{
_posX = window.event.clientX;
_posY = window.event.clientY;
_tidDelay = window.setTimeout(uniqueID+".ShowPopup();", ttDelay);
}
}
function onMouseOut()
{
KillDelay();
if (_popup && !this.contains(event.toElement))
_popup.hide();
}
function onClick()
{
_posX = window.event.clientX;
_posY = window.event.clientY;
ShowPopup();
}
function onKeyDown()
{
if (event.keyCode == 13) // VK_RETURN
{
_posX = this.offsetLeft;
_posY = this.offsetTop;
var p = this.offsetParent;
while (null != p)
{
_posX += p.offsetLeft - p.scrollLeft;
_posY += p.offsetTop - p.scrollTop;
p = p.offsetParent;
}
event.returnValue = false;
ShowPopup();
}
}
function ShowPopup()
{
KillDelay();
if (_popup && (false == _popup.isOpen))
{
var popupBody = _popup.document.body;
popupBody.innerHTML = ttText;
_popup.show(_posX, _posY+20, ttWidth, 6, element.document.body);
var realWidth = popupBody.scrollWidth + popupBody.offsetWidth - popupBody.clientWidth;
var realHeight = popupBody.scrollHeight + popupBody.offsetHeight - popupBody.clientHeight;
_popup.hide();
_popup.show(_posX, _posY+20, realWidth, realHeight, element.document.body);
}
}
function KillDelay()
{
if (_tidDelay)
{
window.clearInterval(_tidDelay);
_tidDelay = null;
}
}
</SCRIPT>