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