产品原型
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.

165 lines
5.8 KiB

4 years ago
  1. //stored on each browser event
  2. var windowEvent;
  3. $axure.internal(function($ax) {
  4. var _legacy = {};
  5. $ax.legacy = _legacy;
  6. var Forms = window.document.getElementsByTagName("FORM");
  7. for(var i = 0; i < Forms.length; i++) {
  8. var Form = Forms[i];
  9. Form.onclick = $ax.legacy.SuppressBubble;
  10. }
  11. $ax.legacy.SuppressBubble = function(event) {
  12. if(IE_10_AND_BELOW) {
  13. window.event.cancelBubble = true;
  14. window.event.returnValue = false;
  15. } else {
  16. if(event) {
  17. event.stopPropagation();
  18. }
  19. }
  20. };
  21. $ax.legacy.BringToFront = function(id, skipFixed) {
  22. _bringToFrontHelper(id);
  23. if(!skipFixed) $ax.legacy.BringFixedToFront();
  24. };
  25. var _bringToFrontHelper = function(id) {
  26. var target = window.document.getElementById(id);
  27. if(target == null) return;
  28. $ax.globals.MaxZIndex = $ax.globals.MaxZIndex + 1;
  29. target.style.zIndex = $ax.globals.MaxZIndex;
  30. };
  31. $ax.legacy.BringFixedToFront = function() {
  32. $ax(function(diagramObject) { return diagramObject.fixedKeepInFront; }).each(function(diagramObject, scriptId) {
  33. _bringToFrontHelper(scriptId);
  34. });
  35. };
  36. $ax.legacy.SendToBack = function(id) {
  37. var target = window.document.getElementById(id);
  38. if(target == null) return;
  39. target.style.zIndex = $ax.globals.MinZIndex = $ax.globals.MinZIndex - 1;
  40. };
  41. $ax.legacy.RefreshScreen = function() {
  42. var oldColor = window.document.body.style.backgroundColor;
  43. var setColor = (oldColor == "rgb(0,0,0)") ? "#FFFFFF" : "#000000";
  44. window.document.body.style.backgroundColor = setColor;
  45. window.document.body.style.backgroundColor = oldColor;
  46. };
  47. $ax.legacy.getAbsoluteLeft = function(currentNode, elementId) {
  48. var oldDisplay = currentNode.css('display');
  49. var displaySet = false;
  50. if(oldDisplay == 'none') {
  51. currentNode.css('display', '');
  52. displaySet = true;
  53. }
  54. var left = currentNode.offset().left;
  55. // Special Layer code
  56. if($ax.getTypeFromElementId(elementId) == 'layer') {
  57. var first = true;
  58. var children = currentNode.children();
  59. for(var i = 0; i < children.length; i++) {
  60. var child = $(children[i]);
  61. var subDisplaySet = false;
  62. if(child.css('display') == 'none') {
  63. child.css('display', '');
  64. subDisplaySet = true;
  65. }
  66. if(first) left = child.offset().left;
  67. else left = Math.min(child.offset().left, left);
  68. first = false;
  69. if(subDisplaySet) child.css('display', 'none');
  70. }
  71. }
  72. if (displaySet) currentNode.css('display', oldDisplay);
  73. return $axure.fn.bodyToWorld(left, true);
  74. };
  75. $ax.legacy.getAbsoluteTop = function(currentNode, elementId) {
  76. var oldDisplay = currentNode.css('display');
  77. var displaySet = false;
  78. if(oldDisplay == 'none') {
  79. currentNode.css('display', '');
  80. displaySet = true;
  81. }
  82. var top = currentNode.offset().top;
  83. // Special Layer code
  84. if ($ax.getTypeFromElementId(elementId) == 'layer') {
  85. var first = true;
  86. var children = currentNode.children();
  87. for (var i = 0; i < children.length; i++) {
  88. var child = $(children[i]);
  89. var subDisplaySet = false;
  90. if (child.css('display') == 'none') {
  91. child.css('display', '');
  92. subDisplaySet = true;
  93. }
  94. if (first) top = child.offset().top;
  95. else top = Math.min(child.offset().top, top);
  96. first = false;
  97. if (subDisplaySet) child.css('display', 'none');
  98. }
  99. }
  100. if(displaySet) currentNode.css('display', oldDisplay);
  101. return top;
  102. };
  103. // ****************** Annotation and Link Functions ****************** //
  104. $ax.legacy.GetAnnotationHtml = function(annJson) {
  105. var retVal = "";
  106. for(var noteName in annJson) {
  107. if(noteName != "label" && noteName != "id") {
  108. retVal += "<div class='annotationName'>" + noteName + "</div>";
  109. retVal += "<div class='annotationValue'>" + linkify(annJson[noteName]) + "</div>";
  110. }
  111. }
  112. return retVal;
  113. function linkify(text) {
  114. var urlRegex = /(\b(((https?|ftp|file):\/\/)|(www\.))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  115. return text.replace(urlRegex, function (url, b, c) {
  116. var url2 = (c == 'www.') ? 'http://' + url : url;
  117. return '<a href="' + url2 + '" target="_blank" class="noteLink">' + url + '</a>';
  118. });
  119. }
  120. };
  121. $ax.legacy.GetScrollable = function(target) {
  122. var $target = $(target);
  123. var last = $target;
  124. // Start past inital target. Can't scroll to target in itself, must be some ancestor.
  125. var current = last.parent();
  126. while(!current.is('body') && !current.is('html')) {
  127. var elementId = current.attr('id');
  128. var diagramObject = elementId && $ax.getObjectFromElementId(elementId);
  129. if (diagramObject && $ax.public.fn.IsDynamicPanel(diagramObject.type) && diagramObject.scrollbars != 'none') {
  130. //returns the panel diagram div which handles scrolling
  131. return $ax.dynamicPanelManager.getShownState(current.attr('id'))[0];
  132. }
  133. last = current;
  134. current = current.parent();
  135. }
  136. // Need to do this because of ie
  137. if(IE_10_AND_BELOW) return window.document.documentElement;
  138. else return window.document.body;
  139. };
  140. });