jQuery(document).ready(function(d){d(document).on("hide_variation",function(h,g){d(".awooc-custom-order.button").addClass("disabled wc-variation-selection-needed")});d(document).on("show_variation",function(h,g){d(".awooc-custom-order.button").removeClass("disabled wc-variation-selection-needed wc-variation-is-unavailable");if(awooc_scripts.mode==="no_stock_no_price"){if(!g.is_purchasable||!g.is_in_stock){d("body.woocommerce").find(".single_variation").hide()}}});d(document).on("click",".awooc-custom-order.button",function(j){if(d(this).is(".disabled")){j.preventDefault();if(d(this).is(".wc-variation-is-unavailable")){window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text)}else{if(d(this).is(".wc-variation-selection-needed")){window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text)}}return false}var i;var k=d(".variations_form").find('input[name="variation_id"]').val(),g=d(this).attr("data-value-product-id"),h=d(".quantity").find('input[name="quantity"]').val();var l={};if(k!=0&&typeof k!=="undefined"){i=k}else{i=g}data={id:i,action:"awooc_ajax_product_form",nonce:awooc_scripts.nonce};d.ajax({url:awooc_scripts.url,data:data,type:"POST",dataType:"json",beforeSend:function(n,m){d(j.currentTarget).block({message:null,overlayCSS:{opacity:0.6}});d(j.currentTarget).fadeIn(200).prepend('
')},success:function(m){d(j.currentTarget).unblock();d(j.currentTarget).find(".cssload-container").remove();d(".awooc-close").attr("title",awooc_scripts.title_close);l={outID:"ID: "+i,outTitle:m.title===false?"":"\n"+awooc_scripts.product_title+m.title,outAttr:m.attr===false?"":"\n"+m.attr,outPrice:m.price===false?"":"\n"+awooc_scripts.product_price+m.pricenumber,outSku:m.sku===false?"":"\n"+m.sku,outCat:m.cat===false?"":"\n"+m.cat,outLink:m.link===false?"":"\n"+m.link,outQty:m.qty===false?"":"\n"+awooc_scripts.product_qty+h};d(".awooc-form-custom-order-title").text(m.title);d(".awooc-form-custom-order-img").html(m.image);d(".awooc-form-custom-order-price").html(m.price);d(".awooc-form-custom-order-price").after(m.qty);d(".awooc-form-custom-order-qty").text(awooc_scripts.product_qty+h);d(".awooc-form-custom-order-sku").html(m.sku);d(".awooc-form-custom-order-attr").html(m.attr);d(".awooc-col.columns-right").html(m.form);b();var n=c(l);d(".awooc-hidden-data").val(n);d(".awooc-hidden-product-id").val(i);d(".awooc-hidden-product-qty").val(h);e();a()}});return false});d(document).on("click",".awooc-close",function(){d.unblockUI();d("#awooc-form-custom-order").addClass("awooc-hide");history.pushState("",document.title,window.location.pathname)});document.addEventListener("wpcf7invalid",function(g){setTimeout(function(){d(".wpcf7-response-output").remove();d(".wpcf7-not-valid-tip").remove()},5000)},false);document.addEventListener("wpcf7mailsent",function(g){setTimeout(d.unblockUI,3000);setTimeout(function(){d(".wpcf7-form")[0].reset();d(".wpcf7-response-output").remove()},3000)},false);function b(){d("div.wpcf7 > form").each(function(){var g=d(this);wpcf7.initForm(g);if(wpcf7.cached){wpcf7.refill(g)}})}function c(g){return"\n"+awooc_scripts.product_data_title+"\n———"+g.outTitle+"\n"+g.outID+g.outCat.replace(/(<([^>]+)>)/ig,"")+g.outPrice+g.outAttr.replace(/(<([^>]+)>)/ig,"")+g.outSku.replace(/(<([^>]+)>)/ig,"")+g.outQty+g.outLink}function a(){d.blockUI({message:d("#awooc-form-custom-order"),css:{width:"100%",maxWidth:"600px",maxHeight:"600px",top:"10%",left:"calc(50% - 300px)",border:"none",cursor:"default",overflowY:"auto",boxShadow:"0px 0px 3px 0px rgba(0, 0, 0, 0.2)",zIndex:"1000000"},overlayCSS:{zIndex:"1000000",backgroundColor:"#000",opacity:0.6,cursor:"wait"},bindEvents:true,timeout:0,fadeIn:400,fadeOut:400,allowBodyStretch:true,centerX:true,centerY:true,onBlock:function(){d("#awooc-form-custom-order").removeClass("awooc-hide");if(window.innerWidth<480){d(".blockUI.blockPage").css({left:"2%",top:"calc(30% - 160px)",height:"auto","overflow-y":"scroll",width:"95%"})}else{if(window.innerWidth<569||window.innerWidth<669){d(".blockUI.blockPage").css({left:"2%",top:"2%",height:"95%","overflow-y":"scroll",width:"95%"})}else{if(window.innerWidth<769){d(".blockUI.blockPage").css({height:"auto","overflow-y":"scroll",width:"95%"})}}}},onUnblock:function(){d("#awooc-form-custom-order").addClass("awooc-hide");f();history.pushState("",document.title,window.location.pathname)},onOverlayClick:function(){d("#awooc-form-custom-order").addClass("awooc-hide");d("html").css({overflow:"initial"});d.unblockUI();f();history.pushState("",document.title,window.location.pathname)}})}function f(){d(".awooc-form-custom-order-title").empty();d(".awooc-form-custom-order-img").empty();d(".awooc-form-custom-order-price").empty();d(".awooc-form-custom-order-qty").empty();d(".awooc-form-custom-order-sku").empty();d(".awooc-form-custom-order-attr").empty()}function e(){var g=d(".wpcf7-mask");if(g.length>0){g.each(function(){var j=d(this),h=j.data("mask");try{j.mask(h);if(h.indexOf("*")==-1&&h.indexOf("a")==-1){j.attr({inputmode:"numeric"})}}catch(i){console.log("Ошибка "+i.name+":"+i.message+"\n"+i.stack)}})}}});