-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprototypePost_custom.js
13229 lines (11176 loc) · 567 KB
/
prototypePost_custom.js
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 8.0.0.3388. Generated 7/15/2019 6:13:11 PM UTC
//***** messagecenter.js *****//
if (typeof console == 'undefined') console = {
log: function () { }
};
// sniff chrome
var CHROME_5_LOCAL = false;
var CHROME = false;
var SAFARI = false;
var FIREFOX = false;
var WEBKIT = false;
var OS_MAC = false;
var IOS = false;
var ANDROID = false;
var MOBILE_DEVICE = false;
var IE = false;
var IE_10_AND_BELOW = false; //ie 10 and lower
var IE_11_AND_ABOVE = false; //ie 11 and above
var BROWSER_VERSION = 5000;
(function () {
if(!window.$axure) window.$axure = function() {};
var useragent = window.navigator.userAgent;
var edgeRegex = /Edge\/([0-9]+)/g;
var edgeMatch = edgeRegex.exec(useragent);
$axure.browser = { isEdge: Boolean(edgeMatch) };
if(!$axure.browser.isEdge) {
var chromeRegex = /Chrome\/([0-9]+).([0-9]+)/g;
var chromeMatch = chromeRegex.exec(useragent);
CHROME = Boolean(chromeMatch);
CHROME_5_LOCAL = chromeMatch &&
Number(chromeMatch[1]) >= 5 &&
location.href.indexOf('file://') >= 0;
}
var safariRegex = /Safari\/([0-9]+)/g;
var safariMatch = safariRegex.exec(useragent);
SAFARI = Boolean(safariMatch) && !CHROME; //because chrome also inserts safari string into user agent
var webkitRegex = /WebKit\//g ;
WEBKIT = Boolean(webkitRegex.exec(useragent));
FIREFOX = useragent.toLowerCase().indexOf('firefox') > -1;
var macRegex = /Mac/g ;
OS_MAC = Boolean(macRegex.exec(window.navigator.platform));
IOS = useragent.match(/iPhone/i) || useragent.match(/iPad/i) || useragent.match(/iPod/i);
ANDROID = useragent.match(/Android/i);
MOBILE_DEVICE = ANDROID || IOS
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Tablet PC/i)
|| navigator.userAgent.match(/Windows Phone/i);
if($.browser) {
if($.browser.msie) IE_10_AND_BELOW = true;
else IE_11_AND_ABOVE = useragent.toLowerCase().indexOf('trident') > -1;
BROWSER_VERSION = $.browser.version;
}
IE = IE_10_AND_BELOW || IE_11_AND_ABOVE;
//Used by sitemap and variables.js getLinkUrl functions so that they know
//whether to embed global variables in URL as query string or hash string
//_shouldSendVars persists the value for sitemap instead of re-checking every time
var _shouldSendVars;
var _shouldSendVarsToServer = function(url) {
if(typeof _shouldSendVars != 'undefined') {
return _shouldSendVars;
}
if(SAFARI || (IE_10_AND_BELOW && BROWSER_VERSION < 10)) {
var urlToCheck = typeof url != 'undefined' ? url : window.location.href;
var serverRegex = /http:\/\/127\.0\.0\.1:[0-9]{5}/g;
var serverMatch = serverRegex.exec(urlToCheck);
var previewRegex = /[0-9]{2}\.[0-9]{2}\.[0-9]{2}/g;
var previewMatch = previewRegex.exec(urlToCheck);
if(Boolean(serverMatch) && Boolean(previewMatch)) {
_shouldSendVars = true;
return _shouldSendVars;
}
}
_shouldSendVars = false;
return _shouldSendVars;
};
$axure.shouldSendVarsToServer = _shouldSendVarsToServer;
})();
(function() {
var _topMessageCenter;
var _messageCenter = {};
var _listeners = [];
var _stateListeners = [];
var _state = {};
var _eventObject = null;
var _queuedMessages = [];
var _initialized = false;
// this is for the non Chrome 5 local scenarios. The "top" message center will dispatch to all the bottom ones
var _childrenMessageCenters = [];
// create $axure if it hasn't been created
if (!window.$axure) window.$axure = function() {};
$axure.messageCenter = _messageCenter;
// isolate scope, and initialize _topMessageCenter.
(function() {
if (!CHROME_5_LOCAL) {
var topAxureWindow = window;
try {
while(topAxureWindow.parent && topAxureWindow.parent !== topAxureWindow
&& topAxureWindow.parent.$axure) topAxureWindow = topAxureWindow.parent;
} catch(e) {}
_topMessageCenter = topAxureWindow.$axure.messageCenter;
}
})();
$(window.document).ready(function() {
if (CHROME_5_LOCAL) {
$('body').append("<div id='axureEventReceiverDiv' style='display:none'></div>" +
"<div id='axureEventSenderDiv' style='display:none'></div>");
_eventObject = window.document.createEvent('Event');
_eventObject.initEvent('axureMessageSenderEvent', true, true);
$('#axureEventReceiverDiv').bind('axureMessageReceiverEvent', function () {
var request = JSON.parse($(this).text());
_handleRequest(request);
});
} else {
if (_topMessageCenter != _messageCenter) {
_topMessageCenter.addChildMessageCenter(_messageCenter);
console.log('adding from ' + window.location.toString());
}
}
});
var _handleRequest = function (request) {
// route the request to all the listeners
for(var i = 0; i < _listeners.length; i++) _listeners[i](request.message, request.data);
// now handle the queued messages if we're initializing
if (request.message == 'initialize') {
_initialized = true;
// send all the queued messages and return
for (var i = 0; i < _queuedMessages.length; i++) {
var qRequest = _queuedMessages[i];
_messageCenter.postMessage(qRequest.message, qRequest.data);
}
_queuedMessages = [];
}
// and then handle the set state messages, if necessary
if (request.message == 'setState') {
_state[request.data.key] = request.data.value;
for (var i = 0; i < _stateListeners.length; i++) {
var keyListener = _stateListeners[i];
// if thep passed a null or empty value, always post the message
if (!keyListener.key || keyListener.key == request.data.key) {
keyListener.listener(request.data.key, request.data.value);
}
}
}
};
// -----------------------------------------------------------------------------------------
// This method allows for dispatching messages in the non-chromelocal scenario.
// Each child calls this on _topMessageCenter
// -----------------------------------------------------------------------------------------
_messageCenter.addChildMessageCenter = function(messageCenter) {
_childrenMessageCenters[_childrenMessageCenters.length] = messageCenter;
};
// -----------------------------------------------------------------------------------------
// This method allows for dispatching messages in the non-chromelocal scenario.
// Each child calls this on _topMessageCenter
// -----------------------------------------------------------------------------------------
_messageCenter.dispatchMessage = function(message, data) {
_handleRequest({
message: message,
data: data
});
};
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
_messageCenter.dispatchMessageRecursively = function(message, data) {
console.log("dispatched to " + window.location.toString());
// dispatch to the top center first
_messageCenter.dispatchMessage(message, data);
$('iframe').each(function(index, frame) {
//try,catch to handle permissions error in FF when loading pages from another domain
try {
if (frame.contentWindow.$axure && frame.contentWindow.$axure.messageCenter) {
frame.contentWindow.$axure.messageCenter.dispatchMessageRecursively(message, data);
}
}catch(e) {}
});
};
var _combineEventMessages = false;
var _compositeEventMessageData = [];
_messageCenter.startCombineEventMessages = function() {
_combineEventMessages = true;
}
_messageCenter.endCombineEventMessages = function () {
_messageCenter.sendCompositeEventMessage();
_combineEventMessages = false;
}
_messageCenter.sendCompositeEventMessage = function () {
_messageCenter.postMessage('axCompositeEventMessage', _compositeEventMessageData);
_compositeEventMessageData = [];
}
_messageCenter.postMessage = function (message, data) {
if(_combineEventMessages) {
if(message == 'axEvent' || message == 'axCase' || message == 'axAction' || message == 'axEventComplete') {
_compositeEventMessageData.push({ 'message': message, 'data': data });
if(_compositeEventMessageData.length >= 10) _messageCenter.sendCompositeEventMessage();
return;
}
}
if(!CHROME_5_LOCAL) {
_topMessageCenter.dispatchMessageRecursively(message, data);
} else {
var request = {
message: message,
data: data
};
if(_initialized) {
var senderDiv = window.document.getElementById('axureEventSenderDiv');
var messageText = JSON.stringify(request);
// console.log('sending event: ' + messageText);
senderDiv.innerText = messageText;
senderDiv.dispatchEvent(_eventObject);
// console.log('event sent');
} else {
_queuedMessages[_queuedMessages.length] = request;
}
}
};
_messageCenter.setState = function(key, value) {
var data = {
key: key,
value: value
};
_messageCenter.postMessage('setState', data);
};
_messageCenter.getState = function(key) {
return _state[key];
};
_messageCenter.addMessageListener = function(listener) {
_listeners[_listeners.length] = listener;
};
_messageCenter.addStateListener = function(key, listener) {
_stateListeners[_stateListeners.length] = {
key: key,
listener: listener
};
};
})();
//***** events.js *****//
// ******* Features MANAGER ******** //
$axure.internal(function($ax) {
var _features = $ax.features = {};
var _supports = _features.supports = {};
_supports.touchstart = typeof window.ontouchstart !== 'undefined';
_supports.touchmove = typeof window.ontouchmove !== 'undefined';
_supports.touchend = typeof window.ontouchend !== 'undefined';
_supports.mobile = _supports.touchstart && _supports.touchend && _supports.touchmove;
// Got this from http://stackoverflow.com/questions/11381673/javascript-solution-to-detect-mobile-browser
var check = navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Tablet PC/i)
|| navigator.userAgent.match(/Windows Phone/i);
_supports.windowsMobile = navigator.userAgent.match(/Tablet PC/i) || navigator.userAgent.match(/Windows Phone/i);
if(!check && _supports.mobile) {
_supports.touchstart = false;
_supports.touchmove = false;
_supports.touchend = false;
_supports.mobile = false;
}
var _eventNames = _features.eventNames = {};
_eventNames.mouseDownName = _supports.touchstart ? 'touchstart' : 'mousedown';
_eventNames.mouseUpName = _supports.touchend ? 'touchend' : 'mouseup';
_eventNames.mouseMoveName = _supports.touchmove ? 'touchmove' : 'mousemove';
});
// ******* EVENT MANAGER ******** //
$axure.internal(function($ax) {
var _objectIdToEventHandlers = {};
var _jBrowserEvent = undefined;
$ax.setjBrowserEvent = function(event) {
_jBrowserEvent = event;
};
$ax.getjBrowserEvent = function() {
return _jBrowserEvent;
};
var _event = {};
$ax.event = _event;
//initilize state
_event.mouseOverObjectId = '';
_event.mouseDownObjectId = '';
_event.mouseOverIds = [];
var EVENT_NAMES = ['mouseenter', 'mouseleave', 'contextmenu', 'change', 'focus', 'blur'];
// Tap, double tap, and touch move, or synthetic.
if(!$ax.features.supports.mobile) {
EVENT_NAMES[EVENT_NAMES.length] = 'click';
EVENT_NAMES[EVENT_NAMES.length] = 'dblclick';
EVENT_NAMES[EVENT_NAMES.length] = 'mousemove';
}
// add the event names for the touch events
EVENT_NAMES[EVENT_NAMES.length] = $ax.features.eventNames.mouseDownName;
EVENT_NAMES[EVENT_NAMES.length] = $ax.features.eventNames.mouseUpName;
for(var i = 0; i < EVENT_NAMES.length; i++) {
var eventName = EVENT_NAMES[i];
//we need the function here to circumvent closure modifying eventName
_event[eventName] = (function(event_Name) {
return function(elementId, fn) {
var elementIdQuery = $jobj(elementId);
var type = $ax.getTypeFromElementId(elementId);
//we need specially track link events so we can enable and disable them along with
//their parent widgets
if(elementIdQuery.is('a')) _attachCustomObjectEvent(elementId, event_Name, fn);
//see notes below
else if($ax.IsTreeNodeObject(type)) _attachTreeNodeEvent(elementId, event_Name, fn);
else if ($ax.IsImageFocusable(type) && (event_Name == 'focus' || event_Name == 'blur')) {
var suitableChild;
var imgChild = $ax.repeater.applySuffixToElementId(elementId, '_img');
var divChild = $ax.repeater.applySuffixToElementId(elementId, '_div');
for (var j = 0; j < elementIdQuery[0].children.length; j++) {
if (elementIdQuery[0].children[j].id == imgChild) suitableChild = imgChild;
if (!suitableChild && elementIdQuery[0].children[j].id == divChild) suitableChild = divChild;
}
if(!suitableChild) suitableChild = imgChild;
_attachDefaultObjectEvent($jobj(suitableChild), elementId, event_Name, fn);
} else {
var inputId = $ax.INPUT(elementId);
var isInput = $jobj(inputId).length != 0;
var id = isInput && (event_Name == 'focus' || event_Name == 'blur') ? inputId : elementId;
_attachDefaultObjectEvent($jobj(id), elementId, event_Name, fn);
}
};
})(eventName);
}
var AXURE_TO_JQUERY_EVENT_NAMES = {
'onMouseOver': 'mouseenter',
'onMouseOut': 'mouseleave',
'onContextMenu': 'contextmenu',
'onChange': 'change',
'onFocus': 'focus',
'onLostFocus': 'blur'
};
// Tap, double tap, and touch move, or synthetic.
if(!$ax.features.supports.mobile) {
AXURE_TO_JQUERY_EVENT_NAMES.onClick = 'click';
AXURE_TO_JQUERY_EVENT_NAMES.onDoubleClick = 'dblclick';
AXURE_TO_JQUERY_EVENT_NAMES.onMouseMove = 'mousemove';
}
AXURE_TO_JQUERY_EVENT_NAMES.onMouseDown = $ax.features.eventNames.mouseDownName;
AXURE_TO_JQUERY_EVENT_NAMES.onMouseUp = $ax.features.eventNames.mouseUpName;
//for dp, if mouse entered without leaving, don't fire mouse enter again
var mouseEnterGuard = {};
var _attachEvents = function (diagramObject, elementId, doMouseEnterGuard) {
var inputId = $ax.repeater.applySuffixToElementId(elementId, '_input');
var id = $jobj(inputId).length ? inputId : elementId;
for(var eventName in diagramObject.interactionMap) {
var jQueryEventName = AXURE_TO_JQUERY_EVENT_NAMES[eventName];
if(!jQueryEventName) continue;
_event[jQueryEventName](id,
//this is needed to escape closure
(function(axEventObject) {
return function (e) {
if(e.type == 'mouseenter' && doMouseEnterGuard) {
if(mouseEnterGuard[elementId]) return;
else mouseEnterGuard[elementId] = true;
}
$ax.setjBrowserEvent(e);
// console.log(axEventObject.description);
var eventInfo = $ax.getEventInfoFromEvent($ax.getjBrowserEvent(), false, elementId);
_handleEvent(elementId, eventInfo, axEventObject);
};
})(diagramObject.interactionMap[eventName])
);
if(jQueryEventName.toLowerCase() == 'mouseenter' && doMouseEnterGuard) {
$jobj(elementId).on('mouseleave touchend', function() {
mouseEnterGuard[elementId] = false;
});
}
}
};
var _descriptionToKey = { 'OnFocus': 'onFocus', 'OnLostFocus': 'onLostFocus' };
var _createProxies = function(diagramObject, elementId) {
var createFocus = _needsProxy(diagramObject, elementId, 'onFocus');
var createLostFocus = _needsProxy(diagramObject, elementId, 'onLostFocus');
if(!createFocus && !createLostFocus) return;
if(!diagramObject.interactionMap) diagramObject.interactionMap = {};
if(createFocus) diagramObject.interactionMap.onFocus = { proxy: true, description: 'OnFocus' };
if(createLostFocus) diagramObject.interactionMap.onLostFocus = { proxy: true, description: 'OnLostFocus' };
}
var preventDefaultEvents = ['OnContextMenu', 'OnKeyUp', 'OnKeyDown'];
var allowBubble = ['OnFocus', 'OnResize', 'OnMouseOut', 'OnMouseOver'];
var _canClick = true;
var _startScroll = [];
var _setCanClick = function(canClick) {
_canClick = canClick;
if(_canClick) _startScroll = [$(window).scrollLeft(), $(window).scrollTop()];
};
var _getCanClick = function() {
if(!$ax.features.supports.mobile) return true;
var endScroll = [$(window).scrollLeft(), $(window).scrollTop()];
return _canClick && _startScroll[0] == endScroll[0] && _startScroll[1] == endScroll[1];
};
//var _notAllowedInvisible = function (type) {
// $ax.getTypeFromElementId(elementId);
// return !$ax.public.fn.IsReferenceDiagramObject(type) && !$ax.public.fn.IsLayer(type);
//}
var _notAllowedInvisible = function (id) {
var type = $ax.getTypeFromElementId(id);
if ($ax.public.fn.IsReferenceDiagramObject(type) || $ax.public.fn.IsLayer(type)) return false;
return !($ax.public.fn.IsVector(type) && _hasCompoundImage(id));
}
var _hasCompoundImage = function (id) {
var query = $jobj(id);
return $ax.public.fn.isCompoundVectorHtml(query[0]);
}
var _suppressedEvents = {}; // Suppressed for next occurance.
var _blockedEvents = {}; // Blocked until unblocked.
_event.addSuppressedEvent = function(id, event) {
if(!_suppressedEvents[id]) _suppressedEvents[id] = [];
var events = _suppressedEvents[id];
if(events.indexOf(event) != -1) return;
events.push(event);
}
_event.blockEvent = function(id, event) {
if(!_blockedEvents[id]) _blockedEvents[id] = {};
var events = _blockedEvents[id];
if(events[event]) ++events[event];
else events[event] = 1;
return function() { _unblockEvent(id, event); };
}
var _isSuppressedEvent = function(id, event) {
var suppressedEvents = _suppressedEvents[id];
var blockedEvents = _blockedEvents[id];
return (suppressedEvents && suppressedEvents.indexOf(event) != -1) || (blockedEvents && blockedEvents[event]);
}
var _removeSuppressedEvent = function(id, event) {
var events = _suppressedEvents[id];
if(!events) return;
if(events.length == 1) {
delete _suppressedEvents[id];
} else {
var eventIndex = events.indexOf(event);
for(var i = eventIndex + 1; i < events.length; i++) events[i - 1] = events[i];
events.pop();
}
}
var _unblockEvent = function(id, event) {
var events = _blockedEvents[id];
if(events) {
if(--events[event] > 0) return;
}
_removeSuppressedEvent(id, event);
}
var _unblockEvent = function(id, event) {
var events = _blockedEvents[id];
if(events) {
if(--events[event] > 0) return;
}
_removeSuppressedEvent(id, event);
}
var eventNesting = 0;
var eventNestingTime = new Date().getTime();
var _handleEvent = $ax.event.handleEvent = function (elementId, eventInfo, axEventObject, skipShowDescriptions, synthetic) {
var eventDescription = axEventObject.description;
if(_enteredWidgets[elementId] && eventDescription == 'OnMouseEnter') return; // Suppress entering a widget when already in widget (ie only)
if(_isSuppressedEvent(elementId, eventDescription)) {
_removeSuppressedEvent(elementId, eventDescription);
return;
}
if(axEventObject.proxy) {
var firingId = _widgetToFocusParent[elementId];
if(firingId) {
var firingObj = $obj(firingId);
var nextEventObj = firingObj.interactionMap && firingObj.interactionMap[_descriptionToKey[eventDescription]];
if(!nextEventObj) nextEventObj = axEventObject;
_handleEvent(firingId, eventInfo, nextEventObj, skipShowDescriptions, synthetic);
}
return;
}
// var x = JSON.stringify(eventInfo);
// var y = JSON.stringify(axEventObject);
var fireTime = new Date().getTime();
if(fireTime - eventNestingTime > 100) {
eventNestingTime = fireTime;
eventNesting = 0;
}
if(eventNesting === 0) {
$ax.recording.maybeRecordEvent(elementId, eventInfo, axEventObject, fireTime);
}
eventNesting += 1;
if(!_getCanClick() && (eventDescription == 'OnClick' || eventDescription == 'OnPageClick')) return;
// If you are supposed to suppress, do that right away.
if(suppressedEventStatus[eventDescription]) {
return;
}
var currentEvent = $ax.getjBrowserEvent();
if(!synthetic && currentEvent && currentEvent.originalEvent && currentEvent.originalEvent.handled && !eventInfo.isMasterEvent) return;
if(!synthetic && elementId && !$ax.style.getObjVisible(elementId) && _notAllowedInvisible(elementId)) return;
//if debug
var axObj = $obj(elementId);
var axObjLabel = axObj ? axObj.label : eventInfo.label;
var axObjType = axObj ? axObj.friendlyType : eventInfo.friendlyType;
if(!skipShowDescriptions || eventDescription == 'OnPageLoad') $ax.messageCenter.postMessage('axEvent', { 'label': axObjLabel, 'type': axObjType, 'event': axEventObject });
var bubble = true;
var showCaseDescriptions = !skipShowDescriptions && _shouldShowCaseDescriptions(axEventObject);
if(!showCaseDescriptions) {
//handle case descriptions
var caseGroups = [];
var currentCaseGroup = [];
caseGroups[0] = currentCaseGroup;
// Those refreshes not after a wait
var guaranteedRefreshes = {};
var caseGroupIndex = 0;
for(var i = 0; i < axEventObject.cases.length; i++) {
var currentCase = axEventObject.cases[i];
if(currentCase.isNewIfGroup && i != 0) {
caseGroupIndex++;
currentCaseGroup = [];
caseGroups[caseGroups.length] = currentCaseGroup;
// Joon: Isn't caseGroups.length always equal to caseGroupIndex?
}
currentCaseGroup[currentCaseGroup.length] = currentCase;
for(var j = 0; j < currentCase.actions.length; j++) {
var action = currentCase.actions[j];
if(action.action == 'wait') break;
if(action.action != 'refreshRepeater') continue;
for(var k = 0; k < action.repeatersToRefresh.length; k++) {
var id = $ax.getElementIdsFromPath(action.repeatersToRefresh[k], eventInfo)[0];
if(id) guaranteedRefreshes[id] = caseGroupIndex;
}
}
}
for(var i = 0; i < caseGroups.length; i++) {
var groupRefreshes = [];
for(var key in guaranteedRefreshes) {
if(guaranteedRefreshes[key] == i) groupRefreshes[groupRefreshes.length] = key;
}
bubble = _handleCaseGroup(eventInfo, caseGroups[i], groupRefreshes) && bubble;
}
} else {
_showCaseDescriptions(elementId, eventInfo, axEventObject, synthetic);
bubble = false;
}
// If not handled, synthetically bubble if you can
if(bubble && _widgetToFocusParent[elementId]) {
firingId = _widgetToFocusParent[elementId];
if(firingId) {
firingObj = $obj(firingId);
nextEventObj = firingObj.interactionMap && firingObj.interactionMap[_descriptionToKey[axEventObject.description]];
if(!nextEventObj) nextEventObj = axEventObject;
_handleEvent(firingId, eventInfo, nextEventObj, skipShowDescriptions, synthetic);
}
return;
}
// Only trigger a supression if it handled this event
if(!bubble && suppressingEvents[eventDescription]) {
suppressedEventStatus[suppressingEvents[eventDescription]] = true;
}
$ax.action.flushAllResizeMoveActions(eventInfo);
// This should not be needed anymore. All refreshes should be inserted, or handled earlier.
var repeaters = $ax.deepCopy($ax.action.repeatersToRefresh);
while($ax.action.repeatersToRefresh.length) $ax.action.repeatersToRefresh.pop();
for(i = 0; i < repeaters.length; i++) $ax.repeater.refreshRepeater(repeaters[i], eventInfo);
if(currentEvent && currentEvent.originalEvent) {
currentEvent.originalEvent.handled = !synthetic && !bubble && allowBubble.indexOf(eventDescription) == -1;
//currentEvent.originalEvent.donotdrag = currentEvent.donotdrag || (!bubble && eventDescription == 'OnMouseDown');
// Prevent default if necessary
if(currentEvent.originalEvent.handled && preventDefaultEvents.indexOf(eventDescription) != -1) {
currentEvent.preventDefault();
}
}
eventNesting -= 1;
if(!showCaseDescriptions) $ax.messageCenter.postMessage('axEventComplete');
};
var _handleScrollEvent = function (elementId, eventInfo, originalEvent, scrolledUp, scrolledDown, interactionMap, skipShowDescription, synthetic) {
if (!interactionMap) return;
if (interactionMap.onScroll) _handleEvent(elementId, eventInfo, interactionMap.onScroll, skipShowDescription, synthetic);
var wasHandled = originalEvent.handled;
if (interactionMap.onScrollUp && scrolledUp) {
originalEvent.handled = false;
_handleEvent(elementId, eventInfo, interactionMap.onScrollUp, skipShowDescription, synthetic);
} else if (interactionMap.onScrollDown && scrolledDown) {
originalEvent.handled = false;
_handleEvent(elementId, eventInfo, interactionMap.onScrollDown, skipShowDescription, synthetic);
}
originalEvent.handled |= wasHandled;
}
var _showCaseDescriptions = function(elementId, eventInfo, axEventObject, synthetic) {
if(axEventObject.cases.length == 0) return true;
var linksId = elementId + "linkBox";
$('#' + linksId).remove();
var $container = $("<div class='intcases' id='" + linksId + "'></div>");
if(!_isEventSimulating(axEventObject)) {
var copy = $ax.eventCopy(eventInfo);
for(var i = 0; i < axEventObject.cases.length; i++) {
var $link = $("<div class='intcaselink'>" + axEventObject.cases[i].description + "</div>");
$link.click(function(j) {
return function () {
var currentCase = axEventObject.cases[j];
$ax.messageCenter.postMessage('axCase', { 'description': currentCase.description });
for(var k = 0; k < currentCase.actions.length; k++) {
$ax.messageCenter.postMessage('axAction', { 'description': currentCase.actions[k].description });
}
$ax.messageCenter.postMessage('axEventComplete');
var bubble = $ax.action.dispatchAction(copy, axEventObject.cases[j].actions);
$ax.action.flushAllResizeMoveActions(copy);
$('#' + linksId).remove();
return bubble;
};
} (i)
);
$container.append($link);
}
} else {
var fullDescription = axEventObject.description + ":<br>";
for(var i = 0; i < axEventObject.cases.length; i++) {
var currentCase = axEventObject.cases[i];
fullDescription += " " + currentCase.description.replace(/<br>/g, '<br> ') + ":<br>";
for(var j = 0; j < currentCase.actions.length; j++) {
fullDescription += " " + currentCase.actions[j].description.replace(/<br>/g, '<br> ') + "<br>";
}
}
fullDescription = fullDescription.substring(0, fullDescription.length - 4);
var $link = $("<div class='intcaselink'>" + fullDescription + "</div>");
$link.click(function() {
_handleEvent(elementId, eventInfo, axEventObject, true, synthetic);
$ax.messageCenter.postMessage('axEventComplete');
$('#' + linksId).remove();
return;
});
$container.append($link);
}
$container.mouseleave(function(e) { $ax.legacy.SuppressBubble(e); });
$('body').append($container);
_showCaseLinks(eventInfo, linksId);
};
var _showCaseLinks = function(eventInfo, linksId) {
var links = window.document.getElementById(linksId);
links.style.top = eventInfo.pageY;
var left = eventInfo.pageX;
links.style.left = left;
$ax.visibility.SetVisible(links, true);
$ax.legacy.BringToFront(linksId, true);
// Switch to using jquery if this is still needed. Really old legacy code, likely for a browser no longer supported.
//$ax.legacy.RefreshScreen();
};
var _shouldShowCaseDescriptions = function(axEventObject) {
if($ax.document.configuration.linkStyle == "alwaysDisplayTargets") return true;
if($ax.document.configuration.linkStyle == "neverDisplayTargets") return false;
if(axEventObject.cases.length == 0) return false;
if(_isEventSimulating(axEventObject)) return false;
if(axEventObject.cases.length >= 2) return true;
return false;
};
var _isEventSimulating = function(axEventObject) {
for(var i = 0; i < axEventObject.cases.length; i++) {
if(axEventObject.cases[i].condition) return true;
}
return false;
};
var _handleCaseGroup = function(eventInfo, caseGroup, groupRefreshes) {
for(var i = 0; i < caseGroup.length; i++) {
var currentCase = caseGroup[i];
if(!currentCase.condition || _processCondition(currentCase.condition, eventInfo)) {
$ax.messageCenter.postMessage('axCase', { 'description': currentCase.description });
for(var j = 0; j < currentCase.actions.length; j++) {
if(currentCase.actions[j].action != 'refreshRepeater') $ax.messageCenter.postMessage('axAction', { 'description': currentCase.actions[j].description });
}
for(var j = 0; j < currentCase.actions.length; j++) {
var action = currentCase.actions[j];
if(action.action == 'wait') break;
if(action.action != 'refreshRepeater') continue;
for(var k = 0; k < action.repeatersToRefresh.length; k++) {
var id = $ax.getElementIdsFromPath(action.repeatersToRefresh[i], eventInfo)[i];
if(id) {
var index = groupRefreshes.indexOf(id);
if(index != -1) $ax.splice(groupRefreshes, index);
}
}
}
// Any guaranteed refreshes that aren't accounted for must be run still.
$ax.action.tryRefreshRepeaters(groupRefreshes, eventInfo);
$ax.action.dispatchAction(eventInfo, currentCase.actions);
return false;
}
}
// Any guaranteed refreshes that aren't accounted for must be run still.
$ax.action.tryRefreshRepeaters(groupRefreshes, eventInfo);
return true;
};
var _processCondition = function(expr, eventInfo) {
return $ax.expr.evaluateExpr(expr, eventInfo);
};
var _attachTreeNodeEvent = function(elementId, eventName, fn) {
//we need to set the cursor here because we want to make sure that every tree node has the default
//cursor set and then it's overridden if it has a click
if(eventName == 'click') window.document.getElementById(elementId).style.cursor = 'pointer';
_attachCustomObjectEvent(elementId, eventName, fn);
};
var _attachDefaultObjectEvent = function(elementIdQuery, elementId, eventName, fn) {
var func = function() {
if(!$ax.style.IsWidgetDisabled(elementId)) return fn.apply(this, arguments);
return true;
};
var bind = !elementIdQuery[eventName];
if(bind) elementIdQuery.bind(eventName, func);
else elementIdQuery[eventName](func);
};
var _attachCustomObjectEvent = function(elementId, eventName, fn) {
var handlers = _objectIdToEventHandlers[elementId];
if(!handlers) _objectIdToEventHandlers[elementId] = handlers = {};
var fnList = handlers[eventName];
if(!fnList) handlers[eventName] = fnList = [];
fnList[fnList.length] = fn;
};
var _fireObjectEvent = function(elementId, event, originalArgs) {
var element = window.document.getElementById(elementId);
var handlerList = _objectIdToEventHandlers[elementId] && _objectIdToEventHandlers[elementId][event];
if(handlerList) {
for(var i = 0; i < handlerList.length; i++) handlerList[i].apply(element, originalArgs);
}
eventNesting -= 1;
};
var _layerToFocusableWidget = {};
var _widgetToFocusParent = {};
_event.layerMapFocus = function(layer, elementId) {
var mainObj = layer.objs[0];
// If first child non existant return
if (!mainObj) return;
var mainId = $ax.getElementIdFromPath([mainObj.id], { relativeTo: elementId });
_widgetToFocusParent[mainId] = elementId;
// If first child is a layer, call recursively
if ($ax.public.fn.IsLayer(mainObj.type)) {
_event.layerMapFocus(mainObj, mainId);
var baseId = _layerToFocusableWidget[mainId];
if(baseId) _layerToFocusableWidget[elementId] = baseId;
return;
}
_layerToFocusableWidget[elementId] = mainId;
}
var _needsProxy = function(obj, id, proxyName) {
// layers don't need on focus ever, proxies will handle them
if ($ax.public.fn.IsLayer(obj.type)) return false;
// If you already focus you don't need to force yourself to proxy.
if(obj.interactionMap && obj.interactionMap[proxyName]) return false;
var parentId = _widgetToFocusParent[id];
if(parentId) return _needsProxyHelper(parentId, proxyName);
return false;
}
var _needsProxyHelper = function(id, proxyName) {
var obj = $obj(id);
if(obj.interactionMap && obj.interactionMap[proxyName]) return true;
var parentId = _widgetToFocusParent[id];
if(parentId) return _needsProxyHelper(parentId, proxyName);
return false;
}
//for button shapes and images the img is focusable instead of the div to get better outlines
// For layers, we remember who their proxy is.
$ax.event.getFocusableWidgetOrChildId = function (elementId) {
var mappedId = _layerToFocusableWidget[elementId];
if (mappedId) elementId = mappedId;
var inputId = $ax.repeater.applySuffixToElementId(elementId, '_input');
var inputQuery = $jobj(inputId);
if(inputQuery.length > 0) return inputId;
var imgId = $ax.repeater.applySuffixToElementId(elementId, '_img');
var imgQuery = $jobj(imgId);
if (imgQuery.length > 0) return imgId;
var divId = $ax.repeater.applySuffixToElementId(elementId, '_div');
var divQuery = $jobj(divId);
if (divQuery.length > 0) return divId;
return elementId;
};
var _enteredWidgets = {};
// key is the suppressing event, and the value is the event that is supressed
var suppressingEvents = {};
// key is the event that will cancel the suppression, and value is the event that was being suppressed
var cancelSuppressions = {};
// suppressed event maps to true if it is supressed
var suppressedEventStatus = {};
var initSuppressingEvents = function () {
suppressingEvents['OnLongClick'] = 'OnClick';
cancelSuppressions['onMouseDown'] = 'OnClick';
// Have to cancel suppressed event here. Only works for non-synthetic events currently
for(var key in cancelSuppressions) {
var jEventName = AXURE_TO_JQUERY_EVENT_NAMES[key];
if(!jEventName) continue;
$('body').bind(jEventName, function () {
suppressedEventStatus[cancelSuppressions[key]] = false;
});
}
};
// TODO: It may be a good idea to split this into multiple functions, or at least pull out more similar functions into private methods
var _initializeObjectEvents = function(query, refreshType) {
query.each(function(dObj, elementId) {
var $element = $jobj(elementId);
var itemId = $ax.repeater.getItemIdFromElementId(elementId);
// Focus has to be done before on focus fires
// Set up focus
if ($ax.public.fn.IsTextArea(dObj.type) || $ax.public.fn.IsTextBox(dObj.type) || $ax.public.fn.IsCheckBox(dObj.type) || $ax.public.fn.IsRadioButton(dObj.type) ||
$ax.public.fn.IsListBox(dObj.type) || $ax.public.fn.IsComboBox(dObj.type) || $ax.public.fn.IsButton(dObj.type) ||
(dObj.tabbable && ($ax.public.fn.IsImageBox(dObj.type) || $ax.public.fn.IsVector(dObj.type) || $ax.IsTreeNodeObject(dObj.type) || $ax.public.fn.IsTableCell(dObj.type)))) {
var focusObj = $jobj($ax.event.getFocusableWidgetOrChildId(elementId));
focusObj.focus(function() {
window.lastFocusedControl = elementId;
});
}
// [MAS: Supressing events were here]
_createProxies(dObj, elementId);
var isDynamicPanel = $ax.public.fn.IsDynamicPanel(dObj.type);
if(dObj.interactionMap) {
_attachEvents(dObj, elementId, isDynamicPanel);
};
if (IE || $axure.browser.isEdge) {
$element.mouseenter(function() {
_enteredWidgets[elementId] = true;
}).mouseleave(function() {
_enteredWidgets[elementId] = false;
});
}
_attachIxStyleEvents(dObj, elementId, $element);
var $axElement = $ax('#' + elementId);
// Base case is set up selected disabled based on the default in the axobj, for non, repeaters and resetting repeaters
var itemReset = refreshType == $ax.repeater.refreshType.reset;
if(!itemId || itemReset) {
//initialize disabled elements, do this first before selected, cause if a widget is disabled, we don't want to apply selected style anymore
if($ax.public.fn.IsVector(dObj.type) || $ax.public.fn.IsImageBox(dObj.type) || isDynamicPanel || $ax.public.fn.IsLayer(dObj.type)) {
if(dObj.disabled) $axElement.enabled(false);
// Initialize selected elements
if(dObj.selected) $axElement.selected(true);
}
} else if(refreshType == $ax.repeater.refreshType.preEval) {
// Otherwise everything should be set up correctly by pre-eval, want to set up selected disabled dictionaries (and disabled status)
// Disabled layer/dynamic panel don't have the disabled class, but they do have the disabled attr written out, so use that in that case
if ($element.hasClass('disabled') ||
(($ax.IsLayer(dObj.type) || $ax.IsDynamicPanel(dObj.type)) && $element.attr('disabled'))) $axElement.enabled(false);
if($element.hasClass('selected')) $axElement.selected(true);
} else {
// Persist means we want to leave it as is, but we want to make sure we use selected based off of the backing data, and not some class that exists because of the reset
$element.removeClass('selected');
}
if(OS_MAC && WEBKIT) {