@internetstiftelsen/styleguide 2.26.19 → 2.26.20
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/assets/js/track.js +15 -0
- package/dist/molecules/form/Form.js +0 -29
- package/dist/organisms/video-guide/VideoGuidePlayback.js +30 -39
- package/dist/organisms/video-guide/VideoGuideSubtitles.js +7 -5
- package/package.json +1 -1
- package/src/assets/js/track.js +9 -0
- package/src/organisms/video-guide/VideoGuidePlayback.js +27 -39
- package/src/organisms/video-guide/VideoGuideSubtitles.js +3 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = track;
|
|
7
|
+
function track(data) {
|
|
8
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
9
|
+
if (window._mtm) {
|
|
10
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
11
|
+
window._mtm.push(data);
|
|
12
|
+
} else {
|
|
13
|
+
console.log('GTM not loaded', data);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -53,10 +53,6 @@ var Form = function () {
|
|
|
53
53
|
_this.clearFieldErrors();
|
|
54
54
|
|
|
55
55
|
if (_this.validate()) {
|
|
56
|
-
if (_this.recaptcha) {
|
|
57
|
-
_this.captchaCallback();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
56
|
_this.send();
|
|
61
57
|
} else {
|
|
62
58
|
_this.displayError({ message: _this.i18n('Alla fält måste vara ifyllda') });
|
|
@@ -140,15 +136,6 @@ var Form = function () {
|
|
|
140
136
|
_this.events.emit('success', json);
|
|
141
137
|
};
|
|
142
138
|
|
|
143
|
-
this.captchaCallback = function () {
|
|
144
|
-
if (typeof window.grecaptcha !== 'undefined' && process.env.RECAPTCHA_KEY !== undefined) {
|
|
145
|
-
/* global grecaptcha */
|
|
146
|
-
grecaptcha.execute(process.env.RECAPTCHA_KEY, { action: _this.recaptcha }).then(function (token) {
|
|
147
|
-
_this.token = token;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
139
|
this.reset = function () {
|
|
153
140
|
_this.element.reset();
|
|
154
141
|
_this.hideMessages();
|
|
@@ -181,13 +168,6 @@ var Form = function () {
|
|
|
181
168
|
this.errors = {};
|
|
182
169
|
this.validationRules = null;
|
|
183
170
|
|
|
184
|
-
this.recaptcha = this.element.getAttribute('data-recaptcha');
|
|
185
|
-
|
|
186
|
-
if (this.recaptcha) {
|
|
187
|
-
window.captchaCallback = this.captchaCallback;
|
|
188
|
-
this.renderCaptchaForm();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
171
|
if (this.validation) {
|
|
192
172
|
this.parseValidationRules();
|
|
193
173
|
}
|
|
@@ -201,15 +181,6 @@ var Form = function () {
|
|
|
201
181
|
value: function collectInputs() {
|
|
202
182
|
this.inputs = this.element.querySelectorAll('input');
|
|
203
183
|
}
|
|
204
|
-
}, {
|
|
205
|
-
key: 'renderCaptchaForm',
|
|
206
|
-
value: function renderCaptchaForm() {
|
|
207
|
-
var s = document.createElement('script');
|
|
208
|
-
s.defer = true;
|
|
209
|
-
s.setAttribute('data-origin', this.recaptcha);
|
|
210
|
-
s.setAttribute('src', 'https://www.google.com/recaptcha/api.js?onload=captchaCallback&render=6LdtNnkUAAAAACYo0vISI-z9tOyr3djjZore-6wY&hl=sv');
|
|
211
|
-
document.body.appendChild(s);
|
|
212
|
-
}
|
|
213
184
|
}, {
|
|
214
185
|
key: 'parseValidationRules',
|
|
215
186
|
value: function parseValidationRules() {
|
|
@@ -10,6 +10,10 @@ var _getCurrentCueIndex = require('./getCurrentCueIndex');
|
|
|
10
10
|
|
|
11
11
|
var _getCurrentCueIndex2 = _interopRequireDefault(_getCurrentCueIndex);
|
|
12
12
|
|
|
13
|
+
var _track = require('../../assets/js/track');
|
|
14
|
+
|
|
15
|
+
var _track2 = _interopRequireDefault(_track);
|
|
16
|
+
|
|
13
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
18
|
|
|
15
19
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -52,15 +56,19 @@ var VideoGuidePlayback = function () {
|
|
|
52
56
|
_this.setPauseActive();
|
|
53
57
|
};
|
|
54
58
|
|
|
55
|
-
this.
|
|
59
|
+
this.resetState = function () {
|
|
56
60
|
_this.setPlayActive();
|
|
57
61
|
_this.clearState();
|
|
58
62
|
_this.setBackwardState(false);
|
|
59
63
|
_this.setForwardState(false);
|
|
60
64
|
|
|
61
65
|
_this.video.currentTime = 0;
|
|
66
|
+
};
|
|
62
67
|
|
|
63
|
-
|
|
68
|
+
this.onEnded = function () {
|
|
69
|
+
_this.resetState();
|
|
70
|
+
|
|
71
|
+
(0, _track2.default)({
|
|
64
72
|
event: 'guided_tour',
|
|
65
73
|
eventInfo: {
|
|
66
74
|
category: 'guided_tour',
|
|
@@ -72,7 +80,7 @@ var VideoGuidePlayback = function () {
|
|
|
72
80
|
|
|
73
81
|
this.onAbort = function () {
|
|
74
82
|
_this.video.pause();
|
|
75
|
-
_this.
|
|
83
|
+
_this.resetState();
|
|
76
84
|
};
|
|
77
85
|
|
|
78
86
|
this.onTimeUpdate = function () {
|
|
@@ -87,9 +95,8 @@ var VideoGuidePlayback = function () {
|
|
|
87
95
|
|
|
88
96
|
var minutes = Math.floor(timeLeft / 60);
|
|
89
97
|
var seconds = Math.floor(timeLeft % 60);
|
|
90
|
-
var formattedTimeLeft = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
91
98
|
|
|
92
|
-
_this.countDownElement.innerText =
|
|
99
|
+
_this.countDownElement.innerText = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
93
100
|
};
|
|
94
101
|
|
|
95
102
|
this.onCueChange = function () {
|
|
@@ -97,11 +104,24 @@ var VideoGuidePlayback = function () {
|
|
|
97
104
|
};
|
|
98
105
|
|
|
99
106
|
this.togglePlay = function () {
|
|
107
|
+
var label = void 0;
|
|
108
|
+
|
|
100
109
|
if (_this.video.paused) {
|
|
110
|
+
label = 'Play';
|
|
101
111
|
_this.video.play();
|
|
102
112
|
} else {
|
|
113
|
+
label = 'Pause';
|
|
103
114
|
_this.video.pause();
|
|
104
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
|
+
});
|
|
105
125
|
};
|
|
106
126
|
|
|
107
127
|
this.nextChapter = function () {
|
|
@@ -113,7 +133,7 @@ var VideoGuidePlayback = function () {
|
|
|
113
133
|
_this.video.currentTime = cues[activeCueIndex + 1].startTime + 0.01;
|
|
114
134
|
_this.updateChapterState();
|
|
115
135
|
|
|
116
|
-
|
|
136
|
+
(0, _track2.default)({
|
|
117
137
|
event: 'guided_tour',
|
|
118
138
|
eventInfo: {
|
|
119
139
|
category: 'guided_tour',
|
|
@@ -133,7 +153,7 @@ var VideoGuidePlayback = function () {
|
|
|
133
153
|
_this.video.currentTime = Math.max(0, cues[activeCueIndex - 1].startTime + 0.01);
|
|
134
154
|
_this.updateChapterState();
|
|
135
155
|
|
|
136
|
-
|
|
156
|
+
(0, _track2.default)({
|
|
137
157
|
event: 'guided_tour',
|
|
138
158
|
eventInfo: {
|
|
139
159
|
category: 'guided_tour',
|
|
@@ -144,8 +164,6 @@ var VideoGuidePlayback = function () {
|
|
|
144
164
|
}
|
|
145
165
|
};
|
|
146
166
|
|
|
147
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
148
|
-
this.dataLayer = window._mtm || [];
|
|
149
167
|
this.video = video;
|
|
150
168
|
this.playBtn = element.querySelector('.js-play-btn');
|
|
151
169
|
this.playIcon = element.querySelector('.js-play-icon');
|
|
@@ -190,9 +208,8 @@ var VideoGuidePlayback = function () {
|
|
|
190
208
|
// Format duration to minutes and seconds
|
|
191
209
|
var minutes = Math.floor(this.duration / 60);
|
|
192
210
|
var seconds = Math.floor(this.duration % 60);
|
|
193
|
-
var formattedDuration = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
194
211
|
|
|
195
|
-
this.totaltimeElement.innerText =
|
|
212
|
+
this.totaltimeElement.innerText = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
196
213
|
}
|
|
197
214
|
}, {
|
|
198
215
|
key: 'sync',
|
|
@@ -228,48 +245,22 @@ var VideoGuidePlayback = function () {
|
|
|
228
245
|
value: function setPlayActive() {
|
|
229
246
|
this.pauseIcon.classList.remove('is-hidden');
|
|
230
247
|
this.playIcon.classList.add('is-hidden');
|
|
231
|
-
|
|
232
|
-
this.dataLayer.push({
|
|
233
|
-
event: 'guided_tour',
|
|
234
|
-
eventInfo: {
|
|
235
|
-
category: 'guided_tour',
|
|
236
|
-
action: 'player_click',
|
|
237
|
-
label: 'Play'
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
248
|
}
|
|
241
249
|
}, {
|
|
242
250
|
key: 'setPauseActive',
|
|
243
251
|
value: function setPauseActive() {
|
|
244
252
|
this.pauseIcon.classList.add('is-hidden');
|
|
245
253
|
this.playIcon.classList.remove('is-hidden');
|
|
246
|
-
|
|
247
|
-
this.dataLayer.push({
|
|
248
|
-
event: 'guided_tour',
|
|
249
|
-
eventInfo: {
|
|
250
|
-
category: 'guided_tour',
|
|
251
|
-
action: 'player_click',
|
|
252
|
-
label: 'Pause'
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
254
|
}
|
|
256
255
|
}, {
|
|
257
256
|
key: 'setForwardState',
|
|
258
257
|
value: function setForwardState(active) {
|
|
259
|
-
|
|
260
|
-
this.forwardsButton.disabled = false;
|
|
261
|
-
} else {
|
|
262
|
-
this.forwardsButton.disabled = true;
|
|
263
|
-
}
|
|
258
|
+
this.forwardsButton.disabled = !active;
|
|
264
259
|
}
|
|
265
260
|
}, {
|
|
266
261
|
key: 'setBackwardState',
|
|
267
262
|
value: function setBackwardState(active) {
|
|
268
|
-
|
|
269
|
-
this.backwardsButton.disabled = false;
|
|
270
|
-
} else {
|
|
271
|
-
this.backwardsButton.disabled = true;
|
|
272
|
-
}
|
|
263
|
+
this.backwardsButton.disabled = !active;
|
|
273
264
|
}
|
|
274
265
|
}, {
|
|
275
266
|
key: 'updateChapterState',
|
|
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
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
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
|
+
|
|
9
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
16
|
|
|
11
17
|
var VideoGuideSubtitles = function () {
|
|
@@ -33,7 +39,7 @@ var VideoGuideSubtitles = function () {
|
|
|
33
39
|
_this.subtitlesBtn.classList.toggle('is-active');
|
|
34
40
|
_this.subtitlesContainer.classList.toggle('is-visible');
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
(0, _track2.default)({
|
|
37
43
|
event: 'guided_tour',
|
|
38
44
|
eventInfo: {
|
|
39
45
|
category: 'guided_tour',
|
|
@@ -41,12 +47,8 @@ var VideoGuideSubtitles = function () {
|
|
|
41
47
|
label: 'Subtitles'
|
|
42
48
|
}
|
|
43
49
|
});
|
|
44
|
-
|
|
45
|
-
console.log(_this.dataLayer);
|
|
46
50
|
};
|
|
47
51
|
|
|
48
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
49
|
-
this.dataLayer = window._mtm || [];
|
|
50
52
|
this.element = element;
|
|
51
53
|
this.video = video;
|
|
52
54
|
this.subtitlesBtn = element.querySelector('.js-subtitles-btn');
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import getCurrentCueIndex from './getCurrentCueIndex';
|
|
2
|
+
import track from '../../assets/js/track';
|
|
2
3
|
|
|
3
4
|
export default class VideoGuidePlayback {
|
|
4
5
|
constructor(element, video) {
|
|
5
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
6
|
-
this.dataLayer = window._mtm || [];
|
|
7
6
|
this.video = video;
|
|
8
7
|
this.playBtn = element.querySelector('.js-play-btn');
|
|
9
8
|
this.playIcon = element.querySelector('.js-play-icon');
|
|
@@ -44,9 +43,8 @@ export default class VideoGuidePlayback {
|
|
|
44
43
|
// Format duration to minutes and seconds
|
|
45
44
|
const minutes = Math.floor(this.duration / 60);
|
|
46
45
|
const seconds = Math.floor(this.duration % 60);
|
|
47
|
-
const formattedDuration = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
48
46
|
|
|
49
|
-
this.totaltimeElement.innerText =
|
|
47
|
+
this.totaltimeElement.innerText = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
sync() {
|
|
@@ -79,45 +77,19 @@ export default class VideoGuidePlayback {
|
|
|
79
77
|
setPlayActive() {
|
|
80
78
|
this.pauseIcon.classList.remove('is-hidden');
|
|
81
79
|
this.playIcon.classList.add('is-hidden');
|
|
82
|
-
|
|
83
|
-
this.dataLayer.push({
|
|
84
|
-
event: 'guided_tour',
|
|
85
|
-
eventInfo: {
|
|
86
|
-
category: 'guided_tour',
|
|
87
|
-
action: 'player_click',
|
|
88
|
-
label: 'Play',
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
80
|
}
|
|
92
81
|
|
|
93
82
|
setPauseActive() {
|
|
94
83
|
this.pauseIcon.classList.add('is-hidden');
|
|
95
84
|
this.playIcon.classList.remove('is-hidden');
|
|
96
|
-
|
|
97
|
-
this.dataLayer.push({
|
|
98
|
-
event: 'guided_tour',
|
|
99
|
-
eventInfo: {
|
|
100
|
-
category: 'guided_tour',
|
|
101
|
-
action: 'player_click',
|
|
102
|
-
label: 'Pause',
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
85
|
}
|
|
106
86
|
|
|
107
87
|
setForwardState(active) {
|
|
108
|
-
|
|
109
|
-
this.forwardsButton.disabled = false;
|
|
110
|
-
} else {
|
|
111
|
-
this.forwardsButton.disabled = true;
|
|
112
|
-
}
|
|
88
|
+
this.forwardsButton.disabled = !active;
|
|
113
89
|
}
|
|
114
90
|
|
|
115
91
|
setBackwardState(active) {
|
|
116
|
-
|
|
117
|
-
this.backwardsButton.disabled = false;
|
|
118
|
-
} else {
|
|
119
|
-
this.backwardsButton.disabled = true;
|
|
120
|
-
}
|
|
92
|
+
this.backwardsButton.disabled = !active;
|
|
121
93
|
}
|
|
122
94
|
|
|
123
95
|
updateChapterState() {
|
|
@@ -168,15 +140,19 @@ export default class VideoGuidePlayback {
|
|
|
168
140
|
this.setPauseActive();
|
|
169
141
|
};
|
|
170
142
|
|
|
171
|
-
|
|
143
|
+
resetState = () => {
|
|
172
144
|
this.setPlayActive();
|
|
173
145
|
this.clearState();
|
|
174
146
|
this.setBackwardState(false);
|
|
175
147
|
this.setForwardState(false);
|
|
176
148
|
|
|
177
149
|
this.video.currentTime = 0;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
onEnded = () => {
|
|
153
|
+
this.resetState();
|
|
178
154
|
|
|
179
|
-
|
|
155
|
+
track({
|
|
180
156
|
event: 'guided_tour',
|
|
181
157
|
eventInfo: {
|
|
182
158
|
category: 'guided_tour',
|
|
@@ -188,7 +164,7 @@ export default class VideoGuidePlayback {
|
|
|
188
164
|
|
|
189
165
|
onAbort = () => {
|
|
190
166
|
this.video.pause();
|
|
191
|
-
this.
|
|
167
|
+
this.resetState();
|
|
192
168
|
};
|
|
193
169
|
|
|
194
170
|
onTimeUpdate = () => {
|
|
@@ -203,9 +179,8 @@ export default class VideoGuidePlayback {
|
|
|
203
179
|
|
|
204
180
|
const minutes = Math.floor(timeLeft / 60);
|
|
205
181
|
const seconds = Math.floor(timeLeft % 60);
|
|
206
|
-
const formattedTimeLeft = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
207
182
|
|
|
208
|
-
this.countDownElement.innerText =
|
|
183
|
+
this.countDownElement.innerText = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
209
184
|
};
|
|
210
185
|
|
|
211
186
|
onCueChange = () => {
|
|
@@ -213,11 +188,24 @@ export default class VideoGuidePlayback {
|
|
|
213
188
|
};
|
|
214
189
|
|
|
215
190
|
togglePlay = () => {
|
|
191
|
+
let label;
|
|
192
|
+
|
|
216
193
|
if (this.video.paused) {
|
|
194
|
+
label = 'Play';
|
|
217
195
|
this.video.play();
|
|
218
196
|
} else {
|
|
197
|
+
label = 'Pause';
|
|
219
198
|
this.video.pause();
|
|
220
199
|
}
|
|
200
|
+
|
|
201
|
+
track({
|
|
202
|
+
event: 'guided_tour',
|
|
203
|
+
eventInfo: {
|
|
204
|
+
category: 'guided_tour',
|
|
205
|
+
action: 'player_click',
|
|
206
|
+
label,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
221
209
|
};
|
|
222
210
|
|
|
223
211
|
nextChapter = () => {
|
|
@@ -228,7 +216,7 @@ export default class VideoGuidePlayback {
|
|
|
228
216
|
this.video.currentTime = cues[activeCueIndex + 1].startTime + 0.01;
|
|
229
217
|
this.updateChapterState();
|
|
230
218
|
|
|
231
|
-
|
|
219
|
+
track({
|
|
232
220
|
event: 'guided_tour',
|
|
233
221
|
eventInfo: {
|
|
234
222
|
category: 'guided_tour',
|
|
@@ -247,7 +235,7 @@ export default class VideoGuidePlayback {
|
|
|
247
235
|
this.video.currentTime = Math.max(0, cues[activeCueIndex - 1].startTime + 0.01);
|
|
248
236
|
this.updateChapterState();
|
|
249
237
|
|
|
250
|
-
|
|
238
|
+
track({
|
|
251
239
|
event: 'guided_tour',
|
|
252
240
|
eventInfo: {
|
|
253
241
|
category: 'guided_tour',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import track from '../../assets/js/track';
|
|
2
|
+
|
|
1
3
|
export default class VideoGuideSubtitles {
|
|
2
4
|
constructor(element, video) {
|
|
3
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
4
|
-
this.dataLayer = window._mtm || [];
|
|
5
5
|
this.element = element;
|
|
6
6
|
this.video = video;
|
|
7
7
|
this.subtitlesBtn = element.querySelector('.js-subtitles-btn');
|
|
@@ -42,7 +42,7 @@ export default class VideoGuideSubtitles {
|
|
|
42
42
|
this.subtitlesBtn.classList.toggle('is-active');
|
|
43
43
|
this.subtitlesContainer.classList.toggle('is-visible');
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
track({
|
|
46
46
|
event: 'guided_tour',
|
|
47
47
|
eventInfo: {
|
|
48
48
|
category: 'guided_tour',
|
|
@@ -50,7 +50,5 @@ export default class VideoGuideSubtitles {
|
|
|
50
50
|
label: 'Subtitles',
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
|
-
|
|
54
|
-
console.log(this.dataLayer);
|
|
55
53
|
};
|
|
56
54
|
}
|