Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gdhaworth/6cce3b3e935b877b470a to your computer and use it in GitHub Desktop.
Save gdhaworth/6cce3b3e935b877b470a to your computer and use it in GitHub Desktop.
<!--
Original snippet is from
http://www.communardo.de/home/techblog/2011/05/02/improve-the-confluence-pagetree-macro-functionality/
-->
<script type="text/javascript" >
AJS.toInit(function ($) {
var currentChildClicked = false;
AJS.bind("pagetree-children-loaded", function() {
if(!currentChildClicked) {
//search for the child element with the style attribute
AJS.$('span.plugin_pagetree_children_span.plugin_pagetree_current').each(function(index, item){
//click on the plus icon to expand the children of the current page
var elem = jQuery(item);
// do not toggle the parent of a childs, if child the current page
if (elem.parent().next().find('.plugin_pagetree_children_span.plugin_pagetree_current').length === 0) {
jQuery(this).parent().parent().find('.plugin_pagetree_childtoggle_container a.plugin_pagetree_childtoggle').trigger('click');
}
});
currentChildClicked = true;
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment