File: /home/lgooir/public_html/wp-content/themes/woodmart/js/scripts/global/beforeSearchContent.min.js
woodmartThemeModule.beforeSearchcontent=function(){function e(e){var o=e.target.closest("form.searchform");document.querySelectorAll(".wd-dropdown-results.wd-opened").forEach(function(e){var t=e.closest(".wd-search-form, .wd-search-dropdown");t&&(t=t.querySelector("form.searchform"),o&&t===o||s(t,e))})}function r(e){var t=this.closest("form"),o=t.parentNode.querySelector(".wd-dropdown-results");s(t,o)}function c(e){var t=this,r=t.closest("form"),c=r.parentNode.querySelector(".wd-dropdown-results"),o=e.keyCode||e.charCode;"Tab"===e.key||e.shiftKey&&"Tab"===e.key||(0!==t.value.length||8!==o&&46!==o?(t.dispatchEvent(new Event("wdOpenBeforeSearchContent")),setTimeout(function(){var e=!0,t=c.querySelector(".wd-search-history"),o=c.querySelector(".wd-search-requests"),n=c.querySelector(".wd-search-area");(e=t&&0!==t.childElementCount||o&&0!==o.childElementCount||n&&(0!==n.childElementCount||0!==n.textContent.length)?e:!1)&&(c.classList.add("wd-opened"),a(r,"open"))},100)):s(r,c))}var t,d,s=function(e,t){t.classList.remove("wd-opened"),a(e,"close"),setTimeout(function(){e.parentNode.classList.remove("wd-searched")},400)},a=function(e,t){e.closest(".wd-search-form.wd-display-form.wd-with-overlay")&&jQuery(".wd-close-side").trigger("wdCloseSideAction",["open"===t?"show":"hide","click"])};t=document.querySelectorAll("form.searchform"),d=!1,document.addEventListener("keydown",function(e){("Tab"===e.key||e.shiftKey&&"Tab"===e.key)&&(d=!0)}),document.addEventListener("mousedown",function(){d=!1}),t.forEach(function(t){var e,o,n=t.parentNode.querySelector(".wd-dropdown-results");n&&(e=t.querySelector('[type="text"]'),o=t.querySelector(".wd-search-cat-btn"),e.addEventListener("focus",c),e.addEventListener("keydown",c),o&&o.addEventListener("click",r),[t,n].forEach(function(e){e.addEventListener("focusout",function(){setTimeout(function(){!d||t.contains(document.activeElement)||n.contains(document.activeElement)||s(t,n)},10)})}))}),document.addEventListener("click",e,{passive:!0})},window.addEventListener("load",function(){woodmartThemeModule.beforeSearchcontent()});