viewer.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // ******* SITEMAP TOOLBAR VIEWER ACTIONS ******** //
  2. $axure.internal(function ($ax) {
  3. var userTriggeredEventNames = ['onClick', 'onDoubleClick', 'onMouseOver', 'onMouseMove', 'onMouseOut', 'onMouseDown', 'onMouseUp',
  4. 'onKeyDown', 'onKeyUp', 'onFocus', 'onLostFocus', 'onTextChange', 'onSelectionChange', 'onSelectedChange', 'onSelect', 'onUnselect',
  5. 'onSwipeLeft', 'onSwipeRight', 'onSwipeUp', 'onSwipeDown', 'onDragStart', 'onDrag', 'onDragDrop', 'onScroll', 'onContextMenu', 'onMouseHover', 'onLongClick'];
  6. $ax.messageCenter.addMessageListener(function(message, data) {
  7. //If annotation toggle message received from sitemap, toggle footnotes
  8. if(message == 'annotationToggle') {
  9. if(data == true) {
  10. $('div.annotation').show();
  11. $('div.annnotelabel').show();
  12. $('div.annnoteimage').show();
  13. } else {
  14. $('div.annotation').hide();
  15. $('div.annnotelabel').hide();
  16. $('div.annnoteimage').hide();
  17. }
  18. }
  19. });
  20. var lastSelectedWidgetNote;
  21. $ax.messageCenter.addMessageListener(function (message, data) {
  22. //If annotation toggle message received from sitemap, toggle footnotes
  23. if(message == 'toggleSelectWidgetNote') {
  24. if(lastSelectedWidgetNote == data) {
  25. $('#' + lastSelectedWidgetNote).removeClass('widgetNoteSelected');
  26. lastSelectedWidgetNote = null;
  27. return;
  28. }
  29. if(lastSelectedWidgetNote) $('#' + lastSelectedWidgetNote).removeClass('widgetNoteSelected');
  30. $('#' + data).addClass('widgetNoteSelected');
  31. lastSelectedWidgetNote = data;
  32. }
  33. });
  34. var highlightEnabled = false;
  35. $ax.messageCenter.addMessageListener(function(message, data) {
  36. if(message == 'highlightInteractive') {
  37. highlightEnabled = data == true;
  38. _applyHighlight($ax('*'));
  39. }
  40. });
  41. var _applyHighlight = $ax.applyHighlight = function(query, ignoreUnset) {
  42. if(ignoreUnset && !highlightEnabled) return;
  43. //Do condition to check if legacy browser (all IE, except 10) and select appropriate pulsate css class name
  44. var userAgentString = navigator.userAgent.toLowerCase();
  45. var isIEpre10 = userAgentString.indexOf('msie 9.') != -1 ||
  46. userAgentString.indexOf('msie 8.') != -1 ||
  47. userAgentString.indexOf('msie 7.') != -1 ||
  48. userAgentString.indexOf('msie 6.') != -1;
  49. var pulsateClassName = 'legacyPulsateBorder';
  50. //Find all widgets with a defined userTriggeredEventName specified in the array above
  51. var $matchingElements = query.filter(function(obj) {
  52. if(obj.interactionMap) {
  53. for(var index in userTriggeredEventNames) {
  54. if(obj.interactionMap[userTriggeredEventNames[index]]) return true;
  55. }
  56. } else if ($ax.public.fn.IsVector(obj.type) && obj.referencePageUrl) {
  57. return true;
  58. }
  59. return false;
  60. }).$();
  61. var isHighlighted = $matchingElements.is('.' + pulsateClassName);
  62. //Toggle the pulsate class on the matched elements
  63. if(highlightEnabled && !isHighlighted) {
  64. $matchingElements.addClass(pulsateClassName);
  65. } else if(!highlightEnabled && isHighlighted) {
  66. $matchingElements.removeClass(pulsateClassName);
  67. }
  68. };
  69. });