-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocinfo.html
More file actions
60 lines (60 loc) · 2.73 KB
/
docinfo.html
File metadata and controls
60 lines (60 loc) · 2.73 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css">
<link rel="stylesheet" href="custom.css">
<link rel="stylesheet" href="../nav-bar.css">
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
// Create toggle anchor
var target = document.querySelector('#header');
var anchor = document.createElement('a');
anchor.className = 'tocSwitch fa fa-arrow-up';
// Add click listener to the button
anchor.addEventListener('click', function (e) {
e.stopPropagation();
var toc = document.querySelector('#toc');
var body = document.querySelector('body');
// If the toc is visible
if (body.classList.contains('toc2')) {
body.classList.remove('toc2');
body.classList.remove('toc-left');
toc.style.display = 'none';
anchor.className = 'tocSwitch fa fa-arrow-down';
} else { // If the toc is not visible
body.classList.add('toc2');
body.classList.add('toc-left');
toc.style.display = 'block';
anchor.className = 'tocSwitch fa fa-arrow-up';
}
});
// Add anchor to DOM
target.appendChild(anchor);
// Add window resize listener
$(window).resize(function() {
var toc = document.querySelector('#toc');
var body = document.querySelector('body');
// If the window is smaller than 768px, collapse the toc by default
if ($(window).width() < 768) {
body.classList.remove('toc2');
body.classList.remove('toc-left');
toc.style.display = 'none';
anchor.className = 'tocSwitch fa fa-arrow-down';
} else { // If the window is bigger than 768px, keep the toc open
body.classList.add('toc2');
body.classList.add('toc-left');
toc.style.display = 'block';
anchor.className = 'tocSwitch fa fa-arrow-up';
}
});
// Add click listener for
$('#toc a').click(function() {
var toc = document.querySelector('#toc');
var body = document.querySelector('body');
if ($(window).width() < 768) {
body.classList.remove('toc2');
body.classList.remove('toc-left');
toc.style.display = 'none';
anchor.className = 'tocSwitch fa fa-arrow-down';
}
});
});
</script>