Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.4 KiB

  1. <PUBLIC:COMPONENT lightweight >
  2. <PUBLIC:PROPERTY name=ttText />
  3. <PUBLIC:PROPERTY name=ttWidth />
  4. <PUBLIC:PROPERTY name=ttDelay />
  5. <PUBLIC:METHOD name=ShowPopup />
  6. <PUBLIC:ATTACH event=onmousemove onevent="onMouseMove();" />
  7. <PUBLIC:ATTACH event=onmouseout onevent="onMouseOut();" />
  8. <PUBLIC:ATTACH event=onclick onevent="onClick();" />
  9. <PUBLIC:ATTACH event=onkeydown onevent="onKeyDown();" />
  10. </PUBLIC:COMPONENT lightweight >
  11. <SCRIPT language="JavaScript">
  12. if (!ttWidth) ttWidth = 300;
  13. if (!ttDelay) ttDelay = 750;
  14. if (top.window.popup == null)
  15. {
  16. top.window.popup = window.createPopup();
  17. if (top.window.popup)
  18. top.window.popup.document.body.style.cssText =
  19. "{ font:menu; border:'1px solid'; margin:0; padding:2px; color:infotext; background:infobackground; overflow:hidden; }";
  20. }
  21. var _popup = top.window.popup;
  22. var _tidDelay = null;
  23. var _posX;
  24. var _posY;
  25. function onMouseMove()
  26. {
  27. KillDelay();
  28. if (_popup && (false == _popup.isOpen) && window.document.hasFocus())
  29. {
  30. _posX = window.event.clientX;
  31. _posY = window.event.clientY;
  32. _tidDelay = window.setTimeout(uniqueID+".ShowPopup();", ttDelay);
  33. }
  34. }
  35. function onMouseOut()
  36. {
  37. KillDelay();
  38. if (_popup && !this.contains(event.toElement))
  39. _popup.hide();
  40. }
  41. function onClick()
  42. {
  43. _posX = window.event.clientX;
  44. _posY = window.event.clientY;
  45. ShowPopup();
  46. }
  47. function onKeyDown()
  48. {
  49. if (event.keyCode == 13) // VK_RETURN
  50. {
  51. _posX = this.offsetLeft;
  52. _posY = this.offsetTop;
  53. var p = this.offsetParent;
  54. while (null != p)
  55. {
  56. _posX += p.offsetLeft - p.scrollLeft;
  57. _posY += p.offsetTop - p.scrollTop;
  58. p = p.offsetParent;
  59. }
  60. event.returnValue = false;
  61. ShowPopup();
  62. }
  63. }
  64. function ShowPopup()
  65. {
  66. KillDelay();
  67. if (_popup && (false == _popup.isOpen))
  68. {
  69. var popupBody = _popup.document.body;
  70. popupBody.innerHTML = ttText;
  71. _popup.show(_posX, _posY+20, ttWidth, 6, element.document.body);
  72. var realWidth = popupBody.scrollWidth + popupBody.offsetWidth - popupBody.clientWidth;
  73. var realHeight = popupBody.scrollHeight + popupBody.offsetHeight - popupBody.clientHeight;
  74. _popup.hide();
  75. _popup.show(_posX, _posY+20, realWidth, realHeight, element.document.body);
  76. }
  77. }
  78. function KillDelay()
  79. {
  80. if (_tidDelay)
  81. {
  82. window.clearInterval(_tidDelay);
  83. _tidDelay = null;
  84. }
  85. }
  86. </SCRIPT>