@internetstiftelsen/styleguide 2.24.0-beta.0.1 → 2.24.0
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/youtube.js +8 -0
- package/dist/molecules/form/Form.js +1 -1
- package/dist/molecules/glider/glider-hero.js +39 -0
- package/dist/organisms/timeline/timeline.js +89 -1
- package/dist/organisms/video-guide/video-guide.js +3 -49
- package/package.json +1 -1
- package/src/app.js +1 -1
- package/src/app.scss +3 -0
- package/src/assets/js/youtube.js +5 -0
- package/src/assets/video/metadata.vtt +9 -9
- package/src/atoms/tag/_tag.scss +1 -0
- package/src/atoms/tag/tag.config.js +10 -0
- package/src/components.js +6 -3
- package/src/configurations/forms/_fields.scss +8 -0
- package/src/globals.scss +1 -27
- package/src/molecules/continue-video-guide/continue-video-guide.config.js +7 -0
- package/src/molecules/continue-video-guide/continue-video-guide.js +84 -0
- package/src/molecules/continue-video-guide/continue-video-guide.scss +110 -0
- package/src/molecules/continue-video-guide/readme.md +3 -0
- package/src/molecules/form/Form.js +1 -1
- package/src/molecules/glider/_glider-hero.scss +1 -6
- package/src/molecules/glider/glider-hero.js +39 -0
- package/src/molecules/natural-language-form/_natural-language-form.scss +8 -0
- package/src/organisms/event-listing-item/_event-listing-item.scss +3 -1
- package/src/organisms/hero/_hero.scss +20 -0
- package/src/organisms/hero/hero.config.js +15 -1
- package/src/organisms/timeline/_timeline.scss +328 -0
- package/src/organisms/timeline/timeline.config.js +7 -0
- package/src/organisms/timeline/timeline.js +185 -0
- package/src/organisms/video-guide/_video-guide.scss +508 -0
- package/src/organisms/video-guide/video-guide.config.js +17 -0
- package/src/organisms/video-guide/video-guide.js +261 -0
- package/src/structures/_article.scss +1 -1
- package/src/utilities/_gutter.scss +1 -1
- package/src/utilities/_manifest.scss +29 -0
|
@@ -21,6 +21,9 @@ function onPlayerStateChange(el, e) {
|
|
|
21
21
|
if (e.data === YT.PlayerState.PLAYING) {
|
|
22
22
|
el.getElementsByTagName('img')[0].style.zIndex = '-1';
|
|
23
23
|
el.getElementsByTagName('button')[0].style.display = 'none';
|
|
24
|
+
} else if (e.data === YT.PlayerState.UNSTARTED) {
|
|
25
|
+
el.getElementsByTagName('img')[0].style.zIndex = null;
|
|
26
|
+
el.getElementsByTagName('button')[0].style.display = null;
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
|
|
@@ -44,6 +47,11 @@ function setupYoutubePlayer(el) {
|
|
|
44
47
|
el.youtube.destroy();
|
|
45
48
|
el.youtube = null;
|
|
46
49
|
el.removeAttribute('data-youtube-ready');
|
|
50
|
+
<<<<<<< HEAD
|
|
51
|
+
=======
|
|
52
|
+
el.getElementsByTagName('img')[0].style.zIndex = null;
|
|
53
|
+
el.getElementsByTagName('button')[0].style.display = null;
|
|
54
|
+
>>>>>>> feature/open-timelineitem
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
playerEl = document.createElement('div');
|
|
@@ -7,6 +7,8 @@ var _gliderJs2 = _interopRequireDefault(_gliderJs);
|
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
8
|
|
|
9
9
|
var gliderElementHero = document.querySelector('.js-glider-hero');
|
|
10
|
+
var dataLayer = window.dataLayer || [];
|
|
11
|
+
var gliderLinks = document.querySelectorAll('.glider-slide a');
|
|
10
12
|
|
|
11
13
|
if (gliderElementHero) {
|
|
12
14
|
var GliderHero = new _gliderJs2.default(gliderElementHero, {
|
|
@@ -41,6 +43,43 @@ if (gliderElementHero) {
|
|
|
41
43
|
}, autoplayDelay);
|
|
42
44
|
}
|
|
43
45
|
}, 0);
|
|
46
|
+
} else {
|
|
47
|
+
document.querySelector('.js-glider-prev').addEventListener('click', function () {
|
|
48
|
+
dataLayer.push({
|
|
49
|
+
event: 'carousel',
|
|
50
|
+
eventInfo: {
|
|
51
|
+
category: 'carousel',
|
|
52
|
+
action: 'click',
|
|
53
|
+
label: 'arrow_left'
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
document.querySelector('.js-glider-next').addEventListener('click', function () {
|
|
59
|
+
dataLayer.push({
|
|
60
|
+
event: 'carousel',
|
|
61
|
+
eventInfo: {
|
|
62
|
+
category: 'carousel',
|
|
63
|
+
action: 'click',
|
|
64
|
+
label: 'arrow_right'
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
[].forEach.call(gliderLinks, function (gliderLink) {
|
|
70
|
+
gliderLink.addEventListener('click', function () {
|
|
71
|
+
var linkTarget = gliderLink.href;
|
|
72
|
+
console.log(linkTarget);
|
|
73
|
+
dataLayer.push({
|
|
74
|
+
event: 'carousel',
|
|
75
|
+
eventInfo: {
|
|
76
|
+
category: 'carousel',
|
|
77
|
+
action: 'click',
|
|
78
|
+
label: linkTarget
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
44
83
|
}
|
|
45
84
|
|
|
46
85
|
module.exports = GliderHero;
|
|
@@ -7,6 +7,7 @@ var _require = require('../../assets/js/offset'),
|
|
|
7
7
|
offsetBottom = _require.offsetBottom,
|
|
8
8
|
offsetLeft = _require.offsetLeft;
|
|
9
9
|
|
|
10
|
+
var dataLayer = window.dataLayer || [];
|
|
10
11
|
var progressBar = document.querySelector('.js-progress-bar');
|
|
11
12
|
var decadeContainer = document.querySelector('.js-decade-container');
|
|
12
13
|
var decadeSections = document.querySelectorAll('.js-timeline-decade');
|
|
@@ -84,6 +85,39 @@ function animateProgressBar() {
|
|
|
84
85
|
progressBar.style.width = progressBarWidth + 'px';
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
function isInViewport(element) {
|
|
89
|
+
var top = element.offsetTop;
|
|
90
|
+
var height = element.offsetHeight;
|
|
91
|
+
|
|
92
|
+
while (element.offsetParent) {
|
|
93
|
+
element = element.offsetParent; // eslint-disable-line
|
|
94
|
+
top += element.offsetTop;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return top < window.pageYOffset + window.innerHeight && top + height > window.pageYOffset;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function decadeIsVisible() {
|
|
101
|
+
[].forEach.call(decadeSections, function (decadeSection) {
|
|
102
|
+
if (isInViewport(decadeSection) && !decadeSection.classList.contains('is-in-view')) {
|
|
103
|
+
decadeSection.classList.add('is-in-view');
|
|
104
|
+
|
|
105
|
+
var decade = decadeSection.id;
|
|
106
|
+
|
|
107
|
+
dataLayer.push({
|
|
108
|
+
event: 'timeline',
|
|
109
|
+
eventInfo: {
|
|
110
|
+
category: 'timeline',
|
|
111
|
+
action: 'active_year',
|
|
112
|
+
label: decade
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
} else if (!isInViewport(decadeSection)) {
|
|
116
|
+
decadeSection.classList.remove('is-in-view');
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
87
121
|
// Run functions on page load
|
|
88
122
|
if (progressBar) {
|
|
89
123
|
buildTimelineNavigation();
|
|
@@ -97,10 +131,12 @@ if (progressBar) {
|
|
|
97
131
|
});
|
|
98
132
|
window.addEventListener('scroll', function () {
|
|
99
133
|
animateProgressBar();
|
|
134
|
+
decadeIsVisible();
|
|
100
135
|
});
|
|
101
136
|
}
|
|
102
137
|
|
|
103
138
|
// DUMMY TIMELINE ITEM OPEN/CLOSE
|
|
139
|
+
<<<<<<< HEAD
|
|
104
140
|
/*
|
|
105
141
|
function wrap(el, wrapper) {
|
|
106
142
|
el.parentNode.insertBefore(wrapper, el);
|
|
@@ -152,4 +188,56 @@ let timeLineItemScrollPosition = 0;
|
|
|
152
188
|
timeLineItemClose.click();
|
|
153
189
|
});
|
|
154
190
|
});
|
|
155
|
-
*/
|
|
191
|
+
*/
|
|
192
|
+
=======
|
|
193
|
+
// function wrap(el, wrapper) {
|
|
194
|
+
// el.parentNode.insertBefore(wrapper, el);
|
|
195
|
+
// wrapper.classList.add('wrapper');
|
|
196
|
+
// wrapper.appendChild(el);
|
|
197
|
+
// }
|
|
198
|
+
//
|
|
199
|
+
// const timeLineItems = document.querySelectorAll('.js-timeline-item');
|
|
200
|
+
// let timeLineItemScrollPosition = 0;
|
|
201
|
+
//
|
|
202
|
+
// [].forEach.call(timeLineItems, (timeLineItem) => {
|
|
203
|
+
// const timeLineItemLink = timeLineItem.querySelector('a');
|
|
204
|
+
// const timeLineItemClose = timeLineItem.querySelector('.js-timeline-item-close');
|
|
205
|
+
// const timeLineItemBottomClose = timeLineItem.querySelector('.js-timeline-item-bottom-close');
|
|
206
|
+
//
|
|
207
|
+
// timeLineItemLink.addEventListener('click', () => {
|
|
208
|
+
// timeLineItemScrollPosition = window.pageYOffset;
|
|
209
|
+
// sessionStorage.setItem('scroll-position', timeLineItemScrollPosition);
|
|
210
|
+
//
|
|
211
|
+
// if (!timeLineItem.classList.contains('is-open')) {
|
|
212
|
+
// timeLineItem.classList.add('is-open');
|
|
213
|
+
// timeLineItem.closest('.row').classList.add('row-has-open-child');
|
|
214
|
+
//
|
|
215
|
+
// // Wrap open timeline item
|
|
216
|
+
// wrap(timeLineItem.querySelector('.wp-block-iis-timeline-post'),
|
|
217
|
+
// document.createElement('div'));
|
|
218
|
+
// }
|
|
219
|
+
// });
|
|
220
|
+
//
|
|
221
|
+
// timeLineItemClose.addEventListener('click', () => {
|
|
222
|
+
// timeLineItem.classList.remove('is-open');
|
|
223
|
+
// timeLineItem.closest('.row').classList.remove('row-has-open-child');
|
|
224
|
+
//
|
|
225
|
+
// // Destroy generated wrapper
|
|
226
|
+
// const wrapper = timeLineItemClose.nextElementSibling;
|
|
227
|
+
// wrapper.replaceWith(...wrapper.childNodes);
|
|
228
|
+
//
|
|
229
|
+
// const top = sessionStorage.getItem('scroll-position');
|
|
230
|
+
// if (top !== null) {
|
|
231
|
+
// window.scrollTo(0, parseInt(top, 10));
|
|
232
|
+
// }
|
|
233
|
+
// sessionStorage.removeItem('scroll-position');
|
|
234
|
+
//
|
|
235
|
+
// // Trigger scroll event to reveal timeline items not yet parallaxed into view
|
|
236
|
+
// window.dispatchEvent(new CustomEvent('scroll'));
|
|
237
|
+
// });
|
|
238
|
+
//
|
|
239
|
+
// timeLineItemBottomClose.addEventListener('click', () => {
|
|
240
|
+
// timeLineItemClose.click();
|
|
241
|
+
// });
|
|
242
|
+
// });
|
|
243
|
+
>>>>>>> feature/open-timelineitem
|
|
@@ -8,7 +8,6 @@ var subtitlesBtn = document.querySelector('.js-subtitles-btn');
|
|
|
8
8
|
var abortButton = document.querySelector('.js-abort-guide');
|
|
9
9
|
var subtitlesElement = document.getElementById('video-subtitles');
|
|
10
10
|
var subtitlesContainer = document.querySelector('.js-subtitles-container');
|
|
11
|
-
var locationList = document.querySelector('.js-chapters');
|
|
12
11
|
var chapterTrackElement = document.getElementById('video-chapters');
|
|
13
12
|
var trackMetadataElement = document.getElementById('video-metadata');
|
|
14
13
|
var subtitlesTrack = subtitlesElement === null ? '' : subtitlesElement.track;
|
|
@@ -19,28 +18,17 @@ var backwardsButton = document.querySelector('.js-previous-chapter');
|
|
|
19
18
|
var timelinePosts = document.querySelectorAll('.js-timeline-post');
|
|
20
19
|
var navigationButton = document.querySelector('.js-show-timelineposts');
|
|
21
20
|
var timeLinePosts = document.querySelector('.js-timeline-posts');
|
|
22
|
-
var currentChapter =
|
|
21
|
+
var currentChapter = 0;
|
|
23
22
|
var manualStep = false;
|
|
24
|
-
var sourceElement = null;
|
|
25
23
|
|
|
26
24
|
// Has src attributes been set already?
|
|
27
|
-
if (
|
|
28
|
-
document.location.reload();
|
|
29
|
-
} else if (video) {
|
|
30
|
-
var dataSrc = video.dataset.src;
|
|
31
|
-
|
|
32
|
-
sourceElement = document.createElement('source');
|
|
33
|
-
sourceElement.setAttribute('src', dataSrc);
|
|
34
|
-
sourceElement.setAttribute('type', 'video/mp4');
|
|
35
|
-
|
|
36
|
-
video.appendChild(sourceElement);
|
|
37
|
-
|
|
25
|
+
if (video) {
|
|
38
26
|
// Store current time in on page reload
|
|
39
27
|
window.addEventListener('unload', function () {
|
|
40
28
|
// Set localStorage if video has started playing
|
|
41
29
|
if (video.currentTime > 0) {
|
|
42
30
|
var currentGuideURL = window.location.href;
|
|
43
|
-
var currentGuideImage =
|
|
31
|
+
var currentGuideImage = video.dataset.featuredImage;
|
|
44
32
|
localStorage.setItem('InmsCurrentTime', video.currentTime);
|
|
45
33
|
localStorage.setItem('InmsDuration', video.duration); // Get totalt duration of video
|
|
46
34
|
localStorage.setItem('InmsCurrentGuideURL', currentGuideURL);
|
|
@@ -140,26 +128,6 @@ function displayChapters() {
|
|
|
140
128
|
// Let data load
|
|
141
129
|
setTimeout(function () {
|
|
142
130
|
video.classList.remove('is-loading');
|
|
143
|
-
[].forEach.call(chapterTrack.cues, function (cues) {
|
|
144
|
-
var chapterName = cues.text;
|
|
145
|
-
var start = cues.startTime;
|
|
146
|
-
var newLocale = document.createElement('li');
|
|
147
|
-
var location = document.createElement('a');
|
|
148
|
-
|
|
149
|
-
location.setAttribute('rel', start);
|
|
150
|
-
newLocale.setAttribute('id', start);
|
|
151
|
-
location.setAttribute('tabindex', '0');
|
|
152
|
-
|
|
153
|
-
// Plain text from the chapter file into HTML text
|
|
154
|
-
var localeDescription = chapterName;
|
|
155
|
-
location.innerHTML = localeDescription;
|
|
156
|
-
newLocale.appendChild(location);
|
|
157
|
-
locationList.appendChild(newLocale);
|
|
158
|
-
|
|
159
|
-
location.addEventListener('click', function () {
|
|
160
|
-
video.currentTime = location.id;
|
|
161
|
-
}, false);
|
|
162
|
-
});
|
|
163
131
|
|
|
164
132
|
// If not set in sessionStorgare, set first cue on forward button on page load
|
|
165
133
|
if (!localStorage.getItem('InmsCurrentTime')) {
|
|
@@ -224,23 +192,10 @@ function displayChapters() {
|
|
|
224
192
|
// get the chapter <li> elements based on the currentLocation
|
|
225
193
|
var locations = [].slice.call(chapter.closest('figure').querySelectorAll('.js-chapters li'));
|
|
226
194
|
|
|
227
|
-
var counter = 0;
|
|
228
|
-
|
|
229
195
|
[].forEach.call(locations, function (location) {
|
|
230
196
|
// remove current classes from all items on page refresh
|
|
231
197
|
location.classList.remove('is-current-item');
|
|
232
198
|
location.querySelector('a').classList.remove('is-current');
|
|
233
|
-
|
|
234
|
-
if (location.classList.contains('is-current-item')) {
|
|
235
|
-
counter += 1; // iterate counter when active chapter is reached
|
|
236
|
-
}
|
|
237
|
-
if (counter < 1) {
|
|
238
|
-
// add watched class to everything before the current chapter to show progress
|
|
239
|
-
location.classList.add('is-watched');
|
|
240
|
-
} else {
|
|
241
|
-
// remove watched on all other items
|
|
242
|
-
location.classList.remove('is-watched');
|
|
243
|
-
}
|
|
244
199
|
});
|
|
245
200
|
chapter.parentNode.classList.add('is-current-item');
|
|
246
201
|
chapter.classList.add('is-current');
|
|
@@ -266,7 +221,6 @@ function displayChapters() {
|
|
|
266
221
|
|
|
267
222
|
[].forEach.call(idSelectors, function (idSelector) {
|
|
268
223
|
idSelector.classList.add('is-current');
|
|
269
|
-
idSelector.focus();
|
|
270
224
|
});
|
|
271
225
|
|
|
272
226
|
if (chapterCues) {
|
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -2,7 +2,7 @@ import './molecules/form';
|
|
|
2
2
|
import './atoms/textarea/rich-text';
|
|
3
3
|
|
|
4
4
|
require('./atoms/grid-toggle/grid-toggle');
|
|
5
|
-
|
|
5
|
+
require('./components');
|
|
6
6
|
|
|
7
7
|
const Button = require('./atoms/button/Button');
|
|
8
8
|
const { open, onClose, onOpen } = require('./molecules/modal/modal');
|
package/src/app.scss
CHANGED
|
@@ -66,6 +66,7 @@ $namespace: '';
|
|
|
66
66
|
@import 'molecules/glider/glider';
|
|
67
67
|
@import 'molecules/glider/glider-course';
|
|
68
68
|
@import 'molecules/glider/glider-hero';
|
|
69
|
+
@import 'molecules/continue-video-guide/continue-video-guide';
|
|
69
70
|
|
|
70
71
|
// Organisms
|
|
71
72
|
@import 'organisms/header/header';
|
|
@@ -85,6 +86,8 @@ $namespace: '';
|
|
|
85
86
|
@import 'organisms/event-listing-item/event-listing-item';
|
|
86
87
|
@import 'organisms/podcast/podcast-episodes';
|
|
87
88
|
@import 'organisms/podcast/podcast-player';
|
|
89
|
+
@import 'organisms/video-guide/video-guide';
|
|
90
|
+
@import 'organisms/timeline/timeline';
|
|
88
91
|
|
|
89
92
|
// Structures
|
|
90
93
|
@import 'structures/manifest';
|
package/src/assets/js/youtube.js
CHANGED
|
@@ -15,6 +15,9 @@ function onPlayerStateChange(el, e) {
|
|
|
15
15
|
if (e.data === YT.PlayerState.PLAYING) {
|
|
16
16
|
el.getElementsByTagName('img')[0].style.zIndex = '-1';
|
|
17
17
|
el.getElementsByTagName('button')[0].style.display = 'none';
|
|
18
|
+
} else if (e.data === YT.PlayerState.UNSTARTED) {
|
|
19
|
+
el.getElementsByTagName('img')[0].style.zIndex = null;
|
|
20
|
+
el.getElementsByTagName('button')[0].style.display = null;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -38,6 +41,8 @@ function setupYoutubePlayer(el) {
|
|
|
38
41
|
el.youtube.destroy();
|
|
39
42
|
el.youtube = null;
|
|
40
43
|
el.removeAttribute('data-youtube-ready');
|
|
44
|
+
el.getElementsByTagName('img')[0].style.zIndex = null;
|
|
45
|
+
el.getElementsByTagName('button')[0].style.display = null;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
playerEl = document.createElement('div');
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
WEBVTT
|
|
2
2
|
|
|
3
3
|
00:00:00.000 --> 00:00:25.000
|
|
4
|
-
|
|
4
|
+
89108
|
|
5
5
|
|
|
6
6
|
00:00:25.000 --> 00:00:39.000
|
|
7
|
-
|
|
7
|
+
91027
|
|
8
8
|
|
|
9
9
|
00:00:39.000 --> 00:01:51.500
|
|
10
|
-
|
|
10
|
+
81345
|
|
11
11
|
|
|
12
12
|
00:01:51.500 --> 00:02:23.000
|
|
13
|
-
|
|
13
|
+
76810
|
|
14
14
|
|
|
15
15
|
00:02:23.000 --> 00:03:27.000
|
|
16
|
-
|
|
16
|
+
86454
|
|
17
17
|
|
|
18
18
|
00:03:27.000 --> 00:03:56.500
|
|
19
|
-
|
|
19
|
+
80127
|
|
20
20
|
|
|
21
21
|
00:03:56.500 --> 00:04:34.000
|
|
22
|
-
|
|
22
|
+
76325
|
|
23
23
|
|
|
24
24
|
00:04:34.000 --> 00:05:17.000
|
|
25
|
-
|
|
25
|
+
76280
|
|
26
26
|
|
|
27
27
|
00:05:17.000 --> 00:06:28.000
|
|
28
|
-
|
|
28
|
+
80725
|
package/src/atoms/tag/_tag.scss
CHANGED
package/src/components.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import 'a11y-toggle';
|
|
2
|
-
import './focusTrap';
|
|
3
|
-
import './assets/js/conditional';
|
|
4
1
|
import './atoms/password-toggle/password-toggle';
|
|
5
2
|
import './utilities/tab-highlighting/tab-highlighting';
|
|
6
3
|
import './molecules/system-error/system-error';
|
|
4
|
+
import 'a11y-toggle';
|
|
7
5
|
import './molecules/cookie-disclaimer/cookie-disclaimer';
|
|
8
6
|
import './organisms/accordion/accordion';
|
|
9
7
|
import './organisms/tabs/tabs';
|
|
@@ -13,7 +11,9 @@ import './molecules/share/share';
|
|
|
13
11
|
import './molecules/natural-language-form/natural-language-form';
|
|
14
12
|
import './atoms/tooltip/tooltip';
|
|
15
13
|
import './atoms/toggle-high-contrast/toggle-high-contrast';
|
|
14
|
+
import './focusTrap';
|
|
16
15
|
import './atoms/height-limiter/height-limiter';
|
|
16
|
+
import './assets/js/conditional';
|
|
17
17
|
import './atoms/file/file';
|
|
18
18
|
import './atoms/file/filePreview';
|
|
19
19
|
import './organisms/podcast/podcast';
|
|
@@ -24,3 +24,6 @@ import './molecules/glider/glider-course';
|
|
|
24
24
|
import './molecules/glider/glider-hero';
|
|
25
25
|
import './molecules/context-menu/context-menu';
|
|
26
26
|
import './molecules/alert/alert';
|
|
27
|
+
import './molecules/continue-video-guide/continue-video-guide';
|
|
28
|
+
import './organisms/video-guide/video-guide';
|
|
29
|
+
import './organisms/timeline/timeline';
|
package/src/globals.scss
CHANGED
|
@@ -25,30 +25,4 @@
|
|
|
25
25
|
@import 'base/fonts/fonts';
|
|
26
26
|
|
|
27
27
|
// Utilities
|
|
28
|
-
@import 'utilities/
|
|
29
|
-
@import 'utilities/padding';
|
|
30
|
-
@import 'utilities/hide';
|
|
31
|
-
@import 'utilities/show';
|
|
32
|
-
@import 'utilities/lists';
|
|
33
|
-
@import 'utilities/position';
|
|
34
|
-
@import 'utilities/fonts';
|
|
35
|
-
@import 'utilities/tab-highlighting/tab-highlighting';
|
|
36
|
-
@import 'utilities/border';
|
|
37
|
-
@import 'utilities/align';
|
|
38
|
-
@import 'utilities/vertical-align';
|
|
39
|
-
@import 'utilities/icons';
|
|
40
|
-
@import 'utilities/wrap';
|
|
41
|
-
@import 'utilities/accessibility-helpers';
|
|
42
|
-
@import 'utilities/links';
|
|
43
|
-
@import 'utilities/z-index';
|
|
44
|
-
@import 'utilities/box-shadow';
|
|
45
|
-
@import 'utilities/flex';
|
|
46
|
-
@import 'utilities/display';
|
|
47
|
-
@import 'utilities/misc';
|
|
48
|
-
@import 'utilities/gutter';
|
|
49
|
-
@import 'utilities/text';
|
|
50
|
-
@import 'utilities/pointer-events';
|
|
51
|
-
@import 'utilities/clear';
|
|
52
|
-
@import 'utilities/fill';
|
|
53
|
-
@import 'utilities/indent';
|
|
54
|
-
@import 'utilities/font-size';
|
|
28
|
+
@import 'utilities/manifest';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import className from '../../assets/js/className';
|
|
2
|
+
|
|
3
|
+
class ProgressRing extends HTMLElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
const stroke = this.getAttribute('stroke');
|
|
7
|
+
const radius = this.getAttribute('radius');
|
|
8
|
+
const normalizedRadius = radius - stroke * 2;
|
|
9
|
+
this.circumference = normalizedRadius * 2 * Math.PI;
|
|
10
|
+
|
|
11
|
+
this.root = this.attachShadow({ mode: 'open' });
|
|
12
|
+
this.root.innerHTML = `
|
|
13
|
+
<svg
|
|
14
|
+
height="${radius * 2}"
|
|
15
|
+
width="${radius * 2}"
|
|
16
|
+
>
|
|
17
|
+
<circle
|
|
18
|
+
stroke="white"
|
|
19
|
+
stroke-dasharray="${this.circumference} ${this.circumference}"
|
|
20
|
+
style="stroke-dashoffset:${this.circumference}"
|
|
21
|
+
stroke-width="${stroke}"
|
|
22
|
+
fill="transparent"
|
|
23
|
+
r="${normalizedRadius}"
|
|
24
|
+
cx="${radius}"
|
|
25
|
+
cy="${radius}"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
circle {
|
|
31
|
+
transition: stroke-dashoffset 0.35s;
|
|
32
|
+
transform: rotate(-90deg);
|
|
33
|
+
transform-origin: 50% 50%;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setProgress(percent) {
|
|
40
|
+
const offset = this.circumference - ((percent / 100) * this.circumference);
|
|
41
|
+
const circle = this.root.querySelector('circle');
|
|
42
|
+
circle.style.strokeDashoffset = offset;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static get observedAttributes() {
|
|
46
|
+
return ['progress'];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
50
|
+
if (name === 'progress') {
|
|
51
|
+
this.setProgress(newValue);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
window.customElements.define('progress-ring', ProgressRing);
|
|
57
|
+
|
|
58
|
+
// Get value from localStorage if present
|
|
59
|
+
if (localStorage.getItem('InmsCurrentTime')) {
|
|
60
|
+
const videoCurrentTime = localStorage.getItem('InmsCurrentTime');
|
|
61
|
+
const videoDuration = localStorage.getItem('InmsDuration');
|
|
62
|
+
const continueElement = document.querySelector('.js-guide-continue');
|
|
63
|
+
const progressRing = document.querySelector('progress-ring');
|
|
64
|
+
const continueLink = document.querySelector('.js-guide-continue-link');
|
|
65
|
+
const guideURL = localStorage.getItem('InmsCurrentGuideURL');
|
|
66
|
+
const guideImage = localStorage.getItem('InmsCurrentGuideImage');
|
|
67
|
+
|
|
68
|
+
if ((videoCurrentTime > 0)
|
|
69
|
+
&& progressRing
|
|
70
|
+
&& continueElement
|
|
71
|
+
&& guideImage
|
|
72
|
+
&& continueLink) {
|
|
73
|
+
const alternativeText = continueLink.dataset.altText;
|
|
74
|
+
const currentProgress = videoCurrentTime / videoDuration;
|
|
75
|
+
const currentGuideImage = document.querySelector('.js-guide-continue-image');
|
|
76
|
+
|
|
77
|
+
continueElement.classList.add(className('m-continue-video-guide--has-progress'));
|
|
78
|
+
continueLink.setAttribute('href', guideURL);
|
|
79
|
+
currentGuideImage.src = guideImage;
|
|
80
|
+
continueLink.querySelector('span').innerText = alternativeText;
|
|
81
|
+
// Calculate percentage played
|
|
82
|
+
progressRing.setAttribute('progress', Math.floor(currentProgress * 100));
|
|
83
|
+
}
|
|
84
|
+
}
|