@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.
- 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 +221 -251
- 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,255 +1,196 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
component.tabLinks.forEach(function (item, index) {
|
|
196
|
-
item.removeAttribute('role', 'tab');
|
|
197
|
-
item.removeAttribute('id', 'tab' + index);
|
|
198
|
-
|
|
199
|
-
if (index > 0) {
|
|
200
|
-
item.removeAttribute('tabindex', '-1');
|
|
201
|
-
} else {
|
|
202
|
-
item.removeAttribute('aria-selected', 'true');
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
component.tabPanels.forEach(function (item, index) {
|
|
207
|
-
item.removeAttribute('role', 'tabpanel');
|
|
208
|
-
item.removeAttribute('aria-labelledby', 'tab' + index);
|
|
209
|
-
item.removeAttribute('tabindex', '-1');
|
|
210
|
-
|
|
211
|
-
if (index > 0) {
|
|
212
|
-
item.removeAttribute('hidden');
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
component.tabList.removeEventListener('click', component.eventCallback);
|
|
217
|
-
component.tabList.removeEventListener('keydown', component.eventCallback);
|
|
218
|
-
tabInstances.delete(component.element);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Handles all event listener callbacks
|
|
223
|
-
* @param {event} event
|
|
224
|
-
*/
|
|
225
|
-
function handleEvents(event) {
|
|
226
|
-
if (event.type === 'click') {
|
|
227
|
-
event.preventDefault();
|
|
228
|
-
TabComponent.prototype.handleTabInteraction.call(this, this.tabLinks.indexOf(event.target));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (event.type === 'keydown') {
|
|
232
|
-
var index = this.tabLinks.indexOf(event.target);
|
|
233
|
-
|
|
234
|
-
// Left and right arrows
|
|
235
|
-
if (event.which === 37 || event.which === 39) {
|
|
236
|
-
event.preventDefault();
|
|
237
|
-
TabComponent.prototype.handleTabInteraction.call(this, index, event.which);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Down arrow
|
|
241
|
-
if (event.which === 40) {
|
|
242
|
-
event.preventDefault();
|
|
243
|
-
TabComponent.prototype.handleTabpanelFocus.call(this, index);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return {
|
|
249
|
-
create: createTabComponent,
|
|
250
|
-
destroy: destroyTabComponent
|
|
251
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
window.a11yTabs = function tabsComponentIIFE(global, document1) {
|
|
3
|
+
const tabInstances = new WeakMap();
|
|
4
|
+
const className = 'o-tab-list';
|
|
5
|
+
const tablistElement = document1.querySelector(`.js-${className}`);
|
|
6
|
+
let updateURLFromHash;
|
|
7
|
+
if (tablistElement) {
|
|
8
|
+
updateURLFromHash = tablistElement.getAttribute('data-update-url');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Instantiates the component
|
|
12
|
+
* @constructor
|
|
13
|
+
* @param {DOM Node} element
|
|
14
|
+
*/ const TabComponent = function TabComponent(element, options) {
|
|
15
|
+
if (!element || !element.nodeType) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const namespace = getComputedStyle(tablistElement, ':before').content.replace(/["']/g, '');
|
|
19
|
+
const defaults = {
|
|
20
|
+
tabList: `.${namespace}${className}`,
|
|
21
|
+
tabItem: `.${namespace}${className}__item`,
|
|
22
|
+
tabLink: `.${namespace}${className}__link`,
|
|
23
|
+
tabPanel: `.${namespace}o-tab-panel`
|
|
24
|
+
};
|
|
25
|
+
this.options = Object.assign(defaults, options);
|
|
26
|
+
this.element = element;
|
|
27
|
+
this.tabList = element.querySelector(this.options.tabList);
|
|
28
|
+
this.tabItems = [].slice.call(this.tabList.querySelectorAll(this.options.tabItem));
|
|
29
|
+
this.tabLinks = [].slice.call(this.tabList.querySelectorAll(this.options.tabLink));
|
|
30
|
+
this.tabPanels = [].slice.call(element.querySelectorAll(this.options.tabPanel));
|
|
31
|
+
this.currentIndex = 0;
|
|
32
|
+
this.tabList.setAttribute('role', 'tablist');
|
|
33
|
+
this.tabItems.forEach((item, index)=>{
|
|
34
|
+
item.setAttribute('role', 'presentation');
|
|
35
|
+
if (index === 0) {
|
|
36
|
+
item.setAttribute('data-tab-active', '');
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
this.tabLinks.forEach((item, index)=>{
|
|
40
|
+
item.setAttribute('role', 'tab');
|
|
41
|
+
if (index > 0) {
|
|
42
|
+
item.setAttribute('tabindex', '-1');
|
|
43
|
+
} else {
|
|
44
|
+
item.setAttribute('aria-selected', 'true');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
this.tabPanels.forEach((item, index)=>{
|
|
48
|
+
item.setAttribute('role', 'tabpanel');
|
|
49
|
+
item.setAttribute('aria-labelledby', `tab${index}`);
|
|
50
|
+
item.setAttribute('tabindex', '-1');
|
|
51
|
+
if (index > 0) {
|
|
52
|
+
item.setAttribute('hidden', '');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
this.eventCallback = handleEvents.bind(this);
|
|
56
|
+
this.tabList.addEventListener('click', this.eventCallback, false);
|
|
57
|
+
this.tabList.addEventListener('keydown', this.eventCallback, false);
|
|
58
|
+
tabInstances.set(this.element, this);
|
|
59
|
+
// Select the correct tab based on URL hash
|
|
60
|
+
if (updateURLFromHash) {
|
|
61
|
+
this.selectTabFromHash();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
TabComponent.prototype = {
|
|
65
|
+
/**
|
|
66
|
+
* Event handler for all tab interactions
|
|
67
|
+
* @param {number} index - Index of the tab being activiated
|
|
68
|
+
* @param {string} direction -
|
|
69
|
+
*/ handleTabInteraction: function handleTabInteraction(index, direction) {
|
|
70
|
+
const { currentIndex } = this;
|
|
71
|
+
let newIndex = index;
|
|
72
|
+
// The click event does not pass in a direction. This is for keyboard support
|
|
73
|
+
if (direction) {
|
|
74
|
+
if (direction === 37) {
|
|
75
|
+
newIndex = index - 1;
|
|
76
|
+
} else {
|
|
77
|
+
newIndex = index + 1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Supports continuous tabbing when reaching beginning or end of tab list
|
|
81
|
+
if (newIndex < 0) {
|
|
82
|
+
newIndex = this.tabLinks.length - 1;
|
|
83
|
+
} else if (newIndex === this.tabLinks.length) {
|
|
84
|
+
newIndex = 0;
|
|
85
|
+
}
|
|
86
|
+
// update tabs
|
|
87
|
+
this.tabLinks[currentIndex].setAttribute('tabindex', '-1');
|
|
88
|
+
this.tabLinks[currentIndex].removeAttribute('aria-selected');
|
|
89
|
+
this.tabItems[currentIndex].removeAttribute('data-tab-active');
|
|
90
|
+
this.tabLinks[newIndex].setAttribute('aria-selected', 'true');
|
|
91
|
+
this.tabItems[newIndex].setAttribute('data-tab-active', '');
|
|
92
|
+
this.tabLinks[newIndex].removeAttribute('tabindex');
|
|
93
|
+
this.tabLinks[newIndex].focus(); // Focus the newly selected tab
|
|
94
|
+
// update tab panels
|
|
95
|
+
this.tabPanels[currentIndex].setAttribute('hidden', '');
|
|
96
|
+
this.tabPanels[newIndex].removeAttribute('hidden');
|
|
97
|
+
// Update the browser's URL hash to reflect the current tab's ID
|
|
98
|
+
const selectedTabId = this.tabLinks[newIndex].id;
|
|
99
|
+
if (updateURLFromHash) {
|
|
100
|
+
window.history.pushState(null, '', `#${selectedTabId}`);
|
|
101
|
+
}
|
|
102
|
+
this.currentIndex = newIndex;
|
|
103
|
+
return this;
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* Set tab panel focus
|
|
107
|
+
* @param {number} index - Tab panel index to receive focus
|
|
108
|
+
*/ handleTabpanelFocus: function handleTabPanelFocus(index) {
|
|
109
|
+
this.tabPanels[index].focus();
|
|
110
|
+
return this;
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Selects a tab based on the URL hash
|
|
114
|
+
*/ selectTabFromHash () {
|
|
115
|
+
const { hash } = global.location;
|
|
116
|
+
if (hash) {
|
|
117
|
+
const targetId = hash.substring(1); // Remove the '#' character
|
|
118
|
+
const targetIndex = this.tabLinks.findIndex((link)=>link.id === targetId);
|
|
119
|
+
if (targetIndex !== -1) {
|
|
120
|
+
this.handleTabInteraction(targetIndex);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Creates or returns existing component
|
|
127
|
+
* @param {string} selector
|
|
128
|
+
*/ function createTabComponent(selector, options) {
|
|
129
|
+
const elements = document1.querySelectorAll(selector);
|
|
130
|
+
[].forEach.call(elements, (element)=>tabInstances.get(element) || new TabComponent(element, options));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Destroys an existing component
|
|
134
|
+
* @param {DOM Node} element
|
|
135
|
+
*/ function destroyTabComponent(element) {
|
|
136
|
+
if (!element || !element.nodeType) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const component = tabInstances.get(element);
|
|
140
|
+
component.tabList.removeAttribute('role', 'tablist');
|
|
141
|
+
component.tabItems.forEach((item, index)=>{
|
|
142
|
+
item.removeAttribute('role', 'presentation');
|
|
143
|
+
if (index === 0) {
|
|
144
|
+
item.removeAttribute('data-tab-active');
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
component.tabLinks.forEach((item, index)=>{
|
|
148
|
+
item.removeAttribute('role', 'tab');
|
|
149
|
+
item.removeAttribute('id', `tab${index}`);
|
|
150
|
+
if (index > 0) {
|
|
151
|
+
item.removeAttribute('tabindex', '-1');
|
|
152
|
+
} else {
|
|
153
|
+
item.removeAttribute('aria-selected', 'true');
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
component.tabPanels.forEach((item, index)=>{
|
|
157
|
+
item.removeAttribute('role', 'tabpanel');
|
|
158
|
+
item.removeAttribute('aria-labelledby', `tab${index}`);
|
|
159
|
+
item.removeAttribute('tabindex', '-1');
|
|
160
|
+
if (index > 0) {
|
|
161
|
+
item.removeAttribute('hidden');
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
component.tabList.removeEventListener('click', component.eventCallback);
|
|
165
|
+
component.tabList.removeEventListener('keydown', component.eventCallback);
|
|
166
|
+
tabInstances.delete(component.element);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Handles all event listener callbacks
|
|
170
|
+
* @param {event} event
|
|
171
|
+
*/ function handleEvents(event) {
|
|
172
|
+
if (event.type === 'click') {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
TabComponent.prototype.handleTabInteraction.call(this, this.tabLinks.indexOf(event.target));
|
|
175
|
+
}
|
|
176
|
+
if (event.type === 'keydown') {
|
|
177
|
+
const index = this.tabLinks.indexOf(event.target);
|
|
178
|
+
// Left and right arrows
|
|
179
|
+
if (event.which === 37 || event.which === 39) {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
TabComponent.prototype.handleTabInteraction.call(this, index, event.which);
|
|
182
|
+
}
|
|
183
|
+
// Down arrow
|
|
184
|
+
if (event.which === 40) {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
TabComponent.prototype.handleTabpanelFocus.call(this, index);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
create: createTabComponent,
|
|
192
|
+
destroy: destroyTabComponent
|
|
193
|
+
};
|
|
252
194
|
}(window, document);
|
|
253
|
-
|
|
254
195
|
// eslint-disable-next-line no-unused-vars,no-undef
|
|
255
|
-
|
|
196
|
+
const tabComponent = a11yTabs.create('[data-tab-component]');
|
|
@@ -1,54 +1,41 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
4
|
-
|
|
5
1
|
// DUMMY TIMELINE ITEM OPEN/CLOSE
|
|
2
|
+
"use strict";
|
|
6
3
|
function wrap(el, wrapper) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
el.parentNode.insertBefore(wrapper, el);
|
|
5
|
+
wrapper.classList.add('wrapper');
|
|
6
|
+
wrapper.appendChild(el);
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
sessionStorage.removeItem('scroll-position');
|
|
46
|
-
|
|
47
|
-
// Trigger scroll event to reveal timeline items not yet parallaxed into view
|
|
48
|
-
window.dispatchEvent(new CustomEvent('scroll'));
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
timeLineItemBottomClose.addEventListener('click', function () {
|
|
52
|
-
timeLineItemClose.click();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
8
|
+
const timeLineItems = document.querySelectorAll('.js-timeline-item');
|
|
9
|
+
let timeLineItemScrollPosition = 0;
|
|
10
|
+
[].forEach.call(timeLineItems, (timeLineItem)=>{
|
|
11
|
+
const timeLineItemLink = timeLineItem.querySelector('a');
|
|
12
|
+
const timeLineItemClose = timeLineItem.querySelector('.js-timeline-item-close');
|
|
13
|
+
const timeLineItemBottomClose = timeLineItem.querySelector('.js-timeline-item-bottom-close');
|
|
14
|
+
timeLineItemLink.addEventListener('click', ()=>{
|
|
15
|
+
timeLineItemScrollPosition = window.pageYOffset;
|
|
16
|
+
sessionStorage.setItem('scroll-position', timeLineItemScrollPosition);
|
|
17
|
+
if (!timeLineItem.classList.contains('is-open')) {
|
|
18
|
+
timeLineItem.classList.add('is-open');
|
|
19
|
+
timeLineItem.closest('.row').classList.add('row-has-open-child');
|
|
20
|
+
// Wrap open timeline item
|
|
21
|
+
wrap(timeLineItem.querySelector('.wp-block-iis-timeline-post'), document.createElement('div'));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
timeLineItemClose.addEventListener('click', ()=>{
|
|
25
|
+
timeLineItem.classList.remove('is-open');
|
|
26
|
+
timeLineItem.closest('.row').classList.remove('row-has-open-child');
|
|
27
|
+
// Destroy generated wrapper
|
|
28
|
+
const wrapper = timeLineItemClose.nextElementSibling;
|
|
29
|
+
wrapper.replaceWith(...wrapper.childNodes);
|
|
30
|
+
const top = sessionStorage.getItem('scroll-position');
|
|
31
|
+
if (top !== null) {
|
|
32
|
+
window.scrollTo(0, parseInt(top, 10));
|
|
33
|
+
}
|
|
34
|
+
sessionStorage.removeItem('scroll-position');
|
|
35
|
+
// Trigger scroll event to reveal timeline items not yet parallaxed into view
|
|
36
|
+
window.dispatchEvent(new CustomEvent('scroll'));
|
|
37
|
+
});
|
|
38
|
+
timeLineItemBottomClose.addEventListener('click', ()=>{
|
|
39
|
+
timeLineItemClose.click();
|
|
40
|
+
});
|
|
41
|
+
});
|