blob: 0640f7a4c392457a6bde61a79a637b7e91b4f852 (
plain)
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
61
62
|
{{ if eq (len (where .Site.Sections "Params.hidefrommenu" "!=" true)) 1 }}
<div class="main-menu">
{{ with (index (where .Site.Sections "Params.hidefrommenu" "!=" true) 0) }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
</div>
{{ else }}
<div class="dropdown main-menu">
<span class="dropbtn" onclick="toggleSectionMenu(this)">
Sections <i class="section-menu fas fa-chevron-down"></i>
</span>
<div class="dropdown-content">
<div class="rounded bg-light mt-2">
<ul class="list-unstyled m-0">
{{ range where .Site.Sections "Params.hidefrommenu" "!=" true }}
{{ $thisSection := replace .File.Dir "\\" "" }}
<li class="dropdown-link pl-3 pr-3 pt-1 pb-1 rounded">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
</div>
</div>
</div>
<script>
let toggleHeight = function(elem) {
if (getComputedStyle(elem)["height"] === "0px") {
elem.style.maxHeight = elem.scrollHeight + 5 + "px";
} else {
elem.style.maxHeight = "0px";
}
};
let toggleSectionMenu = function(x) {
toggleHeight(x.nextElementSibling);
document.querySelector(".section-menu").classList.toggle("fa-chevron-down");
document.querySelector(".section-menu").classList.toggle("fa-chevron-up");
};
let resetSectionMenu = function() {
document.querySelector(".section-menu").classList.add("fa-chevron-down");
document.querySelector(".section-menu").classList.remove("fa-chevron-up");
};
let zeroHeight = function(elem) {
elem.style.maxHeight = "0px";
};
let checkClick = function() {
if (!document.querySelector(".dropdown").contains(event.target)) {
zeroHeight(document.querySelector(".dropdown-content"));
resetSectionMenu();
}
};
window.onclick = function() {
if (!vw.matches) {
checkClick();
}
};
window.ontouchstart = function() {
if (!vw.matches) {
checkClick();
}
};
</script>
{{ end }}
|