forked from loopbackio/loopback.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoc.html
34 lines (28 loc) · 1.08 KB
/
toc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!-- this handles the automatic toc. use ## for subheads to auto-generate the on-page minitoc. if you use html tags, you must supply an ID for the heading element in order for it to appear in the minitoc. -->
<script>
;$(function() {
var level = parseInt({{ include.level | default: 3 }}, 10);
if (level === 1) {level = 'h2'}
if (level === 2) {level = 'h2,h3'}
if (level === 3) {level = 'h2,h3,h4'}
if (level === 4) {level = 'h2,h3,h4,h5'}
var toc = $('#toc')
toc.toc({minimumHeaders: 0, listType: 'ul', showSpeed: 0, headers: level})
/* this offset helps with the space taken up by the floating toolbar */
toc.on('click', 'a', function() {
var target = $(this.getAttribute('href')),
scroll_target = target.offset().top
$(window).scrollTop(scroll_target - 10)
return false
})
.on('click', '.toc-expand-button', function() {
toc.find('> ul').slideToggle('fast');
})
})
</script>
<div id="toc">
<span class="toc-title">Page Contents</span>
<button type="button" class="btn btn-link toc-expand-button">
<i class="fa fa-bars"></i>
</button>
</div>