1/** 2 * Arzpaya FAQ Frontend JavaScript 3 * Matches the behavior from homepage.js 4 */ 5(function() { 6 'use strict'; 7 8 function initFAQ() { 9 const faqItems = document.querySelectorAll('.faq-section .faq-item'); 10 11 if (faqItems.length === 0) { 12 return; 13 } 14 15 faqItems.forEach(item => { 16 const question = item.querySelector('.faq-question'); 17 const answer = item.querySelector('.faq-answer'); 18 19 if (!question || !answer) { 20 return; 21 } 22 23 // Remove any existing event listeners by cloning 24 const newQuestion = question.cloneNode(true); 25 question.parentNode.replaceChild(newQuestion, question); 26 27 newQuestion.addEventListener('click', () => { 28 const isOpen = item.classList.contains('open'); 29 30 // Close all items 31 faqItems.forEach(i => { 32 i.classList.remove('open'); 33 const ans = i.querySelector('.faq-answer'); 34 if (ans) { 35 ans.style.maxHeight = null; 36 } 37 }); 38 39 // Open current item if it was closed 40 if (!isOpen) { 41 item.classList.add('open'); 42 answer.style.maxHeight = answer.scrollHeight + 'px'; 43 newQuestion.setAttribute('aria-expanded', 'true'); 44 } else { 45 newQuestion.setAttribute('aria-expanded', 'false'); 46 } 47 }); 48 }); 49 } 50 51 // Initialize on DOM ready 52 if (document.readyState === 'loading') { 53 document.addEventListener('DOMContentLoaded', initFAQ); 54 } else { 55 initFAQ(); 56 } 57 58 // Re-initialize for dynamically loaded content (AJAX) 59 if (typeof jQuery !== 'undefined') { 60 jQuery(document).on('arzpaya_faq_loaded', initFAQ); 61 } 62})(); 63 64 65 66 67 68 69 70 71 72 73 74 75
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.