This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
/
collapsible-menu.html
86 lines (74 loc) · 4.36 KB
/
collapsible-menu.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
83
84
85
86
<!--
Copyright (c) 2018 Eclipse Foundation, Inc.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
Contributors:
Christopher Guindon <chris.guindon@eclipse-foundation.org>
SPDX-License-Identifier: EPL-2.0
-->
{{ if isset .Site.Menus "sidebar" }}
{{ $currentPage := . }}
{{ if or (eq $currentPage.Params.show_collapsible_menu true) (eq .Site.Params.show_collapsible_menu true) }}
{{ .Scratch.Set "currentSection" "home" }}
{{ if $currentPage.Section }}
{{ .Scratch.Set "currentSection" $currentPage.Section }}
{{ end }}
{{$currentSection := .Scratch.Get "currentSection" }}
<!--- Sidebar layout --->
{{ $sidebarLayout := .Page.Params.sidebar_layout | default .Site.Params.sidebar_layout | default "default" }}
{{ $classname := cond (eq $sidebarLayout "sidebar_block") "sidebar-block" "collapsible-menu" }}
<!----------------------- Collapisible start ------------------------------------>
{{ range .Site.Menus.sidebar }}
{{$parentItem := . }}
{{ if and (.HasChildren) (eq $currentSection $parentItem.Identifier) }}
<div class="{{ $classname }} margin-top-20 container hidden-lg hidden-md visible-sm visible-xs">
<div class="container padding-left-0 padding-right-0 {{ $classname }}-item related-content">
<a href="#sidebars-contents" data-toggle="collapse" aria-expanded="false" aria-controls="sidebars-contents">
<div class="col-xs-6"><i class="fa fa-plus fa-bars"></i></div>
<div class="col-xs-18 {{ $classname }}-text">Related Content</div>
</a>
</div>
<div class="container collapse {{ if eq $classname "sidebar-block" }} padding-left-0 padding-right-0 {{ end }}" id="sidebars-contents">
{{ range .Children }}
{{ if eq .HasChildren false }}
<div class="row {{ $classname }}-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }} <!-- if eq .HasChildren false end -->
{{ if .HasChildren }}
<div class="row {{ $classname }}-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="#sub-children-{{ .Identifier }}" data-toggle="collapse" aria-expanded="false" aria-controls="sub-children{{ .Identifier }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-6">{{ .Pre }}</div>
<div class="col-xs-18 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
<div class="row {{ $classname }}-sub-items {{ if eq $classname "sidebar-block" }} margin-bottom-20 {{ end }} collapse" id="sub-children-{{ .Identifier }}">
<!-- Check if current parent menu has children and has own url, we should add an entry to goto this parent -->
{{ if .URL }}
<div class="row {{ $classname }}-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }}
{{ range .Children }}
<div class="row {{ $classname }}-sub-item{{ if eq $currentPage.Title .Name }} active{{ end }}">
<a href="{{ .URL }}" {{ if eq $currentPage.Title .Name }}class="active"{{ end }}>
<div class="col-xs-18 col-xs-offset-6 {{ $classname }}-text">{{ .Name }}</div>
</a>
</div>
{{ end }} <!--Children's Children end-->
</div>
{{ end }} <!-- if .HasChildren (subchildren) end -->
{{ end }} <!-- range Children end -->
</div>
{{ end }} <!-- if .HasChildren end -->
{{ end }} <!-- range .Site.Menus.sidebar end -->
</div> <!-- div id="{{ $classname }}" end -->
<!-------------------- Collapisible end ----------------------------------------->
{{ end }} <!-- if or (eq $currentPage.Params.show_collapsible_menu true) (eq .Site.Params.show_collapsible_menu true) end-->
{{ end }} <!-- if isset .Site.Menus "sidebar" end -->