hintmanager.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. (function () {
  2. if (window.location.protocol === 'file:' || $axure.player.isCloud) return;
  3. var inited = false;
  4. $axure.messageCenter.addMessageListener(function (message) {
  5. if (message == "finishInit") {
  6. setTimeout(() => {
  7. if (!inited) processFromQueue(0);
  8. inited = true;
  9. }, 1000); // give 1 sec to load all prototype data
  10. }
  11. });
  12. var queue = [processPagesHint, processNotesHint, processConsoleHint];
  13. function processFromQueue(index) {
  14. if (index < queue.length) queue[index](index);
  15. }
  16. function processPagesHint(currentIndex) {
  17. if ($axure.document.sitemap.rootNodes.length > 1 && !$axure.document.configuration.isAxshare) {
  18. $.get('shouldShowSitemapHint', function (shouldShow) {
  19. if (shouldShow) {
  20. var pagesHint = $("<div class='pluginHint left'><span>Click to expand the sitemap and view your project pages.</span></div>");
  21. pagesHint.click(e => e.stopPropagation());
  22. var gotItBtn = $("<button class='ax-button'>Got It</button>");
  23. pagesHint.append(gotItBtn);
  24. $("#sitemapHostBtn").append(pagesHint);
  25. var sitemapControlFrameContainer = $("#sitemapControlFrameContainer");
  26. sitemapControlFrameContainer.click(gotIt);
  27. gotItBtn.click(gotIt);
  28. function gotIt(e) {
  29. e.stopPropagation();
  30. $.get('sitemapHintAccepted');
  31. pagesHint.remove();
  32. sitemapControlFrameContainer.off("click", gotIt);
  33. processFromQueue(currentIndex + 1);
  34. }
  35. }
  36. }).fail(function () {
  37. processFromQueue(currentIndex + 1);
  38. });
  39. } else {
  40. processFromQueue(currentIndex + 1);
  41. }
  42. }
  43. function processNotesHint(currentIndex) {
  44. var hasNotes = $axure.document.configuration.showPageNotes && (($axure.page.notes && !$.isEmptyObject($axure.page.notes)) || ($axure.page.masterNotes && $axure.page.masterNotes.length > 0) || ($axure.page.widgetNotes && $axure.page.widgetNotes.length > 0));
  45. if (hasNotes && !$axure.document.configuration.isAxshare) {
  46. $.get('shouldShowPageNoteHint', function (shouldShow) {
  47. if (shouldShow) {
  48. var notesHint = $("<div class='pluginHint'><span>Click to view the Page and Widget Notes on this page.</span></div>");
  49. notesHint.click(e => e.stopPropagation());
  50. var gotItBtn = $("<button class='ax-button'>Got It</button>");
  51. notesHint.append(gotItBtn);
  52. var pluginBtn = $("#pageNotesHostBtn").append(notesHint);
  53. pluginBtn.click(gotIt);
  54. gotItBtn.click(gotIt);
  55. function gotIt(e) {
  56. e.stopPropagation();
  57. $.get('pageNoteHintAccepted');
  58. notesHint.remove();
  59. pluginBtn.off("click", gotIt);
  60. processFromQueue(currentIndex + 1);
  61. }
  62. }
  63. }).fail(function () {
  64. processFromQueue(currentIndex + 1);
  65. });
  66. } else {
  67. processFromQueue(currentIndex + 1);
  68. }
  69. }
  70. function processConsoleHint() {
  71. if (!$axure.document.configuration.showConsole || $axure.document.configuration.isAxshare) return;
  72. $.get('shouldShowConsoleHint', function (shouldShow) {
  73. if (shouldShow) {
  74. var consoleHint = $("<div class='pluginHint right'><span><b>Reminder:</b> Use the console to see when events and actions are performed.</span></div>");
  75. var btn = $("#debugHostBtn").append(consoleHint);
  76. var delay = 4000;
  77. function runTimeout() {
  78. return setTimeout(() => {
  79. consoleHint.remove();
  80. }, delay);
  81. }
  82. var timeoutId = runTimeout();
  83. btn.mouseenter(() => { clearTimeout(timeoutId); });
  84. btn.mouseleave(() => { timeoutId = runTimeout(); });
  85. btn.click(() => {
  86. clearTimeout(timeoutId);
  87. consoleHint.remove();
  88. });
  89. }
  90. });
  91. }
  92. })();