event.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2017
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. function eventManager(event) {
  9. // Member variables
  10. this.theEvent = event;
  11. if (!this.theEvent)
  12. this.theEvent = window.event;
  13. // Methods
  14. this.cancelBubble = function() {
  15. this.theEvent.cancelBubble = true;
  16. this.theEvent.returnValue = false;
  17. if (this.theEvent.stopPropagation) {
  18. this.theEvent.stopPropagation();
  19. }
  20. }
  21. this.preventDefault = function() {
  22. if (this.theEvent.stopPropagation) {
  23. this.theEvent.preventDefault();
  24. }
  25. }
  26. this.getSrc = function() {
  27. if (typeof this.theEvent.srcElement != "undefined") {
  28. return this.theEvent.srcElement; //IE event source
  29. } else {
  30. return this.theEvent.originalTarget; //Netscape event source
  31. }
  32. }
  33. }
  34. function doEvent (event, cmd) {
  35. var mgr = new eventManager(event);
  36. mgr.cancelBubble();
  37. eval(cmd);
  38. }
  39. function doEventCmd (event, cmd) {
  40. var mgr = new eventManager(event);
  41. mgr.cancelBubble();
  42. doit(cmd);
  43. }
  44. function attrib(name,value) {
  45. this.name = name;
  46. this.value = value;
  47. }
  48. var nodeMap = new Array();
  49. var nodeMapLength = 0;
  50. var timeoutSet = false;
  51. // To compensate for Microsoft KB 269802
  52. function insertIMGNode(container, src, className, attributes, containersDoc) {
  53. var doc = containersDoc;
  54. if (!doc) {
  55. doc = document;
  56. if (!topparent.getGlobal("nn7") && !topparent.getGlobal("safari"))
  57. doc = container.document;
  58. }
  59. var node = doc.createElement("IMG");
  60. node.className = className;
  61. for (var i = 0; i < attributes.length; i++) {
  62. node.setAttribute(attributes[i].name,attributes[i].value);
  63. }
  64. if (topparent.getGlobal("nn7") || topparent.getGlobal("safari"))
  65. node.src = src;
  66. else
  67. setIconSrc(node,src);
  68. container.appendChild(node);
  69. return node;
  70. }
  71. function setIconSrc(node, src) {
  72. node.style.visibility = 'hidden';
  73. storeNode(node,src);
  74. if (!timeoutSet) {
  75. timeoutSet = true;
  76. window.setTimeout("setNodeSrcs();", 1);
  77. window.setTimeout("showNodes();timeoutSet = false;", 1);
  78. }
  79. }
  80. function storeNode(node,src) {
  81. node.setAttribute("theSrc",src);
  82. nodeMap[nodeMapLength++] = node;
  83. }
  84. function setNodeSrcs() {
  85. for (var i = 0; i < nodeMapLength; i++) {
  86. nodeMap[i].src = nodeMap[i].getAttribute("theSrc");
  87. }
  88. }
  89. function showNodes() {
  90. while (nodeMapLength) {
  91. nodeMap[nodeMapLength - 1].style.visibility = 'visible';
  92. nodeMapLength--;
  93. }
  94. }
  95. function isLoadingImages() {
  96. return (nodeMapLength != 0);
  97. }
  98. function getPageOffsetLeft(obj) {
  99. var left = obj.offsetLeft;
  100. var oParent = obj.offsetParent;
  101. while (oParent) {
  102. left += oParent.offsetLeft;
  103. oParent = oParent.offsetParent;
  104. }
  105. return left;
  106. }
  107. function getPageOffsetTop(obj) {
  108. var top = obj.offsetTop;
  109. var oParent = obj.offsetParent;
  110. while (oParent) {
  111. top += oParent.offsetTop;
  112. oParent = oParent.offsetParent;
  113. }
  114. return top;
  115. }