summaryrefslogtreecommitdiff
path: root/_includes/views/banner.html
blob: bd3205c5eb185894c649d0e04b2593e21f9bf08b (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
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
131
{%- include functions.html func='log' level='debug' msg='Get banner_html value' -%}
{% assign name = 'banner_html' %}
{%- include functions.html func='get_value' -%}
{% assign banner_html = return %}

{%- include functions.html func='log' level='debug' msg='Get heading value' -%}
{% assign name = 'heading' %}
{%- include functions.html func='get_value' -%}
{% assign heading = return %}

{%- include functions.html func='log' level='debug' msg='Get subheading value' -%}
{% assign name = 'subheading' %}
{%- include functions.html func='get_value' -%}
{% assign subheading = return %}

{%- include functions.html func='get_banner' -%}

{%- if has_banner -%}
  {%- if banner_background -%}
  <style>
    html .page-banner {
      background: {{ banner_background }};
    }
  </style>
  {%- endif -%}
  {%- if banner_height -%}
  <style>
    {%- assign num = banner_height | times: 1 -%}
    {%- assign unit = banner_height | replace_first: num -%}
    {%- assign banner_min_height = banner_min_height | default: banner_height -%}
    html .page-banner {
      height:  {{ banner_height | times: 0.368 | append: unit }};
      min-height: {{ banner_min_height }};
    }
    html[data-scroll-status="top"] .page-banner {
      height: {{ banner_height }};
    }
  </style>
  {%- endif -%}

  {%- if banner_opacity -%}
  <style>
    html .page-banner .page-banner-img > *:first-child {
      opacity: {{ banner_opacity }};
    }

    html[data-theme="dark"] .page-banner .page-banner-img > *:first-child {
      opacity: {{ banner_opacity | times: 0.718 }};
    }
  </style>
  {%- endif -%}
  {%- if banner_heading_style -%}
  <style>
    html .page-banner .page-banner-inner > *:first-child > *:nth-child(1) {
      {{ banner_heading_style }}
    }
  </style>
  {%- endif -%}
  {%- if banner_subheading_style -%}
  <style>
    html .page-banner .page-banner-inner > *:first-child > *:nth-child(2) {
      {{ banner_subheading_style }}
    }
  </style>
  {%- endif -%}
  <section class="page-banner">
    <div class="page-banner-img">
      {%- if banner_video -%}
        <video
          autoplay=""
          poster="{{ banner_image }}"
          playsinline
        >
          <source src="{{ banner_video }}">
        </video>
        <script>
          (function() {
            var video = document.querySelector('.page-banner .page-banner-img > video');
            var videoPlay = function() {
              video.play().catch (function() {
                  video.muted = true;
                  video.play();
                });
            }

            video.onloadstart = function() {
              video.currentTime = {{ banner_start_at }};
              video.volume = {{ banner_volume }};
              video.muted = (video.volume == 0);
              videoPlay();
            }

            video.onended = function() {
              video.currentTime = {{ banner_start_at }};
              video.volume = 0;
            {%- if banner_loop -%}
              video.play();
            {%- endif -%}
            }
          })();
        </script>
      {%- else -%}
        <div style="background-image: url({{ banner_image }})"></div>
        <img class="img-placeholder" src="{{ banner_image }}">
      {%- endif -%}
    </div>
    <div class="wrapper">
      <div class="page-banner-inner">

        {%- if banner_html -%}

        {%- assign banner_html = 'views/' | append: banner_html -%}
        {%- include {{ banner_html }} -%}

        {%- else -%}

          <div class="page-banner-default">
            <h1 class="page-banner-heading">
              {% t home.heading %}
            </h1>
            <h2 class="page-banner-subheading">
              {% t home.subheading %}
            </h2>
          </div>

        {%- endif -%}
      </div>
    </div>
  </section>
{%- endif -%}