@internetstiftelsen/styleguide 2.22.3-beta.0.58 → 2.22.3-beta.0.60
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.
|
@@ -21,20 +21,9 @@ var navigationButton = document.querySelector('.js-show-timelineposts');
|
|
|
21
21
|
var timeLinePosts = document.querySelector('.js-timeline-posts');
|
|
22
22
|
var currentChapter = 1;
|
|
23
23
|
var manualStep = false;
|
|
24
|
-
var sourceElement = null;
|
|
25
24
|
|
|
26
25
|
// 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
|
-
|
|
26
|
+
if (video) {
|
|
38
27
|
// Store current time in on page reload
|
|
39
28
|
window.addEventListener('unload', function () {
|
|
40
29
|
// Set localStorage if video has started playing
|
|
@@ -135,38 +124,36 @@ function displayChapters() {
|
|
|
135
124
|
});
|
|
136
125
|
|
|
137
126
|
if (chapterTrack.kind === 'chapters') {
|
|
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
|
-
}, 100);
|
|
169
|
-
});
|
|
127
|
+
// Loop through chapters and create chapter list
|
|
128
|
+
// Let data load
|
|
129
|
+
setTimeout(function () {
|
|
130
|
+
video.classList.remove('is-loading');
|
|
131
|
+
[].forEach.call(chapterTrack.cues, function (cues) {
|
|
132
|
+
var chapterName = cues.text;
|
|
133
|
+
var start = cues.startTime;
|
|
134
|
+
var newLocale = document.createElement('li');
|
|
135
|
+
var location = document.createElement('a');
|
|
136
|
+
|
|
137
|
+
location.setAttribute('rel', start);
|
|
138
|
+
newLocale.setAttribute('id', start);
|
|
139
|
+
location.setAttribute('tabindex', '0');
|
|
140
|
+
|
|
141
|
+
// Plain text from the chapter file into HTML text
|
|
142
|
+
var localeDescription = chapterName;
|
|
143
|
+
location.innerHTML = localeDescription;
|
|
144
|
+
newLocale.appendChild(location);
|
|
145
|
+
locationList.appendChild(newLocale);
|
|
146
|
+
|
|
147
|
+
location.addEventListener('click', function () {
|
|
148
|
+
video.currentTime = location.id;
|
|
149
|
+
}, false);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// If not set in sessionStorgare, set first cue on forward button on page load
|
|
153
|
+
if (!localStorage.getItem('InmsCurrentTime')) {
|
|
154
|
+
forwardsButton.setAttribute('data-id', chapterTrack.cues[0].endTime);
|
|
155
|
+
}
|
|
156
|
+
}, 100);
|
|
170
157
|
|
|
171
158
|
forwardsButton.addEventListener('click', function () {
|
|
172
159
|
var dataId = forwardsButton.dataset.id;
|
|
@@ -224,23 +211,10 @@ function displayChapters() {
|
|
|
224
211
|
// get the chapter <li> elements based on the currentLocation
|
|
225
212
|
var locations = [].slice.call(chapter.closest('figure').querySelectorAll('.js-chapters li'));
|
|
226
213
|
|
|
227
|
-
var counter = 0;
|
|
228
|
-
|
|
229
214
|
[].forEach.call(locations, function (location) {
|
|
230
215
|
// remove current classes from all items on page refresh
|
|
231
216
|
location.classList.remove('is-current-item');
|
|
232
217
|
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
218
|
});
|
|
245
219
|
chapter.parentNode.classList.add('is-current-item');
|
|
246
220
|
chapter.classList.add('is-current');
|
|
@@ -253,7 +227,7 @@ function displayChapters() {
|
|
|
253
227
|
// Get timeline post IDs from metadata.vtt
|
|
254
228
|
metadataTrack.addEventListener('cuechange', function () {
|
|
255
229
|
var metadataCues = metadataTrack.activeCues;
|
|
256
|
-
var chapterCues = chapterTrack.activeCues;
|
|
230
|
+
var chapterCues = chapterTrack.activeCues[0];
|
|
257
231
|
|
|
258
232
|
if (metadataCues.length > 0) {
|
|
259
233
|
var metadataCueMatch = metadataTrack.activeCues[0].text;
|
package/package.json
CHANGED
|
@@ -19,20 +19,9 @@ const navigationButton = document.querySelector('.js-show-timelineposts');
|
|
|
19
19
|
const timeLinePosts = document.querySelector('.js-timeline-posts');
|
|
20
20
|
let currentChapter = 1;
|
|
21
21
|
let manualStep = false;
|
|
22
|
-
let sourceElement = null;
|
|
23
22
|
|
|
24
23
|
// Has src attributes been set already?
|
|
25
|
-
if (
|
|
26
|
-
document.location.reload();
|
|
27
|
-
} else if (video) {
|
|
28
|
-
const dataSrc = video.dataset.src;
|
|
29
|
-
|
|
30
|
-
sourceElement = document.createElement('source');
|
|
31
|
-
sourceElement.setAttribute('src', dataSrc);
|
|
32
|
-
sourceElement.setAttribute('type', 'video/mp4');
|
|
33
|
-
|
|
34
|
-
video.appendChild(sourceElement);
|
|
35
|
-
|
|
24
|
+
if (video) {
|
|
36
25
|
// Store current time in on page reload
|
|
37
26
|
window.addEventListener('unload', () => {
|
|
38
27
|
// Set localStorage if video has started playing
|
|
@@ -133,38 +122,36 @@ function displayChapters() {
|
|
|
133
122
|
});
|
|
134
123
|
|
|
135
124
|
if (chapterTrack.kind === 'chapters') {
|
|
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
|
-
}, 100);
|
|
167
|
-
});
|
|
125
|
+
// Loop through chapters and create chapter list
|
|
126
|
+
// Let data load
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
video.classList.remove('is-loading');
|
|
129
|
+
[].forEach.call(chapterTrack.cues, (cues) => {
|
|
130
|
+
const chapterName = cues.text;
|
|
131
|
+
const start = cues.startTime;
|
|
132
|
+
const newLocale = document.createElement('li');
|
|
133
|
+
const location = document.createElement('a');
|
|
134
|
+
|
|
135
|
+
location.setAttribute('rel', start);
|
|
136
|
+
newLocale.setAttribute('id', start);
|
|
137
|
+
location.setAttribute('tabindex', '0');
|
|
138
|
+
|
|
139
|
+
// Plain text from the chapter file into HTML text
|
|
140
|
+
const localeDescription = chapterName;
|
|
141
|
+
location.innerHTML = localeDescription;
|
|
142
|
+
newLocale.appendChild(location);
|
|
143
|
+
locationList.appendChild(newLocale);
|
|
144
|
+
|
|
145
|
+
location.addEventListener('click', () => {
|
|
146
|
+
video.currentTime = location.id;
|
|
147
|
+
}, false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// If not set in sessionStorgare, set first cue on forward button on page load
|
|
151
|
+
if (!localStorage.getItem('InmsCurrentTime')) {
|
|
152
|
+
forwardsButton.setAttribute('data-id', chapterTrack.cues[0].endTime);
|
|
153
|
+
}
|
|
154
|
+
}, 100);
|
|
168
155
|
|
|
169
156
|
forwardsButton.addEventListener('click', () => {
|
|
170
157
|
const dataId = forwardsButton.dataset.id;
|
|
@@ -223,23 +210,10 @@ function displayChapters() {
|
|
|
223
210
|
const locations = [].slice.call(chapter.closest('figure')
|
|
224
211
|
.querySelectorAll('.js-chapters li'));
|
|
225
212
|
|
|
226
|
-
let counter = 0;
|
|
227
|
-
|
|
228
213
|
[].forEach.call(locations, (location) => {
|
|
229
214
|
// remove current classes from all items on page refresh
|
|
230
215
|
location.classList.remove('is-current-item');
|
|
231
216
|
location.querySelector('a').classList.remove('is-current');
|
|
232
|
-
|
|
233
|
-
if (location.classList.contains('is-current-item')) {
|
|
234
|
-
counter += 1; // iterate counter when active chapter is reached
|
|
235
|
-
}
|
|
236
|
-
if (counter < 1) {
|
|
237
|
-
// add watched class to everything before the current chapter to show progress
|
|
238
|
-
location.classList.add('is-watched');
|
|
239
|
-
} else {
|
|
240
|
-
// remove watched on all other items
|
|
241
|
-
location.classList.remove('is-watched');
|
|
242
|
-
}
|
|
243
217
|
});
|
|
244
218
|
chapter.parentNode.classList.add('is-current-item');
|
|
245
219
|
chapter.classList.add('is-current');
|
|
@@ -252,7 +226,7 @@ function displayChapters() {
|
|
|
252
226
|
// Get timeline post IDs from metadata.vtt
|
|
253
227
|
metadataTrack.addEventListener('cuechange', () => {
|
|
254
228
|
const metadataCues = metadataTrack.activeCues;
|
|
255
|
-
const chapterCues = chapterTrack.activeCues;
|
|
229
|
+
const chapterCues = chapterTrack.activeCues[0];
|
|
256
230
|
|
|
257
231
|
if (metadataCues.length > 0) {
|
|
258
232
|
const metadataCueMatch = metadataTrack.activeCues[0].text;
|