-
Notifications
You must be signed in to change notification settings - Fork 3
/
toc.js
22 lines (20 loc) · 867 Bytes
/
toc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var toc = false;
var lookup = {};
$(document).ready( function() {
$('body').prepend( "<button class='toc' style='position: fixed; top: 10px; left: 10px;'>Toggle TOC Mode</button>" );
console.log( "Inside the ready event" );
$('.toc').click( function() {
console.log( "Got the click event" );
toc = !toc;
jQuery.each( [ '.paragraph', '.dlist', '.ulist', '.listingblock', '.colist', '.imageblock', '.admonitionblock' ], function( index, item ) {
$(item)[toc?'hide':'show']();
} );
for( var index = 1; index < 7; index++ ) {
jQuery( 'h' + index ).click( function( item ) {
var hideOrShow = lookup[item.target] = !lookup[item.target];
jQuery( item.target ).siblings()[hideOrShow?'show':'hide']();
} );
}
return true;
});
});