1/******/ (() => { // webpackBootstrap 2/*!*****************************************!*\ 3 !*** ./src/blocks/faq-item/frontend.js ***! 4 \*****************************************/ 5document.addEventListener("DOMContentLoaded", () => { 6 const initFAQItem = faqItem => { 7 const content = faqItem.querySelector(".gutentools-faq-content"); 8 const toggleBtn = faqItem.querySelector(".gutentools-faq-toggle"); 9 const isOpen = content.classList.contains("is-open"); 10 11 // Set initial content state 12 content.style.maxHeight = isOpen ? content.scrollHeight + "px" : "0"; 13 content.style.opacity = isOpen ? "1" : "0"; 14 15 // Set button state 16 toggleBtn.setAttribute("aria-expanded", isOpen); 17 18 // Icon init 19 const icon = toggleBtn.querySelector("i"); 20 if (icon) { 21 const openIcon = toggleBtn.getAttribute("data-open"); 22 const closeIcon = toggleBtn.getAttribute("data-close"); 23 icon.classList.toggle(openIcon, !isOpen); 24 icon.classList.toggle(closeIcon, isOpen); 25 icon.classList.toggle("rotated", isOpen); // Add rotation 26 } 27 return { 28 content, 29 toggleBtn 30 }; 31 }; 32 const handleFAQClick = (faqItem, content, toggleBtn) => { 33 const isOpen = content.classList.contains("is-open"); 34 35 // Animate content 36 if (isOpen) { 37 content.style.maxHeight = content.scrollHeight + "px"; // ensure it's measured 38 requestAnimationFrame(() => { 39 content.style.maxHeight = "0"; 40 content.style.opacity = "0"; 41 }); 42 } else { 43 content.style.maxHeight = content.scrollHeight + "px"; 44 content.style.opacity = "1"; 45 } 46 content.classList.toggle("is-open"); 47 toggleBtn.setAttribute("aria-expanded", !isOpen); 48 49 // Animate icon 50 const icon = toggleBtn.querySelector("i"); 51 if (icon) { 52 const openIcon = toggleBtn.getAttribute("data-open"); 53 const closeIcon = toggleBtn.getAttribute("data-close"); 54 icon.classList.toggle(openIcon, isOpen); 55 icon.classList.toggle(closeIcon, !isOpen); 56 icon.classList.toggle("rotated", !isOpen); 57 } 58 }; 59 document.querySelectorAll(".wp-block-gutentools-faq-item").forEach(faqItem => { 60 const { 61 content, 62 toggleBtn 63 } = initFAQItem(faqItem); 64 const titleWrapper = faqItem.querySelector(".gutentools-faq-title-wrapper"); 65 66 // toggleBtn.addEventListener("click", () => 67 // handleFAQClick(faqItem, content, toggleBtn), 68 // ); 69 if (titleWrapper) { 70 titleWrapper.addEventListener("click", () => handleFAQClick(faqItem, content, toggleBtn)); 71 } 72 }); 73}); 74/******/ })() 75; 76//# sourceMappingURL=frontend.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.