@internetstiftelsen/styleguide 5.0.19 → 5.1.1
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.
- package/dist/app.js +71 -0
- package/dist/assets/js/Events.js +43 -77
- package/dist/assets/js/RequestError.js +16 -31
- package/dist/assets/js/anchorScroll.js +22 -15
- package/dist/assets/js/charCounter.js +100 -142
- package/dist/assets/js/className.js +19 -20
- package/dist/assets/js/conditional.js +96 -152
- package/dist/assets/js/debounce.js +15 -22
- package/dist/assets/js/el.js +108 -159
- package/dist/assets/js/getCookieByName.js +13 -11
- package/dist/assets/js/hasCookieConsent.js +30 -40
- package/dist/assets/js/htmlTextLength.js +12 -10
- package/dist/assets/js/iconToggle.js +16 -20
- package/dist/assets/js/nodeAdded.js +40 -53
- package/dist/assets/js/objToQuery.js +25 -41
- package/dist/assets/js/offset.js +29 -25
- package/dist/assets/js/ot.js +10 -13
- package/dist/assets/js/parallax.js +23 -23
- package/dist/assets/js/queryToObj.js +16 -22
- package/dist/assets/js/readSpeakerHandling.js +26 -28
- package/dist/assets/js/request.js +43 -52
- package/dist/assets/js/responsivePosition.js +46 -74
- package/dist/assets/js/stringToNode.js +11 -10
- package/dist/assets/js/template.js +15 -21
- package/dist/assets/js/textToggle.js +19 -24
- package/dist/assets/js/track.js +14 -12
- package/dist/assets/js/uid.js +10 -6
- package/dist/assets/js/utmGenerator.js +27 -33
- package/dist/assets/js/validationMessage.js +18 -25
- package/dist/assets/js/youtube.js +134 -170
- package/dist/atoms/button/Button.js +42 -55
- package/dist/atoms/file/file.js +25 -29
- package/dist/atoms/file/filePreview.js +27 -31
- package/dist/atoms/grid-toggle/grid-toggle.js +6 -9
- package/dist/atoms/height-limiter/height-limiter.js +37 -50
- package/dist/atoms/password-toggle/password-toggle.js +9 -11
- package/dist/atoms/range/range.js +32 -39
- package/dist/atoms/textarea/rich-text.js +221 -251
- package/dist/atoms/tooltip/tooltip.js +13 -17
- package/dist/components.js +42 -77
- package/dist/focusTrap.js +66 -77
- package/dist/molecules/alert/alert.js +15 -20
- package/dist/molecules/context-menu/context-menu.js +11 -16
- package/dist/molecules/continue-video-guide/continue-video-guide.js +90 -101
- package/dist/molecules/cookie-disclaimer/cookie-disclaimer.js +24 -33
- package/dist/molecules/form/Form.js +242 -352
- package/dist/molecules/form/index.js +15 -14
- package/dist/molecules/glider/glider-course.js +62 -75
- package/dist/molecules/glider/glider-hero.js +88 -101
- package/dist/molecules/glider/glider.js +49 -45
- package/dist/molecules/modal/modal.js +256 -325
- package/dist/molecules/multi-select/multi-select.js +198 -304
- package/dist/molecules/natural-language-form/natural-language-form.js +32 -46
- package/dist/molecules/overview-navigation/overview-navigation.js +90 -141
- package/dist/molecules/share/share.js +15 -20
- package/dist/molecules/system-error/system-error.js +6 -9
- package/dist/organisms/accordion/accordion.js +44 -50
- package/dist/organisms/footer/footer.js +1 -1
- package/dist/organisms/haveibeenpwned/haveibeenpwned.js +17 -16
- package/dist/organisms/mailchimp/mailchimp.js +72 -89
- package/dist/organisms/map-box/map-box.js +3 -4
- package/dist/organisms/mega-menu/mega-menu.js +177 -212
- package/dist/organisms/podcast/podcast.js +192 -215
- package/dist/organisms/schedule/schedule-filter.js +9 -15
- package/dist/organisms/tabs/tabs.js +194 -253
- package/dist/organisms/timeline/openTimelineItem.js +38 -51
- package/dist/organisms/timeline/timeline.js +111 -128
- package/dist/organisms/video-guide/VideoGuidePlayback.js +210 -286
- package/dist/organisms/video-guide/VideoGuideSubtitles.js +57 -80
- package/dist/organisms/video-guide/VideoGuideTimeline.js +74 -108
- package/dist/organisms/video-guide/getCurrentCueIndex.js +11 -9
- package/dist/organisms/video-guide/video-guide.js +66 -103
- package/dist/utilities/tab-highlighting/tab-highlighting.js +14 -22
- package/dist/vendor/toggle/a11y.toggle-switcher.js +10 -16
- package/package.json +78 -99
- package/src/app.js +5 -5
- package/src/assets/js/anchorScroll.js +1 -1
- package/src/assets/js/offset.js +1 -1
- package/src/atoms/button/Button.js +1 -1
- package/src/atoms/icon/richtext-ordered-list.svg +1 -1
- package/src/atoms/icon/sprite.svg +6 -5
- package/src/molecules/glider/glider-course.js +0 -2
- package/src/molecules/glider/glider.js +2 -2
- package/src/organisms/accordion/accordion.js +1 -2
- package/src/organisms/timeline/timeline.js +2 -3
- package/dist/atoms/timeline/anchorScroll.js +0 -13
- package/dist/atoms/toggle-high-contrast/toggle-high-contrast.js +0 -12
- package/dist/molecules/glider/glider-single.js +0 -68
- package/dist/molecules/modal/modal-graph.js +0 -40
- package/dist/molecules/timeline-navigation/timeline-navigation.js +0 -34
- /package/src/atoms/icon/{heading-3.svg → richtext-heading-3.svg} +0 -0
- /package/src/molecules/alert/{_alert.scss → alert.scss} +0 -0
|
@@ -1,288 +1,212 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}, {
|
|
215
|
-
key: 'sync',
|
|
216
|
-
value: function sync() {
|
|
217
|
-
var key = this.sessionKeys.currentTime;
|
|
218
|
-
var guideURL = window.location.href;
|
|
219
|
-
|
|
220
|
-
// If the current guide URL is not the same as the one in session storage, do not sync
|
|
221
|
-
if (sessionStorage.getItem(this.sessionKeys.currentGuideURL) !== guideURL) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (sessionStorage.getItem(key)) {
|
|
226
|
-
var videoCurrentTime = sessionStorage.getItem(key);
|
|
227
|
-
|
|
228
|
-
if (videoCurrentTime > 0) {
|
|
229
|
-
this.video.currentTime = videoCurrentTime;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}, {
|
|
234
|
-
key: 'attach',
|
|
235
|
-
value: function attach() {
|
|
236
|
-
this.playBtn.addEventListener('click', this.togglePlay);
|
|
237
|
-
this.forwardsButton.addEventListener('click', this.nextChapter);
|
|
238
|
-
this.backwardsButton.addEventListener('click', this.previousChapter);
|
|
239
|
-
|
|
240
|
-
window.addEventListener('visibilitychange', this.saveState);
|
|
241
|
-
window.addEventListener('beforeunload', this.saveState);
|
|
242
|
-
}
|
|
243
|
-
}, {
|
|
244
|
-
key: 'setPlayActive',
|
|
245
|
-
value: function setPlayActive() {
|
|
246
|
-
this.pauseIcon.classList.remove('is-hidden');
|
|
247
|
-
this.playIcon.classList.add('is-hidden');
|
|
248
|
-
}
|
|
249
|
-
}, {
|
|
250
|
-
key: 'setPauseActive',
|
|
251
|
-
value: function setPauseActive() {
|
|
252
|
-
this.pauseIcon.classList.add('is-hidden');
|
|
253
|
-
this.playIcon.classList.remove('is-hidden');
|
|
254
|
-
}
|
|
255
|
-
}, {
|
|
256
|
-
key: 'setForwardState',
|
|
257
|
-
value: function setForwardState(active) {
|
|
258
|
-
this.forwardsButton.disabled = !active;
|
|
259
|
-
}
|
|
260
|
-
}, {
|
|
261
|
-
key: 'setBackwardState',
|
|
262
|
-
value: function setBackwardState(active) {
|
|
263
|
-
this.backwardsButton.disabled = !active;
|
|
264
|
-
}
|
|
265
|
-
}, {
|
|
266
|
-
key: 'updateChapterState',
|
|
267
|
-
value: function updateChapterState() {
|
|
268
|
-
var cues = this.chapters.cues;
|
|
269
|
-
|
|
270
|
-
var activeCueIndex = (0, _getCurrentCueIndex2.default)(this.chapters);
|
|
271
|
-
|
|
272
|
-
this.setBackwardState(activeCueIndex > 0);
|
|
273
|
-
this.setForwardState(activeCueIndex < cues.length - 1);
|
|
274
|
-
|
|
275
|
-
this.chapterElements.forEach(function (chapter, i) {
|
|
276
|
-
if (i === activeCueIndex) {
|
|
277
|
-
chapter.classList.add('is-current-item');
|
|
278
|
-
} else {
|
|
279
|
-
chapter.classList.remove('is-current-item');
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}]);
|
|
284
|
-
|
|
285
|
-
return VideoGuidePlayback;
|
|
286
|
-
}();
|
|
287
|
-
|
|
288
|
-
exports.default = VideoGuidePlayback;
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return VideoGuidePlayback;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _getCurrentCueIndex = /*#__PURE__*/ _interop_require_default(require("./getCurrentCueIndex"));
|
|
12
|
+
const _track = /*#__PURE__*/ _interop_require_default(require("../../assets/js/track"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
class VideoGuidePlayback {
|
|
19
|
+
init() {
|
|
20
|
+
this.duration = this.video.duration;
|
|
21
|
+
this.chapters = this.video.textTracks.getTrackById('video-chapters');
|
|
22
|
+
if (this.chapters) {
|
|
23
|
+
this.chapters.addEventListener('cuechange', this.onCueChange);
|
|
24
|
+
this.setForwardState(true);
|
|
25
|
+
}
|
|
26
|
+
// Run on next tick to ensure that the video has loaded and event listeners are attached
|
|
27
|
+
setTimeout(()=>{
|
|
28
|
+
this.sync();
|
|
29
|
+
}, 0);
|
|
30
|
+
// Format duration to minutes and seconds
|
|
31
|
+
const minutes = Math.floor(this.duration / 60);
|
|
32
|
+
const seconds = Math.floor(this.duration % 60);
|
|
33
|
+
this.totaltimeElement.innerText = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
34
|
+
}
|
|
35
|
+
sync() {
|
|
36
|
+
const key = this.sessionKeys.currentTime;
|
|
37
|
+
const guideURL = window.location.href;
|
|
38
|
+
// If the current guide URL is not the same as the one in session storage, do not sync
|
|
39
|
+
if (sessionStorage.getItem(this.sessionKeys.currentGuideURL) !== guideURL) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (sessionStorage.getItem(key)) {
|
|
43
|
+
const videoCurrentTime = sessionStorage.getItem(key);
|
|
44
|
+
if (videoCurrentTime > 0) {
|
|
45
|
+
this.video.currentTime = videoCurrentTime;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
attach() {
|
|
50
|
+
this.playBtn.addEventListener('click', this.togglePlay);
|
|
51
|
+
this.forwardsButton.addEventListener('click', this.nextChapter);
|
|
52
|
+
this.backwardsButton.addEventListener('click', this.previousChapter);
|
|
53
|
+
window.addEventListener('visibilitychange', this.saveState);
|
|
54
|
+
window.addEventListener('beforeunload', this.saveState);
|
|
55
|
+
}
|
|
56
|
+
setPlayActive() {
|
|
57
|
+
this.pauseIcon.classList.remove('is-hidden');
|
|
58
|
+
this.playIcon.classList.add('is-hidden');
|
|
59
|
+
}
|
|
60
|
+
setPauseActive() {
|
|
61
|
+
this.pauseIcon.classList.add('is-hidden');
|
|
62
|
+
this.playIcon.classList.remove('is-hidden');
|
|
63
|
+
}
|
|
64
|
+
setForwardState(active) {
|
|
65
|
+
this.forwardsButton.disabled = !active;
|
|
66
|
+
}
|
|
67
|
+
setBackwardState(active) {
|
|
68
|
+
this.backwardsButton.disabled = !active;
|
|
69
|
+
}
|
|
70
|
+
updateChapterState() {
|
|
71
|
+
const { cues } = this.chapters;
|
|
72
|
+
const activeCueIndex = (0, _getCurrentCueIndex.default)(this.chapters);
|
|
73
|
+
this.setBackwardState(activeCueIndex > 0);
|
|
74
|
+
this.setForwardState(activeCueIndex < cues.length - 1);
|
|
75
|
+
this.chapterElements.forEach((chapter, i)=>{
|
|
76
|
+
if (i === activeCueIndex) {
|
|
77
|
+
chapter.classList.add('is-current-item');
|
|
78
|
+
} else {
|
|
79
|
+
chapter.classList.remove('is-current-item');
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
constructor(element, video){
|
|
84
|
+
this.saveState = ()=>{
|
|
85
|
+
if (this.video.currentTime > 0) {
|
|
86
|
+
const { currentTime, duration, currentGuideURL, currentGuideImage } = this.sessionKeys;
|
|
87
|
+
const guideURL = window.location.href;
|
|
88
|
+
const guideImage = this.video.dataset.featuredImage;
|
|
89
|
+
sessionStorage.setItem(currentTime, this.video.currentTime);
|
|
90
|
+
sessionStorage.setItem(duration, this.video.duration);
|
|
91
|
+
sessionStorage.setItem(currentGuideURL, guideURL);
|
|
92
|
+
sessionStorage.setItem(currentGuideImage, guideImage);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
this.clearState = ()=>{
|
|
96
|
+
Object.values(this.sessionKeys).forEach((key)=>{
|
|
97
|
+
sessionStorage.removeItem(key);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
this.onPlay = ()=>{
|
|
101
|
+
this.setPlayActive();
|
|
102
|
+
};
|
|
103
|
+
this.onPause = ()=>{
|
|
104
|
+
this.setPauseActive();
|
|
105
|
+
};
|
|
106
|
+
this.resetState = ()=>{
|
|
107
|
+
this.setPauseActive();
|
|
108
|
+
this.clearState();
|
|
109
|
+
this.setBackwardState(false);
|
|
110
|
+
this.setForwardState(false);
|
|
111
|
+
this.video.currentTime = 0;
|
|
112
|
+
};
|
|
113
|
+
this.onEnded = ()=>{
|
|
114
|
+
this.resetState();
|
|
115
|
+
(0, _track.default)({
|
|
116
|
+
event: 'guided_tour',
|
|
117
|
+
eventInfo: {
|
|
118
|
+
category: 'guided_tour',
|
|
119
|
+
action: 'guide_completed',
|
|
120
|
+
label: window.location.href
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
this.onAbort = ()=>{
|
|
125
|
+
this.video.pause();
|
|
126
|
+
this.resetState();
|
|
127
|
+
};
|
|
128
|
+
this.onTimeUpdate = ()=>{
|
|
129
|
+
const timeLeft = Math.floor(this.duration - this.video.currentTime);
|
|
130
|
+
// Time update fires every 250ms, so we only want to update the DOM when the time left changes
|
|
131
|
+
if (timeLeft === this.timeLeft) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this.timeLeft = timeLeft;
|
|
135
|
+
const minutes = Math.floor(timeLeft / 60);
|
|
136
|
+
const seconds = Math.floor(timeLeft % 60);
|
|
137
|
+
this.countDownElement.innerText = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
138
|
+
};
|
|
139
|
+
this.onCueChange = ()=>{
|
|
140
|
+
this.updateChapterState();
|
|
141
|
+
};
|
|
142
|
+
this.togglePlay = ()=>{
|
|
143
|
+
let label;
|
|
144
|
+
if (this.video.paused) {
|
|
145
|
+
label = 'Play';
|
|
146
|
+
this.video.play();
|
|
147
|
+
} else {
|
|
148
|
+
label = 'Pause';
|
|
149
|
+
this.video.pause();
|
|
150
|
+
}
|
|
151
|
+
(0, _track.default)({
|
|
152
|
+
event: 'guided_tour',
|
|
153
|
+
eventInfo: {
|
|
154
|
+
category: 'guided_tour',
|
|
155
|
+
action: 'player_click',
|
|
156
|
+
label
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
this.nextChapter = ()=>{
|
|
161
|
+
const { cues } = this.chapters;
|
|
162
|
+
const activeCueIndex = (0, _getCurrentCueIndex.default)(this.chapters);
|
|
163
|
+
if (activeCueIndex < cues.length - 1) {
|
|
164
|
+
this.video.currentTime = cues[activeCueIndex + 1].startTime + 0.01;
|
|
165
|
+
this.updateChapterState();
|
|
166
|
+
(0, _track.default)({
|
|
167
|
+
event: 'guided_tour',
|
|
168
|
+
eventInfo: {
|
|
169
|
+
category: 'guided_tour',
|
|
170
|
+
action: 'player_click',
|
|
171
|
+
label: 'Forward'
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
this.previousChapter = ()=>{
|
|
177
|
+
const { cues } = this.chapters;
|
|
178
|
+
const activeCueIndex = (0, _getCurrentCueIndex.default)(this.chapters);
|
|
179
|
+
if (activeCueIndex > 0) {
|
|
180
|
+
this.video.currentTime = Math.max(0, cues[activeCueIndex - 1].startTime + 0.01);
|
|
181
|
+
this.updateChapterState();
|
|
182
|
+
(0, _track.default)({
|
|
183
|
+
event: 'guided_tour',
|
|
184
|
+
eventInfo: {
|
|
185
|
+
category: 'guided_tour',
|
|
186
|
+
action: 'player_click',
|
|
187
|
+
label: 'Backward'
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
this.video = video;
|
|
193
|
+
this.playBtn = element.querySelector('.js-play-btn');
|
|
194
|
+
this.playIcon = element.querySelector('.js-play-icon');
|
|
195
|
+
this.pauseIcon = element.querySelector('.js-pause-icon');
|
|
196
|
+
this.forwardsButton = element.querySelector('.js-next-chapter');
|
|
197
|
+
this.backwardsButton = element.querySelector('.js-previous-chapter');
|
|
198
|
+
this.totaltimeElement = element.querySelector('.js-totaltime');
|
|
199
|
+
this.countDownElement = element.querySelector('.js-countdown');
|
|
200
|
+
this.chapterElements = Array.from(element.querySelectorAll('.js-chapters li'));
|
|
201
|
+
this.sessionKeys = {
|
|
202
|
+
currentTime: 'InmsCurrentTime',
|
|
203
|
+
duration: 'InmsDuration',
|
|
204
|
+
currentGuideURL: 'InmsCurrentGuideURL',
|
|
205
|
+
currentGuideImage: 'InmsCurrentGuideImage'
|
|
206
|
+
};
|
|
207
|
+
this.duration = null;
|
|
208
|
+
this.timeLeft = null;
|
|
209
|
+
this.init();
|
|
210
|
+
this.attach();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -1,82 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function
|
|
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
|
-
_createClass(VideoGuideSubtitles, [{
|
|
62
|
-
key: 'init',
|
|
63
|
-
value: function init() {
|
|
64
|
-
this.subtitles = this.video.textTracks.getTrackById('video-subtitles');
|
|
65
|
-
}
|
|
66
|
-
}, {
|
|
67
|
-
key: 'attach',
|
|
68
|
-
value: function attach() {
|
|
69
|
-
this.subtitlesBtn.addEventListener('click', this.toggleSubtitles);
|
|
70
|
-
this.subtitles.addEventListener('cuechange', this.onCueChange);
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
|
-
key: 'clearSubtitles',
|
|
74
|
-
value: function clearSubtitles() {
|
|
75
|
-
this.subtitlesContainer.innerHTML = '';
|
|
76
|
-
}
|
|
77
|
-
}]);
|
|
78
|
-
|
|
79
|
-
return VideoGuideSubtitles;
|
|
80
|
-
}();
|
|
81
|
-
|
|
82
|
-
exports.default = VideoGuideSubtitles;
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return VideoGuideSubtitles;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _track = /*#__PURE__*/ _interop_require_default(require("../../assets/js/track"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
class VideoGuideSubtitles {
|
|
18
|
+
init() {
|
|
19
|
+
this.subtitles = this.video.textTracks.getTrackById('video-subtitles');
|
|
20
|
+
}
|
|
21
|
+
attach() {
|
|
22
|
+
this.subtitlesBtn.addEventListener('click', this.toggleSubtitles);
|
|
23
|
+
this.subtitles.addEventListener('cuechange', this.onCueChange);
|
|
24
|
+
}
|
|
25
|
+
clearSubtitles() {
|
|
26
|
+
this.subtitlesContainer.innerHTML = '';
|
|
27
|
+
}
|
|
28
|
+
constructor(element, video){
|
|
29
|
+
this.onEnded = ()=>{
|
|
30
|
+
this.clearSubtitles();
|
|
31
|
+
};
|
|
32
|
+
this.onCueChange = ()=>{
|
|
33
|
+
const { activeCues } = this.subtitles;
|
|
34
|
+
if (activeCues.length > 0) {
|
|
35
|
+
this.subtitlesContainer.innerHTML = `<span>${activeCues[0].text}</span>`;
|
|
36
|
+
} else {
|
|
37
|
+
this.clearSubtitles();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.toggleSubtitles = ()=>{
|
|
41
|
+
this.subtitlesBtn.classList.toggle('is-active');
|
|
42
|
+
this.subtitlesContainer.classList.toggle('is-visible');
|
|
43
|
+
(0, _track.default)({
|
|
44
|
+
event: 'guided_tour',
|
|
45
|
+
eventInfo: {
|
|
46
|
+
category: 'guided_tour',
|
|
47
|
+
action: 'player_click',
|
|
48
|
+
label: 'Subtitles'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
this.element = element;
|
|
53
|
+
this.video = video;
|
|
54
|
+
this.subtitlesBtn = element.querySelector('.js-subtitles-btn');
|
|
55
|
+
this.subtitlesContainer = element.querySelector('.js-subtitles-container');
|
|
56
|
+
this.init();
|
|
57
|
+
this.attach();
|
|
58
|
+
}
|
|
59
|
+
}
|