1document.addEventListener('DOMContentLoaded', function () { 2 const searchButton = document.querySelector('.rf-search-button'); 3 const modal = document.getElementById('rf-search-modal'); 4 const closeButton = document.querySelector('.rf-search-close'); 5 const form = document.getElementById('rf-search-form'); 6 const input = document.getElementById('rf-search-input'); 7 const submitButtons = document.querySelectorAll('.rf-search-submit'); 8 9 if (!searchButton || !modal) return; 10 11 // Open modal on click 12 searchButton.addEventListener('click', function () { 13 openModal(); 14 }); 15 16 // Open modal on Enter/Space key for accessibility 17 searchButton.addEventListener('keydown', function (e) { 18 if (e.key === 'Enter' || e.key === ' ') { 19 e.preventDefault(); 20 openModal(); 21 } 22 }); 23 24 // Close modal 25 closeButton.addEventListener('click', function () { 26 closeModal(); 27 }); 28 29 // Close modal when clicking outside 30 modal.addEventListener('click', function (e) { 31 if (e.target === modal) { 32 closeModal(); 33 } 34 }); 35 36 // Close modal with Escape key 37 document.addEventListener('keydown', function (e) { 38 if (e.key === 'Escape' && modal.classList.contains('active')) { 39 closeModal(); 40 } 41 }); 42 43 // Handle form submission 44 form.addEventListener('submit', function (e) { 45 e.preventDefault(); 46 // Prevent default form submission, buttons will handle redirects 47 }); 48 49 // Add click handlers to submit buttons 50 submitButtons.forEach(button => { 51 button.addEventListener('click', function (e) { 52 e.preventDefault(); 53 54 const query = encodeURIComponent(input.value.trim()); 55 if (!query) { 56 input.focus(); 57 return; 58 } 59 60 const searchType = this.getAttribute('data-search-type'); 61 62 if (searchType === 'realfaith-app') { 63 // Redirect to Real Faith App 64 window.location.href = `https://app.realfaith.com/search?q=${query}&t=all`; 65 } else if (searchType === 'realfaith-site') { 66 // Redirect to Real Faith Site (WooCommerce products) 67 // window.location.href = `https://realfaith.com/?s=${query}&post_type=product`; 68 window.location.href = `https://shop.realfaith.com/search?q=${query}`; 69 } 70 71 // Close modal after initiating redirect 72 closeModal(); 73 }); 74 }); 75 76 // Function to open modal 77 function openModal() { 78 modal.classList.add('active'); 79 modal.setAttribute('aria-hidden', 'false'); 80 input.focus(); 81 } 82 83 // Function to close modal 84 function closeModal() { 85 modal.classList.remove('active'); 86 modal.setAttribute('aria-hidden', 'true'); 87 input.value = ''; // Clear input on close 88 } 89 90 // Make the modal accessible for mobile keyboard 91 input.addEventListener('keydown', function (e) { 92 if (e.key === 'Enter') { 93 e.preventDefault(); 94 // Focus on first submit button when Enter is pressed 95 if (submitButtons.length > 0) { 96 submitButtons[0].focus(); 97 } 98 } 99 }); 100});
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.