sitemap.js 27 KB

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