Forked from timaschew/confluence_pagetree_extension.html
Last active
August 29, 2015 14:05
-
-
Save gdhaworth/6cce3b3e935b877b470a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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