legacy.js.orig 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //stored on each browser event
  2. var windowEvent;
  3. $axure.internal(function($ax) {
  4. var _legacy = {};
  5. $ax.legacy = _legacy;
  6. // ************************** GLOBAL VARS *********************************//
  7. // ************************************************************************//
  8. //Check if IE
  9. //var bIE = false;
  10. //if ((index = navigator.userAgent.indexOf("MSIE")) >= 0) {
  11. // bIE = true;
  12. //}
  13. var Forms = window.document.getElementsByTagName("FORM");
  14. for(var i = 0; i < Forms.length; i++) {
  15. var Form = Forms[i];
  16. Form.onclick = $ax.legacy.SuppressBubble;
  17. }
  18. $ax.legacy.SuppressBubble = function(event) {
  19. if($.browser.msie) {
  20. window.event.cancelBubble = true;
  21. window.event.returnValue = false;
  22. } else {
  23. if(event) {
  24. event.stopPropagation();
  25. }
  26. }
  27. };
  28. // function InsertAfterBegin(dom, html) {
  29. // if(!$.browser.msie) {
  30. // var phtml;
  31. // var range = dom.ownerDocument.createRange();
  32. // range.selectNodeContents(dom);
  33. // range.collapse(true);
  34. // phtml = range.createContextualFragment(html);
  35. // dom.insertBefore(phtml, dom.firstChild);
  36. // } else {
  37. // dom.insertAdjacentHTML("afterBegin", html);
  38. // }
  39. // }
  40. // function InsertBeforeEnd(dom, html) {
  41. // if(!$.browser.msie) {
  42. // var phtml;
  43. // var range = dom.ownerDocument.createRange();
  44. // range.selectNodeContents(dom);
  45. // range.collapse(dom);
  46. // phtml = range.createContextualFragment(html);
  47. // dom.appendChild(phtml);
  48. // } else {
  49. // dom.insertAdjacentHTML("beforeEnd", html);
  50. // }
  51. // }
  52. //Get the id of the Workflow Dialog belonging to element with id = id
  53. // function Workflow(id) {
  54. // return id + 'WF';
  55. // }
  56. $ax.legacy.BringToFront = function(id, skipFixed) {
  57. _bringToFrontHelper(id);
  58. if(!skipFixed) $ax.legacy.BringFixedToFront();
  59. };
  60. var _bringToFrontHelper = function(id) {
  61. var target = window.document.getElementById(id);
  62. if(target == null) return;
  63. $ax.globals.MaxZIndex = $ax.globals.MaxZIndex + 1;
  64. target.style.zIndex = $ax.globals.MaxZIndex;
  65. };
  66. $ax.legacy.BringFixedToFront = function() {
  67. $ax(function(diagramObject) { return diagramObject.fixedKeepInFront; }).each(function(diagramObject, scriptId) {
  68. _bringToFrontHelper(scriptId);
  69. });
  70. };
  71. $ax.legacy.SendToBack = function(id) {
  72. var target = window.document.getElementById(id);
  73. if(target == null) return;
  74. target.style.zIndex = $ax.globals.MinZIndex = $ax.globals.MinZIndex - 1;
  75. };
  76. $ax.legacy.RefreshScreen = function() {
  77. var oldColor = window.document.body.style.backgroundColor;
  78. var setColor = (oldColor == "rgb(0,0,0)") ? "#FFFFFF" : "#000000";
  79. window.document.body.style.backgroundColor = setColor;
  80. window.document.body.style.backgroundColor = oldColor;
  81. };
  82. $ax.legacy.getAbsoluteLeft = function(currentNode) {
  83. var oldDisplay = currentNode.css('display');
  84. var displaySet = false;
  85. if(oldDisplay == 'none') {
  86. currentNode.css('display', '');
  87. displaySet = true;
  88. }
  89. var left = currentNode.offset().left;
  90. if(displaySet) currentNode.css('display', oldDisplay);
  91. var body = $('body');
  92. if(body.css('position') == 'relative') left -= (Number(body.css('left').replace('px', '')) + Math.max(0, ($(window).width() - body.width()) / 2));
  93. return left;
  94. };
  95. $ax.legacy.getAbsoluteTop = function(currentNode) {
  96. var oldDisplay = currentNode.css('display');
  97. var displaySet = false;
  98. if(oldDisplay == 'none') {
  99. currentNode.css('display', '');
  100. displaySet = true;
  101. }
  102. var top = currentNode.offset().top;
  103. if(displaySet) currentNode.css('display', oldDisplay);
  104. return top;
  105. };
  106. // ****************** Annotation and Link Functions ****************** //
  107. $ax.legacy.GetAnnotationHtml = function(annJson) {
  108. var retVal = "";
  109. for(var noteName in annJson) {
  110. if(noteName != "label") {
  111. retVal += "<div class='annotationName'>" + noteName + "</div>";
  112. retVal += "<div class='annotation'>" + annJson[noteName] + "</div>";
  113. }
  114. }
  115. return retVal;
  116. };
  117. $ax.legacy.GetScrollable = function(target) {
  118. var $target = $(target);
  119. var current = $target;
  120. var last = $target;
  121. while(!current.is('body') && !current.is('html')) {
  122. var elementId = current.attr('id');
  123. var diagramObject = elementId && $ax.getObjectFromElementId(elementId);
  124. if(diagramObject && diagramObject.type == 'dynamicPanel' && diagramObject.scrollbars != 'none') {
  125. //returns the panel diagram div which handles scrolling
  126. return window.document.getElementById(last.attr('id'));
  127. }
  128. last = current;
  129. current = current.parent();
  130. }
  131. // Need to do this because of ie
  132. if($.browser.msie) return window.document.documentElement;
  133. else return window.document.body;
  134. };
  135. });