@internetstiftelsen/styleguide 5.0.18 → 5.1.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/app.js +71 -0
- package/dist/assets/js/Events.js +43 -77
- package/dist/assets/js/RequestError.js +16 -31
- package/dist/assets/js/anchorScroll.js +22 -15
- package/dist/assets/js/charCounter.js +100 -142
- package/dist/assets/js/className.js +19 -20
- package/dist/assets/js/conditional.js +96 -152
- package/dist/assets/js/debounce.js +15 -22
- package/dist/assets/js/el.js +108 -159
- package/dist/assets/js/getCookieByName.js +13 -11
- package/dist/assets/js/hasCookieConsent.js +30 -40
- package/dist/assets/js/htmlTextLength.js +12 -10
- package/dist/assets/js/iconToggle.js +16 -20
- package/dist/assets/js/nodeAdded.js +40 -53
- package/dist/assets/js/objToQuery.js +25 -41
- package/dist/assets/js/offset.js +29 -25
- package/dist/assets/js/ot.js +10 -13
- package/dist/assets/js/parallax.js +23 -23
- package/dist/assets/js/queryToObj.js +16 -22
- package/dist/assets/js/readSpeakerHandling.js +26 -28
- package/dist/assets/js/request.js +43 -52
- package/dist/assets/js/responsivePosition.js +46 -74
- package/dist/assets/js/stringToNode.js +11 -10
- package/dist/assets/js/template.js +15 -21
- package/dist/assets/js/textToggle.js +19 -24
- package/dist/assets/js/track.js +14 -12
- package/dist/assets/js/uid.js +10 -6
- package/dist/assets/js/utmGenerator.js +27 -33
- package/dist/assets/js/validationMessage.js +18 -25
- package/dist/assets/js/youtube.js +134 -170
- package/dist/atoms/button/Button.js +42 -55
- package/dist/atoms/file/file.js +25 -29
- package/dist/atoms/file/filePreview.js +27 -31
- package/dist/atoms/grid-toggle/grid-toggle.js +6 -9
- package/dist/atoms/height-limiter/height-limiter.js +37 -50
- package/dist/atoms/password-toggle/password-toggle.js +9 -11
- package/dist/atoms/range/range.js +32 -39
- package/dist/atoms/textarea/rich-text.js +223 -205
- package/dist/atoms/tooltip/tooltip.js +13 -17
- package/dist/components.js +42 -77
- package/dist/focusTrap.js +66 -77
- package/dist/molecules/alert/alert.js +15 -20
- package/dist/molecules/context-menu/context-menu.js +11 -16
- package/dist/molecules/continue-video-guide/continue-video-guide.js +90 -101
- package/dist/molecules/cookie-disclaimer/cookie-disclaimer.js +24 -33
- package/dist/molecules/form/Form.js +242 -352
- package/dist/molecules/form/index.js +15 -14
- package/dist/molecules/glider/glider-course.js +62 -75
- package/dist/molecules/glider/glider-hero.js +88 -101
- package/dist/molecules/glider/glider.js +49 -45
- package/dist/molecules/modal/modal.js +256 -325
- package/dist/molecules/multi-select/multi-select.js +198 -304
- package/dist/molecules/natural-language-form/natural-language-form.js +32 -46
- package/dist/molecules/overview-navigation/overview-navigation.js +90 -141
- package/dist/molecules/share/share.js +15 -20
- package/dist/molecules/system-error/system-error.js +6 -9
- package/dist/organisms/accordion/accordion.js +44 -50
- package/dist/organisms/footer/footer.js +1 -1
- package/dist/organisms/haveibeenpwned/haveibeenpwned.js +17 -16
- package/dist/organisms/mailchimp/mailchimp.js +72 -89
- package/dist/organisms/map-box/map-box.js +3 -4
- package/dist/organisms/mega-menu/mega-menu.js +177 -212
- package/dist/organisms/podcast/podcast.js +192 -215
- package/dist/organisms/schedule/schedule-filter.js +9 -15
- package/dist/organisms/tabs/tabs.js +194 -253
- package/dist/organisms/timeline/openTimelineItem.js +38 -51
- package/dist/organisms/timeline/timeline.js +111 -128
- package/dist/organisms/video-guide/VideoGuidePlayback.js +210 -286
- package/dist/organisms/video-guide/VideoGuideSubtitles.js +57 -80
- package/dist/organisms/video-guide/VideoGuideTimeline.js +74 -108
- package/dist/organisms/video-guide/getCurrentCueIndex.js +11 -9
- package/dist/organisms/video-guide/video-guide.js +66 -103
- package/dist/utilities/tab-highlighting/tab-highlighting.js +14 -22
- package/dist/vendor/toggle/a11y.toggle-switcher.js +10 -16
- package/package.json +78 -99
- package/src/app.js +5 -5
- package/src/assets/js/anchorScroll.js +1 -1
- package/src/assets/js/offset.js +1 -1
- package/src/atoms/button/Button.js +1 -1
- package/src/atoms/icon/richtext-ordered-list.svg +1 -1
- package/src/atoms/icon/sprite.svg +6 -5
- package/src/molecules/glider/glider-course.js +0 -2
- package/src/molecules/glider/glider.js +2 -2
- package/src/organisms/accordion/accordion.js +1 -2
- package/src/organisms/timeline/timeline.js +2 -3
- package/dist/atoms/timeline/anchorScroll.js +0 -13
- package/dist/atoms/toggle-high-contrast/toggle-high-contrast.js +0 -12
- package/dist/molecules/glider/glider-single.js +0 -68
- package/dist/molecules/modal/modal-graph.js +0 -40
- package/dist/molecules/timeline-navigation/timeline-navigation.js +0 -34
- /package/src/atoms/icon/{heading-3.svg → richtext-heading-3.svg} +0 -0
- /package/src/molecules/alert/{_alert.scss → alert.scss} +0 -0
|
@@ -1,252 +1,217 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _focustrap = require("focus-trap");
|
|
5
6
|
/**
|
|
6
7
|
* Collect the needed elements.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var focusTrap = null;
|
|
17
|
-
|
|
8
|
+
*/ const html = document.querySelector('html');
|
|
9
|
+
const megaMenuButton = document.querySelector('.js-toggle-mega-menu');
|
|
10
|
+
const megaMenu = document.getElementById('megaMenu');
|
|
11
|
+
const content = document.getElementById('siteMain');
|
|
12
|
+
const header = document.getElementById('siteHeader');
|
|
13
|
+
const footer = document.getElementById('siteFooter');
|
|
14
|
+
const alert = document.querySelector('.js-dismiss-alert');
|
|
15
|
+
const isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
|
|
16
|
+
let focusTrap = null;
|
|
18
17
|
if (megaMenu) {
|
|
19
|
-
|
|
18
|
+
focusTrap = (0, _focustrap.createFocusTrap)(megaMenu);
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
/**
|
|
23
21
|
* Check if the element is in the viewport
|
|
24
22
|
*
|
|
25
23
|
* @param {Element} element
|
|
26
24
|
* @returns {boolean}
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return rect.top <= window.innerHeight;
|
|
33
|
-
}
|
|
34
|
-
|
|
25
|
+
*/ function isInViewport(element) {
|
|
26
|
+
const rect = element.getBoundingClientRect();
|
|
27
|
+
// Very simple since we only use it for the footer atm
|
|
28
|
+
return rect.top <= window.innerHeight;
|
|
29
|
+
}
|
|
35
30
|
/**
|
|
36
31
|
* Before the animations start we need to change how certain elements
|
|
37
32
|
* are placed. The visual result should be exactly the same as before these changes.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
33
|
+
*/ function prepareAnimation() {
|
|
34
|
+
const scrollTop = window.scrollY || document.body.scrollTop;
|
|
35
|
+
const contentRect = content.getBoundingClientRect();
|
|
36
|
+
const inViewport = isInViewport(footer);
|
|
37
|
+
header.style.flex = '1 0 auto';
|
|
38
|
+
if (!isIE11) {
|
|
39
|
+
const initialFooterTop = footer.getBoundingClientRect().top;
|
|
40
|
+
megaMenu.style.cssText = 'display: block; flex: 1';
|
|
41
|
+
content.style.cssText = `
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: ${scrollTop + contentRect.top}px;
|
|
44
|
+
left: 0;
|
|
45
|
+
right: 0;
|
|
46
|
+
bottom: 0;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
`;
|
|
49
|
+
if (!inViewport) {
|
|
50
|
+
footer.style.transform = 'translateY(100%)';
|
|
51
|
+
} else {
|
|
52
|
+
requestAnimationFrame(()=>{
|
|
53
|
+
const newFooterTop = footer.getBoundingClientRect().top;
|
|
54
|
+
if (newFooterTop > initialFooterTop) {
|
|
55
|
+
footer.style.transform = `translateY(-${newFooterTop - initialFooterTop}px)`;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
66
61
|
/**
|
|
67
62
|
* Removes all changes to all elements that took part in the animations.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
63
|
+
*/ function removeAnimationPreparations() {
|
|
64
|
+
content.removeAttribute('style');
|
|
65
|
+
footer.removeAttribute('style');
|
|
66
|
+
header.removeAttribute('style');
|
|
67
|
+
megaMenu.removeAttribute('style');
|
|
68
|
+
}
|
|
76
69
|
/**
|
|
77
70
|
* Animate the mega menu and footer into the view
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
71
|
+
*/ function animateIn() {
|
|
72
|
+
megaMenuButton.setAttribute('aria-expanded', 'true');
|
|
73
|
+
megaMenu.setAttribute('aria-hidden', 'false');
|
|
74
|
+
if (!isIE11) {
|
|
75
|
+
footer.style.cssText = 'transform: translateY(0); transition: transform 0.25s ease-in-out;';
|
|
76
|
+
footer.classList.add('is-animated');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
88
79
|
/**
|
|
89
80
|
* Preparations before the hide animation starts.
|
|
90
81
|
* The visual result should be exactly the same as before these changes.
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
82
|
+
*/ function prepareOutAnimation() {
|
|
83
|
+
const headerRect = megaMenu.getBoundingClientRect();
|
|
84
|
+
const initialFooterTop = footer.getBoundingClientRect().top;
|
|
85
|
+
/* Take into account it the site has an alert message at the top */ let alertHeight;
|
|
86
|
+
if (alert) {
|
|
87
|
+
alertHeight = alert.offsetHeight;
|
|
88
|
+
} else {
|
|
89
|
+
alertHeight = 0;
|
|
90
|
+
}
|
|
91
|
+
megaMenu.style.cssText = `
|
|
92
|
+
position: absolute;
|
|
93
|
+
top: ${headerRect.top - alertHeight}px;
|
|
94
|
+
left: 0;
|
|
95
|
+
right: 0;
|
|
96
|
+
display: block;
|
|
97
|
+
`;
|
|
98
|
+
content.removeAttribute('style');
|
|
99
|
+
header.removeAttribute('style');
|
|
100
|
+
if (!isIE11) {
|
|
101
|
+
requestAnimationFrame(()=>{
|
|
102
|
+
const newFooterTop = footer.getBoundingClientRect().top;
|
|
103
|
+
footer.style.transition = 'none';
|
|
104
|
+
if (initialFooterTop > newFooterTop) {
|
|
105
|
+
footer.style.transform = `translateY(${initialFooterTop - newFooterTop}px)`;
|
|
106
|
+
} else if (newFooterTop > initialFooterTop) {
|
|
107
|
+
footer.style.transform = `translateY(-${newFooterTop - initialFooterTop}px)`;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
125
112
|
/**
|
|
126
113
|
* Start the animation that hides the mega menu and footer.
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
114
|
+
*/ function animateOut() {
|
|
115
|
+
megaMenuButton.setAttribute('aria-expanded', 'false');
|
|
116
|
+
megaMenu.setAttribute('aria-hidden', 'true');
|
|
117
|
+
if (!isIE11) {
|
|
118
|
+
footer.addEventListener('transitionend', removeAnimationPreparations, {
|
|
119
|
+
once: true
|
|
120
|
+
});
|
|
121
|
+
footer.style.transition = '0.25s ease-in-out';
|
|
122
|
+
footer.classList.remove('is-animated');
|
|
123
|
+
setTimeout(()=>{
|
|
124
|
+
if (!isInViewport(footer)) {
|
|
125
|
+
footer.style.transform = 'translateY(100%)';
|
|
126
|
+
} else {
|
|
127
|
+
footer.style.transform = 'translateY(0)';
|
|
128
|
+
}
|
|
129
|
+
}, 4);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
147
132
|
/**
|
|
148
133
|
* Hide the mega menu (and footer)
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}, 50);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
134
|
+
*/ function hideMegaMenu() {
|
|
135
|
+
if (megaMenu) {
|
|
136
|
+
if (megaMenu.getAttribute('aria-hidden') === 'true') {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
prepareOutAnimation();
|
|
140
|
+
setTimeout(()=>{
|
|
141
|
+
requestAnimationFrame(animateOut);
|
|
142
|
+
if (html.classList.contains('tab-highlight')) {
|
|
143
|
+
focusTrap.deactivate();
|
|
144
|
+
}
|
|
145
|
+
}, 50);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
167
148
|
/**
|
|
168
149
|
* Show the mega menu (and footer)
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
}, 50);
|
|
183
|
-
}
|
|
184
|
-
|
|
150
|
+
*/ function showMegaMenu() {
|
|
151
|
+
if (megaMenu.getAttribute('aria-hidden') === 'false') {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
prepareAnimation();
|
|
155
|
+
setTimeout(()=>{
|
|
156
|
+
requestAnimationFrame(animateIn);
|
|
157
|
+
if (html.classList.contains('tab-highlight')) {
|
|
158
|
+
focusTrap.activate();
|
|
159
|
+
}
|
|
160
|
+
}, 50);
|
|
161
|
+
}
|
|
185
162
|
/**
|
|
186
163
|
* Toggle the mega menu
|
|
187
164
|
* @param {MouseEvent} e
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
165
|
+
*/ function toggleMegaMenu(e) {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
if (megaMenu.getAttribute('aria-hidden') === 'false') {
|
|
168
|
+
hideMegaMenu();
|
|
169
|
+
} else {
|
|
170
|
+
showMegaMenu();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
199
173
|
function handleMouseUp(e) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
174
|
+
const button = e.target.closest('.js-toggle-domain-search-page');
|
|
175
|
+
if (button && megaMenu.getAttribute('aria-hidden') === 'false') {
|
|
176
|
+
hideMegaMenu();
|
|
177
|
+
}
|
|
205
178
|
}
|
|
206
|
-
|
|
207
179
|
if (megaMenuButton && megaMenu) {
|
|
208
|
-
|
|
209
|
-
|
|
180
|
+
megaMenuButton.addEventListener('click', toggleMegaMenu);
|
|
181
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
210
182
|
}
|
|
211
|
-
|
|
212
183
|
/**
|
|
213
184
|
* Toggle the mega menu submenus
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
185
|
+
*/ function collapse(toggle) {
|
|
186
|
+
var id = toggle.getAttribute('data-a11y-toggle');
|
|
187
|
+
var collapsibleBox = document.getElementById(id);
|
|
188
|
+
collapsibleBox.setAttribute('aria-hidden', true);
|
|
189
|
+
toggle.setAttribute('aria-expanded', false);
|
|
190
|
+
}
|
|
222
191
|
function collapseAll(event) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
192
|
+
if (toggles) {
|
|
193
|
+
toggles.filter(function(toggle) {
|
|
194
|
+
return toggle !== event.target;
|
|
195
|
+
}).forEach(collapse);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const toggles = Array.prototype.slice.call(document.querySelectorAll('.js-menu-toggles [data-a11y-toggle]'));
|
|
231
199
|
if (toggles) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
200
|
+
toggles.forEach(function(toggle) {
|
|
201
|
+
toggle.addEventListener('click', collapseAll);
|
|
202
|
+
});
|
|
235
203
|
}
|
|
236
|
-
|
|
237
204
|
/**
|
|
238
205
|
* Handle mega menu and ReadSpeaker when clicking ReadSpeaker button in mega menu
|
|
239
|
-
*/
|
|
240
|
-
var closeMegaMenuBtn = document.querySelector('.js-close-mega-menu');
|
|
241
|
-
|
|
206
|
+
*/ const closeMegaMenuBtn = document.querySelector('.js-close-mega-menu');
|
|
242
207
|
if (closeMegaMenuBtn) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
208
|
+
document.addEventListener('DOMContentLoaded', ()=>{
|
|
209
|
+
closeMegaMenuBtn.addEventListener('click', function() {
|
|
210
|
+
document.querySelector('.js-toggle-mega-menu').click();
|
|
211
|
+
document.getElementById('readspeakerMenuItem').classList.remove('u-hide-md');
|
|
212
|
+
document.getElementById('readspeakerBtn').click();
|
|
213
|
+
document.querySelector('#readspeakerBtn [class*=a-main-menu__list__text]').classList.add('u-hide-md');
|
|
214
|
+
document.querySelector('#readspeakerBtn [class*=a-button--icon]').classList.add('u-hide-md');
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|