-
Notifications
You must be signed in to change notification settings - Fork 922
/
Copy pathtabpane.html
130 lines (106 loc) · 4.22 KB
/
tabpane.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!-- Check parameter types -->
{{ with .Get "langEqualsHeader" }}
{{ if ne ( printf "%T" . ) "bool" }}
{{- errorf "shortcode tabpane: parameter 'langEqualsHeader' must be either true or false" -}}
{{ end }}
{{ end }}
{{ with .Get "text" }}
{{ if ne ( printf "%T" . ) "bool" }}
{{- errorf "shortcode tabpane: parameter 'text' must be either true or false" -}}
{{ end }}
{{ end }}
{{ with .Get "persistLang" }}
{{ if ne ( printf "%T" . ) "bool" }}
{{- errorf "shortcode tabpane: parameter 'persistLang' must be either true or false" -}}
{{ end }}
{{ end }}
{{ with .Get "right" }}
{{ if ne ( printf "%T" . ) "bool" }}
{{- errorf "shortcode tabpane: parameter 'right' must be either true or false" -}}
{{ end }}
{{ end }}
<!-- Set values given defined within tabpane -->
{{- $langPane := default "" ($.Get "lang") -}}
{{- $hloptionsPane := default "" ($.Get "highlight") -}}
{{- $textPane := default false ($.Get "text") -}}
{{- $langEqualsHeader := default false ($.Get "langEqualsHeader") -}}
{{- $persistLang := default true ($.Get "persistLang") -}}
{{- $rightPane := default false ($.Get "right") -}}
{{- $disabled := false -}}
{{- $rightpush := false -}}
{{- $activeSet := false -}}
<!-- Scratchpad gets populated through call to .Inner -->
{{- .Inner -}}
<ul class="nav nav-tabs{{ if $rightPane }} justify-content-end{{ end }}" id="tabs-{{- $.Ordinal -}}" role="tablist">
{{- range $index, $element := $.Scratch.Get "tabs" -}}
{{- $lang := $langPane -}}
{{- if $langEqualsHeader -}}
{{- $lang = $element.header -}}
{{end}}
{{- with $element.language -}}
{{- $lang = $element.language -}}
{{- end -}}
{{- $disabled := false -}}
{{- with $element.disabled -}}
{{- $disabled = . }}
{{- end -}}
{{- $rightpush := false -}}
{{- with $element.rightpush -}}
{{- $rightpush = . }}
{{- end -}}
<!-- Replace space and +, not valid for css selectors -->
{{- $lang := replaceRE "[\\s+]" "-" $lang -}}
<li class="nav-item{{ if $rightpush }} ml-auto{{ end }}">
<!-- Generate the IDs for the <a> and the <div> elements -->
{{- $tabid := printf "tabs-%02v-%v-tab" $.Ordinal $index | anchorize -}}
{{- $entryid := printf "tabs-%02v-%v" $.Ordinal $index | anchorize -}}
<a class="nav-link{{ if and ( not $activeSet ) ( not $disabled ) }} active{{ end }}{{ if $disabled }} disabled{{ end }}{{ if ne $lang "" }}{{ if $persistLang }} persistLang-{{- $lang -}}{{ end }}{{ end }}"
id="{{- $tabid -}}" data-toggle="tab" href="#{{ $entryid }}" role="tab"
{{ if ne $lang "" }}{{- if $persistLang -}}onclick="persistLang({{- $lang -}});"{{end}}{{end}}
aria-controls="{{- $entryid -}}" aria-selected="{{- and ( not $activeSet ) ( not $disabled ) "true" "false" -}}">
{{- index . "header" | markdownify -}}
</a>
</li>
{{ if not $disabled }}
{{ $activeSet = true }}
{{ end }}
{{- end -}}
</ul>
{{ $activeSet = false }}
<!-- Inner content -->
<div class="tab-content" id="tabs-{{- $.Ordinal -}}-content">
{{- range $index, $element := $.Scratch.Get "tabs" -}}
{{- $lang := $langPane -}}
{{- if $langEqualsHeader -}}
{{- $lang = $element.header -}}
{{end}}
{{- with $element.language -}}
{{- $lang = $element.language -}}
{{- end -}}
{{- $disabled := false -}}
{{- with $element.disabled -}}
{{- $disabled = . }}
{{- end -}}
{{- $hloptions := $hloptionsPane -}}
{{- with $element.highlight -}}
{{- $hloptions = $element.highlight -}}
{{- end -}}
{{- $text := $textPane -}}
{{- with $element.text -}}
{{- $text = . }}
{{- end -}}
{{- $tabid := printf "tabs-%02v-%v-tab" $.Ordinal $index | anchorize -}}
{{- $entryid := printf "tabs-%02v-%v" $.Ordinal $index | anchorize -}}
<div class="{{ if $text }}tab-body {{end}}tab-pane fade{{ if and ( not $activeSet ) ( not $disabled ) }} show active{{ end }}"
id="{{ $entryid }}" role="tabpanel" aria-labelled-by="{{ $tabid }}">
{{ if $text }}
{{- index . "content" -}}
{{- else -}}
{{- highlight (trim (index . "content") "\n") $lang $hloptions -}}
{{- end -}}
</div>
{{ if not $disabled }}
{{ $activeSet = true }}
{{ end }}
{{ end }}
</div>