startPost.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. // 8.0.0.3372. Generated 2/5/2018 11:05:16 PM UTC
  2. //***** sitemap.js *****//
  3. var currentNodeUrl = '';
  4. var allNodeUrls = [];
  5. function openNextPage() {
  6. var index = allNodeUrls.indexOf(currentNodeUrl) + 1;
  7. if(index >= allNodeUrls.length) return;
  8. var nextNodeUrl = allNodeUrls[index];
  9. $('.sitemapPageLink[nodeUrl="' + nextNodeUrl + '"]').click();
  10. }
  11. function openPreviousPage() {
  12. var index = allNodeUrls.indexOf(currentNodeUrl) - 1;
  13. if(index < 0) return;
  14. var nextNodeUrl = allNodeUrls[index];
  15. $('.sitemapPageLink[nodeUrl="' + nextNodeUrl + '"]').click();
  16. }
  17. // use this to isolate the scope
  18. (function() {
  19. var SHOW_HIDE_ANIMATION_DURATION = 0;
  20. var HIGHLIGHT_INTERACTIVE_VAR_NAME = 'hi';
  21. var currentPageLoc = '';
  22. var currentPlayerLoc = '';
  23. var currentPageHashString = '';
  24. $(window.document).ready(function() {
  25. $axure.player.createPluginHost({
  26. id: 'sitemapHost',
  27. context: 'interface',
  28. title: 'PAGES',
  29. gid: 1
  30. });
  31. generateSitemap();
  32. $('.sitemapPlusMinusLink').toggle(collapse_click, expand_click);
  33. $('.sitemapPageLink').click(node_click);
  34. $('#sitemapLinksContainer').hide();
  35. $('#linksButton').click(links_click);
  36. $('#adaptiveButton').click(adaptive_click);
  37. $('#adaptiveViewsContainer').hide();
  38. $('#highlightInteractiveButton').click(highlight_interactive);
  39. $('#searchButton').click(search_click);
  40. $('#searchBox').keyup(search_input_keyup);
  41. $('.sitemapLinkField').click(function() { this.select(); });
  42. $('input[value="withoutmap"]').click(withoutSitemapRadio_click);
  43. $('input[value="withmap"]').click(withSitemapRadio_click);
  44. $('#minimizeBox, #collapseBox, #footnotesBox, #highlightBox').change(sitemapUrlOptions_change);
  45. $('#viewSelect').change(sitemapUrlViewSelect_change);
  46. $(document).on('ContainerHeightChange', function() {
  47. updateContainerHeight();
  48. });
  49. // bind to the page load
  50. $axure.page.bind('load.sitemap', function() {
  51. currentPageLoc = $axure.page.location.split("#")[0];
  52. var decodedPageLoc = decodeURI(currentPageLoc);
  53. currentNodeUrl = decodedPageLoc.substr(decodedPageLoc.lastIndexOf('/') ? decodedPageLoc.lastIndexOf('/') + 1 : 0);
  54. currentPlayerLoc = $(location).attr('href').split("#")[0].split("?")[0];
  55. currentPageHashString = '#p=' + currentNodeUrl.substr(0, currentNodeUrl.lastIndexOf('.'));
  56. setVarInCurrentUrlHash('p', currentNodeUrl.substring(0, currentNodeUrl.lastIndexOf('.html')));
  57. $('.sitemapPageLink').parent().parent().removeClass('sitemapHighlight');
  58. $('.sitemapPageLink[nodeUrl="' + currentNodeUrl + '"]').parent().parent().addClass('sitemapHighlight');
  59. var pageName = $axure.page.pageName;
  60. $('.pageNameHeader').html(pageName);
  61. $('#sitemapLinksPageName').html($('.sitemapHighlight > .sitemapPageLinkContainer > .sitemapPageLink > .sitemapPageName').html());
  62. //Click the "Without sitemap" radio button so that it's selected by default
  63. $('input[value="withoutmap"]').click();
  64. //If highlight var is present and set to 1 or else if
  65. //sitemap highlight button is selected then highlight interactive elements
  66. var hiVal = getHashStringVar(HIGHLIGHT_INTERACTIVE_VAR_NAME);
  67. if(hiVal.length > 0 && hiVal == 1) {
  68. $('#highlightInteractiveButton').addClass('sitemapToolbarButtonSelected');
  69. $axure.messageCenter.postMessage('highlightInteractive', true);
  70. } else if($('#highlightInteractiveButton').is('.sitemapToolbarButtonSelected')) {
  71. $axure.messageCenter.postMessage('highlightInteractive', true);
  72. }
  73. //Set the current view if it is defined in the hash string
  74. //If the view is invalid, set it to 'auto' in the string
  75. //ELSE set the view based on the currently selected view in the toolbar menu
  76. var viewStr = getHashStringVar(ADAPTIVE_VIEW_VAR_NAME);
  77. if(viewStr.length > 0) {
  78. var $view = $('.adaptiveViewOption[val="' + viewStr + '"]');
  79. if($view.length > 0) $view.click();
  80. else $('.adaptiveViewOption[val="auto"]').click();
  81. } else if($('.checkedAdaptive').length > 0) {
  82. var $viewOption = $('.checkedAdaptive').parents('.adaptiveViewOption');
  83. if($viewOption.attr('val') != 'auto') $viewOption.click();
  84. }
  85. $axure.messageCenter.postMessage('finishInit');
  86. return false;
  87. });
  88. var $adaptiveViewsContainer = $('#adaptiveViewsContainer');
  89. var $viewSelect = $('#viewSelect');
  90. //Fill out adaptive view container with prototype's defined adaptive views, as well as the default, and Auto
  91. $adaptiveViewsContainer.append('<div class="adaptiveViewOption" val="auto"><div class="adaptiveCheckboxDiv checkedAdaptive"></div>Auto</div>');
  92. $viewSelect.append('<option value="auto">Auto</option>');
  93. if(typeof $axure.document.defaultAdaptiveView.name != 'undefined') {
  94. //If the name is a blank string, make the view name the width if non-zero, else 'any'
  95. var defaultViewName = $axure.document.defaultAdaptiveView.name;
  96. $adaptiveViewsContainer.append('<div class="adaptiveViewOption currentAdaptiveView" val="default"><div class="adaptiveCheckboxDiv"></div>' + defaultViewName + '</div>');
  97. $viewSelect.append('<option value="default">' + defaultViewName + '</option>');
  98. }
  99. var enabledViewIds = $axure.document.configuration.enabledViewIds;
  100. for(var viewIndex = 0; viewIndex < $axure.document.adaptiveViews.length; viewIndex++) {
  101. var currView = $axure.document.adaptiveViews[viewIndex];
  102. if(enabledViewIds.indexOf(currView.id) < 0) continue;
  103. var widthString = currView.size.width == 0 ? 'any' : currView.size.width;
  104. var heightString = currView.size.height == 0 ? 'any' : currView.size.height;
  105. var conditionString = '';
  106. if(currView.condition == '>' || currView.condition == '>=') {
  107. conditionString = ' and above';
  108. } else if(currView.condition == '<' || currView.condition == '<=') {
  109. conditionString = ' and below';
  110. }
  111. var viewString = currView.name + ' (' + widthString + ' x ' + heightString + conditionString + ')';
  112. $adaptiveViewsContainer.append('<div class="adaptiveViewOption" val="' + currView.id + '"><div class="adaptiveCheckboxDiv"></div>' + viewString + '</div>');
  113. $viewSelect.append('<option value="' + currView.id + '">' + viewString + '</option>');
  114. }
  115. $('.adaptiveViewOption').click(adaptiveViewOption_click);
  116. $('.adaptiveViewOption').mouseup(function(event) {
  117. event.stopPropagation();
  118. });
  119. $('#searchBox').focusin(function() {
  120. if($(this).is('.searchBoxHint')) {
  121. $(this).val('');
  122. $(this).removeClass('searchBoxHint');
  123. }
  124. }).focusout(function() {
  125. if($(this).val() == '') {
  126. $(this).addClass('searchBoxHint');
  127. $(this).val('Search');
  128. }
  129. });
  130. $('#searchBox').focusout();
  131. });
  132. function updateContainerHeight() {
  133. $('#sitemapTreeContainer').height($('#sitemapHost').height() - $('#sitemapHeader').outerHeight());
  134. }
  135. function hideAllContainersExcept(exceptContainer) {
  136. //1 - adaptive container, 3 - links container
  137. if(exceptContainer != 1) {
  138. $('#adaptiveViewsContainer').hide();
  139. $('#adaptiveButton').removeClass('sitemapToolbarButtonSelected');
  140. }
  141. if(exceptContainer != 3) {
  142. $('#sitemapLinksContainer').hide();
  143. $('#linksButton').removeClass('sitemapToolbarButtonSelected');
  144. }
  145. }
  146. function collapse_click(event) {
  147. $(this)
  148. .children('.sitemapMinus').removeClass('sitemapMinus').addClass('sitemapPlus').end()
  149. .closest('li').children('ul').hide(SHOW_HIDE_ANIMATION_DURATION);
  150. }
  151. function expand_click(event) {
  152. $(this)
  153. .children('.sitemapPlus').removeClass('sitemapPlus').addClass('sitemapMinus').end()
  154. .closest('li').children('ul').show(SHOW_HIDE_ANIMATION_DURATION);
  155. }
  156. function node_click(event) {
  157. $axure.page.navigate(this.getAttribute('nodeUrl'), true);
  158. }
  159. function links_click(event) {
  160. hideAllContainersExcept(3);
  161. $('#sitemapLinksContainer').toggle();
  162. updateContainerHeight();
  163. if($('#sitemapLinksContainer').is(":visible")) {
  164. $('#linksButton').addClass('sitemapToolbarButtonSelected');
  165. } else {
  166. $('#linksButton').removeClass('sitemapToolbarButtonSelected');
  167. }
  168. }
  169. $axure.messageCenter.addMessageListener(function(message, data) {
  170. if(message == 'adaptiveViewChange') {
  171. $('.adaptiveViewOption').removeClass('currentAdaptiveView');
  172. if(data.viewId) {$('div[val="' + data.viewId + '"]').addClass('currentAdaptiveView');}
  173. else $('div[val="default"]').addClass('currentAdaptiveView');
  174. //when we set adaptive view through user event, we want to update the checkmark on sitemap
  175. if(data.forceSwitchTo) {
  176. $('.checkedAdaptive').removeClass('checkedAdaptive');
  177. $('div[val="' + data.forceSwitchTo + '"]').find('.adaptiveCheckboxDiv').addClass('checkedAdaptive');
  178. }
  179. }
  180. });
  181. $(document).on('pluginShown', function (event, data) {
  182. if(data == 1) {
  183. hideAllContainersExcept(1);
  184. updateContainerHeight();
  185. }
  186. });
  187. $(document).on('sidebarExpanded', function (event, data) {
  188. hideAllContainersExcept(1);
  189. updateContainerHeight();
  190. });
  191. function highlight_interactive(event) {
  192. if($('#highlightInteractiveButton').is('.sitemapToolbarButtonSelected')) {
  193. $('#highlightInteractiveButton').removeClass('sitemapToolbarButtonSelected');
  194. $axure.messageCenter.postMessage('highlightInteractive', false);
  195. //Delete 'hi' hash string var if it exists since default is unselected
  196. deleteVarFromCurrentUrlHash(HIGHLIGHT_INTERACTIVE_VAR_NAME);
  197. } else {
  198. $('#highlightInteractiveButton').addClass('sitemapToolbarButtonSelected');
  199. $axure.messageCenter.postMessage('highlightInteractive', true);
  200. //Add 'hi' hash string var so that stay highlighted across reloads
  201. setVarInCurrentUrlHash(HIGHLIGHT_INTERACTIVE_VAR_NAME, 1);
  202. }
  203. }
  204. function adaptive_click(event) {
  205. hideAllContainersExcept(1);
  206. $('#adaptiveViewsContainer').toggle();
  207. updateContainerHeight();
  208. if(!$('#adaptiveViewsContainer').is(":visible")) {
  209. $('#adaptiveButton').removeClass('sitemapToolbarButtonSelected');
  210. } else {
  211. $('#adaptiveButton').addClass('sitemapToolbarButtonSelected');
  212. }
  213. }
  214. function adaptiveViewOption_click(event) {
  215. var currVal = $(this).attr('val');
  216. $('.checkedAdaptive').removeClass('checkedAdaptive');
  217. $(this).find('.adaptiveCheckboxDiv').addClass('checkedAdaptive');
  218. currentPageLoc = $axure.page.location.split("#")[0];
  219. var decodedPageLoc = decodeURI(currentPageLoc);
  220. var nodeUrl = decodedPageLoc.substr(decodedPageLoc.lastIndexOf('/') ? decodedPageLoc.lastIndexOf('/') + 1 : 0);
  221. var adaptiveData = {
  222. src: nodeUrl
  223. };
  224. adaptiveData.view = currVal;
  225. $axure.messageCenter.postMessage('switchAdaptiveView', adaptiveData);
  226. if(currVal == 'auto') {
  227. //Remove view in hash string if one is set
  228. deleteVarFromCurrentUrlHash(ADAPTIVE_VIEW_VAR_NAME);
  229. } else {
  230. //Set current view in hash string so that it can be maintained across reloads
  231. setVarInCurrentUrlHash(ADAPTIVE_VIEW_VAR_NAME, currVal);
  232. }
  233. }
  234. function search_click(event) {
  235. $('#searchDiv').toggle();
  236. if(!$('#searchDiv').is(":visible")) {
  237. $('#searchButton').removeClass('sitemapToolbarButtonSelected');
  238. $('#searchBox').val('');
  239. $('#searchBox').keyup();
  240. //$('#sitemapToolbar').css('height', '22px');
  241. $('#sitemapTreeContainer').css('top', '31px');
  242. } else {
  243. $('#searchButton').addClass('sitemapToolbarButtonSelected');
  244. $('#searchBox').focus();
  245. //$('#sitemapToolbar').css('height', '50px');
  246. $('#sitemapTreeContainer').css('top', '63px');
  247. }
  248. }
  249. function search_input_keyup(event) {
  250. var searchVal = $(this).val().toLowerCase();
  251. //If empty search field, show all nodes, else grey+hide all nodes and
  252. //ungrey+unhide all matching nodes, as well as unhide their parent nodes
  253. if(searchVal == '') {
  254. $('.sitemapPageName').removeClass('sitemapGreyedName');
  255. $('.sitemapNode').show();
  256. } else {
  257. $('.sitemapNode').hide();
  258. $('.sitemapPageName').addClass('sitemapGreyedName').each(function() {
  259. var nodeName = $(this).text().toLowerCase();
  260. if(nodeName.indexOf(searchVal) != -1) {
  261. $(this).removeClass('sitemapGreyedName').parents('.sitemapNode:first').show().parents('.sitemapExpandableNode').show();
  262. }
  263. });
  264. }
  265. }
  266. function withoutSitemapRadio_click() {
  267. $('#sitemapLinkWithPlayer').val(currentPageLoc);
  268. $('#sitemapOptionsDiv').hide();
  269. $('#minimizeBox').attr('disabled', 'disabled');
  270. $('#collapseBox').attr('disabled', 'disabled');
  271. $('#footnotesBox').attr('disabled', 'disabled');
  272. $('#highlightBox').attr('disabled', 'disabled');
  273. $('#viewSelect').attr('disabled', 'disabled');
  274. $('input[value="withmap"]').parent().removeClass('sitemapRadioSelected');
  275. updateContainerHeight();
  276. }
  277. function withSitemapRadio_click() {
  278. $('#sitemapLinkWithPlayer').val(currentPlayerLoc + currentPageHashString);
  279. $('#minimizeBox').removeAttr('disabled').change();
  280. $('#collapseBox').removeAttr('disabled').change();
  281. $('#footnotesBox').removeAttr('disabled').change();
  282. $('#highlightBox').removeAttr('disabled').change();
  283. $('#viewSelect').removeAttr('disabled').change();
  284. $('#sitemapOptionsDiv').show();
  285. $('input[value="withmap"]').parent().addClass('sitemapRadioSelected');
  286. updateContainerHeight();
  287. }
  288. function sitemapUrlOptions_change() {
  289. var currLinkHash = '#' + $('#sitemapLinkWithPlayer').val().split("#")[1];
  290. var newHash = null;
  291. var varName = '';
  292. var defVal = 1;
  293. if($(this).is('#minimizeBox')) {
  294. varName = SITEMAP_COLLAPSE_VAR_NAME;
  295. } else if($(this).is('#collapseBox')) {
  296. varName = PLUGIN_VAR_NAME;
  297. defVal = 0;
  298. } else if($(this).is('#footnotesBox')) {
  299. varName = FOOTNOTES_VAR_NAME;
  300. defVal = 0;
  301. } else if($(this).is('#highlightBox')) {
  302. varName = HIGHLIGHT_INTERACTIVE_VAR_NAME;
  303. }
  304. newHash = $(this).is(':checked') ? setHashStringVar(currLinkHash, varName, defVal) : deleteHashStringVar(currLinkHash, varName);
  305. if(newHash != null) {
  306. $('#sitemapLinkWithPlayer').val(currentPlayerLoc + newHash);
  307. }
  308. }
  309. function sitemapUrlViewSelect_change() {
  310. var currLinkHash = '#' + $('#sitemapLinkWithPlayer').val().split("#")[1];
  311. var newHash = null;
  312. var $selectedOption = $(this).find('option:selected');
  313. if($selectedOption.length == 0) return;
  314. var selectedVal = $selectedOption.attr('value');
  315. newHash = selectedVal == 'auto' ? deleteHashStringVar(currLinkHash, ADAPTIVE_VIEW_VAR_NAME) : setHashStringVar(currLinkHash, ADAPTIVE_VIEW_VAR_NAME, selectedVal);
  316. if(newHash != null) {
  317. $('#sitemapLinkWithPlayer').val(currentPlayerLoc + newHash);
  318. }
  319. }
  320. function generateSitemap() {
  321. var treeUl = "<div id='sitemapHeader'' class='sitemapHeader'>";
  322. treeUl += "<div id='sitemapToolbar' class='sitemapToolbar'>";
  323. treeUl += "<div class='pluginNameHeader'>PAGES</div>";
  324. treeUl += "<div class='pageNameHeader'></div>";
  325. treeUl += "<div class='pageButtonHeader'>";
  326. if($axure.document.configuration.enabledViewIds.length > 0) {
  327. treeUl += "<a id='adaptiveButton' title='Select Adaptive View' class='sitemapToolbarButton'></a>";
  328. }
  329. treeUl += "<a id='linksButton' title='Get Links' class='sitemapToolbarButton'></a>";
  330. treeUl += "<a id='highlightInteractiveButton' title='Highlight interactive elements' class='sitemapToolbarButton'></a>";
  331. treeUl += "</div>";
  332. treeUl += "</div>";
  333. if($axure.document.adaptiveViews.length > 0) {
  334. treeUl += "<div id='adaptiveViewsContainer'><div style='margin-bottom:10px;'>Adaptive Views</div></div>";
  335. }
  336. //linkcontainer
  337. treeUl += "<div id='sitemapLinksContainer' class='sitemapLinkContainer'>";
  338. treeUl += "<div style='margin-bottom:10px;'>Generate sharable URLs</div>";
  339. treeUl += "<input id='sitemapLinkWithPlayer' type='text' class='sitemapLinkField'/>";
  340. treeUl += "<div class='sitemapOptionContainer'>";
  341. treeUl += "<div><label><input type='radio' name='sitemapToggle' value='withoutmap'/>Without Sidebar</label></div>";
  342. treeUl += "<div style='margin-top:10px;'><label><input type='radio' name='sitemapToggle' value='withmap'/>With Sidebar</label>";
  343. treeUl += "<div id='sitemapOptionsDiv'>";
  344. treeUl += "<div class='sitemapUrlOption'><label><input type='checkbox' id='minimizeBox' />Minimize sidebar</label></div>";
  345. treeUl += "<div class='sitemapUrlOption'><label><input type='checkbox' id='collapseBox' />Pages closed</label></div>";
  346. if($axure.document.configuration.showAnnotations == true) {
  347. treeUl += "<div class='sitemapUrlOption'><label><input type='checkbox' id='footnotesBox' />Hide footnotes</label></div>";
  348. }
  349. treeUl += "<div class='sitemapUrlOption'><label><input type='checkbox' id='highlightBox' />Highlight interactive elements</label></div>";
  350. if($axure.document.configuration.enabledViewIds.length > 0) {
  351. treeUl += "<div id='viewSelectDiv' class='sitemapUrlOption'><label>View: <select id='viewSelect'></select></label></div>";
  352. }
  353. treeUl += "</div></div></div></div>";
  354. /////////////////
  355. treeUl += "</div>";
  356. treeUl += "<div id='sitemapTreeContainer'>";
  357. treeUl += '<div id="searchDiv" style=""><input id="searchBox" style="" type="text"/></div>';
  358. treeUl += "<ul class='sitemapTree' style='clear:both;'>";
  359. var rootNodes = $axure.document.sitemap.rootNodes;
  360. for(var i = 0; i < rootNodes.length; i++) {
  361. treeUl += generateNode(rootNodes[i], 0);
  362. }
  363. treeUl += "</ul></div>";
  364. $('#sitemapHost').html(treeUl);
  365. if($axure.document.adaptiveViews.length <= 0) {
  366. $('#sitemapHost .pageNameHeader').css('padding-right', '55px');
  367. }
  368. }
  369. function generateNode(node, level) {
  370. var hasChildren = (node.children && node.children.length > 0);
  371. var margin, returnVal;
  372. if(hasChildren) {
  373. margin = (9 + level * 17);
  374. returnVal = "<li class='sitemapNode sitemapExpandableNode'><div><div class='sitemapPageLinkContainer' style='margin-left:" + margin + "px'><a class='sitemapPlusMinusLink'><span class='sitemapMinus'></span></a>";
  375. } else {
  376. margin = (21 + level * 17);
  377. returnVal = "<li class='sitemapNode sitemapLeafNode'><div><div class='sitemapPageLinkContainer' style='margin-left:" + margin + "px'>";
  378. }
  379. var isFolder = node.type == "Folder";
  380. if(!isFolder) {
  381. returnVal += "<a class='sitemapPageLink' nodeUrl='" + node.url + "'>";
  382. allNodeUrls.push(node.url);
  383. }
  384. returnVal += "<span class='sitemapPageIcon";
  385. if(node.type == "Flow") { returnVal += " sitemapFlowIcon"; }
  386. if(isFolder) { returnVal += " sitemapFolderIcon"; }
  387. returnVal += "'></span><span class='sitemapPageName'>";
  388. returnVal += $('<div/>').text(node.pageName).html();
  389. returnVal += "</span>";
  390. if(!isFolder) returnVal += "</a>";
  391. returnVal += "</div></div>";
  392. if(hasChildren) {
  393. returnVal += "<ul>";
  394. for(var i = 0; i < node.children.length; i++) {
  395. var child = node.children[i];
  396. returnVal += generateNode(child, level + 1);
  397. }
  398. returnVal += "</ul>";
  399. }
  400. returnVal += "</li>";
  401. return returnVal;
  402. }
  403. })();
  404. //***** page_notes.js *****//
  405. // use this to isolate the scope
  406. (function () {
  407. if(!$axure.document.configuration.showPageNotes && !$axure.document.configuration.showAnnotationsSidebar) { return; }
  408. $(window.document).ready(function () {
  409. $axure.player.createPluginHost({
  410. id: 'pageNotesHost',
  411. context: 'interface',
  412. title: 'NOTES',
  413. gid: 2
  414. });
  415. generatePageNotes();
  416. $(document).on('ContainerHeightChange', function () {
  417. updateContainerHeight();
  418. });
  419. $('#footnotesButton').click(footnotes_click).addClass('sitemapToolbarButtonSelected');
  420. $('#notesNextButton').click(notesNext_click);
  421. $('#notesPreviousButton').click(notesPrevious_click);
  422. // bind to the page load
  423. $axure.page.bind('load.page_notes', function () {
  424. var hasNotes = false;
  425. $('#pageNotesContent').html("");
  426. if($axure.document.configuration.showPageNotes) {
  427. //populate the notes
  428. var notes = $axure.page.notes;
  429. if(notes) {
  430. var showNames = $axure.document.configuration.showPageNoteNames;
  431. for(var noteName in notes) {
  432. var pageNoteUi = "<div class='pageNoteContainer'>";
  433. if(showNames) {
  434. pageNoteUi += "<div class='pageNoteName'>" + noteName + "</div>";
  435. }
  436. pageNoteUi += "<div class='pageNote'>" + linkify(notes[noteName]) + "</div>";
  437. pageNoteUi += "</div>";
  438. pageNoteUi += "<div class='dottedDivider'></div>";
  439. $('#pageNotesContent').append(pageNoteUi);
  440. hasNotes = true;
  441. }
  442. }
  443. }
  444. if($axure.document.configuration.showAnnotationsSidebar) {
  445. var widgetNotes = $axure.page.widgetNotes;
  446. if(widgetNotes) {
  447. for(var i = 0; i < widgetNotes.length; i++) {
  448. var widgetNote = widgetNotes[i];
  449. var widgetNoteUi = "<div class='widgetNoteContainer' data-id='" + widgetNote["id"] + "'>";
  450. widgetNoteUi += "<div class='widgetNoteFootnote'></div>";
  451. widgetNoteUi += "<div class='widgetNoteLabel'>" + widgetNote["label"] + "</div>";
  452. for(var widgetNoteName in widgetNote) {
  453. if(widgetNoteName != "label" && widgetNoteName != "id") {
  454. widgetNoteUi += "<div class='pageNoteName'>" + widgetNoteName + "</div>";
  455. widgetNoteUi += "<div class='pageNote'>" + linkify(widgetNote[widgetNoteName]) + "</div>";
  456. widgetNoteUi += "<div class='nondottedDivider'></div>";
  457. }
  458. }
  459. widgetNoteUi += "</div>";
  460. widgetNoteUi += "<div class='nondottedDivider'></div>";
  461. $('#pageNotesContent').append(widgetNoteUi);
  462. hasNotes = true;
  463. }
  464. $('.widgetNoteContainer').children(':last-child').remove();
  465. $('.widgetNoteFootnote').append("<div class='annnoteline'></div><div class='annnoteline'></div><div class='annnoteline'></div>");
  466. $('.widgetNoteContainer').click(function () {
  467. var wasSelected = $(this).hasClass('widgetNoteContainerSelected');
  468. $('.widgetNoteContainerSelected').removeClass('widgetNoteContainerSelected');
  469. if(!wasSelected) $(this).addClass('widgetNoteContainerSelected');
  470. $axure.messageCenter.postMessage('toggleSelectWidgetNote', this.getAttribute('data-id'));
  471. });
  472. }
  473. }
  474. if(hasNotes) $('#pageNotesEmptyState').hide();
  475. else $('#pageNotesEmptyState').show();
  476. //If footnotes enabled for this prototype...
  477. if($axure.document.configuration.showAnnotations == true) {
  478. //If the fn var is defined and set to 0, hide footnotes
  479. //else if hide-footnotes button selected, hide them
  480. var fnVal = getHashStringVar(FOOTNOTES_VAR_NAME);
  481. if(fnVal.length > 0 && fnVal == 0) {
  482. $('#footnotesButton').removeClass('sitemapToolbarButtonSelected');
  483. $axure.messageCenter.postMessage('annotationToggle', false);
  484. } else if(!$('#footnotesButton').is('.sitemapToolbarButtonSelected')) {
  485. //If the footnotes button isn't selected, hide them on this loaded page
  486. $axure.messageCenter.postMessage('annotationToggle', false);
  487. }
  488. }
  489. return false;
  490. });
  491. function linkify(text) {
  492. var urlRegex = /(\b(((https?|ftp|file):\/\/)|(www\.))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  493. return text.replace(urlRegex, function(url, b, c) {
  494. var url2 = (c == 'www.') ? 'http://' + url : url;
  495. return '<a href="' + url2 + '" target="_blank" class="noteLink">' + url + '</a>';
  496. });
  497. }
  498. });
  499. function updateContainerHeight() {
  500. $('#pageNotesScrollContainer').height($('#pageNotesHost').height() - $('#pageNotesHeader').outerHeight());
  501. }
  502. $(document).on('sidebarCollapse', function (event, data) {
  503. clearSelection();
  504. });
  505. $(document).on('pluginShown', function (event, data) {
  506. if(data != 2) {
  507. clearSelection();
  508. }
  509. });
  510. function clearSelection() {
  511. $('.widgetNoteContainerSelected').removeClass('widgetNoteContainerSelected');
  512. $axure.messageCenter.postMessage('toggleSelectWidgetNote', '');
  513. }
  514. function footnotes_click(event) {
  515. if($('#footnotesButton').is('.sitemapToolbarButtonSelected')) {
  516. $('#footnotesButton').removeClass('sitemapToolbarButtonSelected');
  517. $axure.messageCenter.postMessage('annotationToggle', false);
  518. //Add 'fn' hash string var so that footnotes stay hidden across reloads
  519. setVarInCurrentUrlHash(FOOTNOTES_VAR_NAME, 0);
  520. } else {
  521. $('#footnotesButton').addClass('sitemapToolbarButtonSelected');
  522. $axure.messageCenter.postMessage('annotationToggle', true);
  523. //Delete 'fn' hash string var if it exists since default is visible
  524. deleteVarFromCurrentUrlHash(FOOTNOTES_VAR_NAME);
  525. }
  526. }
  527. function notesNext_click(event) {
  528. openNextPage();
  529. }
  530. function notesPrevious_click(event) {
  531. openPreviousPage();
  532. }
  533. function generatePageNotes() {
  534. var pageNotesUi = "<div id='pageNotesHeader'' class='sitemapHeader'>";
  535. pageNotesUi += "<div id='pageNotesToolbar' class='sitemapToolbar'>";
  536. pageNotesUi += "<div class='pluginNameHeader'>NOTES</div>";
  537. pageNotesUi += "<div class='pageNameHeader'></div>";
  538. pageNotesUi += "<div class='pageButtonHeader'>";
  539. pageNotesUi += "<a id='notesPreviousButton' title='Previous Page' class='sitemapToolbarButton prevPageButton'></a>";
  540. pageNotesUi += "<a id='notesNextButton' title='Next Page' class='sitemapToolbarButton nextPageButton'></a>";
  541. if($axure.document.configuration.showAnnotations == true) {
  542. pageNotesUi += "<a id='footnotesButton' title='Toggle Footnotes' class='sitemapToolbarButton'></a>";
  543. }
  544. pageNotesUi += "</div>";
  545. pageNotesUi += "</div>";
  546. pageNotesUi += "</div>";
  547. pageNotesUi += "<div id='pageNotesScrollContainer'>";
  548. pageNotesUi += "<div id='pageNotesContainer'>";
  549. pageNotesUi += "<div id='pageNotesEmptyState' class='emptyStateContainer'><div class='emptyStateTitle'>No notes for this page.</div><div class='emptyStateContent'>Notes added in Axure RP will appear here.</div><div class='dottedDivider'></div></div>";
  550. pageNotesUi += "<span id='pageNotesContent'></span>";
  551. pageNotesUi += "</div></div>";
  552. $('#pageNotesHost').html(pageNotesUi);
  553. updateContainerHeight();
  554. if(!$axure.document.configuration.showAnnotations) {
  555. $('#pageNotesHost .pageNameHeader').css('padding-right', '55px');
  556. }
  557. }
  558. })();
  559. //***** debug.js *****//
  560. // use this to isolate the scope
  561. (function () {
  562. if(!$axure.document.configuration.showConsole) { return; }
  563. $(document).ready(function () {
  564. $axure.player.createPluginHost({
  565. id: 'debugHost',
  566. context: 'interface',
  567. title: 'CONSOLE',
  568. gid: 3
  569. });
  570. generateDebug();
  571. $('#variablesClearLink').click(clearvars_click);
  572. $('#traceClearLink').click(cleartrace_click);
  573. $(document).on('ContainerHeightChange', function () {
  574. updateContainerHeight();
  575. });
  576. //$('#traceContainer').hide();
  577. //$('#debugTraceLink').click(function () {
  578. // $('#variablesContainer').hide();
  579. // $('#traceContainer').show();
  580. //});
  581. //$('#debugVariablesLink').click(function () {
  582. // $('#variablesContainer').show();
  583. // $('#traceContainer').hide();
  584. //});
  585. var currentStack= [];
  586. var finishedStack = [];
  587. $axure.messageCenter.addMessageListener(function (message, data) {
  588. if(message == 'axCompositeEventMessage') {
  589. for(var i = 0; i < data.length; i++) {
  590. processMessages(data[i].message, data[i].data);
  591. }
  592. } else processMessages(message, data);
  593. });
  594. var processMessages = function(message, data) {
  595. if(message == 'globalVariableValues') {
  596. $('#variablesDiv').empty();
  597. for(var key in data) {
  598. var value = data[key] == '' ? '(blank)' : data[key];
  599. $('#variablesDiv').append('<div class="variableDiv"><span class="variableName">' + key + '</span><br/>' + value + '</div>');
  600. }
  601. } else if(message == 'axEvent') {
  602. var addToStack = "<div class='axEventBlock'>";
  603. addToStack += "<div class='axTime'>" + new Date().toLocaleTimeString() + "</div>";
  604. addToStack += "<div class='axLabel'>" + data.label + " (" + data.type + ")</div>";
  605. addToStack += "<div class='axEvent'>" + data.event.description + "</div>";
  606. currentStack.push(addToStack);
  607. } else if (message == 'axEventComplete') {
  608. currentStack[currentStack.length - 1] += "</div>";
  609. finishedStack.push(currentStack.pop());
  610. if(currentStack.length == 0) {
  611. $('#traceClearLinkContainer').show();
  612. $('#traceEmptyState').hide();
  613. $('.lastAxEvent').removeClass('lastAxEvent');
  614. for(var i = finishedStack.length - 1; i >= 0; i--) {
  615. if($('#traceDiv').children().length > 99) $('#traceDiv').children().last().remove();
  616. $('#traceDiv').prepend(finishedStack[i]);
  617. if(i == finishedStack.length - 1) $('#traceDiv').children().first().addClass('lastAxEvent');
  618. }
  619. finishedStack = [];
  620. }
  621. } else if (message == 'axCase') {
  622. currentStack[currentStack.length - 1] += "<div class='axCase'>" + data.description + "</div>";
  623. } else if (message == 'axAction') {
  624. currentStack[currentStack.length - 1] += "<div class='axAction'>" + data.description + "</div>";
  625. }
  626. }
  627. // bind to the page load
  628. $axure.page.bind('load.debug', function () {
  629. $axure.messageCenter.postMessage('getGlobalVariables', '');
  630. return false;
  631. });
  632. function clearvars_click(event) {
  633. $axure.messageCenter.postMessage('resetGlobalVariables', '');
  634. }
  635. function cleartrace_click(event) {
  636. $('#traceDiv').html('');
  637. $('#traceClearLinkContainer').hide();
  638. $('#traceEmptyState').show();
  639. }
  640. });
  641. function updateContainerHeight() {
  642. $('#debugScrollContainer').height($('#debugHost').height() - $('#debugHeader').outerHeight());
  643. }
  644. function generateDebug() {
  645. var pageNotesUi = "<div id='debugHeader'' class='sitemapHeader'>";
  646. pageNotesUi += "<div id='debugToolbar' class='sitemapToolbar'>";
  647. pageNotesUi += "<div class='pluginNameHeader'>CONSOLE</div>";
  648. pageNotesUi += "<div class='pageNameHeader'></div>";
  649. //pageNotesUi += "<div class='pageButtonHeader'>";
  650. //pageNotesUi += "<a id='previousPageButton' title='Previous Page' class='sitemapToolbarButton'></a>";
  651. //pageNotesUi += "<a id='nextPageButton' title='Next Page' class='sitemapToolbarButton'></a>";
  652. //pageNotesUi += "<a id='variablesClearLink' title='Reset Variables' class='sitemapToolbarButton'></a>";
  653. //pageNotesUi += "</div>";
  654. pageNotesUi += "</div>";
  655. pageNotesUi += "</div>";
  656. //var pageNotesUi = "<div id='debugToolbar'><a id='debugVariablesLink' class='debugToolbarButton'>Variables</a> | <a id='debugTraceLink' class='debugToolbarButton'>Trace</a></div>";
  657. pageNotesUi += "<div id='debugScrollContainer'>";
  658. pageNotesUi += "<div id='debugContainer'>";
  659. pageNotesUi += "<div id='variablesContainer'>";
  660. pageNotesUi += "<div id='variablesClearLinkContainer' class='debugLinksContainer'><a id='variablesClearLink' title='Reset Variables'>Reset Variables</a></div>";
  661. pageNotesUi += "<div id='variablesDiv'></div></div>";
  662. pageNotesUi += "<div class='dottedDivider'></div>";
  663. pageNotesUi += "<div id='traceContainer'>";
  664. pageNotesUi += "<div id='traceClearLinkContainer' class='debugLinksContainer'><a id='traceClearLink' title='Clear Trace'>Clear Trace</a></div>";
  665. pageNotesUi += "<div id='traceEmptyState' class='emptyStateContainer'><div class='emptyStateTitle'>No interactions in the trace.</div><div class='emptyStateContent'>Triggered interactions will appear here.</div><div class='dottedDivider'></div></div>";
  666. pageNotesUi += "<div id='traceDiv'></div></div>";
  667. pageNotesUi += "</div></div>";
  668. $('#debugHost').html(pageNotesUi);
  669. updateContainerHeight();
  670. $('#traceClearLinkContainer').hide();
  671. $('#traceEmptyState').show();
  672. }
  673. })();