woocommerce/assets/js/admin/wc-product-export.min.js

1 line
1.5 KiB
JavaScript

!function(a,b){var c=function(a){this.$form=a,this.xhr=!1,this.$form.find(".woocommerce-exporter-progress").val(0),this.processStep=this.processStep.bind(this),a.on("submit",{productExportForm:this},this.onSubmit)};c.prototype.onSubmit=function(b){b.preventDefault(),b.data.productExportForm.$form.addClass("woocommerce-exporter__exporting"),b.data.productExportForm.$form.find(".woocommerce-exporter-progress").val(0),b.data.productExportForm.$form.find(".woocommerce-exporter-button").prop("disabled",!0),b.data.productExportForm.processStep(1,a(this).serialize(),"")},c.prototype.processStep=function(c,d,e){var f=this,g=a(".woocommerce-exporter-columns").val(),h=a("#woocommerce-exporter-meta:checked").length?1:0,i=a(".woocommerce-exporter-types").val();a.ajax({type:"POST",url:ajaxurl,data:{form:d,action:"woocommerce_do_ajax_product_export",step:c,columns:e,selected_columns:g,export_meta:h,export_types:i,security:wc_product_export_params.export_nonce},dataType:"json",success:function(a){a.success&&("done"===a.data.step?(f.$form.find(".woocommerce-exporter-progress").val(a.data.percentage),b.location=a.data.url,setTimeout(function(){f.$form.removeClass("woocommerce-exporter__exporting"),f.$form.find(".woocommerce-exporter-button").prop("disabled",!1)},2e3)):(f.$form.find(".woocommerce-exporter-progress").val(a.data.percentage),f.processStep(parseInt(a.data.step,10),d,a.data.columns)))}}).fail(function(a){b.console.log(a)})},a.fn.wc_product_export_form=function(){return new c(this),this},a(".woocommerce-exporter").wc_product_export_form()}(jQuery,window);