text: jQuery(function(a){function b(a,b=null){a.find(".read-only").is(":visible")?("notes"==b?a.find(".editable-notes :input").attr("disabled",!1):(a.find(".editable").show(),a.find(":input").attr("disabled",!1)),a.find(".read-only").hide(),a.find(".editable-notes").show(),a.closest(".wcpdf-data-fields").find(".wpo-wcpdf-document-buttons").show()):(a.find(".read-only").show(),a.find(".editable").hide(),a.find(".editable-notes").hide(),a.find(":input").attr("disabled",!0),a.closest(".wcpdf-data-fields").find(".wpo-wcpdf-document-buttons").hide())}a("#doaction, #doaction2").on("click",function(b){let c=a(this).attr("id").substr(2),d=a("select[name=\""+c+"\"]").val();if(-1!==a.inArray(d,wpo_wcpdf_ajax.bulk_actions)){b.preventDefault();let c=d,e=[];if(a("tbody th.check-column input[type=\"checkbox\"]:checked").each(function(){e.push(a(this).val())}),!e.length)return void alert("You have to select order(s) first!");let f=e.join("x");url=-1==wpo_wcpdf_ajax.ajaxurl.indexOf("?")?wpo_wcpdf_ajax.ajaxurl+"?action=generate_wpo_wcpdf&document_type="+c+"&order_ids="+f+"&bulk&_wpnonce="+wpo_wcpdf_ajax.nonce:wpo_wcpdf_ajax.ajaxurl+"&action=generate_wpo_wcpdf&document_type="+c+"&order_ids="+f+"&bulk&_wpnonce="+wpo_wcpdf_ajax.nonce,window.open(url,"_blank")}}),a("#wpo_wcpdf-data-input-box").insertAfter("#woocommerce-order-data"),a("#wpo_wcpdf-data-input-box").on("click",".wpo-wcpdf-set-date-number, .wpo-wcpdf-edit-date-number, .wpo-wcpdf-edit-document-notes",function(){let c=a(this).closest(".wcpdf-data-fields-section");0==c.length&&(c=a(this).closest(".wcpdf-data-fields"));let d=a(this).data("edit");b(c,d)}),a("#wpo_wcpdf-data-input-box").on("click",".wpo-wcpdf-cancel",function(){let c=a(this).closest(".wcpdf-data-fields");b(c)}),a("#wpo_wcpdf-data-input-box").on("click",".wpo-wcpdf-save-document, .wpo-wcpdf-regenerate-document, .wpo-wcpdf-delete-document",function(c){c.preventDefault();let d=a(this).closest(".wcpdf-data-fields"),e=a(this).data("action"),f=a(this).data("nonce"),g=d.data(),h=d.find(":input:visible:not(:disabled)").serialize();if("regenerate"==e){if(!1===window.confirm(wpo_wcpdf_ajax.confirm_regenerate))return;d.find(".wpo-wcpdf-regenerate-document").addClass("wcpdf-regenerate-spin")}else if("delete"==e){if(!1===window.confirm(wpo_wcpdf_ajax.confirm_delete))return;d.find(".wpo-wcpdf-regenerate-document").hide()}d.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),a.ajax({url:wpo_wcpdf_ajax.ajaxurl,data:{action:"wpo_wcpdf_"+e+"_document",security:f,form_data:h,order_id:g.order_id,document_type:g.document,action_type:e,wpcdf_document_data_notice:e+"d"},type:"POST",context:d,success:function(c){b(d),d.closest("#wpo_wcpdf-data-input-box").load(document.URL+" #wpo_wcpdf-data-input-box .postbox-header, #wpo_wcpdf-data-input-box .inside",function(){let b;b=c.success?"success":"error",a(this).find(".wcpdf-data-fields[data-document='"+g.document+"'][data-order_id='"+g.order_id+"']").before("<div class=\"notice notice-"+b+" inline\" style=\"margin:0 10px 10px 10px;\"><p>"+c.data.message+"</p></div>")}),"regenerate"==e&&(d.find(".wpo-wcpdf-regenerate-document").removeClass("wcpdf-regenerate-spin"),b(d)),d.unblock()}})})});