4 * JavaScript code to fold and unfold TOC entries
6 * written 2014 by Werner Lemberg
9 // This code snippet needs `jquery' (http://code.jquery.com/jquery-1.11.2.js)
11 $(document).ready(function() {
17 /* decorate TOC's `li' elements that have children with `folded' class */
18 /* (pandoc doesn't do this) */
19 $("#TOC li").each(function(i) {
20 if ($(this).children().length) {
21 $(this).addClass("folded");
25 /* fold all entries */
26 $(".folded").each(function(i) {
27 $(this).children("ul:first").hide();
30 /* change class to `unfolded' if clicked */
31 $(".folded").click(function(e) {
32 $(this).toggleClass("unfolded");
33 $(this).children("ul:first").slideToggle("300");