@internetstiftelsen/styleguide 5.0.19 → 5.1.1

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.
Files changed (92) hide show
  1. package/dist/app.js +71 -0
  2. package/dist/assets/js/Events.js +43 -77
  3. package/dist/assets/js/RequestError.js +16 -31
  4. package/dist/assets/js/anchorScroll.js +22 -15
  5. package/dist/assets/js/charCounter.js +100 -142
  6. package/dist/assets/js/className.js +19 -20
  7. package/dist/assets/js/conditional.js +96 -152
  8. package/dist/assets/js/debounce.js +15 -22
  9. package/dist/assets/js/el.js +108 -159
  10. package/dist/assets/js/getCookieByName.js +13 -11
  11. package/dist/assets/js/hasCookieConsent.js +30 -40
  12. package/dist/assets/js/htmlTextLength.js +12 -10
  13. package/dist/assets/js/iconToggle.js +16 -20
  14. package/dist/assets/js/nodeAdded.js +40 -53
  15. package/dist/assets/js/objToQuery.js +25 -41
  16. package/dist/assets/js/offset.js +29 -25
  17. package/dist/assets/js/ot.js +10 -13
  18. package/dist/assets/js/parallax.js +23 -23
  19. package/dist/assets/js/queryToObj.js +16 -22
  20. package/dist/assets/js/readSpeakerHandling.js +26 -28
  21. package/dist/assets/js/request.js +43 -52
  22. package/dist/assets/js/responsivePosition.js +46 -74
  23. package/dist/assets/js/stringToNode.js +11 -10
  24. package/dist/assets/js/template.js +15 -21
  25. package/dist/assets/js/textToggle.js +19 -24
  26. package/dist/assets/js/track.js +14 -12
  27. package/dist/assets/js/uid.js +10 -6
  28. package/dist/assets/js/utmGenerator.js +27 -33
  29. package/dist/assets/js/validationMessage.js +18 -25
  30. package/dist/assets/js/youtube.js +134 -170
  31. package/dist/atoms/button/Button.js +42 -55
  32. package/dist/atoms/file/file.js +25 -29
  33. package/dist/atoms/file/filePreview.js +27 -31
  34. package/dist/atoms/grid-toggle/grid-toggle.js +6 -9
  35. package/dist/atoms/height-limiter/height-limiter.js +37 -50
  36. package/dist/atoms/password-toggle/password-toggle.js +9 -11
  37. package/dist/atoms/range/range.js +32 -39
  38. package/dist/atoms/textarea/rich-text.js +221 -251
  39. package/dist/atoms/tooltip/tooltip.js +13 -17
  40. package/dist/components.js +42 -77
  41. package/dist/focusTrap.js +66 -77
  42. package/dist/molecules/alert/alert.js +15 -20
  43. package/dist/molecules/context-menu/context-menu.js +11 -16
  44. package/dist/molecules/continue-video-guide/continue-video-guide.js +90 -101
  45. package/dist/molecules/cookie-disclaimer/cookie-disclaimer.js +24 -33
  46. package/dist/molecules/form/Form.js +242 -352
  47. package/dist/molecules/form/index.js +15 -14
  48. package/dist/molecules/glider/glider-course.js +62 -75
  49. package/dist/molecules/glider/glider-hero.js +88 -101
  50. package/dist/molecules/glider/glider.js +49 -45
  51. package/dist/molecules/modal/modal.js +256 -325
  52. package/dist/molecules/multi-select/multi-select.js +198 -304
  53. package/dist/molecules/natural-language-form/natural-language-form.js +32 -46
  54. package/dist/molecules/overview-navigation/overview-navigation.js +90 -141
  55. package/dist/molecules/share/share.js +15 -20
  56. package/dist/molecules/system-error/system-error.js +6 -9
  57. package/dist/organisms/accordion/accordion.js +44 -50
  58. package/dist/organisms/footer/footer.js +1 -1
  59. package/dist/organisms/haveibeenpwned/haveibeenpwned.js +17 -16
  60. package/dist/organisms/mailchimp/mailchimp.js +72 -89
  61. package/dist/organisms/map-box/map-box.js +3 -4
  62. package/dist/organisms/mega-menu/mega-menu.js +177 -212
  63. package/dist/organisms/podcast/podcast.js +192 -215
  64. package/dist/organisms/schedule/schedule-filter.js +9 -15
  65. package/dist/organisms/tabs/tabs.js +194 -253
  66. package/dist/organisms/timeline/openTimelineItem.js +38 -51
  67. package/dist/organisms/timeline/timeline.js +111 -128
  68. package/dist/organisms/video-guide/VideoGuidePlayback.js +210 -286
  69. package/dist/organisms/video-guide/VideoGuideSubtitles.js +57 -80
  70. package/dist/organisms/video-guide/VideoGuideTimeline.js +74 -108
  71. package/dist/organisms/video-guide/getCurrentCueIndex.js +11 -9
  72. package/dist/organisms/video-guide/video-guide.js +66 -103
  73. package/dist/utilities/tab-highlighting/tab-highlighting.js +14 -22
  74. package/dist/vendor/toggle/a11y.toggle-switcher.js +10 -16
  75. package/package.json +78 -99
  76. package/src/app.js +5 -5
  77. package/src/assets/js/anchorScroll.js +1 -1
  78. package/src/assets/js/offset.js +1 -1
  79. package/src/atoms/button/Button.js +1 -1
  80. package/src/atoms/icon/richtext-ordered-list.svg +1 -1
  81. package/src/atoms/icon/sprite.svg +6 -5
  82. package/src/molecules/glider/glider-course.js +0 -2
  83. package/src/molecules/glider/glider.js +2 -2
  84. package/src/organisms/accordion/accordion.js +1 -2
  85. package/src/organisms/timeline/timeline.js +2 -3
  86. package/dist/atoms/timeline/anchorScroll.js +0 -13
  87. package/dist/atoms/toggle-high-contrast/toggle-high-contrast.js +0 -12
  88. package/dist/molecules/glider/glider-single.js +0 -68
  89. package/dist/molecules/modal/modal-graph.js +0 -40
  90. package/dist/molecules/timeline-navigation/timeline-navigation.js +0 -34
  91. /package/src/atoms/icon/{heading-3.svg → richtext-heading-3.svg} +0 -0
  92. /package/src/molecules/alert/{_alert.scss → alert.scss} +0 -0
@@ -1,252 +1,217 @@
1
- 'use strict';
2
-
3
- var _focusTrap = require('focus-trap');
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
- var html = document.querySelector('html');
9
- var megaMenuButton = document.querySelector('.js-toggle-mega-menu');
10
- var megaMenu = document.getElementById('megaMenu');
11
- var content = document.getElementById('siteMain');
12
- var header = document.getElementById('siteHeader');
13
- var footer = document.getElementById('siteFooter');
14
- var alert = document.querySelector('.js-dismiss-alert');
15
- var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
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
- focusTrap = (0, _focusTrap.createFocusTrap)(megaMenu);
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
- function isInViewport(element) {
29
- var rect = element.getBoundingClientRect();
30
-
31
- // Very simple since we only use it for the footer atm
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
- function prepareAnimation() {
40
- var scrollTop = window.scrollY || document.body.scrollTop;
41
- var contentRect = content.getBoundingClientRect();
42
- var inViewport = isInViewport(footer);
43
-
44
- header.style.flex = '1 0 auto';
45
-
46
- if (!isIE11) {
47
- var initialFooterTop = footer.getBoundingClientRect().top;
48
- megaMenu.style.cssText = 'display: block; flex: 1';
49
-
50
- content.style.cssText = '\n\t position: absolute;\n\t top: ' + (scrollTop + contentRect.top) + 'px;\n\t left: 0;\n\t right: 0;\n\t bottom: 0;\n\t overflow: hidden;\n\t ';
51
-
52
- if (!inViewport) {
53
- footer.style.transform = 'translateY(100%)';
54
- } else {
55
- requestAnimationFrame(function () {
56
- var newFooterTop = footer.getBoundingClientRect().top;
57
-
58
- if (newFooterTop > initialFooterTop) {
59
- footer.style.transform = 'translateY(-' + (newFooterTop - initialFooterTop) + 'px)';
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
- function removeAnimationPreparations() {
70
- content.removeAttribute('style');
71
- footer.removeAttribute('style');
72
- header.removeAttribute('style');
73
- megaMenu.removeAttribute('style');
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
- function animateIn() {
80
- megaMenuButton.setAttribute('aria-expanded', 'true');
81
- megaMenu.setAttribute('aria-hidden', 'false');
82
- if (!isIE11) {
83
- footer.style.cssText = 'transform: translateY(0); transition: transform 0.25s ease-in-out;';
84
- footer.classList.add('is-animated');
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
- function prepareOutAnimation() {
93
- var headerRect = megaMenu.getBoundingClientRect();
94
- var initialFooterTop = footer.getBoundingClientRect().top;
95
-
96
- /* Take into account it the site has an alert message at the top */
97
- var alertHeight = void 0;
98
-
99
- if (alert) {
100
- alertHeight = alert.offsetHeight;
101
- } else {
102
- alertHeight = 0;
103
- }
104
-
105
- megaMenu.style.cssText = '\n position: absolute;\n top: ' + (headerRect.top - alertHeight) + 'px;\n left: 0;\n right: 0;\n display: block;\n\t';
106
-
107
- content.removeAttribute('style');
108
- header.removeAttribute('style');
109
-
110
- if (!isIE11) {
111
- requestAnimationFrame(function () {
112
- var newFooterTop = footer.getBoundingClientRect().top;
113
-
114
- footer.style.transition = 'none';
115
-
116
- if (initialFooterTop > newFooterTop) {
117
- footer.style.transform = 'translateY(' + (initialFooterTop - newFooterTop) + 'px)';
118
- } else if (newFooterTop > initialFooterTop) {
119
- footer.style.transform = 'translateY(-' + (newFooterTop - initialFooterTop) + 'px)';
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
- function animateOut() {
129
- megaMenuButton.setAttribute('aria-expanded', 'false');
130
- megaMenu.setAttribute('aria-hidden', 'true');
131
-
132
- if (!isIE11) {
133
- footer.addEventListener('transitionend', removeAnimationPreparations, { once: true });
134
- footer.style.transition = '0.25s ease-in-out';
135
- footer.classList.remove('is-animated');
136
-
137
- setTimeout(function () {
138
- if (!isInViewport(footer)) {
139
- footer.style.transform = 'translateY(100%)';
140
- } else {
141
- footer.style.transform = 'translateY(0)';
142
- }
143
- }, 4);
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
- function hideMegaMenu() {
151
- if (megaMenu) {
152
- if (megaMenu.getAttribute('aria-hidden') === 'true') {
153
- return;
154
- }
155
-
156
- prepareOutAnimation();
157
-
158
- setTimeout(function () {
159
- requestAnimationFrame(animateOut);
160
- if (html.classList.contains('tab-highlight')) {
161
- focusTrap.deactivate();
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
- function showMegaMenu() {
171
- if (megaMenu.getAttribute('aria-hidden') === 'false') {
172
- return;
173
- }
174
-
175
- prepareAnimation();
176
-
177
- setTimeout(function () {
178
- requestAnimationFrame(animateIn);
179
- if (html.classList.contains('tab-highlight')) {
180
- focusTrap.activate();
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
- function toggleMegaMenu(e) {
190
- e.preventDefault();
191
-
192
- if (megaMenu.getAttribute('aria-hidden') === 'false') {
193
- hideMegaMenu();
194
- } else {
195
- showMegaMenu();
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
- var button = e.target.closest('.js-toggle-domain-search-page');
201
-
202
- if (button && megaMenu.getAttribute('aria-hidden') === 'false') {
203
- hideMegaMenu();
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
- megaMenuButton.addEventListener('click', toggleMegaMenu);
209
- document.addEventListener('mouseup', handleMouseUp);
180
+ megaMenuButton.addEventListener('click', toggleMegaMenu);
181
+ document.addEventListener('mouseup', handleMouseUp);
210
182
  }
211
-
212
183
  /**
213
184
  * Toggle the mega menu submenus
214
- */
215
- function collapse(toggle) {
216
- var id = toggle.getAttribute('data-a11y-toggle');
217
- var collapsibleBox = document.getElementById(id);
218
- collapsibleBox.setAttribute('aria-hidden', true);
219
- toggle.setAttribute('aria-expanded', false);
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
- if (toggles) {
224
- toggles.filter(function (toggle) {
225
- return toggle !== event.target;
226
- }).forEach(collapse);
227
- }
228
- }
229
- var toggles = Array.prototype.slice.call(document.querySelectorAll('.js-menu-toggles [data-a11y-toggle]'));
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
- toggles.forEach(function (toggle) {
233
- toggle.addEventListener('click', collapseAll);
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
- document.addEventListener('DOMContentLoaded', function () {
244
- closeMegaMenuBtn.addEventListener('click', function () {
245
- document.querySelector('.js-toggle-mega-menu').click();
246
- document.getElementById('readspeakerMenuItem').classList.remove('u-hide-md');
247
- document.getElementById('readspeakerBtn').click();
248
- document.querySelector('#readspeakerBtn [class*=a-main-menu__list__text]').classList.add('u-hide-md');
249
- document.querySelector('#readspeakerBtn [class*=a-button--icon]').classList.add('u-hide-md');
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
+ }