legacy.js
7.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//stored on each browser event
var windowEvent;
$axure.internal(function($ax) {
var _legacy = {};
$ax.legacy = _legacy;
// ************************** GLOBAL VARS *********************************//
// ************************************************************************//
//Check if IE
//var bIE = false;
//if ((index = navigator.userAgent.indexOf("MSIE")) >= 0) {
// bIE = true;
//}
var Forms = window.document.getElementsByTagName("FORM");
for(var i = 0; i < Forms.length; i++) {
var Form = Forms[i];
Form.onclick = $ax.legacy.SuppressBubble;
}
$ax.legacy.SuppressBubble = function(event) {
if(IE_10_AND_BELOW) {
window.event.cancelBubble = true;
window.event.returnValue = false;
} else {
if(event) {
event.stopPropagation();
}
}
};
// function InsertAfterBegin(dom, html) {
// if(!IE) {
// var phtml;
// var range = dom.ownerDocument.createRange();
// range.selectNodeContents(dom);
// range.collapse(true);
// phtml = range.createContextualFragment(html);
// dom.insertBefore(phtml, dom.firstChild);
// } else {
// dom.insertAdjacentHTML("afterBegin", html);
// }
// }
// function InsertBeforeEnd(dom, html) {
// if(!IE) {
// var phtml;
// var range = dom.ownerDocument.createRange();
// range.selectNodeContents(dom);
// range.collapse(dom);
// phtml = range.createContextualFragment(html);
// dom.appendChild(phtml);
// } else {
// dom.insertAdjacentHTML("beforeEnd", html);
// }
// }
//Get the id of the Workflow Dialog belonging to element with id = id
// function Workflow(id) {
// return id + 'WF';
// }
$ax.legacy.BringToFront = function(id, skipFixed) {
_bringToFrontHelper(id);
if(!skipFixed) $ax.legacy.BringFixedToFront();
};
var _bringToFrontHelper = function(id) {
var target = window.document.getElementById(id);
if(target == null) return;
$ax.globals.MaxZIndex = $ax.globals.MaxZIndex + 1;
target.style.zIndex = $ax.globals.MaxZIndex;
};
$ax.legacy.BringFixedToFront = function() {
$ax(function(diagramObject) { return diagramObject.fixedKeepInFront; }).each(function(diagramObject, scriptId) {
_bringToFrontHelper(scriptId);
});
};
$ax.legacy.SendToBack = function(id) {
var target = window.document.getElementById(id);
if(target == null) return;
target.style.zIndex = $ax.globals.MinZIndex = $ax.globals.MinZIndex - 1;
};
$ax.legacy.RefreshScreen = function() {
var oldColor = window.document.body.style.backgroundColor;
var setColor = (oldColor == "rgb(0,0,0)") ? "#FFFFFF" : "#000000";
window.document.body.style.backgroundColor = setColor;
window.document.body.style.backgroundColor = oldColor;
};
$ax.legacy.getAbsoluteLeft = function(currentNode, elementId) {
var oldDisplay = currentNode.css('display');
var displaySet = false;
if(oldDisplay == 'none') {
currentNode.css('display', '');
displaySet = true;
}
var left = currentNode.offset().left;
// Special Layer code
if($ax.getTypeFromElementId(elementId) == 'layer') {
var first = true;
var children = currentNode.children();
for(var i = 0; i < children.length; i++) {
var child = $(children[i]);
var subDisplaySet = false;
if(child.css('display') == 'none') {
child.css('display', '');
subDisplaySet = true;
}
if(first) left = child.offset().left;
else left = Math.min(child.offset().left, left);
first = false;
if(subDisplaySet) child.css('display', 'none');
}
}
if (displaySet) currentNode.css('display', oldDisplay);
return $axure.fn.bodyToWorld(left, true);
};
$ax.legacy.getAbsoluteTop = function(currentNode, elementId) {
var oldDisplay = currentNode.css('display');
var displaySet = false;
if(oldDisplay == 'none') {
currentNode.css('display', '');
displaySet = true;
}
var top = currentNode.offset().top;
// Special Layer code
if ($ax.getTypeFromElementId(elementId) == 'layer') {
var first = true;
var children = currentNode.children();
for (var i = 0; i < children.length; i++) {
var child = $(children[i]);
var subDisplaySet = false;
if (child.css('display') == 'none') {
child.css('display', '');
subDisplaySet = true;
}
if (first) top = child.offset().top;
else top = Math.min(child.offset().top, top);
first = false;
if (subDisplaySet) child.css('display', 'none');
}
}
if(displaySet) currentNode.css('display', oldDisplay);
return top;
};
// ****************** Annotation and Link Functions ****************** //
$ax.legacy.GetAnnotationHtml = function(annJson) {
var retVal = "";
for(var noteName in annJson) {
if(noteName != "label" && noteName != "id") {
retVal += "<div class='annotationName'>" + noteName + "</div>";
retVal += "<div class='annotationValue'>" + linkify(annJson[noteName]) + "</div>";
}
}
return retVal;
function linkify(text) {
var urlRegex = /(\b(((https?|ftp|file):\/\/)|(www\.))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(urlRegex, function (url, b, c) {
var url2 = (c == 'www.') ? 'http://' + url : url;
return '<a href="' + url2 + '" target="_blank" class="noteLink">' + url + '</a>';
});
}
};
$ax.legacy.GetScrollable = function(target) {
var $target = $(target);
var last = $target;
// Start past inital target. Can't scroll to target in itself, must be some ancestor.
var current = last.parent();
while(!current.is('body') && !current.is('html')) {
var elementId = current.attr('id');
var diagramObject = elementId && $ax.getObjectFromElementId(elementId);
if (diagramObject && $ax.public.fn.IsDynamicPanel(diagramObject.type) && diagramObject.scrollbars != 'none') {
//returns the panel diagram div which handles scrolling
return window.document.getElementById(last.attr('id'));
}
last = current;
current = current.parent();
}
// Need to do this because of ie
if(IE_10_AND_BELOW) return window.document.documentElement;
else return window.document.body;
};
});