国内流行的内容管理系统(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.

108 lines
4.3KB

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