1/******/ (() => { // webpackBootstrap 2/*!*******************************!*\ 3 !*** ./src/accordion/view.js ***! 4 \*******************************/ 5document.addEventListener("DOMContentLoaded", function () { 6 const accordions = document.querySelectorAll(".mr-accordion"); 7 accordions.forEach(accordion => { 8 const items = accordion.querySelectorAll(".mr-accordion-item"); 9 const isAlwaysOpen = accordion.dataset.alwaysOpen === "true"; 10 items.forEach((item, index) => { 11 const header = item.querySelector(".mr-accordion-item__header"); 12 const panel = item.querySelector(".mr-accordion-item__panel"); 13 const icon = header.querySelector(".mr-accordion-item__icon"); 14 header.addEventListener("click", function () { 15 const isActive = item.classList.contains("is-active"); 16 if (!isAlwaysOpen) { 17 // Close all other items first 18 items.forEach(otherItem => { 19 if (otherItem !== item) { 20 otherItem.classList.remove("is-active"); 21 const otherPanel = otherItem.querySelector(".mr-accordion-item__panel"); 22 const otherIcon = otherItem.querySelector(".mr-accordion-item__icon"); 23 const otherHeader = otherItem.querySelector(".mr-accordion-item__header"); 24 if (otherPanel) { 25 otherPanel.classList.remove("is-active"); 26 otherPanel.style.maxHeight = "0"; 27 } 28 if (otherIcon) { 29 otherIcon.classList.remove("is-active"); 30 } 31 if (otherHeader) { 32 otherHeader.classList.remove("is-active"); 33 } 34 } 35 }); 36 } 37 38 // Toggle current item 39 if (isActive) { 40 item.classList.remove("is-active"); 41 if (panel) { 42 panel.classList.remove("is-active"); 43 panel.style.maxHeight = "0"; 44 } 45 if (icon) { 46 icon.classList.remove("is-active"); 47 } 48 header.classList.remove("is-active"); 49 } else { 50 item.classList.add("is-active"); 51 if (panel) { 52 panel.classList.add("is-active"); 53 panel.style.maxHeight = panel.scrollHeight + "px"; 54 } 55 if (icon) { 56 icon.classList.add("is-active"); 57 } 58 header.classList.add("is-active"); 59 } 60 }); 61 }); 62 63 // Initialize first item as open if specified 64 const firstItem = items[0]; 65 if (firstItem && firstItem.dataset.initialOpen === "true") { 66 firstItem.classList.add("is-active"); 67 const panel = firstItem.querySelector(".mr-accordion-item__panel"); 68 const icon = firstItem.querySelector(".mr-accordion-item__icon"); 69 const header = firstItem.querySelector(".mr-accordion-item__header"); 70 if (panel) { 71 panel.classList.add("is-active"); 72 panel.style.maxHeight = panel.scrollHeight + "px"; 73 } 74 if (icon) { 75 icon.classList.add("is-active"); 76 } 77 if (header) { 78 header.classList.add("is-active"); 79 } 80 } 81 }); 82}); 83/******/ })() 84; 85//# sourceMappingURL=view.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.