@internetstiftelsen/styleguide 2.22.3-beta.0.7 → 2.22.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/js/objToQuery.js +2 -2
  2. package/dist/components.js +1 -9
  3. package/dist/molecules/glider/glider-course.js +7 -7
  4. package/package.json +3 -7
  5. package/src/app.scss +2 -6
  6. package/src/assets/css/footer/isolated-footer.css +7367 -0
  7. package/src/assets/css/footer/isolated-footer.css.map +1 -0
  8. package/src/assets/css/footer/isolated-footer.min.css +2 -0
  9. package/src/assets/js/objToQuery.js +2 -2
  10. package/src/atoms/button/_button.scss +9 -6
  11. package/src/atoms/icon/_all-icons.zip +0 -0
  12. package/src/atoms/icon/spinner-white.svg +9 -1
  13. package/src/atoms/icon/spinner.svg +9 -1
  14. package/src/atoms/icon/sprite.svg +0 -17
  15. package/src/atoms/meta/meta.config.js +1 -1
  16. package/src/base/_normalize.scss +1 -1
  17. package/src/base/fonts/_fonts.scss +8 -8
  18. package/src/brandbook/internetstiftelsen/bildman/303/251r/bildman/303/251r.config.js +5 -0
  19. package/src/brandbook/internetstiftelsen/tonalitet och spr/303/245kbruk/tonalitet och spr/303/245kbruk.config.js" +5 -0
  20. package/src/components.js +0 -4
  21. package/src/configurations/_extends.scss +1 -5
  22. package/src/configurations/_variables.scss +3 -3
  23. package/src/configurations/grid/_grid.scss +2 -17
  24. package/src/configurations/icons.json +1 -1
  25. package/src/configurations/typography/_typography.scss +4 -57
  26. package/src/molecules/glider/_glider.scss +116 -3
  27. package/src/molecules/glider/glider-course.js +7 -7
  28. package/src/molecules/glider/glider.config.js +0 -7
  29. package/src/organisms/hero/_hero.scss +0 -16
  30. package/src/organisms/hero/hero.config.js +1 -10
  31. package/src/pages/timeline/timeline.config.js +19 -0
  32. package/src/structures/_article.scss +3 -3
  33. package/dist/.DS_Store +0 -0
  34. package/dist/assets/js/anchorScroll.js +0 -16
  35. package/dist/assets/js/offset.js +0 -26
  36. package/dist/assets/js/parallax.js +0 -17
  37. package/dist/molecules/continue-video-guide/continue-video-guide.js +0 -91
  38. package/dist/molecules/glider/glider-hero.js +0 -23
  39. package/dist/organisms/timeline/timeline.js +0 -154
  40. package/dist/organisms/video-guide/video-guide.js +0 -298
  41. package/src/.DS_Store +0 -0
  42. package/src/assets/.DS_Store +0 -0
  43. package/src/assets/js/anchorScroll.js +0 -10
  44. package/src/assets/js/offset.js +0 -22
  45. package/src/assets/js/parallax.js +0 -15
  46. package/src/assets/video/.DS_Store +0 -0
  47. package/src/assets/video/Internets-Historia-HEVC-h265-HEVC-h265.mov +0 -0
  48. package/src/assets/video/Internets-Historia-HEVC-h265-vp9-chrome.webm +0 -0
  49. package/src/assets/video/chapters.vtt +0 -25
  50. package/src/assets/video/metadata.vtt +0 -25
  51. package/src/assets/video/movie-webm.webm +0 -0
  52. package/src/assets/video/videoplayer.vtt +0 -25
  53. package/src/atoms/.DS_Store +0 -0
  54. package/src/atoms/icon/step-backwards.svg +0 -1
  55. package/src/atoms/icon/step-forwards.svg +0 -1
  56. package/src/atoms/icon/subtitles.svg +0 -1
  57. package/src/molecules/.DS_Store +0 -0
  58. package/src/molecules/continue-video-guide/continue-video-guide.config.js +0 -7
  59. package/src/molecules/continue-video-guide/continue-video-guide.js +0 -84
  60. package/src/molecules/continue-video-guide/continue-video-guide.scss +0 -104
  61. package/src/molecules/continue-video-guide/readme.md +0 -3
  62. package/src/molecules/glider/_glider-course.scss +0 -121
  63. package/src/molecules/glider/_glider-hero.scss +0 -325
  64. package/src/molecules/glider/glider-hero.js +0 -17
  65. package/src/organisms/hero/_hero--dynamic-headline.scss +0 -161
  66. package/src/organisms/timeline/_timeline.scss +0 -292
  67. package/src/organisms/timeline/timeline.config.js +0 -7
  68. package/src/organisms/timeline/timeline.js +0 -146
  69. package/src/organisms/video-guide/_video-guide.scss +0 -337
  70. package/src/organisms/video-guide/video-guide.config.js +0 -17
  71. package/src/organisms/video-guide/video-guide.js +0 -293
@@ -1,337 +0,0 @@
1
- @charset "UTF-8";
2
-
3
- @include molecule(video-guide) {
4
- flex-direction: column;
5
- background-color: $color-snow;
6
-
7
- @include e(video-container) {
8
- position: relative;
9
- padding-top: 70vh;
10
- width: 100%;
11
- display: flex;
12
- justify-content: center;
13
-
14
- @include bp-up(sm) {
15
- padding-top: 76.25%;
16
- }
17
-
18
- @include bp-up(md) {
19
- padding-top: 56.25%;
20
- }
21
- }
22
-
23
- @include e(timeline-item) {
24
- position: absolute;
25
- top: 0;
26
- left: 0;
27
- right: 0;
28
- bottom: 0;
29
- z-index: 1;
30
- justify-content: center;
31
- display: none;
32
- margin: 0;
33
- padding: 0;
34
-
35
- &:first-child,
36
- &.is-current {
37
- display: flex;
38
- }
39
-
40
- img {
41
- border-radius: 0;
42
- object-fit: cover;
43
- object-position: 50% 25%;
44
- height: 100%;
45
- width: 100%;
46
- }
47
-
48
- @include e(text) {
49
- position: absolute;
50
- top: 50%;
51
- left: auto;
52
- right: auto;
53
- text-align: center;
54
- padding-left: rhythm(2);
55
- padding-right: rhythm(2);
56
-
57
- transform: translateY(-75%);
58
-
59
- @include bp-up(md) {
60
- transform: translateY(-50%);
61
- padding-left: rhythm(4);
62
- padding-right: rhythm(4);
63
- }
64
-
65
- @include bp-up(lg) {
66
- transform: translateY(-50%);
67
- }
68
-
69
- @include bp-up(xl) {
70
- left: rhythm(8);
71
- width: calc(100% - rhythm(16));
72
- max-width: 70%;
73
- text-align: left;
74
- }
75
-
76
- > h2 {
77
- font-family: $font-family-bold;
78
- color: $color-snow;
79
- text-shadow: 0 0 rem(50px) rgba($color-black, 1),
80
- 0 0 rem(10px) rgba($color-black, 1),
81
- rem(1px) rem(1px) rem(2px) rgba($color-black, 0.6);
82
- }
83
-
84
- > a {
85
- font-size: $size-base * 1.3;
86
- font-family: $font-family-headings;
87
- padding: rhythm(0.5) rhythm(2);
88
- color: $color-peacock;
89
- text-decoration: none;
90
- line-height: 1;
91
- position: relative;
92
-
93
- &::after {
94
- content: '';
95
- position: absolute;
96
- z-index: -2;
97
- width: 100%;
98
- height: 100%;
99
- background-color: rgba($color-black, 0.7);
100
- bottom: 0;
101
- left: 0;
102
- }
103
-
104
- &::before {
105
- content: '';
106
- position: absolute;
107
- z-index: -1;
108
- width: 100%;
109
- height: 100%;
110
- background-color: $color-snow;
111
- bottom: 0;
112
- left: 0;
113
- transform-origin: right;
114
- transform: scaleX(0);
115
- transition: transform .3s ease-in-out;
116
- }
117
-
118
- &:hover::before {
119
- transform-origin: left;
120
- transform: scaleX(1);
121
- }
122
- }
123
- }
124
- }
125
-
126
- @include e(video) {
127
- display: block;
128
- position: absolute;
129
- left: auto;
130
- right: auto;
131
- bottom: 0;
132
- z-index: 2;
133
- width: 150px;
134
- height: 150px;
135
-
136
- &.is-loading {
137
- background-image: url("data:image/svg+xml,%3Csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid' class='lds-ring' style='background: none;'%3E%3Ccircle cx='50' cy='50' ng-attr-r='%7B%7Bconfig.radius%7D%7D' ng-attr-stroke='%7B%7Bconfig.base%7D%7D' ng-attr-stroke-width='%7B%7Bconfig.width%7D%7D' fill='none' r='43' stroke='%23a7d8fd' stroke-width='7'%3E%3C/circle%3E%3Ccircle cx='50' cy='50' ng-attr-r='%7B%7Bconfig.radius%7D%7D' ng-attr-stroke='%7B%7Bconfig.stroke%7D%7D' ng-attr-stroke-width='%7B%7Bconfig.innerWidth%7D%7D' ng-attr-stroke-linecap='%7B%7Bconfig.linecap%7D%7D' fill='none' r='43' stroke='%2350b2fc' stroke-width='7' stroke-linecap='square' transform='rotate(27.6965 50 50)'%3E%3CanimateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;180 50 50;720 50 50' keyTimes='0;0.5;1' dur='2.5s' begin='0s' repeatCount='indefinite'%3E%3C/animateTransform%3E%3Canimate attributeName='stroke-dasharray' calcMode='linear' values='9.42477796076938 179.0707812546182;188.4955592153876 -2.842170943040401e-14;9.42477796076938 179.0707812546182' keyTimes='0;0.5;1' dur='2.5' begin='0s' repeatCount='indefinite'%3E%3C/animate%3E%3C/circle%3E%3C/svg%3E%0A");
138
- background-repeat: no-repeat;
139
- background-position: center center;
140
- background-size: 30% 30%;
141
- }
142
-
143
- @include bp-up(sm) {
144
- left: 0;
145
- }
146
-
147
- @include bp-up(lg) {
148
- width: 200px;
149
- height: 200px;
150
- }
151
-
152
- @include bp-up(xxl) {
153
- width: 250px;
154
- height: 250px;
155
- }
156
- }
157
-
158
- @include e(controls) {
159
- background-color: $color-snow;
160
- display: flex;
161
- align-items: center;
162
- justify-content: space-between;
163
- padding-top: rhythm(2);
164
- padding-bottom: rhythm(2);
165
- padding-left: rhythm(1);
166
- padding-right: rhythm(1);
167
- flex-direction: column-reverse;
168
- overflow: hidden;
169
-
170
- @include bp-up(sm) {
171
- transform: translateX(0);
172
- }
173
-
174
- @include bp-up(md) {
175
- align-items: stretch;
176
- flex-direction: row;
177
- padding-left: rhythm(2);
178
- padding-right: rhythm(2);
179
- }
180
- }
181
-
182
- @include e(title) {
183
- line-height: 1;
184
- margin-top: rhythm(1);
185
- }
186
-
187
- @include e(chapters) {
188
- width: 100%;
189
- display: flex;
190
- flex-direction: column;
191
-
192
- @include e(list) {
193
- width: 100%;
194
- height: 100%;
195
- list-style-type: none;
196
- margin: 0;
197
- padding: 0;
198
-
199
- > li {
200
- display: flex;
201
- align-items: center;
202
- background-color: $color-snow;
203
- font-size: $size-medium;
204
- display: none;
205
- line-height: 1;
206
-
207
- @include bp-up(md) {
208
- font-size: $size-medium-plus;
209
- }
210
-
211
- &.is-current-item {
212
- display: block;
213
- }
214
- }
215
- }
216
-
217
- @include bp-up(md) {
218
- align-items: stretch;
219
- }
220
- }
221
-
222
- @include e(buttons) {
223
- display: flex;
224
- width: 100%;
225
- }
226
-
227
- @include e(button) {
228
- display: flex;
229
- align-items: center;
230
- margin: 0 rhythm(1);
231
- padding: 0;
232
- border: 0;
233
- background-color: transparent;
234
-
235
- &:disabled,
236
- &:disabled:focus,
237
- &:not([class*="play"]):not([class*="subtitles"]):not([data-id]),
238
- &:disabled:focus-visible {
239
- pointer-events: none;
240
- cursor: not-allowed;
241
-
242
- > svg {
243
- fill: $color-concrete;
244
- }
245
- }
246
-
247
- &:hover {
248
- > svg {
249
- fill: $color-peacock;
250
- }
251
- }
252
-
253
- @include m(subtitles) {
254
- &.is-active {
255
- svg {
256
- fill: $color-peacock;
257
- }
258
- }
259
- }
260
- }
261
-
262
- @include e(play-icon) {
263
- width: $icon-size-large * 1.5;
264
- height: $icon-size-large * 1.5;
265
- }
266
-
267
- @include e(rewind-icon) {
268
- width: $icon-size-large;
269
- height: $icon-size-large;
270
- }
271
-
272
- @include e(forward-icon) {
273
- width: $icon-size-large;
274
- height: $icon-size-large;
275
- }
276
-
277
- @include e(subtitles-icon) {
278
- width: $icon-size-large * 1.2;
279
- height: $icon-size-large * 1.2;
280
- }
281
-
282
- @include e(subtitles) {
283
- text-align: center;
284
- width: auto;
285
- position: absolute;
286
- bottom: rhythm(1);
287
- z-index: 3;
288
- font-family: $font-family-headings;
289
- min-width: 200px;
290
- max-width: 300px;
291
- display: none;
292
- padding: rhythm(0.5) rhythm(1);
293
- line-height: 1.7;
294
-
295
- @include bp-up(sm) {
296
- font-size: $size-base;
297
- padding: rhythm(1) rhythm(2);
298
- min-width: 300px;
299
- max-width: 400px;
300
- }
301
-
302
- @include bp-up(md) {
303
- font-size: $size-base * 1.5;
304
- padding: rhythm(2) rhythm(4);
305
- min-width: 400px;
306
- max-width: 600px;
307
- }
308
-
309
- @include bp-up(lg) {
310
- font-size: $size-base * 1.7;
311
- min-width: 500px;
312
- max-width: 800px;
313
- bottom: rhythm(2);
314
- align-self: flex-end;
315
- right: rhythm(2);
316
- }
317
-
318
- &.is-visible {
319
- display: inline-block;
320
-
321
- &:empty {
322
- display: none;
323
- }
324
- }
325
-
326
- > span {
327
- background-color: rgba($color-black, 0.8);
328
- color: $color-snow;
329
- }
330
- }
331
-
332
- @include e(button-abort) {
333
- align-self: center;
334
- margin-left: auto;
335
- flex-grow: 0;
336
- }
337
- }
@@ -1,17 +0,0 @@
1
- module.exports = {
2
- status: 'prototype',
3
-
4
- context: {
5
- videoSrc: '/assets/video/Internets-Historia-HEVC-h265-vp9-chrome.webm',
6
- videoSrc2: '/assets/video/Internets-Historia-HEVC-h265-HEVC-h265.mov',
7
-
8
- variants: [
9
- {
10
- name: 'List',
11
- context: {
12
-
13
- }
14
- }
15
- ]
16
- }
17
- }
@@ -1,293 +0,0 @@
1
- const video = document.querySelector('.js-video-guide');
2
- const playBtn = document.querySelector('.js-play-btn');
3
- const playIcon = document.querySelector('.js-play-icon');
4
- const pauseIcon = document.querySelector('.js-pause-icon');
5
- const subtitlesBtn = document.querySelector('.js-subtitles-btn');
6
- const abortButton = document.querySelector('.js-abort-guide');
7
- const subtitlesElement = document.getElementById('video-subtitles');
8
- const subtitlesContainer = document.querySelector('.js-subtitles-container');
9
- const locationList = document.querySelector('.js-chapters');
10
- const chapterTrackElement = document.getElementById('video-chapters');
11
- const trackMetadataElement = document.getElementById('video-metadata');
12
- const subtitlesTrack = (subtitlesElement === null) ? '' : subtitlesElement.track;
13
- const chapterTrack = (chapterTrackElement === null) ? '' : chapterTrackElement.track;
14
- const metadataTrack = (trackMetadataElement === null) ? '' : trackMetadataElement.track;
15
- const forwardsButton = document.querySelector('.js-next-chapter');
16
- const backwardsButton = document.querySelector('.js-previous-chapter');
17
- const timelinePosts = document.querySelectorAll('.js-timeline-post');
18
- let currentChapter = 1;
19
- let manualStep = false;
20
- let sourceElement = null;
21
-
22
- // Has src attributes been set already?
23
- if (sourceElement) {
24
- document.location.reload();
25
- } else if (video) {
26
- const dataSrc = video.dataset.src;
27
-
28
- sourceElement = document.createElement('source');
29
- sourceElement.setAttribute('src', dataSrc);
30
- sourceElement.setAttribute('type', 'video/mp4');
31
-
32
- video.appendChild(sourceElement);
33
-
34
- // Store current time in on page reload
35
- window.addEventListener('unload', () => {
36
- // Set sessionStorage if video has started playing
37
- if (video.currentTime > 0) {
38
- const currentGuideURL = window.location.href;
39
- const currentGuideImage = document.querySelector('.js-guide-continue-image').src;
40
- sessionStorage.setItem('InmsCurrentTime', video.currentTime);
41
- sessionStorage.setItem('InmsDuration', video.duration); // Get totalt duration of video
42
- sessionStorage.setItem('InmsCurrentGuideURL', currentGuideURL);
43
- sessionStorage.setItem('InmsCurrentGuideImage', currentGuideImage);
44
- }
45
- });
46
-
47
- // Get value from sessionStorage in present
48
- if (sessionStorage.getItem('InmsCurrentTime')) {
49
- const videoCurrentTime = sessionStorage.getItem('InmsCurrentTime');
50
-
51
- if (videoCurrentTime > 0) {
52
- video.currentTime = videoCurrentTime;
53
- }
54
- }
55
-
56
- // Toggle subtitles
57
- if (subtitlesBtn) {
58
- subtitlesBtn.addEventListener('click', () => {
59
- subtitlesBtn.classList.toggle('is-active');
60
- subtitlesContainer.classList.toggle('is-visible');
61
- });
62
- }
63
-
64
- // Play / pause
65
- if (playBtn) {
66
- playBtn.addEventListener('click', () => {
67
- if (video.paused) {
68
- video.play();
69
- pauseIcon.classList.remove('is-hidden');
70
- playIcon.classList.add('is-hidden');
71
- manualStep = false;
72
- } else {
73
- video.pause();
74
- pauseIcon.classList.add('is-hidden');
75
- playIcon.classList.remove('is-hidden');
76
- manualStep = true;
77
- }
78
- });
79
-
80
- video.addEventListener('playing', () => {
81
- pauseIcon.classList.remove('is-hidden');
82
- playIcon.classList.add('is-hidden');
83
- manualStep = false;
84
- });
85
-
86
- video.addEventListener('ended', () => {
87
- pauseIcon.classList.add('is-hidden');
88
- playIcon.classList.remove('is-hidden');
89
- video.currentTime = 0;
90
- currentChapter = 1;
91
- manualStep = false;
92
- forwardsButton.removeAttribute('disabled');
93
- subtitlesContainer.innerHTML = '';
94
- sessionStorage.removeItem('InmsCurrentTime');
95
- sessionStorage.removeItem('InmsDuration');
96
- sessionStorage.removeItem('InmsCurrentGuideURL');
97
- sessionStorage.removeItem('InmsCurrentGuideImage');
98
- });
99
- }
100
-
101
- if (abortButton) {
102
- abortButton.addEventListener('click', (e) => {
103
- e.preventDefault();
104
- const urlTarget = abortButton.getAttribute('href');
105
- video.pause();
106
- video.currentTime = 0;
107
- forwardsButton.removeAttribute('disabled');
108
- currentChapter = 1;
109
- manualStep = false;
110
- sessionStorage.removeItem('InmsCurrentTime');
111
- sessionStorage.removeItem('InmsDuration');
112
- sessionStorage.removeItem('InmsCurrentGuideURL');
113
- sessionStorage.removeItem('InmsCurrentGuideImage');
114
- window.location.href = urlTarget;
115
- });
116
- }
117
- }
118
-
119
- function displayChapters() {
120
- if (chapterTrackElement && trackMetadataElement) {
121
- // Set all track elements to hidden mode to allow scripting
122
- [].forEach.call(video.textTracks, (txtTrack) => {
123
- txtTrack.mode = 'hidden';
124
- });
125
-
126
- if (chapterTrack.kind === 'chapters') {
127
- video.addEventListener('loadedmetadata', () => {
128
- // Loop through chapters and create chapter list
129
- // Let data load
130
- setTimeout(() => {
131
- video.classList.remove('is-loading');
132
- [].forEach.call(chapterTrack.cues, (cues) => {
133
- const chapterName = cues.text;
134
- const start = cues.startTime;
135
- const newLocale = document.createElement('li');
136
- const location = document.createElement('a');
137
-
138
- location.setAttribute('rel', start);
139
- newLocale.setAttribute('id', start);
140
- location.setAttribute('tabindex', '0');
141
-
142
- // Plain text from the chapter file into HTML text
143
- const localeDescription = chapterName;
144
- location.innerHTML = localeDescription;
145
- newLocale.appendChild(location);
146
- locationList.appendChild(newLocale);
147
-
148
- location.addEventListener('click', () => {
149
- video.currentTime = location.id;
150
- }, false);
151
- });
152
-
153
- // If not set in sessionStorgare, set first cue on forward button on page load
154
- if (!sessionStorage.getItem('InmsCurrentTime')) {
155
- forwardsButton.setAttribute('data-id', chapterTrack.cues[0].endTime);
156
- }
157
- }, 100);
158
- });
159
-
160
- forwardsButton.addEventListener('click', () => {
161
- const dataId = forwardsButton.dataset.id;
162
- let currentTime = parseInt(dataId, 10);
163
- manualStep = true;
164
- currentTime += 1;
165
- video.currentTime = currentTime;
166
- currentChapter += 1;
167
- });
168
-
169
- backwardsButton.addEventListener('click', () => {
170
- const dataId = backwardsButton.dataset.id;
171
- let lastTime = parseInt(dataId, 10);
172
- lastTime -= 1;
173
- video.currentTime = lastTime;
174
- forwardsButton.removeAttribute('disabled');
175
- manualStep = true;
176
- currentChapter -= 1;
177
-
178
- if (video.currentTime <= 0) {
179
- backwardsButton.removeAttribute('data-id');
180
- }
181
- });
182
-
183
- chapterTrack.addEventListener('cuechange', () => {
184
- // Fire this whenever the chapters changes
185
- const myCues = chapterTrack.activeCues;
186
- if (myCues.length > 0) {
187
- const currentLocation = chapterTrack.activeCues[0].startTime;
188
- const nextLocation = chapterTrack.activeCues[0].endTime;
189
- const cueMatch = chapterTrack.activeCues[0].text;
190
- const matchingCueArray = document.querySelectorAll(`[rel="${currentLocation}"]`);
191
-
192
- // Set Forward and backwards buttons timestamps
193
- forwardsButton.setAttribute('data-id', nextLocation);
194
- backwardsButton.setAttribute('data-id', currentLocation);
195
-
196
- // Add chapter stepping even when video is played
197
- if (manualStep === false) {
198
- currentChapter += 1;
199
- }
200
-
201
- // Disable forwardsbutton when on last chapter
202
- if (currentChapter >= chapterTrack.cues.length) {
203
- forwardsButton.setAttribute('disabled', 'disabled');
204
- }
205
-
206
- // Handle current and watched items
207
- [].forEach.call(matchingCueArray, (matchingCue) => {
208
- const thisChapter = matchingCue;
209
- if (thisChapter.innerHTML === cueMatch) {
210
- const chapter = thisChapter;
211
-
212
- if (chapter === thisChapter) {
213
- // get the chapter <li> elements based on the currentLocation
214
- const locations = [].slice.call(chapter.closest('figure')
215
- .querySelectorAll('.js-chapters li'));
216
-
217
- let counter = 0;
218
-
219
- [].forEach.call(locations, (location) => {
220
- // remove current classes from all items on page refresh
221
- location.classList.remove('is-current-item');
222
- location.querySelector('a').classList.remove('is-current');
223
-
224
- if (location.classList.contains('is-current-item')) {
225
- counter += 1; // iterate counter when active chapter is reached
226
- }
227
- if (counter < 1) {
228
- // add watched class to everything before the current chapter to show progress
229
- location.classList.add('is-watched');
230
- } else {
231
- // remove watched on all other items
232
- location.classList.remove('is-watched');
233
- }
234
- });
235
- chapter.parentNode.classList.add('is-current-item');
236
- chapter.classList.add('is-current');
237
- }
238
- }
239
- });
240
- }
241
- }, false);
242
-
243
- // Get timeline post IDs from metadata.vtt
244
- metadataTrack.addEventListener('cuechange', () => {
245
- const metadataCues = metadataTrack.activeCues;
246
- const chapterCues = chapterTrack.activeCues[0];
247
-
248
- if (metadataCues.length > 0) {
249
- const metadataCueMatch = metadataTrack.activeCues[0].text;
250
-
251
- [].forEach.call(timelinePosts, (timelinePost) => {
252
- timelinePost.classList.remove('is-current');
253
- });
254
-
255
- document.querySelector(`[data-id="${metadataCueMatch}"]`).classList.add('is-current');
256
-
257
- if (chapterCues) {
258
- const chapterStartTime = chapterCues.startTime;
259
-
260
- // Let stuff load
261
- let listElement;
262
- let timeOut = null;
263
-
264
- setTimeout(() => { listElement = document.getElementById(chapterStartTime); }, 100);
265
-
266
- timeOut = function wait(condition, callback) {
267
- if (typeof condition() !== 'undefined' && listElement) {
268
- listElement.classList.add('is-current-item');
269
- } else {
270
- setTimeout(() => {
271
- wait(condition, callback);
272
- }, 0);
273
- }
274
- };
275
- timeOut(() => listElement, () => { });
276
- }
277
- }
278
- }, false);
279
-
280
- // Get subtitles cues from subtitles.vtt
281
- subtitlesTrack.addEventListener('cuechange', () => {
282
- const subtitlesCues = subtitlesTrack.activeCues;
283
-
284
- if (subtitlesCues.length > 0) {
285
- const subtitlesCuesMatch = subtitlesTrack.activeCues[0].text;
286
- subtitlesContainer.innerHTML = `<span>${subtitlesCuesMatch}</span>`;
287
- }
288
- }, false);
289
- }
290
- }
291
- }
292
-
293
- displayChapters(chapterTrackElement);