Buy & Sell on Petspace

learn more about placing orders, contacting brands, reporting issues, shipping orders, contacting retailers, getting paid, and more.

jQuery(document).ready(function() { jQuery("#ezd_searchInput").focus(function() { jQuery('body').addClass('ezd-search-focused'); jQuery('form.ezd_search_form').css('z-index', '999'); }) jQuery(".focus_overlay").click(function() { jQuery('body').removeClass('ezd-search-focused'); jQuery('form.ezd_search_form').css('z-index', 'unset'); }) /** * Search Form Keywords */ jQuery(".header_search_keyword ul li a").on("click", function(e) { e.preventDefault() var content = jQuery(this).text() jQuery("#ezd_searchInput").val(content).focus() ezSearchResults() }) function ezSearchResults() { let keyword = jQuery('#ezd_searchInput').val(); let noresult = jQuery('#ezd-search-results').attr('data-noresult'); if (keyword == "") { jQuery('#ezd-search-results').removeClass('ajax-search').html("") } else { jQuery.ajax({ url: eazydocs_local_object.ajaxurl, type: 'post', data: { action: 'eazydocs_search_results', keyword: keyword }, beforeSend: function() { jQuery(".spinner-border").show(); }, success: function(data) { jQuery(".spinner-border").hide(); // hide search results by pressing Escape button jQuery(document).keyup(function(e) { if (e.key === "Escape") { // escape key maps to keycode `27` jQuery('#ezd-search-results').removeClass('ajax-search').html("") } }); if (data.length > 0) { jQuery('#ezd-search-results').addClass('ajax-search').html(data); } else { var data_error = '
' + noresult + '
'; jQuery('#ezd-search-results').html(data_error); } } }) } } function ezdFetchDelay(callback, ms) { var timer = 0; return function() { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function() { callback.apply(context, args); }, ms || 0); }; } jQuery('#ezd_searchInput').keyup( ezdFetchDelay(function(e) { let keyword = jQuery('#ezd_searchInput').val(); let noresult = jQuery('#ezd-search-results').attr('data-noresult'); if (keyword == "") { jQuery('#ezd-search-results').removeClass('ajax-search').html("") } else { jQuery.ajax({ url: eazydocs_local_object.ajaxurl, type: 'post', data: { action: 'eazydocs_search_results', keyword: keyword }, beforeSend: function() { jQuery(".spinner-border").show(); }, success: function(data) { jQuery(".spinner-border").hide(); // hide search results by pressing Escape button jQuery(document).keyup(function(e) { if (e.key === "Escape") { // escape key maps to keycode `27` jQuery('#ezd-search-results').removeClass('ajax-search').html( "") } }); if (data.length > 0) { jQuery('#ezd-search-results').addClass('ajax-search').html(data); } else { var data_error = '
' + noresult + '
'; jQuery('#ezd-search-results').html(data_error); } } }) } }, 500) ); }); // Search results should close on clearing the input field if ( document.getElementById('ezd_searchInput') ) { document.getElementById('ezd_searchInput').addEventListener('search', function (event) { jQuery('#ezd-search-results').empty().removeClass('ajax-search'); }); } // Prevent form submission when pressing Enter in the search input field document.addEventListener("DOMContentLoaded", function () { const searchInput = document.getElementById("ezd_searchInput"); searchInput.addEventListener("keypress", function (event) { if (event.key === "Enter") { event.preventDefault(); // Prevent form submission } }); });
Brand Guides

Getting Started

Estimated reading: 1 minute 1195 views

Leave a Reply

Your email address will not be published. Required fields are marked *

Email us

Our customer team will review your issue and respond within 24 business hours.