@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,110 +1,76 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
- var VideoGuideTimeline = function () {
12
- function VideoGuideTimeline(element, video) {
13
- var _this = this;
14
-
15
- _classCallCheck(this, VideoGuideTimeline);
16
-
17
- this.togglePosts = function () {
18
- _this.toggleBtn.classList.toggle('is-toggeled');
19
- _this.container.classList.toggle('is-visible');
20
- };
21
-
22
- this.onCueChange = function () {
23
- var activeCues = _this.meta.activeCues;
24
-
25
-
26
- if (activeCues.length > 0) {
27
- var activeCue = activeCues[0];
28
- var activePost = _this.posts.find(function (post) {
29
- return post.dataset.id === activeCue.text;
30
- });
31
-
32
- if (activePost) {
33
- _this.posts.forEach(function (post) {
34
- post.classList.remove('is-current');
35
- });
36
-
37
- activePost.classList.add('is-current');
38
- }
39
-
40
- _this.images.forEach(function (post) {
41
- if (post.dataset.id === activeCue.text) {
42
- post.classList.add('is-current');
43
-
44
- _this.createImageHeadline(activeCue, post);
45
- } else {
46
- post.classList.remove('is-current');
47
- }
48
- });
49
- }
50
- };
51
-
52
- this.element = element;
53
- this.video = video;
54
- this.container = element.querySelector('.js-timeline-posts');
55
- this.posts = Array.from(element.querySelectorAll('.js-timeline-post:not(.js-timeline-image)'));
56
- this.images = Array.from(element.querySelectorAll('.js-timeline-image'));
57
- this.toggleBtn = element.querySelector('.js-show-timelineposts');
58
- this.headlineTpl = element.querySelector('[data-video-headline-tpl]');
59
- this.headlineCache = {};
60
-
61
- this.init();
62
- this.attach();
63
- }
64
-
65
- _createClass(VideoGuideTimeline, [{
66
- key: 'init',
67
- value: function init() {
68
- this.meta = this.video.textTracks.getTrackById('video-metadata');
69
- }
70
- }, {
71
- key: 'attach',
72
- value: function attach() {
73
- this.meta.addEventListener('cuechange', this.onCueChange);
74
-
75
- if (this.toggleBtn) {
76
- this.toggleBtn.addEventListener('click', this.togglePosts);
77
- }
78
- }
79
- }, {
80
- key: 'createImageHeadline',
81
- value: function createImageHeadline(activeCue, post) {
82
- if (activeCue.text in this.headlineCache) {
83
- return;
84
- }
85
-
86
- var element = post.querySelector('[data-video-headline-tpl]');
87
-
88
- if (post.querySelector('[data-video-headline-tpl]')) {
89
- this.headlineCache[activeCue.text] = element;
90
- return;
91
- }
92
-
93
- element = this.headlineTpl.cloneNode(true);
94
- var prevHeadline = element.querySelector('h1');
95
- var headline = document.createElement('h2');
96
-
97
- headline.className = prevHeadline.className;
98
- headline.innerHTML = activeCue.id;
99
-
100
- prevHeadline.parentNode.replaceChild(headline, prevHeadline);
101
- post.appendChild(element);
102
-
103
- this.headlineCache[activeCue.text] = element;
104
- }
105
- }]);
106
-
107
- return VideoGuideTimeline;
108
- }();
109
-
110
- exports.default = VideoGuideTimeline;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return VideoGuideTimeline;
9
+ }
10
+ });
11
+ class VideoGuideTimeline {
12
+ init() {
13
+ this.meta = this.video.textTracks.getTrackById('video-metadata');
14
+ }
15
+ attach() {
16
+ this.meta.addEventListener('cuechange', this.onCueChange);
17
+ if (this.toggleBtn) {
18
+ this.toggleBtn.addEventListener('click', this.togglePosts);
19
+ }
20
+ }
21
+ createImageHeadline(activeCue, post) {
22
+ if (activeCue.text in this.headlineCache) {
23
+ return;
24
+ }
25
+ let element = post.querySelector('[data-video-headline-tpl]');
26
+ if (post.querySelector('[data-video-headline-tpl]')) {
27
+ this.headlineCache[activeCue.text] = element;
28
+ return;
29
+ }
30
+ element = this.headlineTpl.cloneNode(true);
31
+ const prevHeadline = element.querySelector('h1');
32
+ const headline = document.createElement('h2');
33
+ headline.className = prevHeadline.className;
34
+ headline.innerHTML = activeCue.id;
35
+ prevHeadline.parentNode.replaceChild(headline, prevHeadline);
36
+ post.appendChild(element);
37
+ this.headlineCache[activeCue.text] = element;
38
+ }
39
+ constructor(element, video){
40
+ this.togglePosts = ()=>{
41
+ this.toggleBtn.classList.toggle('is-toggeled');
42
+ this.container.classList.toggle('is-visible');
43
+ };
44
+ this.onCueChange = ()=>{
45
+ const { activeCues } = this.meta;
46
+ if (activeCues.length > 0) {
47
+ const activeCue = activeCues[0];
48
+ const activePost = this.posts.find((post)=>post.dataset.id === activeCue.text);
49
+ if (activePost) {
50
+ this.posts.forEach((post)=>{
51
+ post.classList.remove('is-current');
52
+ });
53
+ activePost.classList.add('is-current');
54
+ }
55
+ this.images.forEach((post)=>{
56
+ if (post.dataset.id === activeCue.text) {
57
+ post.classList.add('is-current');
58
+ this.createImageHeadline(activeCue, post);
59
+ } else {
60
+ post.classList.remove('is-current');
61
+ }
62
+ });
63
+ }
64
+ };
65
+ this.element = element;
66
+ this.video = video;
67
+ this.container = element.querySelector('.js-timeline-posts');
68
+ this.posts = Array.from(element.querySelectorAll('.js-timeline-post:not(.js-timeline-image)'));
69
+ this.images = Array.from(element.querySelectorAll('.js-timeline-image'));
70
+ this.toggleBtn = element.querySelector('.js-show-timelineposts');
71
+ this.headlineTpl = element.querySelector('[data-video-headline-tpl]');
72
+ this.headlineCache = {};
73
+ this.init();
74
+ this.attach();
75
+ }
76
+ }
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getCurrentCueIndex;
9
+ }
5
10
  });
6
- exports.default = getCurrentCueIndex;
7
11
  function getCurrentCueIndex(target) {
8
- var activeCue = target.activeCues[0];
9
- var cues = target.cues;
10
-
11
-
12
- return Math.max(Array.prototype.indexOf.call(cues, activeCue), 0);
13
- }
12
+ const activeCue = target.activeCues[0];
13
+ const { cues } = target;
14
+ return Math.max(Array.prototype.indexOf.call(cues, activeCue), 0);
15
+ }
@@ -1,103 +1,66 @@
1
- 'use strict';
2
-
3
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
-
5
- var _VideoGuideSubtitles = require('./VideoGuideSubtitles');
6
-
7
- var _VideoGuideSubtitles2 = _interopRequireDefault(_VideoGuideSubtitles);
8
-
9
- var _VideoGuideTimeline = require('./VideoGuideTimeline');
10
-
11
- var _VideoGuideTimeline2 = _interopRequireDefault(_VideoGuideTimeline);
12
-
13
- var _VideoGuidePlayback = require('./VideoGuidePlayback');
14
-
15
- var _VideoGuidePlayback2 = _interopRequireDefault(_VideoGuidePlayback);
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
-
21
- var VideoGuide = function () {
22
- function VideoGuide(element) {
23
- var _this = this;
24
-
25
- _classCallCheck(this, VideoGuide);
26
-
27
- this.onLoadedMetadata = function () {
28
- _this.playback = new _VideoGuidePlayback2.default(_this.element, _this.video);
29
- _this.subtitles = new _VideoGuideSubtitles2.default(_this.element, _this.video);
30
- _this.timeline = new _VideoGuideTimeline2.default(_this.element, _this.video);
31
-
32
- _this.video.classList.remove('is-loading');
33
- };
34
-
35
- this.dispatchEvent = function (eventName) {
36
- [_this.playback, _this.subtitles, _this.timeline].forEach(function (instance) {
37
- if (instance && eventName in instance) {
38
- instance[eventName]();
39
- }
40
- });
41
- };
42
-
43
- this.onPlay = function () {
44
- return _this.dispatchEvent('onPlay');
45
- };
46
-
47
- this.onPause = function () {
48
- return _this.dispatchEvent('onPause');
49
- };
50
-
51
- this.onEnded = function () {
52
- return _this.dispatchEvent('onEnded');
53
- };
54
-
55
- this.onTimeUpdate = function () {
56
- return _this.dispatchEvent('onTimeUpdate');
57
- };
58
-
59
- this.onAbort = function () {
60
- _this.dispatchEvent('onAbort');
61
- window.location.href = _this.abortBtn.href;
62
- };
63
-
64
- this.element = element;
65
- this.video = element.querySelector('.js-video-guide');
66
- this.abortBtn = element.querySelector('.js-abort-guide');
67
- this.playback = null;
68
- this.subtitles = null;
69
- this.timeline = null;
70
-
71
- // Set all track elements to hidden mode to allow scripting
72
- [].forEach.call(this.video.textTracks, function (txtTrack) {
73
- txtTrack.mode = 'hidden';
74
- });
75
-
76
- this.attach();
77
-
78
- // loadedmetadata might not be fired if the video is already loaded
79
- if (this.video.readyState >= 1) {
80
- this.onLoadedMetadata();
81
- }
82
- }
83
-
84
- _createClass(VideoGuide, [{
85
- key: 'attach',
86
- value: function attach() {
87
- this.video.addEventListener('loadedmetadata', this.onLoadedMetadata);
88
- this.video.addEventListener('play', this.onPlay);
89
- this.video.addEventListener('pause', this.onPause);
90
- this.video.addEventListener('ended', this.onEnded);
91
- this.video.addEventListener('timeupdate', this.onTimeUpdate);
92
- this.abortBtn.addEventListener('click', this.onAbort);
93
- }
94
- }]);
95
-
96
- return VideoGuide;
97
- }();
98
-
99
- var elements = document.querySelectorAll('[data-video-guide]');
100
-
101
- elements.forEach(function (element) {
102
- return new VideoGuide(element);
103
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _VideoGuideSubtitles = /*#__PURE__*/ _interop_require_default(require("./VideoGuideSubtitles"));
6
+ const _VideoGuideTimeline = /*#__PURE__*/ _interop_require_default(require("./VideoGuideTimeline"));
7
+ const _VideoGuidePlayback = /*#__PURE__*/ _interop_require_default(require("./VideoGuidePlayback"));
8
+ function _interop_require_default(obj) {
9
+ return obj && obj.__esModule ? obj : {
10
+ default: obj
11
+ };
12
+ }
13
+ class VideoGuide {
14
+ attach() {
15
+ this.video.addEventListener('loadedmetadata', this.onLoadedMetadata);
16
+ this.video.addEventListener('play', this.onPlay);
17
+ this.video.addEventListener('pause', this.onPause);
18
+ this.video.addEventListener('ended', this.onEnded);
19
+ this.video.addEventListener('timeupdate', this.onTimeUpdate);
20
+ this.abortBtn.addEventListener('click', this.onAbort);
21
+ }
22
+ constructor(element){
23
+ this.onLoadedMetadata = ()=>{
24
+ this.playback = new _VideoGuidePlayback.default(this.element, this.video);
25
+ this.subtitles = new _VideoGuideSubtitles.default(this.element, this.video);
26
+ this.timeline = new _VideoGuideTimeline.default(this.element, this.video);
27
+ this.video.classList.remove('is-loading');
28
+ };
29
+ this.dispatchEvent = (eventName)=>{
30
+ [
31
+ this.playback,
32
+ this.subtitles,
33
+ this.timeline
34
+ ].forEach((instance)=>{
35
+ if (instance && eventName in instance) {
36
+ instance[eventName]();
37
+ }
38
+ });
39
+ };
40
+ this.onPlay = ()=>this.dispatchEvent('onPlay');
41
+ this.onPause = ()=>this.dispatchEvent('onPause');
42
+ this.onEnded = ()=>this.dispatchEvent('onEnded');
43
+ this.onTimeUpdate = ()=>this.dispatchEvent('onTimeUpdate');
44
+ this.onAbort = ()=>{
45
+ this.dispatchEvent('onAbort');
46
+ window.location.href = this.abortBtn.href;
47
+ };
48
+ this.element = element;
49
+ this.video = element.querySelector('.js-video-guide');
50
+ this.abortBtn = element.querySelector('.js-abort-guide');
51
+ this.playback = null;
52
+ this.subtitles = null;
53
+ this.timeline = null;
54
+ // Set all track elements to hidden mode to allow scripting
55
+ [].forEach.call(this.video.textTracks, (txtTrack)=>{
56
+ txtTrack.mode = 'hidden';
57
+ });
58
+ this.attach();
59
+ // loadedmetadata might not be fired if the video is already loaded
60
+ if (this.video.readyState >= 1) {
61
+ this.onLoadedMetadata();
62
+ }
63
+ }
64
+ }
65
+ const elements = document.querySelectorAll('[data-video-guide]');
66
+ elements.forEach((element)=>new VideoGuide(element));
@@ -1,30 +1,22 @@
1
- 'use strict';
2
-
3
1
  // Add class to html-element on tab click
4
-
5
- var element = document.getElementsByTagName('html')[0];
6
- var highLightClass = 'tab-highlight';
7
-
2
+ "use strict";
3
+ const element = document.getElementsByTagName('html')[0];
4
+ const highLightClass = 'tab-highlight';
8
5
  function onKeyDown(e) {
9
- var event = e;
10
- if (!event) {
11
- window.event = event;
12
- }
13
-
14
- var keyCode = event.keyCode || event.which;
15
- var tabKey = 9;
16
-
17
- if (keyCode === tabKey) {
18
- this.classList.add(highLightClass);
19
- }
6
+ const event = e;
7
+ if (!event) {
8
+ window.event = event;
9
+ }
10
+ const keyCode = event.keyCode || event.which;
11
+ const tabKey = 9;
12
+ if (keyCode === tabKey) {
13
+ this.classList.add(highLightClass);
14
+ }
20
15
  }
21
-
22
16
  // Remove class on mouse click
23
17
  function onMouseDown() {
24
- this.classList.remove(highLightClass);
18
+ this.classList.remove(highLightClass);
25
19
  }
26
-
27
20
  // Run on events
28
-
29
21
  element.addEventListener('keydown', onKeyDown);
30
- element.addEventListener('mousedown', onMouseDown);
22
+ element.addEventListener('mousedown', onMouseDown);
@@ -1,21 +1,15 @@
1
- 'use strict';
2
-
3
1
  // Only allow one panel to be opened at a time.
2
+ "use strict";
4
3
  function collapse(toggle) {
5
- var id = toggle.getAttribute('data-a11y-toggle');
6
- var collapsibleBox = document.getElementById(id);
7
- collapsibleBox.setAttribute('aria-hidden', true);
8
- toggle.setAttribute('aria-expanded', false);
4
+ const id = toggle.getAttribute('data-a11y-toggle');
5
+ const collapsibleBox = document.getElementById(id);
6
+ collapsibleBox.setAttribute('aria-hidden', true);
7
+ toggle.setAttribute('aria-expanded', false);
9
8
  }
10
-
11
- var toggles = Array.prototype.slice.call(document.querySelectorAll('[data-a11y-toggle]'));
12
-
9
+ const toggles = Array.prototype.slice.call(document.querySelectorAll('[data-a11y-toggle]'));
13
10
  function collapseAll(event) {
14
- toggles.filter(function (toggle) {
15
- return toggle !== event.target;
16
- }).forEach(collapse);
11
+ toggles.filter((toggle)=>toggle !== event.target).forEach(collapse);
17
12
  }
18
-
19
- toggles.forEach(function (toggle) {
20
- toggle.addEventListener('click', collapseAll);
21
- });
13
+ toggles.forEach((toggle)=>{
14
+ toggle.addEventListener('click', collapseAll);
15
+ });