sitemap.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. var currentNodeUrl = '';
  2. var allNodeUrls = [];
  3. var openNextPage = $axure.player.openNextPage = function () {
  4. var index = allNodeUrls.indexOf(currentNodeUrl) + 1;
  5. if(index >= allNodeUrls.length) return;
  6. var nextNodeUrl = allNodeUrls[index];
  7. currentNodeUrl = nextNodeUrl;
  8. $('.sitemapPageLink[nodeUrl="' + nextNodeUrl + '"]').parent().mousedown();
  9. };
  10. var openPreviousPage = $axure.player.openPreviousPage = function () {
  11. var index = allNodeUrls.indexOf(currentNodeUrl) - 1;
  12. if(index < 0) return;
  13. var nextNodeUrl = allNodeUrls[index];
  14. currentNodeUrl = nextNodeUrl;
  15. $('.sitemapPageLink[nodeUrl="' + nextNodeUrl + '"]').parent().mousedown();
  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: 'project',
  28. title: 'Project Pages',
  29. gid: 1,
  30. });
  31. $(window.document).bind('keyup', function (e) {
  32. if (e.target.localName == "textarea" || e.target.localName == "input") return;
  33. switch(e.which) {
  34. case 188:
  35. openPreviousPage();
  36. break;
  37. case 190:
  38. openNextPage();
  39. break;
  40. default: return; // exit this handler for other keys
  41. }
  42. });
  43. generateSitemap();
  44. $('.leftArrow').click(openPreviousPage);
  45. $('.rightArrow').click(openNextPage);
  46. $('.sitemapPlusMinusLink').click(collapse_click);
  47. $('.sitemapPageLink').parent().mousedown(node_click);
  48. $('#interfaceAdaptiveViewsListContainer').hide();
  49. $('#projectOptionsShowHotspots').click(showHotspots_click);
  50. $('#searchIcon').click(searchBoxClose_click);
  51. $('#searchDiv').click(searchBoxExpand_click);
  52. $('#searchBox').keyup(search_input_keyup);
  53. // bind to the page load
  54. $axure.page.bind('load.sitemap', function() {
  55. currentPageLoc = $axure.page.location.split("#")[0];
  56. var decodedPageLoc = decodeURI(currentPageLoc);
  57. currentNodeUrl = decodedPageLoc.substr(decodedPageLoc.lastIndexOf('/') ? decodedPageLoc.lastIndexOf('/') + 1 : 0);
  58. currentPlayerLoc = $(location).attr('href').split("#")[0].split("?")[0];
  59. currentPageHashString = '#p=' + currentNodeUrl.substr(0, currentNodeUrl.lastIndexOf('.'));
  60. $axure.player.setVarInCurrentUrlHash(PAGE_ID_NAME, $axure.player.getPageIdByUrl(currentNodeUrl));
  61. $axure.player.setVarInCurrentUrlHash(PAGE_URL_NAME, currentNodeUrl.substring(0, currentNodeUrl.lastIndexOf('.html')));
  62. $('#sitemapTreeContainer').find('.sitemapHighlight').removeClass('sitemapHighlight');
  63. $('.sitemapPageLink[nodeUrl="' + currentNodeUrl + '"]').parent().parent().addClass('sitemapHighlight');
  64. var pageName = $axure.page.pageName;
  65. $('.pageNameHeader').html(pageName);
  66. //If highlight var is present and set to 1 or else if
  67. //sitemap highlight button is selected then highlight interactive elements
  68. var hiVal = $axure.player.getHashStringVar(HIGHLIGHT_INTERACTIVE_VAR_NAME);
  69. if(hiVal.length > 0 && hiVal == 1) {
  70. $('#showHotspotsOption').find('.overflowOptionCheckbox').addClass('selected');
  71. if ($('#projectOptionsHotspotsCheckbox').length > 0) $('#projectOptionsHotspotsCheckbox').addClass('selected');
  72. $axure.messageCenter.postMessage('highlightInteractive', true);
  73. } else if ($('#showHotspotsOption').find('.overflowOptionCheckbox').hasClass('selected')) {
  74. $axure.messageCenter.postMessage('highlightInteractive', true);
  75. }
  76. generateAdaptiveViews(false);
  77. if (MOBILE_DEVICE) generateAdaptiveViews(true);
  78. $axure.player.suspendRefreshViewPort = true;
  79. //Set the current view if it is defined in the hash string
  80. //If the view is invalid, set it to 'auto' in the string
  81. //ELSE set the view based on the currently selected view in the toolbar menu
  82. var viewStr = $axure.player.getHashStringVar(ADAPTIVE_VIEW_VAR_NAME);
  83. if(viewStr.length > 0) {
  84. var $view = $('.adaptiveViewOption[val="' + viewStr + '"]');
  85. if($view.length > 0) $view.click();
  86. else $('.adaptiveViewOption[val="auto"]').click();
  87. } else if($('.selectedRadioButton').length > 0) {
  88. var $viewOption = $('.selectedRadioButton').parents('.adaptiveViewOption');
  89. $viewOption.click();
  90. }
  91. updateAdaptiveViewHeader();
  92. function setDefaultScaleForDevice() {
  93. if(MOBILE_DEVICE && $axure.player.isMobileMode()) {
  94. $('.projectOptionsScaleRow[val="0"]').click();
  95. } else {
  96. $('.vpScaleOption[val="0"]').click();
  97. }
  98. }
  99. var scaleStr = $axure.player.getHashStringVar(SCALE_VAR_NAME);
  100. if(scaleStr.length > 0) {
  101. var $scale = $('.vpScaleOption[val="' + scaleStr + '"]');
  102. if($scale.length > 0) $scale.click();
  103. else setDefaultScaleForDevice();
  104. } else {
  105. setDefaultScaleForDevice();
  106. }
  107. var rotateStr = $axure.player.getHashStringVar(ROT_VAR_NAME);
  108. if(rotateStr.length > 0) {
  109. $('#vpRotate').prop('checked', true);
  110. }
  111. $axure.player.suspendRefreshViewPort = false;
  112. if (!$axure.player.isViewOverridden()) $axure.messageCenter.postMessage('setAdaptiveViewForSize', { 'width': $('#mainPanel').width(), 'height': $('#mainPanel').height() });
  113. $axure.player.refreshViewPort();
  114. $axure.messageCenter.postMessage('finishInit');
  115. showMainPanel();
  116. return false;
  117. });
  118. var $vpContainer = $('#interfaceScaleListContainer');
  119. var scaleOptions = '<div class="vpScaleOption" val="0"><div class="scaleRadioButton"><div class="selectedRadioButtonFill"></div></div>Default Scale</div>';
  120. scaleOptions += '<div class="vpScaleOption" val="1"><div class="scaleRadioButton"><div class="selectedRadioButtonFill"></div></div>Scale to Width</div>';
  121. scaleOptions += '<div class="vpScaleOption" val="2"><div class="scaleRadioButton"><div class="selectedRadioButtonFill"></div></div>Scale to Fit</div>';
  122. $(scaleOptions).appendTo($vpContainer);
  123. $('#overflowMenuContainer').append('<div id="showHotspotsOption" class="showOption" style="order: 1"><div class="overflowOptionCheckbox"></div>Show Hotspots</div>');
  124. $('#overflowMenuContainer').append($vpContainer);
  125. $vpContainer.show();
  126. $('#showHotspotsOption').click(showHotspots_click);
  127. $('.vpScaleOption').click(vpScaleOption_click);
  128. $('.vpScaleOption').mouseup(function (event) {
  129. event.stopPropagation();
  130. });
  131. if (MOBILE_DEVICE) {
  132. var scaleOptions = '<div class="projectOptionsScaleRow" val="1"><div class="scaleRadioButton"><div class="selectedRadioButtonFill"></div></div>Scale to fit width</div>';
  133. scaleOptions += '<div class="projectOptionsScaleRow" val="0"><div class="scaleRadioButton"><div class="selectedRadioButtonFill"></div></div>Original size (100%)</div>';
  134. scaleOptions += '<div class="projectOptionsScaleRow" val="2" style="border-bottom: solid 1px #c7c7c7"><div class="scaleRadioButton"><div class="selectedRadioButtonFill"></div></div>Fit all to screen</div>';
  135. $(scaleOptions).appendTo($('#projectOptionsScaleContainer'));
  136. $('.projectOptionsScaleRow').click(vpScaleOption_click);
  137. }
  138. $('#searchBox').focusin(function() {
  139. if($(this).is('.searchBoxHint')) {
  140. $(this).val('');
  141. $(this).removeClass('searchBoxHint');
  142. }
  143. }).focusout(function() {
  144. if($(this).val() == '') {
  145. $(this).addClass('searchBoxHint');
  146. }
  147. });
  148. $('#searchBox').focusout();
  149. });
  150. var _formatViewDimension = function(dim) {
  151. if(dim == 0) return 'any';
  152. if(dim.toString().includes('.')) return dim.toFixed(2);
  153. return dim;
  154. };
  155. function generateAdaptiveViews(forProjectOptions) {
  156. var $container = forProjectOptions ? $('#projectOptionsAdaptiveViewsContainer') : $('#interfaceAdaptiveViewsListContainer');
  157. var $viewSelect = forProjectOptions ? $('#projectOptionsViewSelect') : $('#viewSelect');
  158. var adaptiveViewOptionClass = forProjectOptions ? 'projectOptionsAdaptiveViewRow' : 'adaptiveViewOption';
  159. var currentViewClass = forProjectOptions ? '' : 'currentAdaptiveView';
  160. $container.empty();
  161. $viewSelect.empty();
  162. //Fill out adaptive view container with prototype's defined adaptive views, as well as the default, and Auto
  163. var viewsList = '<div class="' + adaptiveViewOptionClass + '" val="auto"><div class="adapViewRadioButton selectedRadioButton"><div class="selectedRadioButtonFill"></div></div>Adaptive</div>';
  164. var viewSelect = '<option value="auto">Adaptive</option>';
  165. if (typeof $axure.page.defaultAdaptiveView.name != 'undefined') {
  166. //If the name is a blank string, make the view name the width if non-zero, else 'any'
  167. var defaultView = $axure.page.defaultAdaptiveView;
  168. var defaultViewName = defaultView.name;
  169. var widthString = _formatViewDimension(defaultView.size.width);
  170. var heightString = _formatViewDimension(defaultView.size.height);
  171. var viewString = defaultViewName + ' (' + widthString + ' x ' + heightString + ')';
  172. viewsList += '<div class="' + adaptiveViewOptionClass + ' ' + currentViewClass + '" val="default"data-dim="' + defaultView.size.width + 'x' + defaultView.size.height + '">' +
  173. '<div class="adapViewRadioButton"><div class="selectedRadioButtonFill"></div></div>' + viewString + '</div>';
  174. viewSelect += '<option value="default">' + viewString + '</option>';
  175. }
  176. var useViews = $axure.document.configuration.useViews;
  177. var hasViews = false;
  178. if(useViews) {
  179. for(var viewIndex = 0; viewIndex < $axure.page.adaptiveViews.length; viewIndex++) {
  180. var currView = $axure.page.adaptiveViews[viewIndex];
  181. var widthString = _formatViewDimension(currView.size.width);
  182. var heightString = _formatViewDimension(currView.size.height);
  183. var viewString = currView.name + ' (' + widthString + ' x ' + heightString + ')';
  184. viewsList += '<div class="' + adaptiveViewOptionClass +
  185. ((forProjectOptions && (viewIndex == $axure.page.adaptiveViews.length - 1)) ? '" style="border-bottom: solid 1px #c7c7c7; margin-bottom: 15px;' : '') +
  186. '" val="' +
  187. currView.id +
  188. '" data-dim="' +
  189. currView.size.width +
  190. 'x' +
  191. currView.size.height +
  192. '"><div class="adapViewRadioButton"><div class="selectedRadioButtonFill"></div></div>' +
  193. viewString +
  194. '</div>';
  195. viewSelect += '<option value="' + currView.id + '">' + viewString + '</option>';
  196. hasViews = true;
  197. }
  198. }
  199. $container.append(viewsList);
  200. $viewSelect.append(viewSelect);
  201. if (!hasViews) {
  202. if (forProjectOptions) {
  203. $('#projectOptionsAdaptiveViewsHeader').hide();
  204. $('#projectOptionsAdaptiveViewsContainer').hide();
  205. } else $('#interfaceAdaptiveViewsContainer').hide();
  206. } else {
  207. if (forProjectOptions) {
  208. $('#projectOptionsAdaptiveViewsHeader').show();
  209. $('#projectOptionsAdaptiveViewsContainer').show();
  210. } else $('#interfaceAdaptiveViewsContainer').show();
  211. }
  212. $(('.' + adaptiveViewOptionClass)).click(adaptiveViewOption_click);
  213. if (!forProjectOptions) {
  214. $(('.' + adaptiveViewOptionClass)).mouseup(function (event) {
  215. event.stopPropagation();
  216. });
  217. }
  218. }
  219. function collapse_click(event) {
  220. if($(this).children('.sitemapPlus').length > 0) {
  221. expand_click($(this));
  222. } else {
  223. $(this)
  224. .children('.sitemapMinus').removeClass('sitemapMinus').addClass('sitemapPlus').end()
  225. .closest('li').children('ul').hide(SHOW_HIDE_ANIMATION_DURATION);
  226. }
  227. event.stopPropagation();
  228. }
  229. function expand_click($this) {
  230. $this
  231. .children('.sitemapPlus').removeClass('sitemapPlus').addClass('sitemapMinus').end()
  232. .closest('li').children('ul').show(SHOW_HIDE_ANIMATION_DURATION);
  233. }
  234. function searchBoxExpand_click(event) {
  235. if (!$('#searchIcon').hasClass('sitemapToolbarButtonSelected')) {
  236. $('#searchIcon').addClass('sitemapToolbarButtonSelected')
  237. $('#searchBox').width(0);
  238. $('#searchBox').show();
  239. $('#searchBox').animate({ width: '95%' }, { duration: 200, complete: function () { $('#searchBox').focus(); } });
  240. }
  241. }
  242. function searchBoxClose_click(event) {
  243. if ($('#searchIcon').hasClass('sitemapToolbarButtonSelected')) {
  244. $('#searchBox').animate({ width: '0%' }, { duration: 200,
  245. complete: function () {
  246. $('#searchBox').hide();
  247. $('#searchIcon').removeClass('sitemapToolbarButtonSelected')
  248. }});
  249. $('#searchBox').val('');
  250. $('#searchBox').keyup();
  251. }
  252. }
  253. function node_click(event) {
  254. hideMainPanel();
  255. $('#sitemapTreeContainer').find('.sitemapHighlight').removeClass('sitemapHighlight');
  256. $(this).parent().addClass('sitemapHighlight');
  257. $axure.page.navigate($(this).children('.sitemapPageLink')[0].getAttribute('nodeUrl'), true);
  258. }
  259. function hideMainPanel() {
  260. $('#mainPanel').css('opacity', '0');
  261. $('#clippingBounds').css('opacity', '0');
  262. }
  263. function showMainPanel() {
  264. $('#mainPanel').animate({ opacity: 1 }, 10);
  265. $('#clippingBounds').animate({ opacity: 1 }, 10);
  266. }
  267. $axure.messageCenter.addMessageListener(function(message, data) {
  268. if(message == 'adaptiveViewChange') {
  269. $('.adaptiveViewOption').removeClass('currentAdaptiveView');
  270. if(data.viewId) {$('.adaptiveViewOption[val="' + data.viewId + '"]').addClass('currentAdaptiveView');}
  271. else $('.adaptiveViewOption[val="default"]').addClass('currentAdaptiveView');
  272. //when we set adaptive view through user event, we want to update the checkmark on sitemap
  273. if(data.forceSwitchTo) {
  274. $('.adapViewRadioButton').find('.selectedRadioButtonFill').hide();
  275. $('.adapViewRadioButton').removeClass('selectedRadioButton');
  276. $('div[val="' + data.forceSwitchTo + '"]').find('.adapViewRadioButton').addClass('selectedRadioButton');
  277. $('div[val="' + data.forceSwitchTo + '"]').find('.selectedRadioButtonFill').show();
  278. }
  279. updateAdaptiveViewHeader();
  280. $axure.player.refreshViewPort();
  281. } else if(message == 'previousPage') {
  282. openPreviousPage();
  283. } else if(message == 'nextPage') {
  284. openNextPage();
  285. }
  286. });
  287. $axure.player.toggleHotspots = function (val) {
  288. var overflowMenuCheckbox = $('#showHotspotsOption').find('.overflowOptionCheckbox');
  289. if ($(overflowMenuCheckbox).hasClass('selected')) {
  290. if (!val) $('#showHotspotsOption').click();
  291. } else {
  292. if (val) $('#showHotspotsOption').click();
  293. }
  294. }
  295. function showHotspots_click(event) {
  296. var overflowMenuCheckbox = $('#showHotspotsOption').find('.overflowOptionCheckbox');
  297. var projOptionsCheckbox = $('#projectOptionsHotspotsCheckbox');
  298. if ($(overflowMenuCheckbox).hasClass('selected')) {
  299. overflowMenuCheckbox.removeClass('selected');
  300. if (projOptionsCheckbox.length > 0 ) projOptionsCheckbox.removeClass('selected');
  301. $axure.messageCenter.postMessage('highlightInteractive', false);
  302. //Delete 'hi' hash string var if it exists since default is unselected
  303. $axure.player.deleteVarFromCurrentUrlHash(HIGHLIGHT_INTERACTIVE_VAR_NAME);
  304. } else {
  305. overflowMenuCheckbox.addClass('selected');
  306. if (projOptionsCheckbox.length > 0) projOptionsCheckbox.addClass('selected');
  307. $axure.messageCenter.postMessage('highlightInteractive', true);
  308. //Add 'hi' hash string var so that stay highlighted across reloads
  309. $axure.player.setVarInCurrentUrlHash(HIGHLIGHT_INTERACTIVE_VAR_NAME, 1);
  310. }
  311. }
  312. function adaptiveViewOption_click(event) {
  313. var currVal = $(this).attr('val');
  314. $('.adaptiveViewOption').removeClass('currentAdaptiveView');
  315. if(currVal) {$('.adaptiveViewOption[val="' + currVal + '"]').addClass('currentAdaptiveView');}
  316. else $('.adaptiveViewOption[val="default"]').addClass('currentAdaptiveView');
  317. $('.adapViewRadioButton').find('.selectedRadioButtonFill').hide();
  318. $('.adapViewRadioButton').removeClass('selectedRadioButton');
  319. $('div[val="' + currVal + '"]').find('.adapViewRadioButton').addClass('selectedRadioButton');
  320. $('div[val="' + currVal + '"]').find('.selectedRadioButtonFill').show();
  321. selectAdaptiveView(currVal);
  322. $axure.player.closePopup();
  323. updateAdaptiveViewHeader();
  324. }
  325. var selectAdaptiveView = $axure.player.selectAdaptiveView = function(currVal) {
  326. if (currVal == 'auto') {
  327. $axure.messageCenter.postMessage('setAdaptiveViewForSize', { 'width': $('#mainPanel').width(), 'height': $('#mainPanel').height() });
  328. $axure.player.deleteVarFromCurrentUrlHash(ADAPTIVE_VIEW_VAR_NAME);
  329. } else {
  330. currentPageLoc = $axure.page.location.split("#")[0];
  331. var decodedPageLoc = decodeURI(currentPageLoc);
  332. var nodeUrl = decodedPageLoc.substr(decodedPageLoc.lastIndexOf('/')
  333. ? decodedPageLoc.lastIndexOf('/') + 1
  334. : 0);
  335. var adaptiveData = {
  336. src: nodeUrl
  337. };
  338. adaptiveData.view = currVal;
  339. $axure.messageCenter.postMessage('switchAdaptiveView', adaptiveData);
  340. $axure.player.setVarInCurrentUrlHash(ADAPTIVE_VIEW_VAR_NAME, currVal);
  341. }
  342. }
  343. $axure.player.updateAdaptiveViewHeader = updateAdaptiveViewHeader = function () {
  344. var hasDefinedDim = true;
  345. var dimensionlessViewStr = '(any x any)';
  346. var viewString = $('.adaptiveViewOption.currentAdaptiveView').text();
  347. if (viewString != null && viewString.indexOf(dimensionlessViewStr) >= 0) hasDefinedDim = false;
  348. if (!hasDefinedDim) {
  349. var viewName = viewString.substring(0, viewString.lastIndexOf(' ('));
  350. var widthString = $('#mainPanelContainer').width();
  351. viewString = viewName + ' (' + widthString + ' x any)';
  352. }
  353. $('.adaptiveViewHeader').html(viewString);
  354. }
  355. $axure.player.selectScaleOption = function (scaleVal) {
  356. var $scale = $('.vpScaleOption[val="' + scaleVal + '"]');
  357. if ($scale.length > 0) $scale.click();
  358. }
  359. function vpScaleOption_click(event) {
  360. var scaleCheckDiv = $(this).find('.scaleRadioButton');
  361. var scaleVal = $(this).attr('val');
  362. if (scaleCheckDiv.hasClass('selectedRadioButton')) return false;
  363. var $selectedScaleOption = $('.vpScaleOption[val="' + scaleVal + '"], .projectOptionsScaleRow[val="' + scaleVal + '"]');
  364. var $allScaleOptions = $('.vpScaleOption, .projectOptionsScaleRow');
  365. $allScaleOptions.find('.scaleRadioButton').removeClass('selectedRadioButton');
  366. $allScaleOptions.find('.selectedRadioButtonFill').hide();
  367. $selectedScaleOption.find('.scaleRadioButton').addClass('selectedRadioButton');
  368. $selectedScaleOption.find('.selectedRadioButtonFill').show();
  369. if (scaleVal == '0') {
  370. $axure.player.deleteVarFromCurrentUrlHash(SCALE_VAR_NAME);
  371. } else if (typeof scaleVal !== 'undefined') {
  372. $axure.player.setVarInCurrentUrlHash(SCALE_VAR_NAME, scaleVal);
  373. }
  374. $axure.player.refreshViewPort();
  375. }
  376. function search_input_keyup(event) {
  377. var searchVal = $(this).val().toLowerCase();
  378. //If empty search field, show all nodes, else grey+hide all nodes and
  379. //ungrey+unhide all matching nodes, as well as unhide their parent nodes
  380. if(searchVal == '') {
  381. $('.sitemapPageName').removeClass('sitemapGreyedName');
  382. $('.sitemapNode').show();
  383. } else {
  384. $('.sitemapNode').hide();
  385. $('.sitemapPageName').addClass('sitemapGreyedName').each(function() {
  386. var nodeName = $(this).text().toLowerCase();
  387. if(nodeName.indexOf(searchVal) != -1) {
  388. $(this).removeClass('sitemapGreyedName').parents('.sitemapNode:first').show().parents('.sitemapExpandableNode').show();
  389. }
  390. });
  391. }
  392. }
  393. function generateSitemap() {
  394. var treeUl = "<div id='sitemapHeader'' class='sitemapHeader'>";
  395. treeUl += "<div id='sitemapToolbar' class='sitemapToolbar'>";
  396. treeUl += '<div id="searchDiv"><span id="searchIcon" class="sitemapToolbarButton"></span><input id="searchBox" type="text"/></div>';
  397. treeUl += "<div class='leftArrow sitemapToolbarButton'></div>";
  398. treeUl += "<div class='rightArrow sitemapToolbarButton'></div>";
  399. treeUl += "</div>";
  400. treeUl += "</div>";
  401. ///////////////////
  402. var sitemapTitle = $axure.player.getProjectName();
  403. if (!sitemapTitle) sitemapTitle = "Pages";
  404. treeUl += "<div class='sitemapPluginNameHeader pluginNameHeader'>" + sitemapTitle + "</div>";
  405. treeUl += "<div id='sitemapTreeContainer'>";
  406. treeUl += "<ul class='sitemapTree' style='clear:both;'>";
  407. var rootNodes = $axure.document.sitemap.rootNodes;
  408. for(var i = 0; i < rootNodes.length; i++) {
  409. treeUl += generateNode(rootNodes[i], 0);
  410. }
  411. treeUl += "</ul></div>";
  412. if (!MOBILE_DEVICE) {
  413. treeUl += "<div id='changePageInstructions' class='pageSwapInstructions'>Use ";
  414. treeUl += '<span class="backKeys"></span>';
  415. treeUl += " and ";
  416. treeUl += '<span class="forwardKeys"></span>';
  417. treeUl += " keys<br>to move between pages";
  418. treeUl += "</div>";
  419. }
  420. $('#sitemapHost').html(treeUl);
  421. }
  422. function generateNode(node, level) {
  423. var hasChildren = (node.children && node.children.length > 0);
  424. var margin, returnVal;
  425. if(hasChildren) {
  426. margin = (9 + level * 17);
  427. returnVal = "<li class='sitemapNode sitemapExpandableNode'><div><div class='sitemapPageLinkContainer' style='margin-left:" + margin + "px'><a class='sitemapPlusMinusLink'><span class='sitemapMinus'></span></a>";
  428. } else {
  429. margin = (19 + level * 17);
  430. returnVal = "<li class='sitemapNode sitemapLeafNode'><div><div class='sitemapPageLinkContainer' style='margin-left:" + margin + "px'>";
  431. }
  432. var isFolder = node.type == "Folder";
  433. if(!isFolder) {
  434. returnVal += "<a class='sitemapPageLink' nodeUrl='" + node.url + "'>";
  435. allNodeUrls.push(node.url);
  436. }
  437. returnVal += "<span class='sitemapPageIcon";
  438. if(isFolder) { returnVal += " sitemapFolderIcon"; }
  439. returnVal += "'></span><span class='sitemapPageName'>";
  440. returnVal += $('<div/>').text(node.pageName).html();
  441. returnVal += "</span>";
  442. if(!isFolder) returnVal += "</a>";
  443. returnVal += "</div></div>";
  444. if(hasChildren) {
  445. returnVal += "<ul>";
  446. for(var i = 0; i < node.children.length; i++) {
  447. var child = node.children[i];
  448. returnVal += generateNode(child, level + 1);
  449. }
  450. returnVal += "</ul>";
  451. }
  452. returnVal += "</li>";
  453. return returnVal;
  454. }
  455. })();