// use this to isolate the scope (function () { var SHOW_HIDE_ANIMATION_DURATION = 0; $(document).ready(function () { $axure.player.createPluginHost({ id: 'sitemapHost', context: 'interface', title: 'Sitemap' }); generateSitemap(); $('.sitemapPlusMinusLink').toggle(collapse_click, expand_click); $('.sitemapPageLink').click(node_click); $('#linkscontainer').hide(); $('#togglelinks').click(links_click); $('.sitemapLinkField').click(function () { this.select() }) // $('#sitemapHost').parent().resize(function () { // $('#sitemapHost').height($(this).height()); // }); // bind to the page load $axure.page.bind('load.sitemap', function () { var pageLoc = $axure.page.location.split("#")[0]; var decodedPageLoc = decodeURI(pageLoc); var nodeUrl = decodedPageLoc.substr(decodedPageLoc.lastIndexOf('/') ? decodedPageLoc.lastIndexOf('/') + 1 : 0); $('.sitemapPageLink').removeClass('sitemapHighlight'); $('.sitemapPageLink[nodeUrl=' + nodeUrl + ']').addClass('sitemapHighlight'); $('#linkspagename').html($('.sitemapHighlight > .sitemapPageName').html()); var playerLoc = $(location).attr('href').split("#")[0]; var qString = "?Page=" + nodeUrl.substr(0, nodeUrl.lastIndexOf('.')); $('#linkwithplayer').val(playerLoc + qString); $('#linkwithoutplayer').val(pageLoc); $('#closeplayer').unbind('click'); $('#closeplayer').click(function () { window.location.href = pageLoc; }); return false; }); }); function collapse_click(event) { $(this) .children('.sitemapMinus').removeClass('sitemapMinus').addClass('sitemapPlus').end() .closest('li').children('ul').hide(SHOW_HIDE_ANIMATION_DURATION); } function expand_click(event) { $(this) .children('.sitemapPlus').removeClass('sitemapPlus').addClass('sitemapMinus').end() .closest('li').children('ul').show(SHOW_HIDE_ANIMATION_DURATION); } function node_click(event) { $axure.page.navigate(this.getAttribute('nodeUrl')); } function links_click(event) { $('#linkscontainer').toggle(); if ($('#linkscontainer').is(":visible")) { $('#togglelinks').html('Hide Links'); } else { $('#togglelinks').html('Show Links'); } } function generateSitemap() { var treeUl = "
"; treeUl += "
Show Links
"; treeUl += "
"; $('#sitemapHost').html(treeUl); } function generateNode(node) { var hasChildren = (node.children && node.children.length > 0); if (hasChildren) { var returnVal = "
  • "; } else { var returnVal = "
  • "; } returnVal += "" returnVal += $('
    ').text(node.pageName).html(); returnVal += "
    "; if (hasChildren) { returnVal += ""; } returnVal += "
  • "; return returnVal; } })();