File: /storage/v4513/tepnot/public_html/wp-content/plugins/dokan-pro/modules/rma/assets/js/scripts.js
(()=>{var n,o;n=jQuery,o={modal:null,init:function(){n("input#dokan_rma_product_override").on("change",this.toggleProductrmaOption),n("select#dokan-warranty-type").on("change",this.toggleTypeContent),n("select#dokan-warranty-length").on("change",this.toggleLenghtContent),n("table.dokan-rma-addon-warranty-table").on("click","a.add-item",this.addRow),n("table.dokan-rma-addon-warranty-table").on("click","a.remove-item",this.removeRow),n("form#dokan-update-request-status").on("submit",this.changeRequestStatus),n("a.dokan-send-refund-request").on("click",this.openRefundPopup),n("a.dokan-send-coupon-request").on("click",this.openCouponPopup),n("body").on("submit","form#dokan-send-refund-popup-form",this.submitRefundRequest),n("body").on("submit","form#dokan-send-coupon-popup-form",this.sendCouponRequest),this.initialize()},initialize:function(){n("select#dokan-warranty-type").trigger("change"),n("input#dokan_rma_product_override").trigger("change")},addRow:function(o){o.preventDefault();var a=n(this).closest("tr").first().clone().appendTo(n(this).closest("tbody"));a.find("input").val(""),a.find("select").val("days")},removeRow:function(o){o.preventDefault(),1!=n(this).closest("tbody").find("tr").length&&n(this).closest("tr").remove()},toggleProductrmaOption:function(o){o.preventDefault(),n(this).is(":checked")?n(".dokan-product-rma-option-wrapper").slideDown():n(".dokan-product-rma-option-wrapper").slideUp(300,function(){n(this).hide()})},toggleTypeContent:function(o){o.preventDefault();var a=n(this),t=".hide_if_no_warranty",e=".show_if_no_warranty",d=a.val();n.each(["included_warranty","addon_warranty"],function(n,o){t=t+", .hide_if_"+o,e=e+", .show_if_"+o}),n(t).show(),n(e).hide(),n(".show_if_"+d).show(),n(".hide_if_"+d).hide(),"included_warranty"===d&&n("select#dokan-warranty-length").trigger("change")},toggleLenghtContent:function(o){o.preventDefault();var a=n(this).val();n(".hide_if_lifetime, .hide_if_limited").show(),n(".show_if_lifetime, .show_if_limited").hide(),n(".show_if_"+a).show(),n(".hide_if_"+a).hide()},changeRequestStatus:function(o){o.preventDefault();var a=n(this),t={action:"dokan-update-return-request",nonce:DokanRMA.nonce,formData:a.serialize()};jQuery(".dokan-status-update-panel").block({message:null,overlayCSS:{background:"#fff url("+dokan.ajax_loader+") no-repeat center",opacity:.6}}),n.post(DokanRMA.ajaxurl,t,function(n){n.success?(jQuery(".dokan-status-update-panel").unblock(),alert(n.data.message),window.location.reload()):(jQuery(".dokan-status-update-panel").unblock(),dokan_sweetalert(n.data,{icon:"warning"}))})},openRefundPopup:function(o){o.preventDefault();var a=n(this);wp.template("dokan-send-refund"),modal=n(".dokan-rma-modals").iziModal({closeButton:!0,appendTo:"body",title:"",headerColor:dokan.modal_header_color,onOpening:function(o){o.startLoading();var t={action:"dokan-get-refund-order-data",nonce:DokanRMA.nonce,request_id:a.data("request_id")};n.post(DokanRMA.ajaxurl,t,function(a){n("#dokan-send-refund-popup").find(".refund-content").html(a.data);let t=n("#dokan-send-refund-popup").html();n(".dokan-rma-modals .iziModal-content").html(t),n("table.dokan-refund-item-list-table").find("input.refund_item_amount").on("keyup",function(){total=0,n("table.dokan-refund-item-list-table").find("input.refund_item_amount").each(function(o,a){total+=parseFloat(accounting.unformat(n(a).val(),dokan_refund.mon_decimal_point))}),n(".dokan-popup-total-refund-amount").find("span.amount").text(accounting.formatNumber(total,dokan_refund.currency_format_num_decimals,"",dokan_refund.mon_decimal_point)),n('input[name="refund_total_amount"]').val(accounting.formatNumber(total,dokan_refund.currency_format_num_decimals,"",dokan_refund.mon_decimal_point))}),o.stopLoading()})}}),modal.iziModal("open")},openCouponPopup:function(o){o.preventDefault();var a=n(this);wp.template("dokan-send-coupon"),modal=n(".dokan-rma-coupon-modals").iziModal({closeButton:!0,appendTo:"body",title:"",headerColor:dokan.modal_header_color,onOpening:function(o){o.startLoading();var t={action:"dokan-get-coupon-order-data",nonce:DokanRMA.nonce,request_id:a.data("request_id")};n.post(DokanRMA.ajaxurl,t,function(a){n("#dokan-send-coupon-popup").find(".coupon-content").html(a.data);let t=n("#dokan-send-coupon-popup").html();n(".dokan-rma-coupon-modals .iziModal-content").html(t),o.stopLoading(),n("table.dokan-refund-item-list-table").find("input.refund_item_amount").on("keyup",function(){total=0,n("table.dokan-refund-item-list-table").find("input.refund_item_amount").each(function(o,a){total+=parseFloat(accounting.unformat(n(a).val(),dokan_refund.mon_decimal_point))}),n(".dokan-popup-total-refund-amount").find("span.amount").text(accounting.formatNumber(total,dokan_refund.currency_format_num_decimals,"",dokan_refund.mon_decimal_point)),n('input[name="refund_total_amount"]').val(accounting.formatNumber(total,dokan_refund.currency_format_num_decimals,"",dokan_refund.mon_decimal_point))})})}}),modal.iziModal("open")},submitRefundRequest:function(o){o.preventDefault();var a=n(this),t={action:"dokan-send-refund-request",nonce:DokanRMA.nonce,formData:a.serialize()};modal.iziModal("startLoading"),n.post(DokanRMA.ajaxurl,t,function(n){n.success?(modal.iziModal("stopLoading"),window.location.reload()):(modal.iziModal("stopLoading"),n.data.error?dokan_sweetalert(n.data.error,{icon:"warning"}):dokan_sweetalert(n.data,{icon:"warning"}))})},sendCouponRequest:function(o){o.preventDefault();var a=n(this),t={action:"dokan-send-coupon-request",nonce:DokanRMA.nonce,formData:a.serialize()};n("#dokan-send-coupon-popup").block({message:null,overlayCSS:{background:"#fff url("+dokan.ajax_loader+") no-repeat center",opacity:.6}}),n.post(DokanRMA.ajaxurl,t,function(o){o.success?(alert(o.data),n("#dokan-send-coupon-popup").unblock(),window.location.reload()):(n("#dokan-send-coupon-popup").unblock(),dokan_sweetalert(o.data,{icon:"warning"}))})}},n(document).ready(function(){o.init()})})();