File: /home/salamatk/takarzan.ir/wp-content/themes/xts-luman/js/scripts/ajaxSearch.min.js
(x=>{XTSThemeModule.$document.on("xtsPjaxComplete",function(){XTSThemeModule.ajaxSearch()}),XTSThemeModule.xtsElementorAddAction("frontend/element_ready/xts_ajax_search.default",function(){XTSThemeModule.ajaxSearch()}),XTSThemeModule.ajaxSearch=function(){void 0!==x.fn.devbridgeAutocomplete&&x("form.xts-ajax-search").each(function(){var a=x(this),n=parseInt(a.data("count")),r=parseInt(a.data("thumbnail")),o=a.parents(".xts-search-wrapper").find(".xts-search-results"),i=a.data("post_type"),d=xts_settings.ajaxurl+"?action=xts_ajax_search",c=parseInt(a.data("symbols_count")),l=a.find('[name="product_cat"]'),u=a.data("sku"),p=a.data("categories_on_results"),h=parseInt(a.data("price")),g=o;a.parents(".xts-search-wrapper").hasClass("xts-design-widgets xts-search-full-screen")&&(g=a.parents(".xts-search-wrapper").find(".xts-search-footer")),0<a.parents(".xts-search-wrapper").find(".xts-shape-overlays").length&&(g=a.parents(".xts-search-wrapper").find(".xts-search-results-wrapper")),0<n&&(d+="&number="+n),d+="&post_type="+i,l.length&&""!==l.val()&&(d+="&product_cat="+l.val()),o.on("click",".xts-search-results-btn",function(){a.trigger("submit")}),a.find('[type="text"]').on("focus keyup",function(){var e,s,t=x(this);t.hasClass("xts-search-inited")||(t.devbridgeAutocomplete({serviceUrl:d,appendTo:o.hasClass("xts-dropdown")?o.find(".xts-dropdown-inner"):o,minChars:c,onSelect:function(e){0<e.permalink.length&&(window.location.href=e.permalink)},onHide:function(){g.removeClass("xts-opened"),g.removeClass("xts-no-results")},onSearchStart:function(){a.addClass("search-loading")},beforeRender:function(e){x(e).find(".suggestion-divider-title").parent().addClass("suggestion-divider"),x(e).find(".xts-search-no-found").parent().addClass("suggestion-no-found"),2<e[0].childElementCount&&x(e).append('<div class="xts-search-results-btn">'+xts_settings.all_results+"</div>"),x(e).removeAttr("style")},onSearchComplete:function(){a.removeClass("search-loading"),XTSThemeModule.$document.trigger("xtsImagesLoaded")},formatResult:function(e,s){var s="("+(s="&"===s?"&":s).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")+")",t="";return e.divider&&(t+=' <h5 class="suggestion-divider-title">'+e.divider+"</h5>"),r&&e.thumbnail&&(t+=' <div class="suggestion-thumb">'+e.thumbnail+"</div>"),e.value&&(t=(t+=' <div class="suggestion-content">')+'<h4 class="suggestion-title xts-entities-title">'+e.value.replace(new RegExp(s,"gi"),"<strong>$1</strong>").replace(/<(\/?strong)>/g,"<$1>")+"</h4>"),"yes"===p&&e.categories&&(t+=' <div class="suggestion-cat suggestion-meta">'+e.categories+"</div>"),"yes"===u&&e.sku&&(t+=' <div class="suggestion-sku suggestion-meta">'+e.sku+"</div>"),h&&e.price&&(t+=' <div class="price">'+e.price+"</div>"),e.value&&(t+=" </div>"),e.no_found?(g.addClass("xts-no-results"),t='<div class="xts-search-no-found">'+e.value+"</div>"):g.removeClass("xts-no-results"),g.addClass("xts-opened"),g.addClass("xts-searched"),t}}),l.length&&(e=a.find('[type="text"]').devbridgeAutocomplete(),s=xts_settings.ajaxurl+"?action=xts_ajax_search",0<n&&(s+="&number="+n),s+="&post_type="+i,l.on("cat_selected",function(){""!==l.val()?e.setOptions({serviceUrl:s+"&product_cat="+l.val()}):e.setOptions({serviceUrl:s}),e.hide(),e.onValueChange()})),t.addClass("xts-search-inited"))}),XTSThemeModule.$document.on("click",function(e){e=e.target;x(e).is(".xts-search-form")||x(e).parents().is(".xts-search-form")||a.find('[type="text"]').devbridgeAutocomplete("hide")}),x(".xts-search-results").on("click",function(e){e.stopPropagation()})})},x(document).ready(function(){XTSThemeModule.ajaxSearch()})})(jQuery);