@kth/style 1.14.2 → 1.15.0-alpha.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 (109) hide show
  1. package/README.md +76 -4
  2. package/dist/backtotop.js +57 -0
  3. package/dist/cjs/index.js +276 -0
  4. package/dist/cjs/types/index.d.ts +2 -0
  5. package/dist/consent/klaro-no-css.js +6324 -0
  6. package/dist/consent/klaro.css +820 -0
  7. package/dist/consent/kth-klaro.scss +286 -0
  8. package/dist/esm/index.js +276 -0
  9. package/dist/icons/legacy/scss/_svg_data.scss +194 -0
  10. package/dist/icons/legacy/svg/arrow-back-black.svg +5 -0
  11. package/dist/icons/legacy/svg/arrow-back-blue.svg +5 -0
  12. package/dist/icons/legacy/svg/arrow-back-white.svg +5 -0
  13. package/dist/icons/legacy/svg/arrow-collapse-black.svg +1 -0
  14. package/dist/icons/legacy/svg/arrow-collapse-blue.svg +5 -0
  15. package/dist/icons/legacy/svg/arrow-collapse-white.svg +5 -0
  16. package/dist/icons/legacy/svg/arrow-expand-black.svg +5 -0
  17. package/dist/icons/legacy/svg/arrow-expand-blue.svg +5 -0
  18. package/dist/icons/legacy/svg/arrow-expand-white.svg +5 -0
  19. package/dist/icons/legacy/svg/arrow-maximize-blue.svg +5 -0
  20. package/dist/icons/legacy/svg/arrow-minimize-blue.svg +5 -0
  21. package/dist/icons/legacy/svg/arrow-next-black.svg +5 -0
  22. package/dist/icons/legacy/svg/arrow-next-white.svg +5 -0
  23. package/dist/icons/legacy/svg/arrow-up-down-black.svg +5 -0
  24. package/dist/icons/legacy/svg/arrow-up-down-white.svg +5 -0
  25. package/dist/icons/legacy/svg/asterisk-black.svg +5 -0
  26. package/dist/icons/legacy/svg/audio-blue.svg +5 -0
  27. package/dist/icons/legacy/svg/audio-white.svg +5 -0
  28. package/dist/icons/legacy/svg/back-to-top-blue.svg +6 -0
  29. package/dist/icons/legacy/svg/calculate-blue.svg +5 -0
  30. package/dist/icons/legacy/svg/check-black.svg +5 -0
  31. package/dist/icons/legacy/svg/close-black.svg +5 -0
  32. package/dist/icons/legacy/svg/close-white.svg +1 -0
  33. package/dist/icons/legacy/svg/code-blue.svg +5 -0
  34. package/dist/icons/legacy/svg/code-white.svg +5 -0
  35. package/dist/icons/legacy/svg/compressed-blue.svg +13 -0
  36. package/dist/icons/legacy/svg/compressed-white.svg +13 -0
  37. package/dist/icons/legacy/svg/copy-blue.svg +5 -0
  38. package/dist/icons/legacy/svg/date-black.svg +5 -0
  39. package/dist/icons/legacy/svg/date-blue.svg +5 -0
  40. package/dist/icons/legacy/svg/date-white.svg +5 -0
  41. package/dist/icons/legacy/svg/delete-blue.svg +5 -0
  42. package/dist/icons/legacy/svg/doc-blue.svg +5 -0
  43. package/dist/icons/legacy/svg/doc-white.svg +5 -0
  44. package/dist/icons/legacy/svg/download-blue.svg +5 -0
  45. package/dist/icons/legacy/svg/download-white.svg +5 -0
  46. package/dist/icons/legacy/svg/edit-blue.svg +5 -0
  47. package/dist/icons/legacy/svg/email-white.svg +5 -0
  48. package/dist/icons/legacy/svg/error-black.svg +5 -0
  49. package/dist/icons/legacy/svg/eye-black.svg +5 -0
  50. package/dist/icons/legacy/svg/eye-blue.svg +5 -0
  51. package/dist/icons/legacy/svg/eye-off-black.svg +5 -0
  52. package/dist/icons/legacy/svg/eye-off-blue.svg +5 -0
  53. package/dist/icons/legacy/svg/favorite-active-blue.svg +5 -0
  54. package/dist/icons/legacy/svg/favorite-blue.svg +5 -0
  55. package/dist/icons/legacy/svg/file-blue.svg +5 -0
  56. package/dist/icons/legacy/svg/file-white.svg +5 -0
  57. package/dist/icons/legacy/svg/filter-blue.svg +5 -0
  58. package/dist/icons/legacy/svg/folder-blue.svg +5 -0
  59. package/dist/icons/legacy/svg/folder-white.svg +5 -0
  60. package/dist/icons/legacy/svg/gallery-active-black.svg +5 -0
  61. package/dist/icons/legacy/svg/gallery-back-black.svg +5 -0
  62. package/dist/icons/legacy/svg/gallery-next-black.svg +5 -0
  63. package/dist/icons/legacy/svg/gallery-passive-black.svg +5 -0
  64. package/dist/icons/legacy/svg/gallery-pause-black.svg +5 -0
  65. package/dist/icons/legacy/svg/gallery-play-black.svg +5 -0
  66. package/dist/icons/legacy/svg/image-blue.svg +5 -0
  67. package/dist/icons/legacy/svg/image-white.svg +5 -0
  68. package/dist/icons/legacy/svg/information-black.svg +5 -0
  69. package/dist/icons/legacy/svg/language-black.svg +5 -0
  70. package/dist/icons/legacy/svg/language-white.svg +1 -0
  71. package/dist/icons/legacy/svg/link-black.svg +5 -0
  72. package/dist/icons/legacy/svg/link-blue.svg +1 -0
  73. package/dist/icons/legacy/svg/menu-black.svg +8 -0
  74. package/dist/icons/legacy/svg/message-white.svg +5 -0
  75. package/dist/icons/legacy/svg/notification-white.svg +5 -0
  76. package/dist/icons/legacy/svg/open-modal-blue.svg +5 -0
  77. package/dist/icons/legacy/svg/open-window-black.svg +5 -0
  78. package/dist/icons/legacy/svg/open-window-blue.svg +5 -0
  79. package/dist/icons/legacy/svg/open-window-white.svg +5 -0
  80. package/dist/icons/legacy/svg/page-first-black.svg +5 -0
  81. package/dist/icons/legacy/svg/page-last-black.svg +5 -0
  82. package/dist/icons/legacy/svg/pdf-blue.svg +6 -0
  83. package/dist/icons/legacy/svg/pdf-white.svg +6 -0
  84. package/dist/icons/legacy/svg/ppt-blue.svg +5 -0
  85. package/dist/icons/legacy/svg/ppt-white.svg +5 -0
  86. package/dist/icons/legacy/svg/print-blue.svg +5 -0
  87. package/dist/icons/legacy/svg/quote-black.svg +5 -0
  88. package/dist/icons/legacy/svg/quote-white.svg +5 -0
  89. package/dist/icons/legacy/svg/scale-blue.svg +5 -0
  90. package/dist/icons/legacy/svg/search-blue.svg +5 -0
  91. package/dist/icons/legacy/svg/settings-blue.svg +5 -0
  92. package/dist/icons/legacy/svg/sort-ascending-white.svg +5 -0
  93. package/dist/icons/legacy/svg/sort-descending-white.svg +5 -0
  94. package/dist/icons/legacy/svg/success-black.svg +5 -0
  95. package/dist/icons/legacy/svg/text-blue.svg +5 -0
  96. package/dist/icons/legacy/svg/text-white.svg +5 -0
  97. package/dist/icons/legacy/svg/thumb-down-blue.svg +5 -0
  98. package/dist/icons/legacy/svg/thumb-up-blue.svg +5 -0
  99. package/dist/icons/legacy/svg/upload-blue.svg +5 -0
  100. package/dist/icons/legacy/svg/upload-white.svg +5 -0
  101. package/dist/icons/legacy/svg/user-management-blue.svg +5 -0
  102. package/dist/icons/legacy/svg/video-blue.svg +5 -0
  103. package/dist/icons/legacy/svg/video-white.svg +5 -0
  104. package/dist/icons/legacy/svg/xls-blue.svg +5 -0
  105. package/dist/icons/legacy/svg/xls-white.svg +5 -0
  106. package/dist/menus.js +227 -0
  107. package/package.json +3 -1
  108. package/scss/components/backtotop.scss +24 -0
  109. package/scss/components/commonStyle.scss +91 -0
@@ -0,0 +1,286 @@
1
+ // Overrides the default Klaro style for consent modal.
2
+ @use "../../scss/tokens/colors.scss";
3
+
4
+ .klaro {
5
+ // Consent overlay on media
6
+ .context-notice {
7
+ // background: rgba($white, 0.9);
8
+ background: var(--background-color);
9
+ flex-wrap: nowrap;
10
+ border-radius: 0;
11
+
12
+ .cm-btn {
13
+ padding: 0.5rem 1.5rem;
14
+ line-height: 1.5;
15
+ border-radius: 50rem;
16
+ min-height: 2.75rem;
17
+ font-weight: bold;
18
+ font-size: 1rem;
19
+
20
+ &.cm-btn-success-var {
21
+ color: var(--color-on-primary);
22
+ background-color: var(--color-primary);
23
+ border: 1px solid transparent;
24
+ }
25
+
26
+ &.cm-btn-success {
27
+ color: var(--color-text);
28
+ background: var(--color-background);
29
+ border: 1px solid var(--color-border);
30
+ }
31
+ }
32
+ }
33
+
34
+ //Consent dialog, with information and three buttons that lets you choose actions
35
+ .cookie-notice {
36
+ p {
37
+ color: var(--color-text);
38
+ }
39
+
40
+ &:not(.cookie-modal-notice) {
41
+ position: fixed;
42
+ padding: 0.5rem 1.5rem 1.5rem;
43
+ margin: 0.625rem;
44
+ max-width: 760px;
45
+ background-color: var(--color-background);
46
+ border-radius: 0.25rem;
47
+ box-shadow:
48
+ 0 2px 10px 2px var(--color-gray-medium),
49
+ 5px 5px 10px 0 var(--color-gray-medium);
50
+ border: none;
51
+ bottom: 0;
52
+ right: 0;
53
+ left: 0;
54
+
55
+ .cn-buttons {
56
+ display: flex;
57
+ flex-wrap: wrap;
58
+ gap: 0.5rem;
59
+ margin-top: 1rem;
60
+
61
+ @media (max-width: 575px) {
62
+ margin-top: 0.5rem;
63
+ }
64
+
65
+ .cm-btn {
66
+ @media (max-width: 384px) {
67
+ width: auto;
68
+ }
69
+
70
+ &.cm-btn-success,
71
+ &.cm-btn-danger.cn-decline,
72
+ &.cm-btn-learn-more.cm-btn-info {
73
+ padding: 0.5rem 1.5rem;
74
+ min-height: 2.75rem;
75
+ font-weight: bold;
76
+ font-size: 1rem;
77
+ border-radius: 50rem;
78
+ margin: 0;
79
+ }
80
+
81
+ &.cm-btn-success {
82
+ color: var(--color-on-primary);
83
+ background-color: var(--color-primary);
84
+ border: 1px solid transparent;
85
+ }
86
+
87
+ &.cm-btn-danger.cn-decline,
88
+ &.cm-btn-learn-more.cm-btn-info {
89
+ color: var(--color-text);
90
+ background-color: var(--color-background);
91
+ border: 1px solid var(--color-border);
92
+ }
93
+ }
94
+ }
95
+
96
+ @media (max-width: 768px) {
97
+ margin: 0.625rem;
98
+ position: fixed;
99
+ max-width: fit-content;
100
+ width: 100%;
101
+ height: auto;
102
+ bottom: 0;
103
+ right: 0;
104
+ }
105
+ }
106
+ }
107
+
108
+ //Modal that appears when "Manage services/Hantera valbara tjänster" is clicked
109
+ .cookie-modal {
110
+ z-index: 99999;
111
+
112
+ .cm-modal.cm-klaro {
113
+ background-color: var(--color-background);
114
+ max-width: 794px;
115
+
116
+ p {
117
+ color: var(--color-text);
118
+ font-size: 1rem;
119
+ }
120
+
121
+ li {
122
+ color: var(--color-text);
123
+ &.active {
124
+ border: 3px solid var(--color-primary);
125
+ }
126
+ }
127
+
128
+ a {
129
+ color: var(--color-tertiary);
130
+ text-decoration: underline;
131
+ text-underline-offset: 0.25rem;
132
+ }
133
+
134
+ //Header section
135
+ .cm-header {
136
+ padding: 1.5rem;
137
+
138
+ .hide {
139
+ svg {
140
+ stroke: var(--color-text);
141
+ }
142
+ }
143
+
144
+ .title {
145
+ font-size: 1.875rem;
146
+ font-weight: 400;
147
+ color: var(--color-text);
148
+ line-height: 2.5rem;
149
+ margin-top: 0;
150
+ margin-bottom: 0.875rem;
151
+ }
152
+ }
153
+
154
+ //Body section
155
+ .cm-body {
156
+ padding: 1.5rem;
157
+
158
+ .cm-service {
159
+ span {
160
+ &.cm-list-title,
161
+ &.cm-required {
162
+ color: var(--color-text);
163
+ font-size: 1rem;
164
+ }
165
+ }
166
+
167
+ .cm-list-label {
168
+ .slider {
169
+ background-color: var(--color-gray-dark);
170
+ &:before {
171
+ background-color: var(--color-on-primary);
172
+ }
173
+ }
174
+ }
175
+
176
+ .cm-list-input {
177
+ &.required:checked + .cm-list-label .slider {
178
+ background-color: var(--color-success);
179
+ }
180
+
181
+ &.only-required + .cm-list-label .slider {
182
+ background-color: var(--color-gray-dark);
183
+ opacity: 0.5;
184
+ }
185
+
186
+ &:checked + .cm-list-label .slider {
187
+ background-color: var(--color-success);
188
+ }
189
+ }
190
+ }
191
+ }
192
+
193
+ //Footer section
194
+ .cm-footer {
195
+ .cm-powered-by a {
196
+ display: none;
197
+ }
198
+
199
+ @media (max-width: 768px) {
200
+ padding: 0 1rem;
201
+
202
+ .cm-footer-buttons {
203
+ display: block;
204
+ width: 100%;
205
+
206
+ .cm-btn {
207
+ width: 100%;
208
+ margin-top: 1.4rem;
209
+ }
210
+ }
211
+ }
212
+
213
+ .cm-btn {
214
+ padding: 0.5rem 1.5rem;
215
+ border-radius: 50rem;
216
+ min-height: 2.75rem;
217
+ font-weight: bold;
218
+ font-size: 1rem;
219
+
220
+ &.cm-btn-success {
221
+ color: var(--color-on-primary);
222
+ background-color: var(--color-primary);
223
+ border: 1px solid transparent;
224
+
225
+ &.cm-btn-accept {
226
+ background-color: var(--color-success);
227
+ }
228
+ }
229
+
230
+ &.cm-btn-decline {
231
+ color: var(--color-text);
232
+ background-color: var(--color-background);
233
+ border: 1px solid var(--color-border);
234
+ }
235
+ }
236
+ }
237
+ }
238
+ }
239
+ }
240
+
241
+ /*
242
+ * Handle videos in columnsplitters agrid lists with 4 columns.
243
+ */
244
+ .block {
245
+ &.columnSplitter {
246
+ &.row {
247
+ &.using4Columns {
248
+ .klaro {
249
+ .context-notice {
250
+ p {
251
+ font-size: 0.9rem;
252
+ margin-bottom: 0;
253
+ }
254
+
255
+ .cm-btn {
256
+ margin-bottom: 0.25rem;
257
+ min-height: 1.75rem;
258
+ padding: 0.3rem 0.6rem;
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+
266
+ &.list {
267
+ &.grid {
268
+ .gridRowItem {
269
+ &.gridRowItem_4 {
270
+ .context-notice {
271
+ p {
272
+ font-size: 0.9rem;
273
+ margin-bottom: 0;
274
+ }
275
+
276
+ .cm-btn {
277
+ margin-bottom: 0.25rem;
278
+ min-height: 1.75rem;
279
+ padding: 0.3rem 0.6rem;
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
package/dist/esm/index.js CHANGED
@@ -122,4 +122,280 @@ class MenuPanel {
122
122
  }
123
123
  }
124
124
 
125
+ /* eslint-disable func-names */ /* eslint-disable no-var */ window.addEventListener(
126
+ "load",
127
+ () => {
128
+ /**
129
+ * Back to top link
130
+ */ var lastKnownScrollPosition = 0;
131
+ var ticking = false;
132
+ var backToTopButton = document.querySelector("#back-to-top");
133
+ if (!backToTopButton) {
134
+ backToTopButton = document.createElement("div");
135
+ backToTopButton = document.body.appendChild(backToTopButton);
136
+ backToTopButton.id = "back-to-top";
137
+ backToTopButton.setAttribute("role", "link");
138
+ backToTopButton.setAttribute("aria-hidden", "true");
139
+ if (document.documentElement.lang === "sv-SE") {
140
+ backToTopButton.innerText = "Till sidans topp";
141
+ } else {
142
+ backToTopButton.innerText = "To page top";
143
+ }
144
+ if (document.querySelector("footer")) {
145
+ document.body.insertBefore(
146
+ backToTopButton,
147
+ document.querySelector("footer"),
148
+ );
149
+ }
150
+ }
151
+ backToTopButton.addEventListener("click", function () {
152
+ window.scrollTo({ top: 0, behavior: "smooth" });
153
+ this.classList.toggle("show");
154
+ this.setAttribute("aria-hidden", true);
155
+ });
156
+ function handleBackToTop(scrollPos) {
157
+ if (scrollPos > 200) {
158
+ backToTopButton.classList.add("show");
159
+ backToTopButton.removeAttribute("aria-hidden");
160
+ } else {
161
+ backToTopButton.classList.remove("show");
162
+ backToTopButton.setAttribute("aria-hidden", true);
163
+ }
164
+ }
165
+ window.addEventListener("scroll", () => {
166
+ lastKnownScrollPosition = window.scrollY;
167
+ if (!ticking) {
168
+ window.requestAnimationFrame(() => {
169
+ handleBackToTop(lastKnownScrollPosition);
170
+ ticking = false;
171
+ });
172
+ ticking = true;
173
+ }
174
+ });
175
+ },
176
+ );
177
+
178
+ /* eslint-disable no-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-use-before-define */ function klaroOnload() {
179
+ var klaro = document.querySelector("#klaro div.klaro");
180
+ function noVisibleKlaro() {
181
+ return (
182
+ !klaro ||
183
+ window.getComputedStyle(klaro).display === "none" ||
184
+ klaro.querySelector("a") === null
185
+ );
186
+ }
187
+ if (noVisibleKlaro()) {
188
+ return;
189
+ }
190
+ if (klaro !== document.body.firstElementChild) {
191
+ document.body.insertBefore(klaro, document.body.firstElementChild);
192
+ }
193
+ const getNextFocusableElement = function _getNextFocusableElement(
194
+ element,
195
+ step,
196
+ ) {
197
+ var elements = Array.prototype.slice.call(
198
+ klaro.querySelectorAll(
199
+ "a:not([disabled]), button:not([disabled]), input:not([disabled])",
200
+ ),
201
+ );
202
+ if (!elements) return null;
203
+ elements = elements.filter(
204
+ (e) => window.getComputedStyle(e).display !== "none",
205
+ );
206
+ for (var i = 0; i < elements.length; i++) {
207
+ if (elements[i] === element) {
208
+ if (i < elements.length - step) {
209
+ return elements[i + step];
210
+ }
211
+ return elements[0];
212
+ }
213
+ }
214
+ return elements[0];
215
+ };
216
+ const resetActiveLI = function _resetActiveLI() {
217
+ var elements = Array.prototype.slice.call(
218
+ klaro.querySelectorAll("li.active"),
219
+ );
220
+ if (!elements) return;
221
+ elements.forEach((e) => e.classList.remove("active"));
222
+ }; // eslint-disable-next-line no-shadow
223
+ const handleKeydown = (event) => {
224
+ if (noVisibleKlaro()) {
225
+ window.removeEventListener("keydown", handleKeydown);
226
+ return;
227
+ }
228
+ if (event.key === "Tab") {
229
+ const nextElement = getNextFocusableElement(
230
+ event.target,
231
+ event.shiftKey ? -1 : 1,
232
+ );
233
+ if (nextElement) {
234
+ event.preventDefault();
235
+ nextElement.focus();
236
+ resetActiveLI();
237
+ if (nextElement.tagName === "INPUT") {
238
+ nextElement.parentElement.closest("li").classList.add("active");
239
+ }
240
+ }
241
+ } else if (event.key === "Escape") {
242
+ const closeButton = klaro.querySelector(
243
+ "div.klaro .cookie-modal button.hide",
244
+ );
245
+ if (closeButton) {
246
+ closeButton.click();
247
+ }
248
+ }
249
+ };
250
+ window.addEventListener("keydown", handleKeydown);
251
+ const config = { childList: true, subtree: true, attributes: true };
252
+ const callback = function _callback(mutationsList) {
253
+ for (const mutation of mutationsList) {
254
+ if (mutation.type === "childList") {
255
+ if (mutation.addedNodes.length > 0) {
256
+ for (const node of mutation.addedNodes) {
257
+ if (node.nodeType === 1) {
258
+ if (node.classList.contains("cookie-modal")) {
259
+ var inputs = Array.prototype.slice.call(
260
+ node.querySelectorAll("input"),
261
+ );
262
+ for (const input of inputs) {
263
+ input.setAttribute("tabindex", "0");
264
+ }
265
+ }
266
+ }
267
+ }
268
+ } else if (mutation.removedNodes.length > 0) {
269
+ for (const node of mutation.removedNodes) {
270
+ if (node.nodeType === 1) {
271
+ if (
272
+ node.classList.contains("cn-body") ||
273
+ node.classList.contains("cookie-modal")
274
+ ) {
275
+ window.removeEventListener("keydown", handleKeydown);
276
+ }
277
+ }
278
+ }
279
+ }
280
+ } else if (mutation.attributeName === "style") {
281
+ if (
282
+ window.getComputedStyle(klaro).getPropertyValue("display") === "none"
283
+ ) {
284
+ window.removeEventListener("keydown", handleKeydown);
285
+ }
286
+ }
287
+ }
288
+ };
289
+ const observer = new MutationObserver(callback);
290
+ observer.observe(klaro, config);
291
+ }
292
+ window.addEventListener("load", () => {
293
+ klaroOnload();
294
+ });
295
+ window.addEventListener("load", () => {
296
+ // If no mobile menu containers are present, skip it all togehter
297
+ if (
298
+ !document.getElementById("mobileMenuWrapper") ||
299
+ !document.getElementById("mobileMenuList") ||
300
+ !document.getElementById("mobileMenuContent") ||
301
+ !document.getElementById("nav-icon")
302
+ ) {
303
+ return;
304
+ }
305
+ var mainMenu = document.getElementById("mainMenu"); // Get main menu
306
+ var megaMenu = document.getElementById("megaMenu"); // Get mega menu
307
+ var secondaryMenu = document.querySelector(".secondaryMenu"); // Get secondary menu
308
+ if (!mainMenu && !megaMenu && !secondaryMenu) {
309
+ document.getElementById("mobileMenuWrapper").style.display = "none"; // Hide mobile menu wrapper/container if there is no menus
310
+ }
311
+ if (mainMenu) {
312
+ // For main menu items, copy a link if it exists, otherwise copy the link content
313
+ createMobileMenuItems(mainMenu.querySelectorAll("li"), true);
314
+ } else if (megaMenu) {
315
+ // For mega menu items, copy only the the first alinks
316
+ createMobileMenuItems(megaMenu.querySelectorAll("li"), false);
317
+ }
318
+ if (secondaryMenu) {
319
+ createMobileMenuItemsForSecondaryMenu(
320
+ secondaryMenu.querySelectorAll("li a"),
321
+ );
322
+ }
323
+ function createMobileMenuItems(menuItems, includeInline) {
324
+ for (var i = 0; i < menuItems.length; i++) {
325
+ var linkToCopy = menuItems[i].querySelector("a");
326
+ if (linkToCopy || includeInline) {
327
+ var listItem = document.createElement("li");
328
+ listItem.className =
329
+ menuItems[i].className !== "" ? menuItems[i].className : "nav-item";
330
+ if (linkToCopy) {
331
+ var link = document.createElement("a");
332
+ link.href = linkToCopy.href;
333
+ link.text = linkToCopy.text;
334
+ link.className = linkToCopy.className;
335
+ listItem.appendChild(link);
336
+ } else if (includeInline) {
337
+ listItem.innerHTML = menuItems[i].innerHTML;
338
+ }
339
+ document.getElementById("mobileMenuList").appendChild(listItem);
340
+ }
341
+ }
342
+ }
343
+ function createMobileMenuItemsForSecondaryMenu(menuItems) {
344
+ var secondaryMenuWrapper = document.createElement("li");
345
+ secondaryMenuWrapper.className = "secondaryMenuWrap";
346
+ var secondaryMenuContainer = document.createElement("ul");
347
+ secondaryMenuContainer.className = "secondaryMenuContainer";
348
+ for (var i = 0; i < menuItems.length; i++) {
349
+ var link = document.createElement("a");
350
+ link.className = "secondaryMenu";
351
+ link.href = menuItems[i].href;
352
+ link.text = menuItems[i].text;
353
+ if (menuItems[i].hreflang) {
354
+ link.hreflang = menuItems[i].hreflang;
355
+ }
356
+ var secondaryMenuListItem = document.createElement("li");
357
+ secondaryMenuListItem.className = "item nav-item secondaryItem";
358
+ secondaryMenuListItem.appendChild(link);
359
+ secondaryMenuContainer.appendChild(secondaryMenuListItem);
360
+ }
361
+ secondaryMenuWrapper.appendChild(secondaryMenuContainer);
362
+ document.getElementById("mobileMenuList").appendChild(secondaryMenuWrapper);
363
+ } // Mega menu icon toggler.
364
+ document.getElementById("nav-icon").onclick = function _onclick() {
365
+ if (document.body.style.overflow !== "hidden") {
366
+ document.body.style.overflow = "hidden";
367
+ } else {
368
+ document.body.style.overflow = "initial";
369
+ }
370
+ document.getElementById("mobileMenuContent").classList.toggle("show");
371
+ this.classList.toggle("open");
372
+ };
373
+ });
374
+ function stickyMainMenu() {
375
+ if (!document.querySelector("#mainMenu ul.nav.nav-list")) return;
376
+ function isInViewport(element) {
377
+ if (!element) return false;
378
+ const rect = element.getBoundingClientRect();
379
+ return (
380
+ rect.top >= 0 &&
381
+ rect.left >= 0 &&
382
+ rect.bottom <=
383
+ (window.innerHeight || document.documentElement.clientHeight) &&
384
+ rect.right <= (window.innerWidth || document.documentElement.clientWidth)
385
+ );
386
+ }
387
+ if (
388
+ isInViewport(
389
+ document.querySelector("#mainMenu ul.nav.nav-list:last-of-type")
390
+ ?.lastElementChild,
391
+ )
392
+ ) {
393
+ document.querySelector("#mainMenu").classList.add("sticky-menu");
394
+ } else {
395
+ document.querySelector("#mainMenu").classList.remove("sticky-menu");
396
+ }
397
+ }
398
+ window.addEventListener("load", stickyMainMenu);
399
+ window.addEventListener("resize", stickyMainMenu);
400
+
125
401
  export { MenuPanel };