viewer.js 2.8 KB

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