@internetstiftelsen/styleguide 2.24.11 → 2.24.12
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 +0 -8
- package/dist/atoms/textarea/rich-text.js +33 -3
- package/dist/organisms/podcast/podcast.js +85 -3
- package/package.json +11 -3
- package/src/atoms/button/_button.scss +42 -0
- package/src/atoms/button/button.config.js +7 -0
- package/src/atoms/textarea/rich-text.js +18 -2
- package/src/organisms/podcast/_podcast-player.scss +36 -6
- package/src/organisms/podcast/podcast.js +85 -3
- package/src/pages/magazine/magazine.config.js +1 -1
|
@@ -28,14 +28,6 @@ function onPlayerStateChange(el, e) {
|
|
|
28
28
|
} else if (e.data === YT.PlayerState.UNSTARTED) {
|
|
29
29
|
el.getElementsByTagName('img')[0].style.zIndex = null;
|
|
30
30
|
el.getElementsByTagName('button')[0].style.display = null;
|
|
31
|
-
|
|
32
|
-
if (el.youtube) {
|
|
33
|
-
var playerEl = el.querySelector('[data-youtube-container]');
|
|
34
|
-
|
|
35
|
-
playerEl.parentNode.removeChild(playerEl);
|
|
36
|
-
el.youtube.destroy();
|
|
37
|
-
el.youtube = null;
|
|
38
|
-
}
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
33
|
|
|
@@ -8,12 +8,40 @@ exports.init = init;
|
|
|
8
8
|
|
|
9
9
|
var _core = require('@tiptap/core');
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _extensionDocument = require('@tiptap/extension-document');
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _extensionDocument2 = _interopRequireDefault(_extensionDocument);
|
|
14
|
+
|
|
15
|
+
var _extensionParagraph = require('@tiptap/extension-paragraph');
|
|
16
|
+
|
|
17
|
+
var _extensionParagraph2 = _interopRequireDefault(_extensionParagraph);
|
|
18
|
+
|
|
19
|
+
var _extensionText = require('@tiptap/extension-text');
|
|
20
|
+
|
|
21
|
+
var _extensionText2 = _interopRequireDefault(_extensionText);
|
|
22
|
+
|
|
23
|
+
var _extensionBulletList = require('@tiptap/extension-bullet-list');
|
|
24
|
+
|
|
25
|
+
var _extensionBulletList2 = _interopRequireDefault(_extensionBulletList);
|
|
26
|
+
|
|
27
|
+
var _extensionListItem = require('@tiptap/extension-list-item');
|
|
28
|
+
|
|
29
|
+
var _extensionListItem2 = _interopRequireDefault(_extensionListItem);
|
|
30
|
+
|
|
31
|
+
var _extensionBold = require('@tiptap/extension-bold');
|
|
32
|
+
|
|
33
|
+
var _extensionBold2 = _interopRequireDefault(_extensionBold);
|
|
34
|
+
|
|
35
|
+
var _extensionItalic = require('@tiptap/extension-italic');
|
|
36
|
+
|
|
37
|
+
var _extensionItalic2 = _interopRequireDefault(_extensionItalic);
|
|
14
38
|
|
|
15
39
|
var _extensionLink = require('@tiptap/extension-link');
|
|
16
40
|
|
|
41
|
+
var _extensionHistory = require('@tiptap/extension-history');
|
|
42
|
+
|
|
43
|
+
var _extensionHistory2 = _interopRequireDefault(_extensionHistory);
|
|
44
|
+
|
|
17
45
|
var _className = require('../../assets/js/className');
|
|
18
46
|
|
|
19
47
|
var _className2 = _interopRequireDefault(_className);
|
|
@@ -146,11 +174,13 @@ function setupTextArea(el) {
|
|
|
146
174
|
var editorEl = document.createElement('div');
|
|
147
175
|
var editor = new _core.Editor({
|
|
148
176
|
element: editorEl,
|
|
149
|
-
extensions: [
|
|
177
|
+
extensions: [_extensionDocument2.default, _extensionParagraph2.default, _extensionText2.default, _extensionListItem2.default, _extensionBulletList2.default, _extensionBold2.default, _extensionItalic2.default, _extensionLink.Link.configure({
|
|
150
178
|
openOnClick: false,
|
|
151
179
|
HTMLAttributes: {
|
|
152
180
|
class: 'u-link'
|
|
153
181
|
}
|
|
182
|
+
}), _extensionHistory2.default.configure({
|
|
183
|
+
depth: 10
|
|
154
184
|
})],
|
|
155
185
|
content: el.value,
|
|
156
186
|
onTransaction: function onTransaction(props) {
|
|
@@ -16,6 +16,7 @@ var stepBackward = document.querySelector('.js-step-backward');
|
|
|
16
16
|
var playButton = document.querySelector('.js-play-button');
|
|
17
17
|
var playIcon = document.querySelector('.js-play-icon');
|
|
18
18
|
var pauseIcon = document.querySelector('.js-pause-icon');
|
|
19
|
+
var closeButton = document.querySelector('.js-close-player');
|
|
19
20
|
var rssURL = '';
|
|
20
21
|
|
|
21
22
|
if (podCast) {
|
|
@@ -30,7 +31,6 @@ if (!namespaceElement) {
|
|
|
30
31
|
|
|
31
32
|
function timeupdate() {
|
|
32
33
|
audio.addEventListener('timeupdate', function () {
|
|
33
|
-
var timeleft = timeleftElement;
|
|
34
34
|
var duration = parseInt(audio.duration, 10);
|
|
35
35
|
var currentTime = parseInt(audio.currentTime, 10);
|
|
36
36
|
var timeLeft = duration - currentTime;
|
|
@@ -44,7 +44,7 @@ function timeupdate() {
|
|
|
44
44
|
|
|
45
45
|
if (timeLeft > 0) {
|
|
46
46
|
timeleftElement.classList.remove('u-visibility-hidden');
|
|
47
|
-
|
|
47
|
+
timeleftElement.innerHTML = m + ':' + s;
|
|
48
48
|
}
|
|
49
49
|
}, false);
|
|
50
50
|
}
|
|
@@ -52,7 +52,7 @@ function timeupdate() {
|
|
|
52
52
|
var html = '';
|
|
53
53
|
|
|
54
54
|
function getItems(el) {
|
|
55
|
-
html += '\n\t<li>\n\t\t<button\n\t\t\tclass="' + namespace + 'o-podcast-player__button display-flex js-play-episode"\n\t\t\tdata-src="' + el.querySelector('enclosure').getAttribute('url') + '"\n\t\t\tdata-title="' + el.querySelector('title').innerHTML + '"\n\t\t\tdata-description="' + el.querySelector('description').innerHTML.replace(/(<([^>]+)>)/gi, '').replace('<![CDATA[', '').replace(']]>', '') + '"\n\t\t\tdata-image="' + el.querySelector('image').getAttribute('href') + '"\n\t\t\tdata-duration="' + el.querySelector('duration').innerHTML + '"\n\t\t\ttype="button"><svg class="icon ' + namespace + 'o-podcast-player__play-icon u-m-r-2"><use xlink:href="#icon-play"></use></svg></div><div class="u-visuallyhidden">Spela avsnittet ' + el.querySelector('title').innerHTML + '</div></button>\n\t\t<div class="' + namespace + 'o-podcast-player__show-info">\n\t\t\t<div class="' + namespace + 'o-podcast-player__title">' + el.querySelector('title').innerHTML + '</div>\n\t\t\t<div class="' + namespace + 'o-podcast-player__description">' + el.querySelector('description').innerHTML + '</div>\n\t\t</div>\n\t</li>\n';
|
|
55
|
+
html += '\n\t<li>\n\t\t<button\n\t\t\tclass="' + namespace + 'o-podcast-player__button display-flex js-play-episode"\n\t\t\tdata-src="' + el.querySelector('enclosure').getAttribute('url') + '"\n\t\t\tdata-title="' + el.querySelector('title').innerHTML + '"\n\t\t\tdata-description="' + el.querySelector('description').innerHTML.replace(/(<([^>]+)>)/gi, '').replace('<![CDATA[', '').replace(']]>', '') + '"\n\t\t\tdata-image="' + el.querySelector('image').getAttribute('href') + '"\n\t\t\tdata-duration="' + el.querySelector('duration').innerHTML + '"\n\t\t\ttype="button"><svg class="icon ' + namespace + 'o-podcast-player__play-icon u-m-r-2"><use xlink:href="#icon-play"></use></svg></div><div class="u-visuallyhidden">Spela avsnittet ' + el.querySelector('title').innerHTML + '</div></button>\n\t\t<div class="' + namespace + 'o-podcast-player__show-info">\n\t\t\t<div class="' + namespace + 'o-podcast-player__title">' + el.querySelector('title').innerHTML + '</div>\n\t\t\t<div class="' + namespace + 'o-podcast-player__description js-description">' + el.querySelector('description').innerHTML + '</div>\n\t\t</div>\n\t</li>\n';
|
|
56
56
|
|
|
57
57
|
if (jsTrackList) {
|
|
58
58
|
jsTrackList.innerHTML = html;
|
|
@@ -107,6 +107,7 @@ document.body.addEventListener('click', function (e) {
|
|
|
107
107
|
if (playButton) {
|
|
108
108
|
playButton.addEventListener('click', function () {
|
|
109
109
|
if (audio.paused) {
|
|
110
|
+
audio.muted = false;
|
|
110
111
|
audio.play();
|
|
111
112
|
pauseIcon.classList.remove('is-hidden');
|
|
112
113
|
playIcon.classList.add('is-hidden');
|
|
@@ -146,4 +147,85 @@ if (stepBackward) {
|
|
|
146
147
|
audio.currentTime -= 15;
|
|
147
148
|
timeupdate();
|
|
148
149
|
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Handle continous play when user leaves the page
|
|
153
|
+
window.addEventListener('unload', function () {
|
|
154
|
+
var podcastData = {
|
|
155
|
+
podCastTitle: title.innerHTML,
|
|
156
|
+
episodeDescription: description.innerHTML,
|
|
157
|
+
episodeSrc: audio.src,
|
|
158
|
+
episodeCurrentTime: audio.currentTime,
|
|
159
|
+
episodeDuration: durationElement.innerHTML,
|
|
160
|
+
episodeImage: image.src
|
|
161
|
+
};
|
|
162
|
+
localStorage.setItem('episodeData', JSON.stringify(podcastData));
|
|
163
|
+
|
|
164
|
+
if (!audio.paused) {
|
|
165
|
+
var existing = localStorage.getItem('episodeData');
|
|
166
|
+
existing = existing ? JSON.parse(existing) : {};
|
|
167
|
+
existing.podcastWasPlaying = true;
|
|
168
|
+
localStorage.setItem('episodeData', JSON.stringify(existing));
|
|
169
|
+
} else {
|
|
170
|
+
var _existing = localStorage.getItem('episodeData');
|
|
171
|
+
_existing = _existing ? JSON.parse(_existing) : {};
|
|
172
|
+
_existing.podcastWasPlaying = false;
|
|
173
|
+
localStorage.setItem('episodeData', JSON.stringify(_existing));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
if (localStorage.getItem('episodeData') && podCast) {
|
|
178
|
+
var arr = JSON.parse(localStorage.getItem('episodeData'));
|
|
179
|
+
|
|
180
|
+
if (arr.episodeCurrentTime) {
|
|
181
|
+
podCast.classList.remove(namespace + 'o-podcast-player--hidden');
|
|
182
|
+
audio.src = arr.episodeSrc;
|
|
183
|
+
image.src = arr.episodeImage;
|
|
184
|
+
title.innerHTML = arr.podCastTitle;
|
|
185
|
+
description.innerHTML = arr.episodeDescription;
|
|
186
|
+
durationElement.innerHTML = arr.episodeDuration;
|
|
187
|
+
|
|
188
|
+
if (arr.podcastWasPlaying === true) {
|
|
189
|
+
var playPromise = audio.play();
|
|
190
|
+
|
|
191
|
+
if (playPromise !== undefined) {
|
|
192
|
+
playPromise.then(function () {
|
|
193
|
+
// Continue playing audio on reload
|
|
194
|
+
audio.currentTime = arr.episodeCurrentTime;
|
|
195
|
+
timeupdate();
|
|
196
|
+
audio.play();
|
|
197
|
+
pauseIcon.classList.remove('is-hidden');
|
|
198
|
+
playIcon.classList.add('is-hidden');
|
|
199
|
+
}).catch(function () {
|
|
200
|
+
// User reloaded page manually. Cannot play audio
|
|
201
|
+
audio.addEventListener('loadedmetadata', function () {
|
|
202
|
+
audio.currentTime = arr.episodeCurrentTime;
|
|
203
|
+
timeupdate();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
pauseIcon.classList.add('is-hidden');
|
|
207
|
+
playIcon.classList.remove('is-hidden');
|
|
208
|
+
audio.pause();
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
audio.addEventListener('loadedmetadata', function () {
|
|
213
|
+
audio.currentTime = arr.episodeCurrentTime;
|
|
214
|
+
timeupdate();
|
|
215
|
+
});
|
|
216
|
+
pauseIcon.classList.add('is-hidden');
|
|
217
|
+
playIcon.classList.remove('is-hidden');
|
|
218
|
+
audio.pause();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (closeButton) {
|
|
224
|
+
closeButton.addEventListener('click', function () {
|
|
225
|
+
audio.currentTime = 0;
|
|
226
|
+
timeupdate();
|
|
227
|
+
audio.pause();
|
|
228
|
+
localStorage.removeItem('episodeData');
|
|
229
|
+
podCast.classList.add(namespace + 'o-podcast-player--hidden');
|
|
230
|
+
});
|
|
149
231
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetstiftelsen/styleguide",
|
|
3
|
-
"version": "2.24.
|
|
3
|
+
"version": "2.24.12",
|
|
4
4
|
"main": "dist/components.js",
|
|
5
5
|
"ports": {
|
|
6
6
|
"fractal": "3000"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"css-loader": "^5.2.6",
|
|
60
60
|
"cssnano": "^5.0.6",
|
|
61
61
|
"eslint": "^7.28.0",
|
|
62
|
-
"imagemin-cli": "^
|
|
62
|
+
"imagemin-cli": "^7.0.0",
|
|
63
63
|
"onchange": "^6.1.0",
|
|
64
64
|
"postcss-class-prefix": "^0.3.0",
|
|
65
65
|
"postcss-cli": "^8.3.1",
|
|
@@ -69,8 +69,16 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@tiptap/core": "^2.0.0-beta.131",
|
|
72
|
+
"@tiptap/extension-bold": "^2.0.0-beta.199",
|
|
73
|
+
"@tiptap/extension-bullet-list": "^2.0.0-beta.199",
|
|
74
|
+
"@tiptap/extension-document": "^2.0.0-beta.199",
|
|
75
|
+
"@tiptap/extension-dropcursor": "^2.0.0-beta.199",
|
|
76
|
+
"@tiptap/extension-history": "^2.0.0-beta.199",
|
|
77
|
+
"@tiptap/extension-italic": "^2.0.0-beta.199",
|
|
72
78
|
"@tiptap/extension-link": "^2.0.0-beta.25",
|
|
73
|
-
"@tiptap/
|
|
79
|
+
"@tiptap/extension-list-item": "^2.0.0-beta.199",
|
|
80
|
+
"@tiptap/extension-paragraph": "^2.0.0-beta.199",
|
|
81
|
+
"@tiptap/extension-text": "^2.0.0-beta.199",
|
|
74
82
|
"a11y-toggle": "^2.1.0",
|
|
75
83
|
"focus-trap": "^6.7.3",
|
|
76
84
|
"glider-js": "^1.7.7",
|
|
@@ -455,6 +455,48 @@
|
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
+
@include m(sandstone) {
|
|
459
|
+
color: $color-sandstone;
|
|
460
|
+
|
|
461
|
+
&:hover,
|
|
462
|
+
&:focus {
|
|
463
|
+
color: $color-sandstone-light;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
@include e(text) {
|
|
467
|
+
color: $color-cyberspace;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
@include e(icon) {
|
|
471
|
+
fill: $color-cyberspace;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
@include m(sandstone-light) {
|
|
476
|
+
box-shadow: 0 0 0 1px inset $color-sandstone;
|
|
477
|
+
color: $color-sandstone-light;
|
|
478
|
+
|
|
479
|
+
&:hover {
|
|
480
|
+
color: $color-sandstone;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
&:focus {
|
|
484
|
+
color: $color-sandstone-light;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
&:hover:focus {
|
|
488
|
+
color: $color-sandstone-light;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
@include e(text) {
|
|
492
|
+
color: $color-cyberspace;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
@include e(icon) {
|
|
496
|
+
fill: $color-cyberspace;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
458
500
|
@include m(dashed) {
|
|
459
501
|
border: 1px dashed;
|
|
460
502
|
background: transparent;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/core';
|
|
2
|
-
import
|
|
2
|
+
import Document from '@tiptap/extension-document';
|
|
3
|
+
import Paragraph from '@tiptap/extension-paragraph';
|
|
4
|
+
import Text from '@tiptap/extension-text';
|
|
5
|
+
import BulletList from '@tiptap/extension-bullet-list';
|
|
6
|
+
import ListItem from '@tiptap/extension-list-item';
|
|
7
|
+
import Bold from '@tiptap/extension-bold';
|
|
8
|
+
import Italic from '@tiptap/extension-italic';
|
|
3
9
|
import { Link } from '@tiptap/extension-link';
|
|
10
|
+
import History from '@tiptap/extension-history';
|
|
4
11
|
import className from '../../assets/js/className';
|
|
5
12
|
import { open } from '../../molecules/modal/modal';
|
|
6
13
|
|
|
@@ -141,13 +148,22 @@ export function setupTextArea(el, onChange = () => {}) {
|
|
|
141
148
|
const editor = new Editor({
|
|
142
149
|
element: editorEl,
|
|
143
150
|
extensions: [
|
|
144
|
-
|
|
151
|
+
Document,
|
|
152
|
+
Paragraph,
|
|
153
|
+
Text,
|
|
154
|
+
ListItem,
|
|
155
|
+
BulletList,
|
|
156
|
+
Bold,
|
|
157
|
+
Italic,
|
|
145
158
|
Link.configure({
|
|
146
159
|
openOnClick: false,
|
|
147
160
|
HTMLAttributes: {
|
|
148
161
|
class: 'u-link',
|
|
149
162
|
},
|
|
150
163
|
}),
|
|
164
|
+
History.configure({
|
|
165
|
+
depth: 10,
|
|
166
|
+
}),
|
|
151
167
|
],
|
|
152
168
|
content: el.value,
|
|
153
169
|
onTransaction(props) {
|
|
@@ -60,6 +60,18 @@
|
|
|
60
60
|
margin-bottom: 0;
|
|
61
61
|
color: $color-ruby;
|
|
62
62
|
font-family: $font-family-headings;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
text-overflow: ellipsis;
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
max-width: rem(200px);
|
|
67
|
+
|
|
68
|
+
@include bp-up(sm) {
|
|
69
|
+
max-width: rem(250px);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@include bp-up(lg) {
|
|
73
|
+
max-width: rem(500px);
|
|
74
|
+
}
|
|
63
75
|
}
|
|
64
76
|
|
|
65
77
|
@include e(description) {
|
|
@@ -74,7 +86,7 @@
|
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
@include bp-up(sm) {
|
|
77
|
-
max-width: rem(
|
|
89
|
+
max-width: rem(250px);
|
|
78
90
|
}
|
|
79
91
|
|
|
80
92
|
@include bp-up(lg) {
|
|
@@ -82,16 +94,23 @@
|
|
|
82
94
|
}
|
|
83
95
|
}
|
|
84
96
|
|
|
97
|
+
@include e(playtime) {
|
|
98
|
+
@include bp-between(sm, md) {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@include e(spacer) {
|
|
104
|
+
@include bp-between(sm, md) {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
85
109
|
@include e(controls) {
|
|
86
110
|
display: flex;
|
|
87
111
|
flex-grow: 1;
|
|
88
112
|
align-items: center;
|
|
89
113
|
justify-content: center;
|
|
90
|
-
transform: translateX(math.div($time-left-width, 2));
|
|
91
|
-
|
|
92
|
-
@include bp-up(sm) {
|
|
93
|
-
transform: translateX(0);
|
|
94
|
-
}
|
|
95
114
|
}
|
|
96
115
|
|
|
97
116
|
@include e(spacer) {
|
|
@@ -146,4 +165,15 @@
|
|
|
146
165
|
height: rhythm(1);
|
|
147
166
|
}
|
|
148
167
|
}
|
|
168
|
+
|
|
169
|
+
@include e(close) {
|
|
170
|
+
position: absolute;
|
|
171
|
+
right: rhythm(0.5);
|
|
172
|
+
top: 50%;
|
|
173
|
+
transform: translateY(-50%);
|
|
174
|
+
|
|
175
|
+
@include bp-up(xxl) {
|
|
176
|
+
right: rhythm(2);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
149
179
|
}
|
|
@@ -14,6 +14,7 @@ const stepBackward = document.querySelector('.js-step-backward');
|
|
|
14
14
|
const playButton = document.querySelector('.js-play-button');
|
|
15
15
|
const playIcon = document.querySelector('.js-play-icon');
|
|
16
16
|
const pauseIcon = document.querySelector('.js-pause-icon');
|
|
17
|
+
const closeButton = document.querySelector('.js-close-player');
|
|
17
18
|
let rssURL = '';
|
|
18
19
|
|
|
19
20
|
if (podCast) {
|
|
@@ -28,7 +29,6 @@ if (!namespaceElement) {
|
|
|
28
29
|
|
|
29
30
|
function timeupdate() {
|
|
30
31
|
audio.addEventListener('timeupdate', () => {
|
|
31
|
-
const timeleft = timeleftElement;
|
|
32
32
|
const duration = parseInt(audio.duration, 10);
|
|
33
33
|
const currentTime = parseInt(audio.currentTime, 10);
|
|
34
34
|
const timeLeft = duration - currentTime;
|
|
@@ -43,7 +43,7 @@ function timeupdate() {
|
|
|
43
43
|
|
|
44
44
|
if (timeLeft > 0) {
|
|
45
45
|
timeleftElement.classList.remove('u-visibility-hidden');
|
|
46
|
-
|
|
46
|
+
timeleftElement.innerHTML = `${m}:${s}`;
|
|
47
47
|
}
|
|
48
48
|
}, false);
|
|
49
49
|
}
|
|
@@ -63,7 +63,7 @@ function getItems(el) {
|
|
|
63
63
|
type="button"><svg class="icon ${namespace}o-podcast-player__play-icon u-m-r-2"><use xlink:href="#icon-play"></use></svg></div><div class="u-visuallyhidden">Spela avsnittet ${el.querySelector('title').innerHTML}</div></button>
|
|
64
64
|
<div class="${namespace}o-podcast-player__show-info">
|
|
65
65
|
<div class="${namespace}o-podcast-player__title">${el.querySelector('title').innerHTML}</div>
|
|
66
|
-
<div class="${namespace}o-podcast-player__description">${el.querySelector('description').innerHTML}</div>
|
|
66
|
+
<div class="${namespace}o-podcast-player__description js-description">${el.querySelector('description').innerHTML}</div>
|
|
67
67
|
</div>
|
|
68
68
|
</li>
|
|
69
69
|
`;
|
|
@@ -120,6 +120,7 @@ document.body.addEventListener('click', (e) => {
|
|
|
120
120
|
if (playButton) {
|
|
121
121
|
playButton.addEventListener('click', () => {
|
|
122
122
|
if (audio.paused) {
|
|
123
|
+
audio.muted = false;
|
|
123
124
|
audio.play();
|
|
124
125
|
pauseIcon.classList.remove('is-hidden');
|
|
125
126
|
playIcon.classList.add('is-hidden');
|
|
@@ -160,3 +161,84 @@ if (stepBackward) {
|
|
|
160
161
|
timeupdate();
|
|
161
162
|
});
|
|
162
163
|
}
|
|
164
|
+
|
|
165
|
+
// Handle continous play when user leaves the page
|
|
166
|
+
window.addEventListener('unload', () => {
|
|
167
|
+
const podcastData = {
|
|
168
|
+
podCastTitle: title.innerHTML,
|
|
169
|
+
episodeDescription: description.innerHTML,
|
|
170
|
+
episodeSrc: audio.src,
|
|
171
|
+
episodeCurrentTime: audio.currentTime,
|
|
172
|
+
episodeDuration: durationElement.innerHTML,
|
|
173
|
+
episodeImage: image.src,
|
|
174
|
+
};
|
|
175
|
+
localStorage.setItem('episodeData', JSON.stringify(podcastData));
|
|
176
|
+
|
|
177
|
+
if (!audio.paused) {
|
|
178
|
+
let existing = localStorage.getItem('episodeData');
|
|
179
|
+
existing = existing ? JSON.parse(existing) : {};
|
|
180
|
+
existing.podcastWasPlaying = true;
|
|
181
|
+
localStorage.setItem('episodeData', JSON.stringify(existing));
|
|
182
|
+
} else {
|
|
183
|
+
let existing = localStorage.getItem('episodeData');
|
|
184
|
+
existing = existing ? JSON.parse(existing) : {};
|
|
185
|
+
existing.podcastWasPlaying = false;
|
|
186
|
+
localStorage.setItem('episodeData', JSON.stringify(existing));
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
if (localStorage.getItem('episodeData') && podCast) {
|
|
191
|
+
const arr = JSON.parse(localStorage.getItem('episodeData'));
|
|
192
|
+
|
|
193
|
+
if (arr.episodeCurrentTime) {
|
|
194
|
+
podCast.classList.remove(`${namespace}o-podcast-player--hidden`);
|
|
195
|
+
audio.src = arr.episodeSrc;
|
|
196
|
+
image.src = arr.episodeImage;
|
|
197
|
+
title.innerHTML = arr.podCastTitle;
|
|
198
|
+
description.innerHTML = arr.episodeDescription;
|
|
199
|
+
durationElement.innerHTML = arr.episodeDuration;
|
|
200
|
+
|
|
201
|
+
if (arr.podcastWasPlaying === true) {
|
|
202
|
+
const playPromise = audio.play();
|
|
203
|
+
|
|
204
|
+
if (playPromise !== undefined) {
|
|
205
|
+
playPromise.then(() => {
|
|
206
|
+
// Continue playing audio on reload
|
|
207
|
+
audio.currentTime = arr.episodeCurrentTime;
|
|
208
|
+
timeupdate();
|
|
209
|
+
audio.play();
|
|
210
|
+
pauseIcon.classList.remove('is-hidden');
|
|
211
|
+
playIcon.classList.add('is-hidden');
|
|
212
|
+
}).catch(() => {
|
|
213
|
+
// User reloaded page manually. Cannot play audio
|
|
214
|
+
audio.addEventListener('loadedmetadata', () => {
|
|
215
|
+
audio.currentTime = arr.episodeCurrentTime;
|
|
216
|
+
timeupdate();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
pauseIcon.classList.add('is-hidden');
|
|
220
|
+
playIcon.classList.remove('is-hidden');
|
|
221
|
+
audio.pause();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
audio.addEventListener('loadedmetadata', () => {
|
|
226
|
+
audio.currentTime = arr.episodeCurrentTime;
|
|
227
|
+
timeupdate();
|
|
228
|
+
});
|
|
229
|
+
pauseIcon.classList.add('is-hidden');
|
|
230
|
+
playIcon.classList.remove('is-hidden');
|
|
231
|
+
audio.pause();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (closeButton) {
|
|
237
|
+
closeButton.addEventListener('click', () => {
|
|
238
|
+
audio.currentTime = 0;
|
|
239
|
+
timeupdate();
|
|
240
|
+
audio.pause();
|
|
241
|
+
localStorage.removeItem('episodeData');
|
|
242
|
+
podCast.classList.add(`${namespace}o-podcast-player--hidden`);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
@@ -5,7 +5,7 @@ module.exports = {
|
|
|
5
5
|
alt: 'Hands typing on laptop',
|
|
6
6
|
img_url: '/assets/images/ALX_0876.jpg',
|
|
7
7
|
title: 'Gymnasieskolor med hög bandbredd har bättre skolresultat',
|
|
8
|
-
url: '
|
|
8
|
+
url: '/components/preview/magazine',
|
|
9
9
|
exerpt: 'Eget nulla <strong>facilisi etiam</strong> dignissim diam quis enim lobortis scelerisque. Faucibus a pellentesque sit amet porttitor.',
|
|
10
10
|
is_padded: true,
|
|
11
11
|
is_wide: false,
|