Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save BjoernSchotte/8886926 to your computer and use it in GitHub Desktop.

Select an option

Save BjoernSchotte/8886926 to your computer and use it in GitHub Desktop.
/*
* found on https://confluence.atlassian.com/display/CONFKB/2012/12/17/Advance+warning+of+plans+to+merge+Documentation+theme+with+the+default+theme?focusedCommentId=320603332#comment-320603332
*/
<script type="text/javascript">
AJS.toInit(function ($) {
//improve the pagetree functionality: "selected" class at selected page and expand the children of selected page
//first save the original pagetree function "origHideEmptyChildrenContainer"
var origHideEmptyChildrenContainer = AJS.pagetree.hideEmptyChildrenContainers;
//define our own one and overwrite the original pagetree function "hideEmptyChildrenContainers"
//this function is called by the pagetree after children loading
AJS.pagetree.hideEmptyChildrenContainers = function(pagetreeChildrenDiv) {
//search for the child element with the style attribute
pagetreeChildrenDiv.find('span.plugin_pagetree_children_span').each(function(){
if(jQuery(this).attr('style')) {
//add a marker for the seleted page... now we can style it with css
jQuery(this).addClass("selected");
//click on the plus icon to expand the children of the current page
jQuery(this).parent().parent().find('.plugin_pagetree_childtoggle_container a.icon-plus').trigger('click');
}
});
//call the saved original function...
origHideEmptyChildrenContainer(pagetreeChildrenDiv);
};
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment