File: /home/dfwparty/www/wp-content/plugins/ultimate-elementor/assets/min-js/uael-advanced-search.min.js
!function(e){"use strict";class t{constructor(e){this.$scope=e,this.$container=e.find(".uael-advanced-search-container"),this.$input=this.$container.find(".uael-advanced-search-input"),this.$button=this.$container.find(".uael-advanced-search-button"),this.$results=this.$container.find(".uael-advanced-search-results"),this.$resultsContent=this.$container.find(".uael-search-results-content"),this.$resultsCount=this.$container.find(".uael-search-results-count"),this.$loadMoreBtn=this.$container.find(".uael-load-more-button"),this.$noResults=this.$container.find(".uael-search-no-results"),this.$popularKeywords=this.$container.find(".uael-popular-keyword"),this.settings=JSON.parse(this.$container.attr("data-settings")||"{}"),this.searchTimeout=null,this.currentPage=1,this.totalResults=0,this.isLoading=!1,this.currentSearchTerm="",this.preventBlurClose=!1,this.intersectionObserver=null,this.init()}init(){this.bindEvents(),this.$loadMoreBtn.hide(),this.setupIntersectionObserver()}bindEvents(){const t=this.settings.search_debounce_delay||300;this.$input.on("input",this.debounce(this.handleSearch.bind(this),t)),this.$input.on("focus",this.handleInputFocus.bind(this)),this.$input.on("blur",this.handleInputBlur.bind(this)),this.$button.on("click",this.handleButtonClick.bind(this)),this.$popularKeywords.on("click",this.handlePopularKeywordClick.bind(this)),this.$loadMoreBtn.on("click",this.handleLoadMore.bind(this)),this.$results.on("click",function(e){e.stopPropagation()}),e(document).on("click",this.handleDocumentClick.bind(this)),this.$input.on("keydown",this.handleKeyboardNavigation.bind(this)),this.$container.find(".uael-advanced-search-form").on("submit",function(e){e.preventDefault()})}handleSearch(e){const t=e.target.value.trim(),s=this.settings.minimum_search_length||2;0!==t.length?t.length<s||(this.currentSearchTerm=t,this.currentPage=1,this.performSearch(t,!0)):this.hideResults()}handleInputFocus(){this.currentSearchTerm&&this.$resultsContent.children().length>0&&this.showResults()}handleInputBlur(){setTimeout(()=>{this.$results.is(":hover")||this.isLoading||this.preventBlurClose||this.hideResults()},250)}handleButtonClick(e){e.preventDefault();const t=this.$input.val().trim();t&&(this.currentSearchTerm=t,this.currentPage=1,this.performSearch(t,!0))}handlePopularKeywordClick(t){t.preventDefault();const s=e(t.target).data("keyword");this.$input.val(s),this.currentSearchTerm=s,this.currentPage=1,this.$results.is(":visible")?(this.hideResults(),setTimeout(()=>{this.performSearch(s,!0)},150)):this.performSearch(s,!0)}handleLoadMore(e){e.preventDefault(),e.stopPropagation(),!this.isLoading&&this.currentSearchTerm&&(this.preventBlurClose=!0,this.itemCountBeforeLoadMore=this.$resultsContent.find(".uael-search-result-item").length,this.currentPage++,this.performSearch(this.currentSearchTerm,!1))}handleDocumentClick(e){this.$container.is(e.target)||0!==this.$container.has(e.target).length||this.$results.is(e.target)||0!==this.$results.has(e.target).length||this.hideResults()}handleKeyboardNavigation(e){const t=this.$resultsContent.find(".uael-search-result-item");let s=t.filter(".uael-active");switch(e.keyCode){case 40:if(e.preventDefault(),0===s.length)t.first().addClass("uael-active");else{s.removeClass("uael-active");const e=s.next(".uael-search-result-item");e.length>0?e.addClass("uael-active"):t.first().addClass("uael-active")}break;case 38:if(e.preventDefault(),0===s.length)t.last().addClass("uael-active");else{s.removeClass("uael-active");const e=s.prev(".uael-search-result-item");e.length>0?e.addClass("uael-active"):t.last().addClass("uael-active")}break;case 13:if(e.preventDefault(),s.length>0){const e=s.find("a").first();e.length>0&&(window.location.href=e.attr("href"))}else this.currentSearchTerm&&(this.currentPage=1,this.performSearch(this.currentSearchTerm,!0));break;case 27:this.hideResults(),this.$input.blur()}}performSearch(t,s=!1){if(this.isLoading)return;if(!t)return void this.hideResults();this.isLoading=!0,this.showLoadingState();const i=!s&&this.currentPage>1,n=this.settings.initial_results||5,r=this.settings.results_per_page||10;let a=0,o=n;i&&(a=n+(this.currentPage-2)*r,o=r);const h={action:i?"uael_advanced_search_load_more":"uael_advanced_search",search_term:t,posts_per_page:o,offset:a,nonce:this.settings.nonce,show_image:void 0!==this.settings.show_image?this.settings.show_image:"yes"};if(i?h.post_types=JSON.stringify(this.settings.post_types||["post"]):h.post_types_json=JSON.stringify(this.settings.post_types||["post"]),"yes"===this.settings.enable_taxonomy_search&&this.settings.taxonomy_names&&this.settings.taxonomy_names.length>0&&(h.search_taxonomies="yes",h.taxonomy_names=this.settings.taxonomy_names),this.settings.search_ordering&&"relevance"!==this.settings.search_ordering){const e={date:{orderby:"date",order:"DESC"},date_asc:{orderby:"date",order:"ASC"},title:{orderby:"title",order:"ASC"},title_desc:{orderby:"title",order:"DESC"},comment_count:{orderby:"comment_count",order:"DESC"},menu_order:{orderby:"menu_order",order:"ASC"},modified:{orderby:"modified",order:"DESC"}}[this.settings.search_ordering];e&&(h.orderby=e.orderby,h.order=e.order)}const l="undefined"!=typeof uael_advanced_search_script&&uael_advanced_search_script.ajax_url?uael_advanced_search_script.ajax_url:"undefined"!=typeof ajaxurl?ajaxurl:"/wp-admin/admin-ajax.php";e.ajax({url:l,type:"POST",data:h,success:e=>{this.handleSearchSuccess(e,s)},error:(e,t,s)=>{this.handleSearchError(s)},complete:()=>{this.isLoading=!1,this.hideLoadingState()}})}handleSearchSuccess(e,t){if(e.success&&e.data){const s=e.data;t&&this.$resultsContent.empty(),s.posts_html&&s.posts_html.length>0?(this.renderResults(s.posts_html),this.updateResultsCount(s.total_count),this.showResults(),s.has_more&&"yes"===this.settings.show_pagination?(this.$loadMoreBtn.hide(),setTimeout(()=>{this.observeLastResultItem()},150)):(this.$loadMoreBtn.hide(),this.intersectionObserver&&this.intersectionObserver.disconnect()),t||void 0===this.itemCountBeforeLoadMore||(this.scrollToNewlyLoadedItem(this.itemCountBeforeLoadMore),this.itemCountBeforeLoadMore=void 0),this.$noResults.hide()):t&&this.showNoResults(),this.totalResults=s.total_count||0}else t&&this.showNoResults();this.preventBlurClose=!1}handleSearchError(e){console.error("Search error:",e),0===this.$resultsContent.children().length&&this.showNoResults(),this.preventBlurClose=!1}renderResults(t){this.$resultsContent.append(t),this.$resultsContent.find(".uael-search-result-item").off("click").on("click",function(t){if(!e(t.target).is("a")){const t=e(this).find("a").first();t.length>0&&(window.location.href=t.attr("href"))}})}updateResultsCount(e){if("yes"===this.settings.show_total_results&&this.$resultsCount.length>0){const t=this.$resultsContent.find(".uael-search-result-item").length,s=this.settings.total_results_text||"Total [count] Results";let i;i=e>t?`Showing 1-${t} of ${e} Results`:s.replace("[count]",e),this.$resultsCount.html(i).show()}}showResults(){this.$results.show(),this.$container.addClass("uael-results-open"),this.adjustResultsContainerHeight()}adjustResultsContainerHeight(){const e=this.$resultsContent.find(".uael-search-result-item").length;this.$results.removeClass("uael-results-few uael-results-many"),e<=3?this.$results.addClass("uael-results-few"):this.$results.addClass("uael-results-many")}hideResults(){this.$results.hide(),this.$container.removeClass("uael-results-open")}showNoResults(){this.$resultsContent.empty(),this.$resultsCount.hide(),this.$loadMoreBtn.hide(),this.$noResults.show(),this.showResults()}showLoadingState(){this.$container.addClass("uael-loading"),this.$loadMoreBtn.prop("disabled",!0)}hideLoadingState(){this.$container.removeClass("uael-loading"),this.$loadMoreBtn.prop("disabled",!1)}scrollToNewlyLoadedItem(e){const t=this.$resultsContent.find(".uael-search-result-item").eq(e);t.length>0&&setTimeout(()=>{t[0].scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},100)}setupIntersectionObserver(){window.IntersectionObserver?(this.useFallbackVisibility=!1,this.intersectionObserver=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&this.$loadMoreBtn.fadeIn(300)})},{root:this.$resultsContent[0],rootMargin:"0px",threshold:.1})):this.useFallbackVisibility=!0}observeLastResultItem(){if(this.useFallbackVisibility)return void this.$loadMoreBtn.show();this.intersectionObserver&&this.intersectionObserver.disconnect();const e=this.$resultsContent.find(".uael-search-result-item:last");e.length>0&&this.intersectionObserver&&this.intersectionObserver.observe(e[0])}debounce(e,t){let s;return function(...i){clearTimeout(s),s=setTimeout(()=>{clearTimeout(s),e(...i)},t)}}}e(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/uael-advanced-search.default",function(e){e.data("uael-search-initialized")||(e.data("uael-search-initialized",!0),new t(e))})}),e(document).ready(function(){e(".uael-advanced-search-container").each(function(){const s=e(this).closest(".elementor-widget-uael-advanced-search");s.data("uael-search-initialized")||(s.data("uael-search-initialized",!0),new t(s))})})}(jQuery);