Hi!
I have a certain enormous prototype, and because my colleagues have bookmarked links to individual pages of the prototype, I wanted a script that would collapse all folders in the sitemap no matter what page they start on, but will NOT collapse it again upon navigating to a different page, as that would be super-annoying after opening the folder of interest.
I hobbled together this Axshare plug-in after searching the forums and reading Meirion’s post above. Note: the plugin requires that you have defined the global variable “sitemapCollapsed” in your prototype.
Add the plugin to the footer of each page in Axshare:
<script>
$axure.internal(function($ax){
$ax.public.getGlobalVariable = $ax.getGlobalVariable = function(name) {
return $ax.globalVariableProvider.getVariableValue(name);
};
});
if($axure.getGlobalVariable('sitemapCollapsed') != 'true') {
void(window.parent.jQuery.fn.reverse = [].reverse);
void(window.parent.$('.sitemapMinus').reverse().each(function(){this.click()}));
$axure.setGlobalVariable('sitemapCollapsed','true');
};
</script>
Edit: here is an alternate script that doesn’t rely on a global variable. it collapses the tree only if every single folder is open (as it is on loading the first page). If even a single folder is closed, the tree won’t collapse.
It’s almost inconceivable that someone would manually open every single folder in my prototype, so it shouldn’t interfere with the user at all.
<script>
var collapseSitemap = true;
void(window.parent.$('.sitemapPlus').each(function(){collapseSitemap = false}));
if(collapseSitemap) {
void(window.parent.jQuery.fn.reverse = [].reverse);
void(window.parent.$('.sitemapMinus').reverse().each(function(){this.click()}));
};
</script>