-
Notifications
You must be signed in to change notification settings - Fork 56
/
productVersionDrawer.html
83 lines (75 loc) · 3.09 KB
/
productVersionDrawer.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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!-- Scripts for clicking out of the list to close -->
<script>
// I've heard that .stopPropogation() is not ideal, potentially needs a rework
$( document ).ready(function() {
$('.productButtonTitleDrawer').click( function(event){
event.stopPropagation();
$('.hiddenProductsDrawer').toggle();
});
$(document).click( function(){
$('.hiddenProductsDrawer').hide();
});
$('.versionButtonTitleDrawer').click( function(event){
event.stopPropagation();
$('.hiddenVersionsDrawer').toggle();
});
$(document).click( function(){
$('.hiddenVersionsDrawer').hide();
});
});
</script>
<div class="buttonHolder">
<!-- Dropdown for products -->
<div id="productButtonDrawer">
{{ if isset .Params "product" }}
{{ $display := .Params.product }}
<a class="productButtonTitleDrawer">{{ $display }}<i class="fa fa-chevron-down dropdownArrow" aria-hidden="true"></i></a>
{{ else }}
{{ $display := "Projects" }}
<a class="productButtonTitleDrawer">{{ $display }}<i class="fa fa-chevron-down dropdownArrow" aria-hidden="true"></i></a>
{{ end }}
<div class="hiddenProductsDrawer" style="display: none;">
<ul class="hiddenItems">
{{ range sort .Site.Params.Products "weight" }}
{{ $.Scratch.Set "url" "" }}
{{ if eq .identifier "uchiwa" }}
{{ $.Scratch.Set "url" "https://docs.uchiwa.io/" }}
{{ else }}
{{ $.Scratch.Set "url" (printf "/%s/%s/" .identifier .latest) }}
{{ end }}
{{ $url := $.Scratch.Get "url" }}
<li class="hiddenItem"><a href="{{ $url }}">{{ .name }}</a></li>
{{ end }}
</ul>
</div>
</div>
<br>
<!-- Dropdown for versions -->
<div id="versionButtonDrawer">
{{ if isset .Params "version" }}
{{ $display := .Params.version }}
<a class="versionButtonTitleDrawer">{{ $display }}<i class="fa fa-chevron-down dropdownArrow" aria-hidden="true"></i></a>
{{ else }}
{{ $display := "Version" }}
<a class="versionButtonTitleDrawer">{{ $display }}<i class="fa fa-chevron-down dropdownArrow" aria-hidden="true"></i></a>
{{ end }}
<div class="hiddenVersionsDrawer" style="display: none;">
<ul class="hiddenItems">
<!-- Grab info for the current product from global -->
{{ $product := .Section }}
{{ $product2 := replace $product "-" "_" }}
{{ $product_info := (index .Site.Params.products $product2) }}
<!-- There is not an easy way to reverse the versions map
so we need to do all this extra stuff just to do so -->
{{ range $k, $v := $product_info.versions }}
{{ $.Scratch.SetInMap "versionList" $k $k }}
{{ end }}
{{ $versionList := (default (slice) ($.Scratch.GetSortedMapValues "versionList")) }}
{{ range $index := seq (len $versionList) }}
{{ $index := sub (len $versionList) $index }}
<li class="hiddenItem"><a href="/{{ $product }}/{{ index $versionList $index }}">{{ index $versionList $index }}</a></li>
{{ end }}
</ul>
</div>
</div>
</div>