"use strict";(function($){var _ajax;$(document).ready(function(){$(document).on("click",'input[type="checkbox"]',function(e){let name=$(this).attr("name");let val=$(this).val();if(val==""){$('input[name="'+name+'"]').prop("checked",!1)}});$(document).on("click",".whfilter_form .submit-filter, .whfilter_form .reset-filter",function(e){e.preventDefault();let form=$(this).parents("form");let selectedIdForm=form.attr("id");let formdata=form.serialize();if($(this).attr("type")=="reset"){document.getElementById(selectedIdForm).reset();formdata=$(`#${selectedIdForm} :input[value!=""][value!="."]`).serialize()}
let multiplePerpage=$(`#multiple-post-perpage.${selectedIdForm}`).val();if(multiplePerpage){formdata+="&mutltiple_perpage="+multiplePerpage}
let sortby=$(`#sortby.${selectedIdForm}`).val();if(sortby){let order=$(`.${selectedIdForm}.whfilter-overview [name="order"]`).val();let order_meta_key=$(`.${selectedIdForm}.whfilter-overview [name="order_meta_key"]`).val();formdata+="&sortby="+sortby+"&order="+order;if(order_meta_key){formdata+="&order_meta_key="+order_meta_key}}
let data={action:"submit_filter",data:formdata,};whSubmiFilter(data,selectedIdForm)});$(document).on("submit",".whfilter_form",function(e){e.preventDefault()});$(document).on("change",".whfilter_form",function(e){e.preventDefault();let form=$(this);let selectedIdForm=form.attr("id");let submit=form.data("auto-submit");let formdata=form.serialize();let multiplePerpage=$(`#multiple-post-perpage.${selectedIdForm}`).val();if(multiplePerpage){formdata+="&mutltiple_perpage="+multiplePerpage}
let sortby=$(`#sortby.${selectedIdForm}`).val();if(sortby){let order=$(`.${selectedIdForm}.whfilter-overview [name="order"]`).val();let order_meta_key=$(`.${selectedIdForm}.whfilter-overview [name="order_meta_key"]`).val();formdata+="&sortby="+sortby+"&order="+order;if(order_meta_key){formdata+="&order_meta_key="+order_meta_key}}
let data={action:"submit_filter",data:formdata,};if(submit=="auto"){whSubmiFilter(data,selectedIdForm)}});$(document).on("change","#sortby",function(e){e.preventDefault();let selectedIdForm=$(this).data("sortby");let form=$(`#${selectedIdForm}`);let sortby=$(this).val();let submit=form.data("auto-submit");let formdata=form.serialize();let multiplePerpage=$(`#multiple-post-perpage.${selectedIdForm}`).val();if(multiplePerpage){formdata+="&mutltiple_perpage="+multiplePerpage}
if(sortby){let order=$(`.whfilter-overview.${selectedIdForm} [name="order"]`).val();let order_meta_key=$(`.whfilter-overview.${selectedIdForm} [name="order_meta_key"]`).val();formdata+="&sortby="+sortby+"&order="+order;if(order_meta_key){formdata+="&order_meta_key="+order_meta_key}}
let data={action:"submit_filter",data:formdata,};if(submit=="auto"){whSubmiFilter(data,selectedIdForm)}});$(document).on("click",".sort-order",function(e){e.preventDefault();let selectedIdForm=$(this).data("sortorder");let form=$(`#${selectedIdForm}`);let order=$(`.whfilter-overview.${selectedIdForm} [name="order"]`).val();if(order=="ASC"){$(`.whfilter-overview.${selectedIdForm} [name="order"]`).val("DESC");$(`.sort-order.${selectedIdForm} span`).removeClass("icon-arrow-asc").addClass("icon-arrow-desc")}else{$(`.whfilter-overview.${selectedIdForm} [name="order"]`).val("ASC");$(`.sort-order.${selectedIdForm} span`).removeClass("icon-arrow-desc").addClass("icon-arrow-asc")}
let submit=form.data("auto-submit");let formdata=form.serialize();let multiplePerpage=$(`#multiple-post-perpage.${selectedIdForm}`).val();if(multiplePerpage){formdata+="&mutltiple_perpage="+multiplePerpage}
let sortby=$(`#sortby.${selectedIdForm}`).val();if(sortby){let order_meta_key=$(`.whfilter-overview.${selectedIdForm} [name="order_meta_key"]`).val();formdata+="&sortby="+sortby+"&order="+order;if(order_meta_key){formdata+="&order_meta_key="+order_meta_key}}
let data={action:"submit_filter",data:formdata,};if(submit=="auto"){whSubmiFilter(data,selectedIdForm)}});$(document).on("click",".whfilter-overview button.page-numbers",function(e){e.preventDefault();let selectedIdForm=$(this).closest(".ajax-response").data("listingfilter");let form=$(`#${selectedIdForm}.whfilter_form`);let formdata=form.serialize();let paged=$(this).data("page");let multiplePerpage=$(`#multiple-post-perpage.${selectedIdForm}`).val();if(multiplePerpage){formdata+="&mutltiple_perpage="+multiplePerpage}
let sortby=$(`#sortby.${selectedIdForm}`).val();if(sortby){let order=$(`.whfilter-overview.${selectedIdForm} [name="order"]`).val();let order_meta_key=$(`.whfilter-overview.${selectedIdForm} [name="order_meta_key"]`).val();formdata+="&sortby="+sortby+"&order="+order;if(order_meta_key){formdata+="&order_meta_key="+order_meta_key}}
let data={action:"submit_filter",data:formdata,paged:paged,};whSubmiFilter(data,selectedIdForm)});$(document).on("change","#multiple-post-perpage",function(e){e.preventDefault();let selectedIdForm=$(this).data("multipleperpage");let form=$(`#${selectedIdForm}`);let formdata=form.serialize();let multiplePerpage=$(this).val();let submit=form.data("auto-submit");let sortby=$(`#sortby.${selectedIdForm}`).val();if(multiplePerpage){formdata+="&mutltiple_perpage="+multiplePerpage}
if(sortby){let order=$(`.whfilter-overview.${selectedIdForm} [name="order"]`).val();let order_meta_key=$(`.whfilter-overview.${selectedIdForm} [name="order_meta_key"]`).val();formdata+="&sortby="+sortby+"&order="+order;if(order_meta_key){formdata+="&order_meta_key="+order_meta_key}}
let data={action:"submit_filter",data:formdata,};if(submit=="auto"){whSubmiFilter(data,selectedIdForm)}})});function whSubmiFilter(data,idFormFilter){data.data+="&form_filter="+idFormFilter.match(/(\d+)/)[0];let ajaxResults=$(`.ajax-response.${idFormFilter}`);let formWhFilter=$(`#${idFormFilter}.whfilter_form`);if(_ajax==="undefined"){_ajax.abort()}
let loading=' <div class="ajaxloading '+idFormFilter+'">'+ajax.loading+"</div>";formWhFilter.trigger("whfilter_submit",data);_ajax=$.ajax({url:ajax.ajaxurl,type:"post",data:data,beforeSend:function(){$(document).find(".ajaxloading").remove();$(document).find(ajaxResults).before(loading)},success:function(response){ajaxResults.html("");ajaxResults.html(response.html);$(`.${idFormFilter} .info-results .result-count`).html(response.info);formWhFilter.trigger("whfilter_submited",response);if($(".whfilter_form").length<2){window.history.pushState(response,"",response.newurl)}
$("html, body").animate({scrollTop:eval(formWhFilter.offset().top-200),},350)},complete:function(){$(document).find(`.ajaxloading.${idFormFilter}`).remove()},})}})(jQuery)