single.html 2.47 KB
Newer Older
1
2
3
{{ define "main" }}
  {{ .Content }}

4
5
6
7
8
  {{ $tabs_to_display := slice }}
  {{ $tabs_ids := slice }}
  {{ range $index, $entry := .Params.tabs }}
    {{ $tabs_ids = $tabs_ids | append $entry.ids }}
    {{ $tabs_to_display = $tabs_to_display | append $entry }}
9
10
11
  {{ end }}

  <main class="container">
12
    <h1>{{ .Title }}</h1>
13
    <nav class="nav nav-pills nav-fill dp-nav-pills" role="tablist">
14
      {{ range $index, $navTab := $tabs_ids }}
15
16
17
18
19
      <a class="nav-item nav-link{{ if (eq $index 0) }} active{{ else }}{{ end }} ml-2 mb-2 dp-background-color--hero" id="{{ .id }}"
        href='{{print "#" .id "-content"}}' data-bs-toggle="tab" role="tab"
        aria-controls='{{print .id "-content"}}' aria-selected="{{ if (eq $index 0) }}true{{ else }}false{{ end }}">
        <h6 class="m-0">{{ .name }}</h6>
      </a>
20
      {{ end }}
21
22
23
    </nav>
    <div class="tab-content mt-5">
      {{ $parentScope := . }}
24
      {{ range $index, $tabPanel := $tabs_to_display }}
25
26
27
        {{ $id := default "" }}
        {{ range .ids }}{{ $id = .id }}{{ end }}
        <div class="tab-pane fade {{ if (eq $index 0) }}active show{{ else }}{{ end }}" id='{{ print $id "-content" }}' role="tabpanel" aria-labelledby='{{print $id "-tab"}}'>
28
          <article>
29
            <h2>{{ .title }}</h2>
30
31
32
            {{ range $index, $p := .content }}
              {{ $len := len . }}
              {{ $last := sub $len 1 }}
33
34
              {{ if isset . "headers" }}
              <h6>{{ safeHTML .headers }}</h6>
35
36
37
38
39
40
              {{ end }}
              <p>{{ safeHTML .text }}</p>
              {{ if and (ge $len 2) (eq $index $last) }}
              {{ end }}
            {{ end }}
          </article>
41
          {{ if isset . "data" }}
42
          <a class="btn btn-primary" href="{{ .data }}" id="download-button-{{ $index }}">{{ i18n "download_csv" }}</a>
43
          {{ end }}
44
          {{ if isset . "partial" }}
45
46
47
48
49
            {{ partial .partial $parentScope }}
          {{ end }}
        </div>
      {{ end }}
    </div>
50
51
  </main>

52
53
  <script>
    $(function () {
54
      $('.nav-pills a').on('click', function (e) {
55
56
57
58
        e.preventDefault();
        $(this).tab('show');
      });
    });
59

60
    $(document).ready(() => {
61

62
63
64
65
66
67
68
69
70
      // Toggle "Read more" / "Read less" button
      $('[data-toggle="collapse"]').click(function () {
        $(this).toggleClass("active");
        if ($(this).hasClass("active")) {
          $(this).text("Read less");
        } else {
          $(this).text("Read more");
        }
      });
71
72
    });
  </script>
73
{{ end }}