国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
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.

94 lines
3.9KB

  1. self.onError=null;
  2. currentX = currentY = 0;
  3. whichIt = null;
  4. lastScrollX = 0; lastScrollY = 0;
  5. NS = (document.layers) ? 1 : 0;
  6. IE = (document.all) ? 1 : 0;
  7. function heartBeat() {
  8. if (IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
  9. if (NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
  10. if (diffY != lastScrollY) {
  11. percent = .1 * (diffY - lastScrollY);
  12. if (percent > 0) percent = Math.ceil(percent);
  13. else percent = Math.floor(percent);
  14. if (IE) document.all.floater.style.pixelTop += percent;
  15. if (NS) document.floater.top += percent;
  16. lastScrollY = lastScrollY + percent;
  17. } if (diffX != lastScrollX) {
  18. percent = .1 * (diffX - lastScrollX);
  19. if (percent > 0) percent = Math.ceil(percent);
  20. else percent = Math.floor(percent);
  21. if (IE) document.all.floater.style.pixelLeft += percent;
  22. if (NS) document.floater.left += percent;
  23. lastScrollX = lastScrollX + percent;
  24. }
  25. }
  26. function checkFocus(x, y) {
  27. stalkerx = document.floater.pageX;
  28. stalkery = document.floater.pageY;
  29. stalkerwidth = document.floater.clip.width;
  30. stalkerheight = document.floater.clip.height;
  31. if ((x > stalkerx && x < (stalkerx + stalkerwidth)) && (y > stalkery && y < (stalkery + stalkerheight))) return true;
  32. else return false;
  33. }
  34. function grabIt(e) {
  35. if (IE) {
  36. whichIt = event.srcElement;
  37. while (whichIt.id.indexOf("floater") == -1) {
  38. whichIt = whichIt.parentElement;
  39. if (whichIt == null) { return true; }
  40. }
  41. whichIt.style.pixelLeft = whichIt.offsetLeft;
  42. whichIt.style.pixelTop = whichIt.offsetTop;
  43. currentX = (event.clientX + document.body.scrollLeft);
  44. currentY = (event.clientY + document.body.scrollTop);
  45. } else {
  46. window.captureEvents(Event.MOUSEMOVE);
  47. if (checkFocus(e.pageX, e.pageY)) {
  48. whichIt = document.floater;
  49. StalkerTouchedX = e.pageX - document.floater.pageX;
  50. StalkerTouchedY = e.pageY - document.floater.pageY;
  51. }
  52. } return true;
  53. }
  54. function moveIt(e) {
  55. if (whichIt == null) { return false; }
  56. if (IE) {
  57. newX = (event.clientX + document.body.scrollLeft);
  58. newY = (event.clientY + document.body.scrollTop);
  59. distanceX = (newX - currentX); distanceY = (newY - currentY);
  60. currentX = newX; currentY = newY;
  61. whichIt.style.pixelLeft += distanceX;
  62. whichIt.style.pixelTop += distanceY;
  63. if (whichIt.style.pixelTop < document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
  64. if (whichIt.style.pixelLeft < document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
  65. if (whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
  66. if (whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
  67. event.returnValue = false;
  68. } else {
  69. whichIt.moveTo(e.pageX - StalkerTouchedX, e.pageY - StalkerTouchedY);
  70. if (whichIt.left < 0 + self.pageXOffset) whichIt.left = 0 + self.pageXOffset;
  71. if (whichIt.top < 0 + self.pageYOffset) whichIt.top = 0 + self.pageYOffset;
  72. if ((whichIt.left + whichIt.clip.width) >= (window.innerWidth + self.pageXOffset - 17)) whichIt.left = ((window.innerWidth + self.pageXOffset) - whichIt.clip.width) - 17;
  73. if ((whichIt.top + whichIt.clip.height) >= (window.innerHeight + self.pageYOffset + 50)) whichIt.top = ((window.innerHeight + self.pageYOffset) - whichIt.clip.height) - 17;
  74. return false;
  75. }
  76. return false;
  77. }
  78. function dropIt() {
  79. whichIt = null;
  80. if (NS) window.releaseEvents(Event.MOUSEMOVE);
  81. return true;
  82. }
  83. if (NS) {
  84. window.captureEvents(Event.MOUSEUPEvent.MOUSEDOWN);
  85. window.onmousedown = grabIt;
  86. window.onmousemove = moveIt;
  87. window.onmouseup = dropIt;
  88. }
  89. if (IE) {
  90. document.onmousedown = grabIt;
  91. document.onmousemove = moveIt;
  92. document.onmouseup = dropIt;
  93. }
  94. if (NS || IE) action = window.setInterval("heartBeat()", 1);