diff --git a/assets/js/admin/backbone-modal.min.js b/assets/js/admin/backbone-modal.min.js index b549b2ca7d5..7a557e711b1 100644 --- a/assets/js/admin/backbone-modal.min.js +++ b/assets/js/admin/backbone-modal.min.js @@ -1 +1 @@ -!function(e,t,n){"use strict";e.fn.WCBackboneModal=function(t){return this.each(function(){new e.WCBackboneModal(e(this),t)})},e.WCBackboneModal=function(t,n){var o=e.extend({},e.WCBackboneModal.defaultOptions,n);o.template&&new e.WCBackboneModal.View({target:o.template,string:o.variable})},e.WCBackboneModal.defaultOptions={template:"",variable:{}},e.WCBackboneModal.View=t.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:undefined,_string:undefined,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions"},resizeContent:function(){var t=e(".wc-backbone-modal-content").find("article"),n=.75*e(window).height();t.css({"max-height":n+"px"})},initialize:function(t){var o=this;this._target=t.target,this._string=t.string,n.bindAll(this,"render"),this.render(),e(window).resize(function(){o.resizeContent()})},render:function(){var t=wp.template(this._target);this.$el.append(t(this._string)),e(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),this.$(".wc-backbone-modal-content").attr("tabindex","0").focus(),e(document.body).trigger("init_tooltips"),e(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(t){t.preventDefault(),e(document.body).trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),e(document).off("focusin"),e(document.body).css({overflow:"auto"}),this.remove(),e(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(t){e(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(t)},getFormData:function(){var t={};return e(document.body).trigger("wc_backbone_modal_before_update",this._target),e.each(e("form",this.$el).serializeArray(),function(n,o){-1!==o.name.indexOf("[]")?(o.name=o.name.replace("[]",""),t[o.name]=e.makeArray(t[o.name]),t[o.name].push(o.value)):t[o.name]=o.value}),t},keyboardActions:function(e){var t=e.keyCode||e.which;13!==t||e.target.tagName&&("input"===e.target.tagName.toLowerCase()||"textarea"===e.target.tagName.toLowerCase())||this.addButton(e),27===t&&this.closeButton(e)}})}(jQuery,Backbone,_); \ No newline at end of file +!function(e,t,n){"use strict";e.fn.WCBackboneModal=function(t){return this.each(function(){var n=new e.WCBackboneModal(e(this),t)(n())})},e.WCBackboneModal=function(t,n){var o=e.extend({},e.WCBackboneModal.defaultOptions,n);o.template&&new e.WCBackboneModal.View({target:o.template,string:o.variable})()},e.WCBackboneModal.defaultOptions={template:"",variable:{}},e.WCBackboneModal.View=t.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:undefined,_string:undefined,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions"},resizeContent:function(){var t=e(".wc-backbone-modal-content").find("article"),n=.75*e(window).height();t.css({"max-height":n+"px"})},initialize:function(t){var o=this;this._target=t.target,this._string=t.string,n.bindAll(this,"render"),this.render(),e(window).resize(function(){o.resizeContent()})},render:function(){var t=wp.template(this._target);this.$el.append(t(this._string)),e(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),this.$(".wc-backbone-modal-content").attr("tabindex","0").focus(),e(document.body).trigger("init_tooltips"),e(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(t){t.preventDefault(),e(document.body).trigger("wc_backbone_modal_before_remove",this._target),this.undelegateEvents(),e(document).off("focusin"),e(document.body).css({overflow:"auto"}),this.remove(),e(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(t){e(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(t)},getFormData:function(){var t={};return e(document.body).trigger("wc_backbone_modal_before_update",this._target),e.each(e("form",this.$el).serializeArray(),function(n,o){-1!==o.name.indexOf("[]")?(o.name=o.name.replace("[]",""),t[o.name]=e.makeArray(t[o.name]),t[o.name].push(o.value)):t[o.name]=o.value}),t},keyboardActions:function(e){var t=e.keyCode||e.which;13!==t||e.target.tagName&&("input"===e.target.tagName.toLowerCase()||"textarea"===e.target.tagName.toLowerCase())||this.addButton(e),27===t&&this.closeButton(e)}})}(jQuery,Backbone,_); \ No newline at end of file diff --git a/assets/js/admin/meta-boxes-order.min.js b/assets/js/admin/meta-boxes-order.min.js index 3f37bf0d1ba..e419f397738 100644 --- a/assets/js/admin/meta-boxes-order.min.js +++ b/assets/js/admin/meta-boxes-order.min.js @@ -1 +1 @@ -jQuery(function(e){var o={states:null,init:function(){"undefined"!=typeof woocommerce_admin_meta_boxes_order&&"undefined"!=typeof woocommerce_admin_meta_boxes_order.countries&&(this.states=e.parseJSON(woocommerce_admin_meta_boxes_order.countries.replace(/"/g,'"'))),e(".js_field-country").selectWoo().change(this.change_country),e(".js_field-country").trigger("change",[!0]),e(document.body).on("change","select.js_field-state",this.change_state),e("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),e("a.edit_address").click(this.edit_address),e("a.billing-same-as-shipping").on("click",this.copy_billing_to_shipping),e("a.load_customer_billing").on("click",this.load_billing),e("a.load_customer_shipping").on("click",this.load_shipping),e("#customer_user").on("change",this.change_customer_user)},change_country:function(t,i){if(void 0===i&&(i=!1),null!==o.states){var a=e(this),n=a.val(),r=a.parents("div.edit_address").find(":input.js_field-state"),c=r.parent(),d=r.attr("name"),_=r.attr("id"),m=a.data("woocommerce.stickState-"+n)?a.data("woocommerce.stickState-"+n):r.val(),s=r.attr("placeholder");if(i&&a.data("woocommerce.stickState-"+n,m),c.show().find(".select2-container").remove(),e.isEmptyObject(o.states[n]))r.replaceWith('');else{var l=e(''),u=o.states[n];l.append(e('")),e.each(u,function(o){l.append(e('"))}),l.val(m),r.replaceWith(l),l.show().selectWoo().hide().change()}e(document.body).trigger("contry-change.woocommerce",[n,e(this).closest("div")]),e(document.body).trigger("country-change.woocommerce",[n,e(this).closest("div")])}},change_state:function(){var o=e(this),t=o.val(),i=o.parents("div.edit_address").find(":input.js_field-country"),a=i.val();i.data("woocommerce.stickState-"+a,t)},init_tiptip:function(){e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})},edit_address:function(o){o.preventDefault();var t=e(this),i=t.closest(".order_data_column"),a=i.find("div.edit_address"),n=i.find("div.address"),r=a.find(".js_field-country"),c=a.find(".js_field-state");n.hide(),t.parent().find("a").toggle(),r.val()||r.val(woocommerce_admin_meta_boxes_order.default_country).change(),c.val()||c.val(woocommerce_admin_meta_boxes_order.default_state).change(),a.show()},change_customer_user:function(){e("#_billing_country").val()||(e("a.edit_address").click(),o.load_billing(!0),o.load_shipping(!0))},load_billing:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_billing)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.billing,function(o,t){e(":input#_billing_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},load_shipping:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_shipping)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.shipping,function(o,t){e(":input#_shipping_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},copy_billing_to_shipping:function(){return window.confirm(woocommerce_admin_meta_boxes.copy_billing)&&e('.order_data_column :input[name^="_billing_"]').each(function(){var o=e(this).attr("name");o=o.replace("_billing_","_shipping_"),e(":input#"+o).val(e(this).val()).change()}),!1}},t={init:function(){this.stupidtable.init(),e("#woocommerce-order-items").on("click","button.add-line-item",this.add_line_item).on("click","button.add-coupon",this.add_coupon).on("click","a.remove-coupon",this.remove_coupon).on("click","button.refund-items",this.refund_items).on("click",".cancel-action",this.cancel).on("click","button.add-order-item",this.add_item).on("click","button.add-order-fee",this.add_fee).on("click","button.add-order-shipping",this.add_shipping).on("click","button.add-order-tax",this.add_tax).on("click","button.save-action",this.save_line_items).on("click","a.delete-order-tax",this.delete_tax).on("click","button.calculate-action",this.recalculate).on("click","a.edit-order-item",this.edit_item).on("click","a.delete-order-item",this.delete_item).on("click","tr.item, tr.fee, tr.shipping, tr.refund",this.select_row).on("click","tr.item :input, tr.fee :input, tr.shipping :input, tr.refund :input, tr.item a, tr.fee a, tr.shipping a, tr.refund a",this.select_row_child).on("click","button.bulk-delete-items",this.bulk_actions.do_delete).on("click","button.bulk-increase-stock",this.bulk_actions.do_increase_stock).on("click","button.bulk-decrease-stock",this.bulk_actions.do_reduce_stock).on("click",".delete_refund",this.refunds.delete_refund).on("click","button.do-api-refund, button.do-manual-refund",this.refunds.do_refund).on("change",".refund input.refund_line_total, .refund input.refund_line_tax",this.refunds.input_changed).on("change keyup",".wc-order-refund-items #refund_amount",this.refunds.amount_changed).on("change","input.refund_order_item_qty",this.refunds.refund_quantity_changed).on("change","input.quantity",this.quantity_changed).on("keyup change",".split-input :input",function(){var o=e(this).parent().prev().find(":input");o&&(""===o.val()||o.is(".match-total"))&&o.val(e(this).val()).addClass("match-total")}).on("keyup",".split-input :input",function(){e(this).removeClass("match-total")}).on("click","button.add_order_item_meta",this.item_meta.add).on("click","button.remove_order_item_meta",this.item_meta.remove),e(document.body).on("wc_backbone_modal_loaded",this.backbone.init).on("wc_backbone_modal_response",this.backbone.response)},block:function(){e("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e("#woocommerce-order-items").unblock()},reload_items:function(){var i={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};t.block(),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(i){e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i),o.init_tiptip(),t.unblock(),t.stupidtable.init()}})},quantity_changed:function(){var o=e(this).closest("tr.item"),t=e(this).val(),i=e(this).attr("data-qty"),a=e("input.line_total",o),n=e("input.line_subtotal",o),r=accounting.unformat(a.attr("data-total"),woocommerce_admin.mon_decimal_point)/i;a.val(parseFloat(accounting.formatNumber(r*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var c=accounting.unformat(n.attr("data-subtotal"),woocommerce_admin.mon_decimal_point)/i;n.val(parseFloat(accounting.formatNumber(c*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),e("input.line_tax",o).each(function(){var a=e(this),n=a.data("tax_id"),r=accounting.unformat(a.attr("data-total_tax"),woocommerce_admin.mon_decimal_point)/i,c=e('input.line_subtotal_tax[data-tax_id="'+n+'"]',o),d=accounting.unformat(c.attr("data-subtotal_tax"),woocommerce_admin.mon_decimal_point)/i;00?e("#restock_refunded_items").closest("tr").show():(e("#restock_refunded_items").closest("tr").hide(),e(".woocommerce_order_items input.refund_order_item_qty").each(function(){e(this).val()>0&&e("#restock_refunded_items").closest("tr").show()})),e(this).trigger("refund_quantity_changed")}},item_meta:{add:function(){var o=e(this).closest("tr.item, tr.shipping"),t=o.find("tbody.meta_items"),i=t.find("tr").length+1,a='';return t.append(a),!1},remove:function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_meta)){var o=e(this).closest("tr");o.find(":input").val(""),o.hide()}return!1}},select_row:function(){var o=!1;o=e(this).is("tr")?e(this):e(this).closest("tr");var t=e(this).closest("table");o.is(".selected")?o.removeClass("selected"):o.addClass("selected");var i=t.find("tr.selected");if(i.length){e("div.wc-order-item-bulk-edit").slideDown();var a=!1;i.each(function(){e(this).is("tr.item")&&(a=!0)}),a?e(".bulk-increase-stock, .bulk-decrease-stock").show():e(".bulk-increase-stock, .bulk-decrease-stock").hide()}else e("div.wc-order-item-bulk-edit").slideUp()},select_row_child:function(e){e.stopPropagation()},bulk_actions:{do_delete:function(o){o.preventDefault();var i=e("table.woocommerce_order_items").find("tr.selected");if(i.length&&window.confirm(woocommerce_admin_meta_boxes.remove_item_notice)){t.block();var a=[],n=[],r=[];e.map(i,function(o){var t=e(o);t.is(".refund")?n.push(parseInt(e(t).data("order_refund_id"),10)):a.push(parseInt(e(t).data("order_item_id"),10))}),a.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:a,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),n.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{action:"woocommerce_delete_refund",refund_id:n,security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),r?e.when.apply(e,r).done(function(){t.reload_items(),t.unblock()}):t.unblock()}},do_increase_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})},do_reduce_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})}},backbone:{init:function(o,t){"wc-modal-add-products"===t&&(e(document.body).trigger("wc-enhanced-select-init"),e("#add_item_id").selectWoo("open").selectWoo("focus"))},response:function(e,o,i){if("wc-modal-add-tax"===o){var a=i.add_order_tax,n="";i.manual_tax_rate_id&&(n=i.manual_tax_rate_id),t.backbone.add_tax(a,n)}"wc-modal-add-products"===o&&t.backbone.add_item(i.add_order_items)},add_item:function(i){if(i){t.block();var a={action:"woocommerce_add_order_item",item_to_add:i,dataType:"json",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce,data:e("#wc-backbone-modal-dialog form").serialize()};e.post(woocommerce_admin_meta_boxes.ajax_url,a,function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()})}},add_tax:function(i,a){if(a&&(i=a),!i)return!1;var n=e(".order-tax-id").map(function(){return e(this).val()}).get();if(-1===e.inArray(i,n)){t.block();var r={action:"woocommerce_add_order_tax",rate_id:i,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,dataType:"json",type:"POST",success:function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()}})}else window.alert(woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists)}},stupidtable:{init:function(){e(".woocommerce_order_items").stupidtable(),e(".woocommerce_order_items").on("aftertablesort",this.add_arrows)},add_arrows:function(o,t){var i=e(this).find("th"),a="asc"===t.direction?"↑":"↓",n=t.column;i.find(".wc-arrow").remove(),i.eq(n).append(''+a+"")}}},i={init:function(){e("#woocommerce-order-notes").on("click","button.add_note",this.add_order_note).on("click","a.delete_note",this.delete_order_note)},add_order_note:function(){if(e("textarea#add_order_note").val()){e("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:e("textarea#add_order_note").val(),note_type:e("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,o,function(o){e("ul.order_notes").prepend(o),e("#woocommerce-order-notes").unblock(),e("#add_order_note").val("")}),!1}},delete_order_note:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_note)){var o=e(this).closest("li.note");e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_delete_order_note",note_id:e(o).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(){e(o).remove()})}return!1}},a={init:function(){e(".order_download_permissions").on("click","button.grant_access",this.grant_access).on("click","button.revoke_access",this.revoke_access)},grant_access:function(){var o=e("#grant_access_id").val();if(o){e(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_grant_access_to_download",product_ids:o,loop:e(".order_download_permissions .wc-metabox").length,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(o){o?e(".order_download_permissions .wc-metaboxes").append(o):window.alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),e(document.body).trigger("wc-init-datepickers"),e("#grant_access_id").val("").change(),e(".order_download_permissions").unblock()}),!1}},revoke_access:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke)){var o=e(this).parent().parent(),t=e(this).attr("rel").split(",")[0],i=e(this).attr("rel").split(",")[1],a=e(this).data("permission_id");if(t>0){e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n={action:"woocommerce_revoke_access_to_download",product_id:t,download_id:i,permission_id:a,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,n,function(){e(o).fadeOut("300",function(){e(o).remove()})})}else e(o).fadeOut("300",function(){e(o).remove()})}return!1}};o.init(),t.init(),i.init(),a.init()}); \ No newline at end of file +jQuery(function(e){var o={states:null,init:function(){"undefined"!=typeof woocommerce_admin_meta_boxes_order&&"undefined"!=typeof woocommerce_admin_meta_boxes_order.countries&&(this.states=e.parseJSON(woocommerce_admin_meta_boxes_order.countries.replace(/"/g,'"'))),e(".js_field-country").selectWoo().change(this.change_country),e(".js_field-country").trigger("change",[!0]),e(document.body).on("change","select.js_field-state",this.change_state),e("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),e("a.edit_address").click(this.edit_address),e("a.billing-same-as-shipping").on("click",this.copy_billing_to_shipping),e("a.load_customer_billing").on("click",this.load_billing),e("a.load_customer_shipping").on("click",this.load_shipping),e("#customer_user").on("change",this.change_customer_user)},change_country:function(t,i){if(void 0===i&&(i=!1),null!==o.states){var a=e(this),n=a.val(),r=a.parents("div.edit_address").find(":input.js_field-state"),c=r.parent(),d=r.attr("name"),_=r.attr("id"),m=a.data("woocommerce.stickState-"+n)?a.data("woocommerce.stickState-"+n):r.val(),s=r.attr("placeholder");if(i&&a.data("woocommerce.stickState-"+n,m),c.show().find(".select2-container").remove(),e.isEmptyObject(o.states[n]))r.replaceWith('');else{var l=e(''),u=o.states[n];l.append(e('")),e.each(u,function(o){l.append(e('"))}),l.val(m),r.replaceWith(l),l.show().selectWoo().hide().change()}e(document.body).trigger("contry-change.woocommerce",[n,e(this).closest("div")]),e(document.body).trigger("country-change.woocommerce",[n,e(this).closest("div")])}},change_state:function(){var o=e(this),t=o.val(),i=o.parents("div.edit_address").find(":input.js_field-country"),a=i.val();i.data("woocommerce.stickState-"+a,t)},init_tiptip:function(){e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})},edit_address:function(o){o.preventDefault();var t=e(this),i=t.closest(".order_data_column"),a=i.find("div.edit_address"),n=i.find("div.address"),r=a.find(".js_field-country"),c=a.find(".js_field-state");n.hide(),t.parent().find("a").toggle(),r.val()||r.val(woocommerce_admin_meta_boxes_order.default_country).change(),c.val()||c.val(woocommerce_admin_meta_boxes_order.default_state).change(),a.show()},change_customer_user:function(){e("#_billing_country").val()||(e("a.edit_address").click(),o.load_billing(!0),o.load_shipping(!0))},load_billing:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_billing)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.billing,function(o,t){e(":input#_billing_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},load_shipping:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_shipping)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.shipping,function(o,t){e(":input#_shipping_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},copy_billing_to_shipping:function(){return window.confirm(woocommerce_admin_meta_boxes.copy_billing)&&e('.order_data_column :input[name^="_billing_"]').each(function(){var o=e(this).attr("name");o=o.replace("_billing_","_shipping_"),e(":input#"+o).val(e(this).val()).change()}),!1}},t={init:function(){this.stupidtable.init(),e("#woocommerce-order-items").on("click","button.add-line-item",this.add_line_item).on("click","button.add-coupon",this.add_coupon).on("click","a.remove-coupon",this.remove_coupon).on("click","button.refund-items",this.refund_items).on("click",".cancel-action",this.cancel).on("click","button.add-order-item",this.add_item).on("click","button.add-order-fee",this.add_fee).on("click","button.add-order-shipping",this.add_shipping).on("click","button.add-order-tax",this.add_tax).on("click","button.save-action",this.save_line_items).on("click","a.delete-order-tax",this.delete_tax).on("click","button.calculate-action",this.recalculate).on("click","a.edit-order-item",this.edit_item).on("click","a.delete-order-item",this.delete_item).on("click","tr.item, tr.fee, tr.shipping, tr.refund",this.select_row).on("click","tr.item :input, tr.fee :input, tr.shipping :input, tr.refund :input, tr.item a, tr.fee a, tr.shipping a, tr.refund a",this.select_row_child).on("click","button.bulk-delete-items",this.bulk_actions.do_delete).on("click","button.bulk-increase-stock",this.bulk_actions.do_increase_stock).on("click","button.bulk-decrease-stock",this.bulk_actions.do_reduce_stock).on("click",".delete_refund",this.refunds.delete_refund).on("click","button.do-api-refund, button.do-manual-refund",this.refunds.do_refund).on("change",".refund input.refund_line_total, .refund input.refund_line_tax",this.refunds.input_changed).on("change keyup",".wc-order-refund-items #refund_amount",this.refunds.amount_changed).on("change","input.refund_order_item_qty",this.refunds.refund_quantity_changed).on("change","input.quantity",this.quantity_changed).on("keyup change",".split-input :input",function(){var o=e(this).parent().prev().find(":input");o&&(""===o.val()||o.is(".match-total"))&&o.val(e(this).val()).addClass("match-total")}).on("keyup",".split-input :input",function(){e(this).removeClass("match-total")}).on("click","button.add_order_item_meta",this.item_meta.add).on("click","button.remove_order_item_meta",this.item_meta.remove),e(document.body).on("wc_backbone_modal_loaded",this.backbone.init).on("wc_backbone_modal_response",this.backbone.response)},block:function(){e("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e("#woocommerce-order-items").unblock()},reload_items:function(){var i={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};t.block(),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(i){e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i),o.init_tiptip(),t.unblock(),t.stupidtable.init()}})},quantity_changed:function(){var o=e(this).closest("tr.item"),t=e(this).val(),i=e(this).attr("data-qty"),a=e("input.line_total",o),n=e("input.line_subtotal",o),r=accounting.unformat(a.attr("data-total"),woocommerce_admin.mon_decimal_point)/i;a.val(parseFloat(accounting.formatNumber(r*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var c=accounting.unformat(n.attr("data-subtotal"),woocommerce_admin.mon_decimal_point)/i;n.val(parseFloat(accounting.formatNumber(c*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),e("input.line_tax",o).each(function(){var a=e(this),n=a.data("tax_id"),r=accounting.unformat(a.attr("data-total_tax"),woocommerce_admin.mon_decimal_point)/i,c=e('input.line_subtotal_tax[data-tax_id="'+n+'"]',o),d=accounting.unformat(c.attr("data-subtotal_tax"),woocommerce_admin.mon_decimal_point)/i;00?e("#restock_refunded_items").closest("tr").show():(e("#restock_refunded_items").closest("tr").hide(),e(".woocommerce_order_items input.refund_order_item_qty").each(function(){e(this).val()>0&&e("#restock_refunded_items").closest("tr").show()})),e(this).trigger("refund_quantity_changed")}},item_meta:{add:function(){var o=e(this).closest("tr.item, tr.shipping"),t=o.find("tbody.meta_items"),i=t.find("tr").length+1,a='';return t.append(a),!1},remove:function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_meta)){var o=e(this).closest("tr");o.find(":input").val(""),o.hide()}return!1}},select_row:function(){var o=!1;o=e(this).is("tr")?e(this):e(this).closest("tr");var t=e(this).closest("table");o.is(".selected")?o.removeClass("selected"):o.addClass("selected");var i=t.find("tr.selected");if(i.length){e("div.wc-order-item-bulk-edit").slideDown();var a=!1;i.each(function(){e(this).is("tr.item")&&(a=!0)}),a?e(".bulk-increase-stock, .bulk-decrease-stock").show():e(".bulk-increase-stock, .bulk-decrease-stock").hide()}else e("div.wc-order-item-bulk-edit").slideUp()},select_row_child:function(e){e.stopPropagation()},bulk_actions:{do_delete:function(o){o.preventDefault();var i=e("table.woocommerce_order_items").find("tr.selected");if(i.length&&window.confirm(woocommerce_admin_meta_boxes.remove_item_notice)){t.block();var a=[],n=[],r=[];e.map(i,function(o){var t=e(o);t.is(".refund")?n.push(parseInt(e(t).data("order_refund_id"),10)):a.push(parseInt(e(t).data("order_item_id"),10))}),a.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:a,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),n.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{action:"woocommerce_delete_refund",refund_id:n,security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),r?e.when.apply(e,r).done(function(){t.reload_items(),t.unblock()}):t.unblock()}},do_increase_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})},do_reduce_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})}},backbone:{init:function(o,t){"wc-modal-add-products"===t&&(e(document.body).trigger("wc-enhanced-select-init"),e("#add_item_id").selectWoo("open").selectWoo("focus"))},response:function(e,o,i){if("wc-modal-add-tax"===o){var a=i.add_order_tax,n="";i.manual_tax_rate_id&&(n=i.manual_tax_rate_id),t.backbone.add_tax(a,n)}"wc-modal-add-products"===o&&t.backbone.add_item(i.add_order_items)},add_item:function(i){if(i){t.block();var a={action:"woocommerce_add_order_item",item_to_add:i,dataType:"json",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce,data:e("#wc-backbone-modal-dialog form").serialize()};"true"===e("button.cancel-action").attr("data-reload")&&(a.items=e("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize()),e.post(woocommerce_admin_meta_boxes.ajax_url,a,function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()})}},add_tax:function(i,a){if(a&&(i=a),!i)return!1;var n=e(".order-tax-id").map(function(){return e(this).val()}).get();if(-1===e.inArray(i,n)){t.block();var r={action:"woocommerce_add_order_tax",rate_id:i,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,dataType:"json",type:"POST",success:function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()}})}else window.alert(woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists)}},stupidtable:{init:function(){e(".woocommerce_order_items").stupidtable(),e(".woocommerce_order_items").on("aftertablesort",this.add_arrows)},add_arrows:function(o,t){var i=e(this).find("th"),a="asc"===t.direction?"↑":"↓",n=t.column;i.find(".wc-arrow").remove(),i.eq(n).append(''+a+"")}}},i={init:function(){e("#woocommerce-order-notes").on("click","button.add_note",this.add_order_note).on("click","a.delete_note",this.delete_order_note)},add_order_note:function(){if(e("textarea#add_order_note").val()){e("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:e("textarea#add_order_note").val(),note_type:e("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,o,function(o){e("ul.order_notes").prepend(o),e("#woocommerce-order-notes").unblock(),e("#add_order_note").val("")}),!1}},delete_order_note:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_note)){var o=e(this).closest("li.note");e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_delete_order_note",note_id:e(o).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(){e(o).remove()})}return!1}},a={init:function(){e(".order_download_permissions").on("click","button.grant_access",this.grant_access).on("click","button.revoke_access",this.revoke_access)},grant_access:function(){var o=e("#grant_access_id").val();if(o){e(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_grant_access_to_download",product_ids:o,loop:e(".order_download_permissions .wc-metabox").length,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(o){o?e(".order_download_permissions .wc-metaboxes").append(o):window.alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),e(document.body).trigger("wc-init-datepickers"),e("#grant_access_id").val("").change(),e(".order_download_permissions").unblock()}),!1}},revoke_access:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke)){var o=e(this).parent().parent(),t=e(this).attr("rel").split(",")[0],i=e(this).attr("rel").split(",")[1],a=e(this).data("permission_id");if(t>0){e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n={action:"woocommerce_revoke_access_to_download",product_id:t,download_id:i,permission_id:a,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,n,function(){e(o).fadeOut("300",function(){e(o).remove()})})}else e(o).fadeOut("300",function(){e(o).remove()})}return!1}};o.init(),t.init(),i.init(),a.init()}); \ No newline at end of file diff --git a/assets/js/admin/meta-boxes-product-variation.js b/assets/js/admin/meta-boxes-product-variation.js index 49937ee1630..c1a7379d277 100644 --- a/assets/js/admin/meta-boxes-product-variation.js +++ b/assets/js/admin/meta-boxes-product-variation.js @@ -1043,4 +1043,4 @@ wc_meta_boxes_product_variations_ajax.init(); wc_meta_boxes_product_variations_pagenav.init(); -}); +})( jQuery ); diff --git a/assets/js/admin/meta-boxes-product-variation.min.js b/assets/js/admin/meta-boxes-product-variation.min.js index 5dd3818f7fb..f5edd3feba5 100644 --- a/assets/js/admin/meta-boxes-product-variation.min.js +++ b/assets/js/admin/meta-boxes-product-variation.min.js @@ -1 +1 @@ -jQuery(function(a){var e={init:function(){a("#variable_product_options").on("change","input.variable_is_downloadable",this.variable_is_downloadable).on("change","input.variable_is_virtual",this.variable_is_virtual).on("change","input.variable_manage_stock",this.variable_manage_stock).on("click","button.notice-dismiss",this.notice_dismiss).on("click","h3 .sort",this.set_menu_order).on("reload",this.reload),a("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock").change(),a("#woocommerce-product-data").on("woocommerce_variations_loaded",this.variations_loaded),a(document.body).on("woocommerce_variations_added",this.variation_added)},reload:function(){o.load_variations(1),t.set_paginav(0)},variable_is_downloadable:function(){a(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").hide(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").show()},variable_is_virtual:function(){a(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").show(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").hide()},variable_manage_stock:function(){a(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").hide(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").show()},notice_dismiss:function(){a(this).closest("div.notice").remove()},variations_loaded:function(i,o){o=o||!1;var t=a("#woocommerce-product-data");o||(a("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock",t).change(),a(".woocommerce_variation",t).each(function(e,i){var o=a(i),t=a(".sale_price_dates_from",o).val(),n=a(".sale_price_dates_to",o).val();""===t&&""===n||a("a.sale_schedule",o).click()}),a(".woocommerce_variations .variation-needs-update",t).removeClass("variation-needs-update"),a("button.cancel-variation-changes, button.save-variation-changes",t).attr("disabled","disabled")),a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".woocommerce_variations .tips, .woocommerce_variations .help_tip, .woocommerce_variations .woocommerce-help-tip",t).tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),a(".sale_price_dates_fields",t).find("input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,onSelect:function(){var e=a(this).is(".sale_price_dates_from")?"minDate":"maxDate",i=a(this).closest(".sale_price_dates_fields").find("input"),o=a(this).datepicker("getDate");i.not(this).datepicker("option",e,o),a(this).change()}}),a(".woocommerce_variations",t).sortable({items:".woocommerce_variation",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){e.variation_row_indexes()}}),a(document.body).trigger("wc-enhanced-select-init")},variation_added:function(a,i){1===i&&e.variations_loaded(null,!0)},set_menu_order:function(e){e.preventDefault();var i=a(this).closest(".woocommerce_variation").find(".variation_menu_order"),t=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_menu_order,i.val());null!=t&&(i.val(parseInt(t,10)).change(),o.save_variations())},variation_row_indexes:function(){var e=a("#variable_product_options").find(".woocommerce_variations"),i=parseInt(e.attr("data-page"),10),o=parseInt((i-1)*woocommerce_admin_meta_boxes_variations.variations_per_page,10);a(".woocommerce_variations .woocommerce_variation").each(function(e,i){a(".variation_menu_order",i).val(parseInt(a(i).index(".woocommerce_variations .woocommerce_variation"),10)+1+o).change()})}},i={variable_image_frame:null,setting_variation_image_id:null,setting_variation_image:null,wp_media_post_id:wp.media.model.settings.post.id,init:function(){a("#variable_product_options").on("click",".upload_image_button",this.add_image),a("a.add_media").on("click",this.restore_wp_media_post_id)},add_image:function(e){var o=a(this),t=o.attr("rel"),n=o.closest(".upload_image");if(i.setting_variation_image=n,i.setting_variation_image_id=t,e.preventDefault(),o.is(".remove"))a(".upload_image_id",i.setting_variation_image).val("").change(),i.setting_variation_image.find("img").eq(0).attr("src",woocommerce_admin_meta_boxes_variations.woocommerce_placeholder_img_src),i.setting_variation_image.find(".upload_image_button").removeClass("remove");else{if(i.variable_image_frame)return i.variable_image_frame.uploader.uploader.param("post_id",i.setting_variation_image_id),void i.variable_image_frame.open();wp.media.model.settings.post.id=i.setting_variation_image_id,i.variable_image_frame=wp.media.frames.variable_image=wp.media({title:woocommerce_admin_meta_boxes_variations.i18n_choose_image,button:{text:woocommerce_admin_meta_boxes_variations.i18n_set_image},states:[new wp.media.controller.Library({title:woocommerce_admin_meta_boxes_variations.i18n_choose_image,filterable:"all"})]}),i.variable_image_frame.on("select",function(){var e=i.variable_image_frame.state().get("selection").first().toJSON(),o=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;a(".upload_image_id",i.setting_variation_image).val(e.id).change(),i.setting_variation_image.find(".upload_image_button").addClass("remove"),i.setting_variation_image.find("img").eq(0).attr("src",o),wp.media.model.settings.post.id=i.wp_media_post_id}),i.variable_image_frame.open()}},restore_wp_media_post_id:function(){wp.media.model.settings.post.id=i.wp_media_post_id}},o={init:function(){a("li.variations_tab a").on("click",this.initial_load),a("#variable_product_options").on("click","button.save-variation-changes",this.save_variations).on("click","button.cancel-variation-changes",this.cancel_variations).on("click",".remove_variation",this.remove_variation),a(document.body).on("change","#variable_product_options .woocommerce_variations :input",this.input_changed).on("change",".variations-defaults select",this.defaults_changed),a("form#post").on("submit",this.save_on_submit),a(".wc-metaboxes-wrapper").on("click","a.do_variation_action",this.do_variation_action)},check_for_changes:function(){var e=a("#variable_product_options").find(".woocommerce_variations .variation-needs-update");if(0o&&0!==o&&(n=o),t.go_to_page(n,-1)})):o.unblock()}return!1},link_all_variations:function(){if(o.check_for_changes(),window.confirm(woocommerce_admin_meta_boxes_variations.i18n_link_all_variations)){o.block();var e={action:"woocommerce_link_all_variations",post_id:woocommerce_admin_meta_boxes_variations.post_id,security:woocommerce_admin_meta_boxes_variations.link_variation_nonce};a.post(woocommerce_admin_meta_boxes_variations.ajax_url,e,function(e){var i=parseInt(e,10);1===i?window.alert(i+" "+woocommerce_admin_meta_boxes_variations.i18n_variation_added):0===i||i>1?window.alert(i+" "+woocommerce_admin_meta_boxes_variations.i18n_variations_added):window.alert(woocommerce_admin_meta_boxes_variations.i18n_no_variations_added),i>0?(t.go_to_page(1,i),a("#variable_product_options").trigger("woocommerce_variations_added",i)):o.unblock()})}return!1},input_changed:function(){a(this).closest(".woocommerce_variation").addClass("variation-needs-update"),a("button.cancel-variation-changes, button.save-variation-changes").removeAttr("disabled"),a("#variable_product_options").trigger("woocommerce_variations_input_changed")},defaults_changed:function(){a(this).closest("#variable_product_options").find(".woocommerce_variation:first").addClass("variation-needs-update"),a("button.cancel-variation-changes, button.save-variation-changes").removeAttr("disabled"),a("#variable_product_options").trigger("woocommerce_variations_defaults_changed")},do_variation_action:function(){var e,i=a("select.variation_actions").val(),n={},r=0;switch(i){case"add_variation":return void o.add_variation();case"link_all_variations":return void o.link_all_variations();case"delete_all":window.confirm(woocommerce_admin_meta_boxes_variations.i18n_delete_all_variations)&&window.confirm(woocommerce_admin_meta_boxes_variations.i18n_last_warning)&&(n.allowed=!0,r=-1*parseInt(a("#variable_product_options").find(".woocommerce_variations").attr("data-total"),10));break;case"variable_regular_price_increase":case"variable_regular_price_decrease":case"variable_sale_price_increase":case"variable_sale_price_decrease":if(null==(e=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_a_value_fixed_or_percent)))return;e.indexOf("%")>=0?n.value=accounting.unformat(e.replace(/\%/,""),woocommerce_admin.mon_decimal_point)+"%":n.value=accounting.unformat(e,woocommerce_admin.mon_decimal_point);break;case"variable_regular_price":case"variable_sale_price":case"variable_stock":case"variable_weight":case"variable_length":case"variable_width":case"variable_height":case"variable_download_limit":case"variable_download_expiry":if(null==(e=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_a_value)))return;n.value=e;break;case"variable_sale_schedule":if(n.date_from=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_scheduled_sale_start),n.date_to=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_scheduled_sale_end),null===n.date_from&&(n.date_from=!1),null===n.date_to&&(n.date_to=!1),!1===n.date_to&&!1===n.date_from)return;break;default:a("select.variation_actions").trigger(i),n=a("select.variation_actions").triggerHandler(i+"_ajax_data",n)}"delete_all"===i&&n.allowed?a("#variable_product_options").find(".variation-needs-update").removeClass("variation-needs-update"):o.check_for_changes(),o.block(),a.ajax({url:woocommerce_admin_meta_boxes_variations.ajax_url,data:{action:"woocommerce_bulk_edit_variations",security:woocommerce_admin_meta_boxes_variations.bulk_edit_variations_nonce,product_id:woocommerce_admin_meta_boxes_variations.post_id,product_type:a("#product-type").val(),bulk_action:i,data:n},type:"POST",success:function(){t.go_to_page(1,r)}})}},t={init:function(){a(document.body).on("woocommerce_variations_added",this.update_single_quantity).on("change",".variations-pagenav .page-selector",this.page_selector).on("click",".variations-pagenav .first-page",this.first_page).on("click",".variations-pagenav .prev-page",this.prev_page).on("click",".variations-pagenav .next-page",this.next_page).on("click",".variations-pagenav .last-page",this.last_page)},update_variations_count:function(e){var i=a("#variable_product_options").find(".woocommerce_variations"),o=parseInt(i.attr("data-total"),10)+e,t=a(".variations-pagenav .displaying-num");return i.attr("data-total",o),1===o?t.text(woocommerce_admin_meta_boxes_variations.i18n_variation_count_single.replace("%qty%",o)):t.text(woocommerce_admin_meta_boxes_variations.i18n_variation_count_plural.replace("%qty%",o)),o},update_single_quantity:function(e,i){if(1===i){var o=a(".variations-pagenav");t.update_variations_count(i),o.is(":hidden")&&(a("option, optgroup",".variation_actions").show(),a(".variation_actions").val("add_variation"),a("#variable_product_options").find(".toolbar").show(),o.show(),a(".pagination-links",o).hide())}},set_paginav:function(e){var i=a("#variable_product_options").find(".woocommerce_variations"),o=t.update_variations_count(e),n=a("#variable_product_options").find(".toolbar"),r=a(".variation_actions"),_=a(".variations-pagenav"),s=a(".pagination-links",_),c=Math.ceil(o/woocommerce_admin_meta_boxes_variations.variations_per_page),d="";i.attr("data-total_pages",c),a(".total-pages",_).text(c);for(var m=1;m<=c;m++)d+='";a(".page-selector",_).empty().html(d),0===o?(n.not(".toolbar-top, .toolbar-buttons").hide(),_.hide(),a("option, optgroup",r).hide(),a(".variation_actions").val("add_variation"),a('option[data-global="true"]',r).show()):(n.show(),_.show(),a("option, optgroup",r).show(),a(".variation_actions").val("add_variation"),1===c?s.hide():s.show())},check_is_enabled:function(e){return!a(e).hasClass("disabled")},change_classes:function(e,i){var o=a(".variations-pagenav .first-page"),t=a(".variations-pagenav .prev-page"),n=a(".variations-pagenav .next-page"),r=a(".variations-pagenav .last-page");1===e?(o.addClass("disabled"),t.addClass("disabled")):(o.removeClass("disabled"),t.removeClass("disabled")),i===e?(n.addClass("disabled"),r.addClass("disabled")):(n.removeClass("disabled"),r.removeClass("disabled"))},set_page:function(e){a(".variations-pagenav .page-selector").val(e).first().change()},go_to_page:function(a,e){a=a||1,e=e||0,t.set_paginav(e),t.set_page(a)},page_selector:function(){var e=parseInt(a(this).val(),10),i=a("#variable_product_options").find(".woocommerce_variations");a(".variations-pagenav .page-selector").val(e),o.check_for_changes(),t.change_classes(e,parseInt(i.attr("data-total_pages"),10)),o.load_variations(e)},first_page:function(){return t.check_is_enabled(this)&&t.set_page(1),!1},prev_page:function(){if(t.check_is_enabled(this)){var e=a("#variable_product_options").find(".woocommerce_variations"),i=parseInt(e.attr("data-page"),10)-1,o=0=o?o:i;t.set_page(n)}return!1},last_page:function(){if(t.check_is_enabled(this)){var e=a("#variable_product_options").find(".woocommerce_variations").attr("data-total_pages");t.set_page(e)}return!1}};e.init(),i.init(),o.init(),t.init()}); \ No newline at end of file +!function(a){"use strict";var e={init:function(){a("#variable_product_options").on("change","input.variable_is_downloadable",this.variable_is_downloadable).on("change","input.variable_is_virtual",this.variable_is_virtual).on("change","input.variable_manage_stock",this.variable_manage_stock).on("click","button.notice-dismiss",this.notice_dismiss).on("click","h3 .sort",this.set_menu_order).on("reload",this.reload),a("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock").change(),a("#woocommerce-product-data").on("woocommerce_variations_loaded",this.variations_loaded),a(document.body).on("woocommerce_variations_added",this.variation_added)},reload:function(){o.load_variations(1),t.set_paginav(0)},variable_is_downloadable:function(){a(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").hide(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").show()},variable_is_virtual:function(){a(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").show(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").hide()},variable_manage_stock:function(){a(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").hide(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").show()},notice_dismiss:function(){a(this).closest("div.notice").remove()},variations_loaded:function(i,o){o=o||!1;var t=a("#woocommerce-product-data");o||(a("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock",t).change(),a(".woocommerce_variation",t).each(function(e,i){var o=a(i),t=a(".sale_price_dates_from",o).val(),n=a(".sale_price_dates_to",o).val();""===t&&""===n||a("a.sale_schedule",o).click()}),a(".woocommerce_variations .variation-needs-update",t).removeClass("variation-needs-update"),a("button.cancel-variation-changes, button.save-variation-changes",t).attr("disabled","disabled")),a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".woocommerce_variations .tips, .woocommerce_variations .help_tip, .woocommerce_variations .woocommerce-help-tip",t).tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),a(".sale_price_dates_fields",t).find("input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,onSelect:function(){var e=a(this).is(".sale_price_dates_from")?"minDate":"maxDate",i=a(this).closest(".sale_price_dates_fields").find("input"),o=a(this).datepicker("getDate");i.not(this).datepicker("option",e,o),a(this).change()}}),a(".woocommerce_variations",t).sortable({items:".woocommerce_variation",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){e.variation_row_indexes()}}),a(document.body).trigger("wc-enhanced-select-init")},variation_added:function(a,i){1===i&&e.variations_loaded(null,!0)},set_menu_order:function(e){e.preventDefault();var i=a(this).closest(".woocommerce_variation").find(".variation_menu_order"),t=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_menu_order,i.val());null!=t&&(i.val(parseInt(t,10)).change(),o.save_variations())},variation_row_indexes:function(){var e=a("#variable_product_options").find(".woocommerce_variations"),i=parseInt(e.attr("data-page"),10),o=parseInt((i-1)*woocommerce_admin_meta_boxes_variations.variations_per_page,10);a(".woocommerce_variations .woocommerce_variation").each(function(e,i){a(".variation_menu_order",i).val(parseInt(a(i).index(".woocommerce_variations .woocommerce_variation"),10)+1+o).change()})}},i={variable_image_frame:null,setting_variation_image_id:null,setting_variation_image:null,wp_media_post_id:wp.media.model.settings.post.id,init:function(){a("#variable_product_options").on("click",".upload_image_button",this.add_image),a("a.add_media").on("click",this.restore_wp_media_post_id)},add_image:function(e){var o=a(this),t=o.attr("rel"),n=o.closest(".upload_image");if(i.setting_variation_image=n,i.setting_variation_image_id=t,e.preventDefault(),o.is(".remove"))a(".upload_image_id",i.setting_variation_image).val("").change(),i.setting_variation_image.find("img").eq(0).attr("src",woocommerce_admin_meta_boxes_variations.woocommerce_placeholder_img_src),i.setting_variation_image.find(".upload_image_button").removeClass("remove");else{if(i.variable_image_frame)return i.variable_image_frame.uploader.uploader.param("post_id",i.setting_variation_image_id),void i.variable_image_frame.open();wp.media.model.settings.post.id=i.setting_variation_image_id,i.variable_image_frame=wp.media.frames.variable_image=wp.media({title:woocommerce_admin_meta_boxes_variations.i18n_choose_image,button:{text:woocommerce_admin_meta_boxes_variations.i18n_set_image},states:[new wp.media.controller.Library({title:woocommerce_admin_meta_boxes_variations.i18n_choose_image,filterable:"all"})]}),i.variable_image_frame.on("select",function(){var e=i.variable_image_frame.state().get("selection").first().toJSON(),o=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;a(".upload_image_id",i.setting_variation_image).val(e.id).change(),i.setting_variation_image.find(".upload_image_button").addClass("remove"),i.setting_variation_image.find("img").eq(0).attr("src",o),wp.media.model.settings.post.id=i.wp_media_post_id}),i.variable_image_frame.open()}},restore_wp_media_post_id:function(){wp.media.model.settings.post.id=i.wp_media_post_id}},o={init:function(){a("li.variations_tab a").on("click",this.initial_load),a("#variable_product_options").on("click","button.save-variation-changes",this.save_variations).on("click","button.cancel-variation-changes",this.cancel_variations).on("click",".remove_variation",this.remove_variation),a(document.body).on("change","#variable_product_options .woocommerce_variations :input",this.input_changed).on("change",".variations-defaults select",this.defaults_changed),a("form#post").on("submit",this.save_on_submit),a(".wc-metaboxes-wrapper").on("click","a.do_variation_action",this.do_variation_action)},check_for_changes:function(){var e=a("#variable_product_options").find(".woocommerce_variations .variation-needs-update");if(0o&&0!==o&&(n=o),t.go_to_page(n,-1)})):o.unblock()}return!1},link_all_variations:function(){if(o.check_for_changes(),window.confirm(woocommerce_admin_meta_boxes_variations.i18n_link_all_variations)){o.block();var e={action:"woocommerce_link_all_variations",post_id:woocommerce_admin_meta_boxes_variations.post_id,security:woocommerce_admin_meta_boxes_variations.link_variation_nonce};a.post(woocommerce_admin_meta_boxes_variations.ajax_url,e,function(e){var i=parseInt(e,10);1===i?window.alert(i+" "+woocommerce_admin_meta_boxes_variations.i18n_variation_added):0===i||i>1?window.alert(i+" "+woocommerce_admin_meta_boxes_variations.i18n_variations_added):window.alert(woocommerce_admin_meta_boxes_variations.i18n_no_variations_added),i>0?(t.go_to_page(1,i),a("#variable_product_options").trigger("woocommerce_variations_added",i)):o.unblock()})}return!1},input_changed:function(){a(this).closest(".woocommerce_variation").addClass("variation-needs-update"),a("button.cancel-variation-changes, button.save-variation-changes").removeAttr("disabled"),a("#variable_product_options").trigger("woocommerce_variations_input_changed")},defaults_changed:function(){a(this).closest("#variable_product_options").find(".woocommerce_variation:first").addClass("variation-needs-update"),a("button.cancel-variation-changes, button.save-variation-changes").removeAttr("disabled"),a("#variable_product_options").trigger("woocommerce_variations_defaults_changed")},do_variation_action:function(){var e,i=a("select.variation_actions").val(),n={},r=0;switch(i){case"add_variation":return void o.add_variation();case"link_all_variations":return void o.link_all_variations();case"delete_all":window.confirm(woocommerce_admin_meta_boxes_variations.i18n_delete_all_variations)&&window.confirm(woocommerce_admin_meta_boxes_variations.i18n_last_warning)&&(n.allowed=!0,r=-1*parseInt(a("#variable_product_options").find(".woocommerce_variations").attr("data-total"),10));break;case"variable_regular_price_increase":case"variable_regular_price_decrease":case"variable_sale_price_increase":case"variable_sale_price_decrease":if(null==(e=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_a_value_fixed_or_percent)))return;e.indexOf("%")>=0?n.value=accounting.unformat(e.replace(/\%/,""),woocommerce_admin.mon_decimal_point)+"%":n.value=accounting.unformat(e,woocommerce_admin.mon_decimal_point);break;case"variable_regular_price":case"variable_sale_price":case"variable_stock":case"variable_weight":case"variable_length":case"variable_width":case"variable_height":case"variable_download_limit":case"variable_download_expiry":if(null==(e=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_a_value)))return;n.value=e;break;case"variable_sale_schedule":if(n.date_from=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_scheduled_sale_start),n.date_to=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_scheduled_sale_end),null===n.date_from&&(n.date_from=!1),null===n.date_to&&(n.date_to=!1),!1===n.date_to&&!1===n.date_from)return;break;default:a("select.variation_actions").trigger(i),n=a("select.variation_actions").triggerHandler(i+"_ajax_data",n)}"delete_all"===i&&n.allowed?a("#variable_product_options").find(".variation-needs-update").removeClass("variation-needs-update"):o.check_for_changes(),o.block(),a.ajax({url:woocommerce_admin_meta_boxes_variations.ajax_url,data:{action:"woocommerce_bulk_edit_variations",security:woocommerce_admin_meta_boxes_variations.bulk_edit_variations_nonce,product_id:woocommerce_admin_meta_boxes_variations.post_id,product_type:a("#product-type").val(),bulk_action:i,data:n},type:"POST",success:function(){t.go_to_page(1,r)}})}},t={init:function(){a(document.body).on("woocommerce_variations_added",this.update_single_quantity).on("change",".variations-pagenav .page-selector",this.page_selector).on("click",".variations-pagenav .first-page",this.first_page).on("click",".variations-pagenav .prev-page",this.prev_page).on("click",".variations-pagenav .next-page",this.next_page).on("click",".variations-pagenav .last-page",this.last_page)},update_variations_count:function(e){var i=a("#variable_product_options").find(".woocommerce_variations"),o=parseInt(i.attr("data-total"),10)+e,t=a(".variations-pagenav .displaying-num");return i.attr("data-total",o),1===o?t.text(woocommerce_admin_meta_boxes_variations.i18n_variation_count_single.replace("%qty%",o)):t.text(woocommerce_admin_meta_boxes_variations.i18n_variation_count_plural.replace("%qty%",o)),o},update_single_quantity:function(e,i){if(1===i){var o=a(".variations-pagenav");t.update_variations_count(i),o.is(":hidden")&&(a("option, optgroup",".variation_actions").show(),a(".variation_actions").val("add_variation"),a("#variable_product_options").find(".toolbar").show(),o.show(),a(".pagination-links",o).hide())}},set_paginav:function(e){var i=a("#variable_product_options").find(".woocommerce_variations"),o=t.update_variations_count(e),n=a("#variable_product_options").find(".toolbar"),r=a(".variation_actions"),_=a(".variations-pagenav"),s=a(".pagination-links",_),c=Math.ceil(o/woocommerce_admin_meta_boxes_variations.variations_per_page),d="";i.attr("data-total_pages",c),a(".total-pages",_).text(c);for(var m=1;m<=c;m++)d+='";a(".page-selector",_).empty().html(d),0===o?(n.not(".toolbar-top, .toolbar-buttons").hide(),_.hide(),a("option, optgroup",r).hide(),a(".variation_actions").val("add_variation"),a('option[data-global="true"]',r).show()):(n.show(),_.show(),a("option, optgroup",r).show(),a(".variation_actions").val("add_variation"),1===c?s.hide():s.show())},check_is_enabled:function(e){return!a(e).hasClass("disabled")},change_classes:function(e,i){var o=a(".variations-pagenav .first-page"),t=a(".variations-pagenav .prev-page"),n=a(".variations-pagenav .next-page"),r=a(".variations-pagenav .last-page");1===e?(o.addClass("disabled"),t.addClass("disabled")):(o.removeClass("disabled"),t.removeClass("disabled")),i===e?(n.addClass("disabled"),r.addClass("disabled")):(n.removeClass("disabled"),r.removeClass("disabled"))},set_page:function(e){a(".variations-pagenav .page-selector").val(e).first().change()},go_to_page:function(a,e){a=a||1,e=e||0,t.set_paginav(e),t.set_page(a)},page_selector:function(){var e=parseInt(a(this).val(),10),i=a("#variable_product_options").find(".woocommerce_variations");a(".variations-pagenav .page-selector").val(e),o.check_for_changes(),t.change_classes(e,parseInt(i.attr("data-total_pages"),10)),o.load_variations(e)},first_page:function(){return t.check_is_enabled(this)&&t.set_page(1),!1},prev_page:function(){if(t.check_is_enabled(this)){var e=a("#variable_product_options").find(".woocommerce_variations"),i=parseInt(e.attr("data-page"),10)-1,o=0=o?o:i;t.set_page(n)}return!1},last_page:function(){if(t.check_is_enabled(this)){var e=a("#variable_product_options").find(".woocommerce_variations").attr("data-total_pages");t.set_page(e)}return!1}};e.init(),i.init(),o.init(),t.init()}(jQuery); \ No newline at end of file diff --git a/assets/js/admin/wc-setup.min.js b/assets/js/admin/wc-setup.min.js index 58c016fe6b2..fb7289c5a15 100644 --- a/assets/js/admin/wc-setup.min.js +++ b/assets/js/admin/wc-setup.min.js @@ -1 +1 @@ -jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function s(){e("form.activate-jetpack").submit()}function t(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return s();setTimeout(t,3e3)}).fail(function(){s()})}e(".button-next").on("click",function(){var s=e(this).parents("form").get(0);return("function"!=typeof s.checkValidity||s.checkValidity())&&i(),!0}),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"),e(this).closest(".wc-wizard-service-item").addClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").removeClass("hide")):(e(this).closest(".wc-wizard-service-toggle").addClass("disabled"),e(this).closest(".wc-wizard-service-item").removeClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").addClass("hide"))}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){i.stopPropagation();var s=e(this).find(".wc-wizard-service-toggle input");s.prop("checked",!s.prop("checked")).change()}),e(".wc-wizard-services-list-toggle").on("change",".wc-wizard-service-enable input",function(){e(this).closest(".wc-wizard-services-list-toggle").toggleClass("closed"),e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var s=e(this).closest(".wc-wizard-service-description"),t=i.target.value,c=s.find(".shipping-method-descriptions");c.find(".shipping-method-description").addClass("hide"),c.find("."+t).removeClass("hide");var r=s.find(".shipping-method-settings");r.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),r.find("."+t).removeClass("hide").find(".shipping-method-required-field").prop("required",!0)}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-enable",function(){var i=e(this).is(":checked");e(this).closest(".wc-wizard-service-item").find(".shipping-method-required-field").prop("required",i)}),e(".activate-jetpack").on("click",".button-primary",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),t()}),e(".wc-wizard-services").on("change","input#stripe_create_account",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!0),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email").show()):(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!1),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email").hide())}),e(".wc-wizard-services input#stripe_create_account").change()}); \ No newline at end of file +jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function s(){e("form.activate-jetpack").submit()}function t(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return s();setTimeout(t,3e3)}).fail(function(){s()})}e(".button-next").on("click",function(){var s=e(this).parents("form").get(0);return("function"!=typeof s.checkValidity||s.checkValidity())&&i(),!0}),e(".wc-wizard-services").on("change",".wc-wizard-service-enable input",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-toggle").removeClass("disabled"),e(this).closest(".wc-wizard-service-item").addClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").removeClass("hide")):(e(this).closest(".wc-wizard-service-toggle").addClass("disabled"),e(this).closest(".wc-wizard-service-item").removeClass("checked"),e(this).closest(".wc-wizard-service-item").find(".wc-wizard-service-settings").addClass("hide"))}),e(".wc-wizard-services").on("click",".wc-wizard-service-enable",function(i){i.stopPropagation();var s=e(this).find(".wc-wizard-service-toggle input");s.prop("checked",!s.prop("checked")).change()}),e(".wc-wizard-services-list-toggle").on("change",".wc-wizard-service-enable input",function(){e(this).closest(".wc-wizard-services-list-toggle").toggleClass("closed"),e(this).closest(".wc-wizard-services").find(".wc-wizard-service-item").slideToggle().css("display","flex")}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-select .method",function(i){var s=e(this).closest(".wc-wizard-service-description"),t=i.target.value,c=s.find(".shipping-method-descriptions");c.find(".shipping-method-description").addClass("hide"),c.find("."+t).removeClass("hide");var r=s.find(".shipping-method-settings");r.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),r.find("."+t).removeClass("hide").find(".shipping-method-required-field").prop("required",!0)}),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-enable",function(){var i=e(this).is(":checked");e(this).closest(".wc-wizard-service-item").find(".shipping-method-required-field").prop("required",i)}),e(".activate-jetpack").on("click",".button-primary",function(e){if(i(),"no"===wc_setup_params.pending_jetpack_install)return!0;e.preventDefault(),t()}),e(".wc-wizard-services").on("change","input#stripe_create_account",function(){e(this).is(":checked")?(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!0),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email").show()):(e(this).closest(".wc-wizard-service-settings").find("input.payment-email-input").prop("required",!1),e(this).closest(".wc-wizard-service-settings").find(".wc-wizard-service-setting-stripe_email").hide())}),e(".wc-wizard-services input#stripe_create_account").change(),e("select#store_country_state").on("change",function(){var i=this.value.split(":")[0];e("select#currency_code").val(wc_setup_currencies[i]).change()})}); \ No newline at end of file diff --git a/assets/js/frontend/add-to-cart.min.js b/assets/js/frontend/add-to-cart.min.js index 5f7c73ce5f5..fae12c51ea8 100644 --- a/assets/js/frontend/add-to-cart.min.js +++ b/assets/js/frontend/add-to-cart.min.js @@ -1 +1 @@ -jQuery(function(t){if("undefined"==typeof wc_add_to_cart_params)return!1;var a=function(){t(document.body).on("click",".add_to_cart_button",this.onAddToCart).on("click",".remove_from_cart_button",this.onRemoveFromCart).on("added_to_cart",this.updateButton).on("added_to_cart",this.updateCartPage).on("added_to_cart removed_from_cart",this.updateFragments)};a.prototype.onAddToCart=function(a){var o=t(this);if(o.is(".ajax_add_to_cart")){if(!o.attr("data-product_id"))return!0;a.preventDefault(),o.removeClass("added"),o.addClass("loading");var r={};t.each(o.data(),function(t,a){r[t]=a}),t(document.body).trigger("adding_to_cart",[o,r]),t.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),r,function(a){a&&(a.error&&a.product_url?window.location=a.product_url:"yes"!==wc_add_to_cart_params.cart_redirect_after_add?t(document.body).trigger("added_to_cart",[a.fragments,a.cart_hash,o]):window.location=wc_add_to_cart_params.cart_url)})}},a.prototype.onRemoveFromCart=function(a){var o=t(this),r=o.closest(".woocommerce-mini-cart-item");a.preventDefault(),r.block({message:null,overlayCSS:{opacity:.6}}),t.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_from_cart"),{cart_item_key:o.data("cart_item_key")},function(a){a&&a.fragments?t(document.body).trigger("removed_from_cart",[a.fragments,a.cart_hash]):window.location=o.attr("href")}).fail(function(){window.location=o.attr("href")})},a.prototype.updateButton=function(a,o,r,e){(e=void 0!==e&&e)&&(e.removeClass("loading"),e.addClass("added"),wc_add_to_cart_params.is_cart||0!==e.parent().find(".added_to_cart").length||e.after(' '+wc_add_to_cart_params.i18n_view_cart+""),t(document.body).trigger("wc_cart_button_updated",[e]))},a.prototype.updateCartPage=function(){var a=window.location.toString().replace("add-to-cart","added-to-cart");t(".shop_table.cart").load(a+" .shop_table.cart:eq(0) > *",function(){t(".shop_table.cart").stop(!0).css("opacity","1").unblock(),t(document.body).trigger("cart_page_refreshed")}),t(".cart_totals").load(a+" .cart_totals:eq(0) > *",function(){t(".cart_totals").stop(!0).css("opacity","1").unblock(),t(document.body).trigger("cart_totals_refreshed")})},a.prototype.updateFragments=function(a,o){o&&(t.each(o,function(a){t(a).addClass("updating").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}})}),t.each(o,function(a,o){t(a).replaceWith(o),t(a).stop(!0).css("opacity","1").unblock()}),t(document.body).trigger("wc_fragments_loaded"))},new a}); +jQuery(function(t){if("undefined"==typeof wc_add_to_cart_params)return!1;var a=function(){t(document.body).on("click",".add_to_cart_button",this.onAddToCart).on("click",".remove_from_cart_button",this.onRemoveFromCart).on("added_to_cart",this.updateButton).on("added_to_cart",this.updateCartPage).on("added_to_cart removed_from_cart",this.updateFragments)};a.prototype.onAddToCart=function(a){var o=t(this);if(o.is(".ajax_add_to_cart")){if(!o.attr("data-product_id"))return!0;a.preventDefault(),o.removeClass("added"),o.addClass("loading");var r={};t.each(o.data(),function(t,a){r[t]=a}),t(document.body).trigger("adding_to_cart",[o,r]),t.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),r,function(a){a&&(a.error&&a.product_url?window.location=a.product_url:"yes"!==wc_add_to_cart_params.cart_redirect_after_add?t(document.body).trigger("added_to_cart",[a.fragments,a.cart_hash,o]):window.location=wc_add_to_cart_params.cart_url)})}},a.prototype.onRemoveFromCart=function(a){var o=t(this),r=o.closest(".woocommerce-mini-cart-item");a.preventDefault(),r.block({message:null,overlayCSS:{opacity:.6}}),t.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","remove_from_cart"),{cart_item_key:o.data("cart_item_key")},function(a){a&&a.fragments?t(document.body).trigger("removed_from_cart",[a.fragments,a.cart_hash]):window.location=o.attr("href")}).fail(function(){window.location=o.attr("href")})},a.prototype.updateButton=function(a,o,r,e){(e=void 0!==e&&e)&&(e.removeClass("loading"),e.addClass("added"),wc_add_to_cart_params.is_cart||0!==e.parent().find(".added_to_cart").length||e.after(' '+wc_add_to_cart_params.i18n_view_cart+""),t(document.body).trigger("wc_cart_button_updated",[e]))},a.prototype.updateCartPage=function(){var a=window.location.toString().replace("add-to-cart","added-to-cart");t(".shop_table.cart").load(a+" .shop_table.cart:eq(0) > *",function(){t(".shop_table.cart").stop(!0).css("opacity","1").unblock(),t(document.body).trigger("cart_page_refreshed")}),t(".cart_totals").load(a+" .cart_totals:eq(0) > *",function(){t(".cart_totals").stop(!0).css("opacity","1").unblock(),t(document.body).trigger("cart_totals_refreshed")})},a.prototype.updateFragments=function(a,o){o&&(t.each(o,function(a){t(a).addClass("updating").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}})}),t.each(o,function(a,o){t(a).replaceWith(o),t(a).stop(!0).css("opacity","1").unblock()}),t(document.body).trigger("wc_fragments_loaded"))},new a}); \ No newline at end of file diff --git a/assets/js/frontend/address-i18n.min.js b/assets/js/frontend/address-i18n.min.js index bbedbd43350..b03f8c494d5 100644 --- a/assets/js/frontend/address-i18n.min.js +++ b/assets/js/frontend/address-i18n.min.js @@ -1 +1 @@ -jQuery(function(e){function a(e,a){a?(e.find("label").append(' *'),e.addClass("validate-required")):(e.find("label abbr").remove(),e.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var t=wc_address_i18n_params.locale.replace(/"/g,'"'),i=e.parseJSON(t);e(document.body).bind("country_to_state_changing",function(t,l,d){var r,n=d;r="undefined"!=typeof i[l]?i[l]:i["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),f=n.find("#billing_city_field, #shipping_city_field"),s=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),f.attr("data-o_class",f.attr("class")),s.attr("data-o_class",s.attr("class")));var p=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(p,function(e,t){var l=n.find(t);i["default"][e]&&("state"!==e&&("undefined"==typeof i["default"][e].hidden||!1===i["default"][e].hidden?l.show():!0===i["default"][e].hidden&&l.hide().find("input").val("")),"postcode"!==e&&"city"!==e&&"state"!==e||(i["default"][e].label&&l.find("label").html(i["default"][e].label),i["default"][e].placeholder?l.find("input").attr("placeholder",i["default"][e].placeholder):i["default"][e].label&&!l.find("label").length&&(l.find("input").attr("placeholder",i["default"][e].label),l.find(".select2-selection__placeholder").text(i["default"][e].label))),!0===i["default"][e].required&&0===l.find("label abbr").length&&a(l,!0),i["default"][e].priority&&l.data("priority",i["default"][e].priority)),r[e]&&(r[e].label&&l.find("label").html(r[e].label),r[e].placeholder?(l.find("input").attr("placeholder",r[e].placeholder),l.find(".select2-selection__placeholder").text(r[e].placeholder)):r[e].label&&!l.find("label").length&&(l.find("input").attr("placeholder",r[e].label),l.find(".select2-selection__placeholder").text(r[e].label)),a(l,!1),"undefined"==typeof r[e].required&&!0===i["default"][e].required?a(l,!0):!0===r[e].required&&a(l,!0),"state"!==e&&(!0===r[e].hidden?l.hide().find("input").val(""):l.show()),r[e].priority?l.data("priority",r[e].priority):i["default"][e].priority&&l.data("priority",i["default"][e].priority))}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,t){var i=e(t).find(".form-row"),l=i.first().parent(),d=0;i.each(function(){e(this).data("priority")||e(this).data("priority",d+1),d=e(this).data("priority")}),i.sort(function(a,t){var i=e(a).data("priority"),l=e(t).data("priority");return i>l?1:i*'),e.addClass("validate-required")):(e.find("label abbr").remove(),e.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var i=wc_address_i18n_params.locale.replace(/"/g,'"'),d=e.parseJSON(i);e(document.body).bind("country_to_state_changing",function(i,t,r){var l,n=r;l="undefined"!=typeof d[t]?d[t]:d["default"];var o=n.find("#billing_postcode_field, #shipping_postcode_field"),s=n.find("#billing_city_field, #shipping_city_field"),f=n.find("#billing_state_field, #shipping_state_field");o.attr("data-o_class")||(o.attr("data-o_class",o.attr("class")),s.attr("data-o_class",s.attr("class")),f.attr("data-o_class",f.attr("class")));var p=e.parseJSON(wc_address_i18n_params.locale_fields);e.each(p,function(i,t){var r=n.find(t),o=e.extend(!0,{},d["default"][i],l[i]);"undefined"!=typeof o.label&&r.find("label").html(o.label),"undefined"!=typeof o.placeholder&&(r.find("input").attr("placeholder",o.placeholder),r.find(".select2-selection__placeholder").text(o.placeholder)),"undefined"!=typeof o.placeholder||"undefined"==typeof o.label||r.find("label").length||(r.find("input").attr("placeholder",o.label),r.find(".select2-selection__placeholder").text(o.label)),"undefined"!=typeof o.required?a(r,o.required):a(r,!1),"undefined"!=typeof o.priority&&r.data("priority",o.priority),"state"!==i&&("undefined"!=typeof o.hidden&&!0===o.hidden?r.hide().find("input").val(""):r.show())}),e(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(a,i){var d=e(i).find(".form-row"),t=d.first().parent(),r=0;d.each(function(){e(this).data("priority")||e(this).data("priority",r+1),r=e(this).data("priority")}),d.sort(function(a,i){var d=e(a).data("priority"),t=e(i).data("priority");return d>t?1:d0&&o'),s(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),a=''+wc_password_strength_meter_params.i18n_password_hint+"",o=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";switch(e.removeClass("short bad good strong"),t.remove(),o0&&o'),s(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),a=''+wc_password_strength_meter_params.i18n_password_hint+"",o=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";switch(e.removeClass("short bad good strong"),t.remove(),o