1 line
9.6 KiB
JavaScript
1 line
9.6 KiB
JavaScript
|
!function(i){function e(){const o=function(){let o,c;var e={hidden:"visibilitychange",webkitHidden:"webkitvisibilitychange",mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange"};for(o in e)if(o in document){c=e[o];break}return function(e){return e&&document.addEventListener(c,e),!document[o]}}();o(function(){var e=function(o){var c=document.cookie.split(";");for(let e=0;e<c.length;e++){var t=c[e].split("=");if(o===t[0].trim())return decodeURIComponent(t[1])}return null}(cartflows.active_checkout_cookie);e&&o()&&parseInt(cartflows.current_step)!==parseInt(e)&&(i(".woocommerce-checkout-payment, .woocommerce-checkout-review-order-table").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),i(document.body).trigger("update_checkout"),i(document).ajaxComplete(function(e,o){o.hasOwnProperty("responseJSON")&&(o=o.responseJSON.hasOwnProperty("fragments")?o.responseJSON.fragments:null)&&o.hasOwnProperty("wcf_cart_data")&&i(document.body).trigger("wcf_cart_data_restored",[o.wcf_cart_data])}))})}function r(){function r(e,o,c,t){let a=!1;""===e||"select"===t&&" "===e?o.hasClass("validate-required")&&(c.addClass("field-required"),a=!0):c.removeClass("field-required"),[t=!1,e,o]=[a,o,c],e.find(".wcf-field-required-error").remove(),t&&"yes"===cartflows.field_validation.is_enabled?(t=e.find("label").text(),o.after('<span class="wcf-field-required-error">'+t.replace(/\*/g,"").trim()+" "+cartflows.field_validation.error_msg+"</span>")):e.find(".wcf-field-required-error").remove()}var e=(o=i("form.woocommerce-checkout")).find("input, textarea"),o=o.find("select");e.on("blur",function(){var e,o=i(this),c=o.attr("type"),t=o.closest("p.form-row"),a=o.val();r(a,t,o,c),"number"===c&&(c=o.attr("min"),e=o.attr("max"),a=Number(a),t=t,o=o,c=Number(c),e=Number(e),""===a||a<c||e<a?(o.addClass("field-required"),o.after('<span class="wcf-field-required-error">'+cartflows.field_validation_msgs.number_field+c+" & "+e+"</span>")):(o.removeClass("field-required"),t.find(".wcf-field-required-error").remove()))}),o.on("blur",function(){var e=i(this).closest("p.form-row"),o=e.find(".select2-container--default"),c=e.find("select").val();r(c,e,o,"select")})}function s(){if("yes"===cartflows.allow_persistence&&!1!==function(){var e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}()){var e="form.woocommerce-checkout #customer_details";const o={set(){const e=[];var o=i("form.woocommerce-checkout #customer_details");localStorage.removeItem("cartflows_checkout_form"),o.find("input[type=text], select, input[type=email], input[type=tel]").each(function(){e.push({name:this.name,value:this.value})}),cartflows_checkout_form=JSON.stringify(e),localStorage.setItem("cartflows_checkout_form",cartflows_checkout_form)},get(){if(null!==localStorage.getItem("cartflows_checkout_form")){checkout_data=JSON.parse(localStorage.getItem("cartflows_checkout_form"));for(let e=0;e<checkout_data.length;e++)i("form.woocommerce-checkout [name="+checkout_data[e].name+"]").hasClass("select2-hidden-accessible")?i("form.woocommerce-checkout [name="+checkout_data[e].name+"]").selectWoo("val",[checkout_data[e].value]):i("form.woocommerce-checkout [name="+checkout_data[e].name+"]").val(checkout_data[e].value)}}};o.get(),i(e+" input, "+e+" select").on("change",function(){o.set()})}}function n(){var e=i(".wcf-field-modern-label .woocommerce input, .wcf-field-modern-label .woocommerce select, .wcf-field-modern-label .woocommerce textarea");function o(e){var o=e.closest(".form-row"),c=e.is("select")||e.hasClass("select2-hidden-accessible")?e.find(":selected").text():e.val(),e=e.attr("type");""===c?o.removeClass("wcf-anim-label"):"hidden"===e?o.addClass("wcf-anim-hidden-label"):o.addClass("wcf-anim-label")}e.on("focusout input",function(){var e=i(this);o(e)}),i(e).each(function(){o(i(this))})}const l={init(){i(document.body).on("click",".wcf-submit-coupon",this.submit_coupon),i(document.body).on("click",".wcf-remove-coupon",this.remove_coupon)},submit_coupon(e){e.preventDefault();const c=i(".wcf-custom-coupon-field"),o=i(this).closest(c),
|