(function () { if (window.location.hostname !== 'trade.rockbottomgolf.com') return; if (window.rbgTradeSearchOverrideInstalled) return; window.rbgTradeSearchOverrideInstalled = true; function disableLegacyQuickSearch() { document.querySelectorAll( '#nav-quick-search[data-search-quick], ' + '#nav-menu-quick-search[data-search-quick]' ).forEach(input => { // Stop the imported theme from fetching trade /search.php while typing. input.removeAttribute('data-search-quick'); input.setAttribute('data-trade-search-input', ''); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', disableLegacyQuickSearch, { once: true }); } else { disableLegacyQuickSearch(); } // Window capture runs before the imported theme's document-level handler. window.addEventListener('submit', function (event) { const form = event.target; if (!(form instanceof HTMLFormElement) || !form.matches('[data-quick-search-form]')) return; // Handle the search first and prevent the old code from causing the error. event.preventDefault(); event.stopImmediatePropagation(); const input = form.querySelector( '[data-trade-search-input], [data-search-quick]' ); const query = input ? input.value.trim() : ''; if (!query) { if (input) input.focus(); return; } const destination = new URL('https://www.rockbottomgolf.com/search.php'); destination.searchParams.set('search_query', query); window.location.assign(destination.href); }, true); // Send shoppers to the actual Rock Bottom Golf cart instead. window.addEventListener('click', function (event) { const target = event.target; const cartButton = target instanceof Element ? target.closest('[data-cart-slide-preview]') : null; if (!cartButton) return; event.preventDefault(); event.stopImmediatePropagation(); window.location.assign('https://www.rockbottomgolf.com/cart.php'); }, true); }());