Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/cartflows-pro   php

Repository URL to install this package:

Version: 1.6.10 

/ min-js / checkout.min.js

!function(u){function c(e){e.length&&(event.preventDefault(),u("html, body").stop().animate({scrollTop:e.offset().top-50},100))}function s(){u(".woocommerce-checkout-review-order-table, .wcf-product-option-wrap").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function n(e){jQuery(".wc_payment_methods").length?e.hasOwnProperty("cart_total")&&(0<parseFloat(e.cart_total)?e.hasOwnProperty("fragments")&&u.each(e.fragments,function(e,t){u(e).replaceWith(t)}):u("body").trigger("update_checkout"),u(".woocommerce-checkout-review-order-table, .wcf-product-option-wrap").unblock()):(u("body").trigger("update_checkout"),u(".woocommerce-checkout-review-order-table, .wcf-product-option-wrap").unblock())}var t={vars:{originalTitle:document.title,interval:null},On:function(e,t){var c=this;c.vars.interval=setInterval(function(){document.title=c.vars.originalTitle==document.title?e:c.vars.originalTitle},t||1e3)},Off:function(){clearInterval(this.vars.interval),document.title=this.vars.originalTitle}},o=function(){if("true"==r()){u(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-steps div.wcf-current").removeClass("wcf-current");var e=u(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-nav-btns a").attr("href");"#customer_details"==e?(c(u(".wcf-embed-checkout-form-nav")),u(".wcf-embed-checkout-form-two-step .woocommerce").removeClass("step-two"),u(".wcf-embed-checkout-form-two-step .woocommerce").addClass("step-one"),u(".wcf-embed-checkout-form-two-step").find(".step-one").addClass("wcf-current")):"#wcf-order-wrap"==e&&(c(u(".wcf-embed-checkout-form-nav")),u(".wcf-embed-checkout-form-two-step .woocommerce").removeClass("step-one"),u(".wcf-embed-checkout-form-two-step .woocommerce").addClass("step-two"),u(".wcf-embed-checkout-form-two-step").find(".step-two").addClass("wcf-current"))}},i=function(){u(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-steps a").on("click",function(e){if(e.preventDefault(),"true"==r()){var t=u(this),c=t.closest(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-steps div");u(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-steps div.wcf-current").removeClass("wcf-current"),c.addClass("wcf-current");var o=t.closest(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-steps div a").attr("href");"#customer_details"==o?(u(".wcf-embed-checkout-form-two-step .woocommerce").removeClass("step-two"),u(".wcf-embed-checkout-form-two-step .woocommerce").addClass("step-one")):"#wcf-order-wrap"==o&&(u(".wcf-embed-checkout-form-two-step .woocommerce").removeClass("step-one"),u(".wcf-embed-checkout-form-two-step .woocommerce").addClass("step-two"))}})},a=function(){var e=u(".wcf-item-choose-options a"),f=u(".wcf-quick-view-wrapper");f.appendTo(document.body);var i=f.find(".wcf-quick-view-bg"),a=f.find("#wcf-quick-view-modal"),r=a.find("#wcf-quick-view-content"),c=a.find("#wcf-quick-view-close"),o=a.find(".wcf-content-main-wrapper");o.width(),o.height();e.off("click").on("click",function(e){e.preventDefault();var t=u(this),c=t.closest(".wcf-item");c.find(".wcf-item-selector input").is(":checked")||c.find(".wcf-item-selector input").trigger("click");var o=t.data("product");t.addClass("wcf-variation-popup-open"),a.hasClass("loading")||a.addClass("loading"),i.hasClass("wcf-quick-view-bg-ready")||i.addClass("wcf-quick-view-bg-ready"),u(document).trigger("wcf_quick_view_loading"),s(t,o)});var s=function(e,t){a.css("opacity",0),u.ajax({url:cartflows.ajax_url,data:{action:"wcf_woo_quick_view",product_id:t},dataType:"html",type:"POST",success:function(e){r.html(e),n()}})},n=function(){var e=r.find(".variations_form");if(e.trigger("check_variations"),e.trigger("reset_image"),!a.hasClass("open")){a.removeClass("loading").addClass("open");var t=d(),c=u("html");c.css("margin-right",t),c.addClass("wcf-quick-view-is-open")}0<e.length&&"function"==typeof e.wc_variation_form&&(e.wc_variation_form(),e.find("select").trigger("change"));var o=a.find(".wcf-qv-image-slider");1<o.find("li").length?o.flexslider({animation:"slide",start:function(e){setTimeout(function(){l(!0)},300)}}):setTimeout(function(){l(!0)},300),u(document).trigger("wcf_quick_view_loader_stop")},l=function(e){var t=r,c=t.find(".product .wcf-qv-image-slider").first().height(),o=t.find(".product .summary.entry-summary"),i=o.css("content");void 0!==i&&544==i.replace(/[^0-9]/g,"")&&0!=c&&null!==c?o.css("height",c):o.css("height",""),!0===e&&a.css("opacity",1)},d=function(){var e=u('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');u("body").append(e);var t=u("div",e).innerWidth();e.css("overflow-y","scroll");var c=u("div",e).innerWidth();return u(e).remove(),t-c};!function(){o.on("click",function(e){this===e.target&&t()}),u(document).on("keyup",function(e){27===e.keyCode&&t()}),c.on("click",function(e){e.preventDefault(),t()});var t=function(){i.removeClass("wcf-quick-view-bg-ready"),a.removeClass("open").removeClass("loading"),u("html").removeClass("wcf-quick-view-is-open"),u("html").css("margin-right",""),e.removeClass("wcf-variation-popup-open"),setTimeout(function(){r.html("")},600)}}(),window.addEventListener("resize",function(e){l()});function t(){f.off("click","#wcf-quick-view-content .single_add_to_cart_button").off("wcf_added_to_cart").on("click","#wcf-quick-view-content .single_add_to_cart_button",this.onAddToCart).on("wcf_added_to_cart",this.updateButton)}t.prototype.onAddToCart=function(e){e.preventDefault();var t=u(this).closest("form");if(!t[0].checkValidity())return t[0].reportValidity(),!1;var c=u(this),o=t.find('input[name="product_id"]').val()||"",i=t.find('input[name="variation_id"]').val()||"",a=u(".wcf-variation-popup-open"),r=a.closest(".wcf-qty-row"),s=r.find(".wcf-qty-selection").val()||1,n=r.data("options"),l=u("._wcf_checkout_id").val(),d=r.find(".wcf-item-wrap");n.input_quantity=s,n.checkout_id=l,c.is(".single_add_to_cart_button")&&(c.removeClass("added"),c.addClass("loading"),""!=i&&jQuery.ajax({url:cartflows.ajax_url,type:"POST",data:{action:"wcf_add_cart_single_product",form_data:t.serialize(),product_id:o,variation_id:i,quantity:s,option:n,security:cartflows.wcf_quick_view_add_cart_nonce},dataType:"json",success:function(e){if(e.hasOwnProperty("cartflows_data")&&"yes"===e.cartflows_data.added_to_cart){if(result=e.cartflows_data,a.closest(".wcf-item").find(".wcf-display-attributes").html(result.display_attr),a.closest(".wcf-item").find(".wcf-item-image").html(result.variation_image),a.attr("data-variation",result.variation_id),n.variation_id=result.variation_id,n.original_price=result.original_price,n.discounted_price=result.discounted_price,n.subscription_price=result.subscription_price,n.sign_up_fee=result.signup_fee,r.attr("data-options",JSON.stringify(n)),0<r.find(".wcf-item-selector").length){var t=r.data("options");t.variation_id=result.variation_id,r.attr("data-options",JSON.stringify(t))}r.find(".wcf-display-quantity").html(result.display_quantity),r.find(".wcf-display-price").html(result.display_price),r.find(".wcf-display-discount-value").html(result.display_discount_value),r.find(".wcf-display-discount-percent").html(result.display_discount_percent),d.find(".wcf_subscription_price").html(result.display_subscription_price),d.find(".wcf_subscription_period").html(result.display_subscription_details),d.find(".wcf_subscription_fee").html(result.display_signup_fee),d.find(".wcf_subscription_free_trial").html(result.trial_period_string)}u(document.body).trigger("wc_fragment_refresh"),f.trigger("wcf_added_to_cart",[c])}}))},t.prototype.updateButton=function(e,t){u("body").trigger("update_checkout"),c.trigger("click")},new t},r=function(){var e,t,c,o;e=u(".wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-billing-fields, .wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-account-fields").find('input[type="text"], input[type="tel"], input[type="email"], input[type="password"]'),$billing_chekboxes=u(".wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-billing-fields, .wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-account-fields").find('input[type="checkbox"]'),t=u(".wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-billing-fields").find(".select2"),c=u(".wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-shipping-fields").find('input[type="text"], input[type="tel"], input[type="email"], input[type="password"]'),$shipping_chekboxes=u(".wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper").find('input[type="checkbox"]'),o=u(".wcf-embed-checkout-form-two-step form.woocommerce-checkout .woocommerce-shipping-fields").find(".select2");var i=u(".wcf-embed-checkout-form-two-step form.woocommerce-checkout").find('h3#ship-to-different-address input[type="checkbox"]:checked').val(),r="true",s="";return Array.from(e).forEach(function(e){var t=e.type,c=e.name,o=e.closest(".form-row").classList.contains("validate-required"),i=u.trim(e.value);if("account_password"==c||"account_username"==c){var a=document.getElementById("createaccount");o=!a||!!u(a).is(":checked")}o&&""==i?(e.classList.add("field-required"),r="false",""==s&&(s=e)):("email"==t&&0==/^([a-zA-Z0-9_\+\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,14})$/.test(i)&&(e.classList.add("field-required"),r="false",""==s&&(s=e)),e.classList.remove("field-required"))}),Array.from($billing_chekboxes).forEach(function(e){var t=e.closest(".form-row").classList.contains("validate-required"),c=!1;u(e).is(":checked")&&(c=!0),t&&0==c?(e.classList.add("field-required"),r="false",""==s&&(s=e)):e.classList.remove("field-required")}),Array.from(t).forEach(function(e){var t=e.closest(".form-row"),c=t.classList.contains("validate-required"),o=u.trim(t.querySelector(".select2-selection__rendered[title]"));name=t.querySelector("select").name,c&&""==o?(e.classList.add("field-required"),r="false",""==s&&(s=e)):e.classList.remove("field-required")}),1==i&&(Array.from(c).forEach(function(e){var t=e.type,c=(e.name,e.closest(".form-row"));has_class=c.classList.contains("validate-required"),field_value=u.trim(e.value),has_class&&""==field_value?(e.classList.add("field-required"),r="false",""==s&&(s=e)):("email"==t&&0==/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(field_value)&&(e.classList.add("field-required"),r="false",""==s&&(s=e)),e.classList.remove("field-required"))}),Array.from(o).forEach(function(e){var t=e.closest(".form-row"),c=t.classList.contains("validate-required"),o=u.trim(t.querySelector(".select2-selection__rendered[title]"));name=t.querySelector("select").name,whiteSpace=/\s/g.test(o),c&&""==o?(e.classList.add("field-required"),r="false",""==s&&(s=e)):e.classList.remove("field-required")}),Array.from($shipping_chekboxes).forEach(function(e){var t=e.closest(".form-row").classList.contains("validate-required"),c=!1;u(e).is(":checked")&&(c=!0),t&&0==c?(e.classList.add("field-required"),r="false",""==s&&(s=e)):e.classList.remove("field-required")})),""!=s&&s.trigger("focus"),r};u(function(e){u(document).on("cartflows_remove_product",function(e,t){jQuery('.wcf-multiple-sel[value="'+t+'"]').prop("checked",!1),jQuery('.wcf-single-sel[value="'+t+'"]').prop("checked",!1)}),jQuery.each(cartflows_optimized_fields,function(c,e){e.is_optimized&&(jQuery("#"+c).prepend('<a href="#" id="wcf_optimized_'+c+'">'+e.field_label+"</a>"),jQuery("#wcf_optimized_"+c).on("click",function(e){e.preventDefault(),jQuery("#"+c).removeClass("wcf-hide-field");var t=c.replace(/_field/g,"");u("#"+t).trigger("focus"),jQuery(this).remove()}))}),"yes"===cartflows_animate_tab_fields.enabled&&(u(window).blur(function(){t.On(cartflows_animate_tab_fields.title)}),u(window).on("focus",function(){t.Off()})),"yes"===cartflows.allow_autocomplete_zipcode&&function(){var a;u(document.body).on("textInput input change keypress paste","#billing_postcode, #shipping_postcode",function(e){var t=u(this),c=t.attr("id").split("_")[0],o=t.val().trim(),i=u("#"+c+"_country").val();""!==i&&""!==o&&(clearTimeout(a),a=setTimeout(function(){-1===["GB","CA"].indexOf(i)&&r(c,i,o)},800))});var r=function(c,e,t){u.ajax({url:"https://api.zippopotam.us/"+e+"/"+t,cache:!0,dataType:"json",type:"GET",success:function(e,t){u.each(e.places,function(e,t){return u("#"+c+"_city").val(this["place name"]).trigger("change"),u('[name="'+c+'_state"]:visible').val(this["state abbreviation"]).trigger("change"),!1})},error:function(e,t){}})}}(),u(document).on("change",".wcf-single-sel",function(){var t=u(this).closest(".wcf-qty-row"),c=t.data("options"),e=t.find(".wcf-qty input"),o=parseInt(e.val()),i=u("._wcf_checkout_id").val();(o<=0||isNaN(o))&&(e.val(1),o=1),c.input_quantity=o,c.checkout_id=i,s(),u.ajax({url:cartflows.ajax_url,data:{action:"wcf_single_selection",option:c,security:cartflows.wcf_single_selection_nonce},dataType:"json",type:"POST",success:function(e){e.hasOwnProperty("cartflows_data")&&(t.find(".wcf-display-quantity").html(e.cartflows_data.display_quantity),t.find(".wcf-display-price").html(e.cartflows_data.display_price),t.find(".wcf-display-discount-value").html(e.cartflows_data.display_discount_value),t.find(".wcf-display-discount-percent").html(e.cartflows_data.display_discount_percent),t.find(".wcf_subscription_price").html(e.cartflows_data.subscription_price),t.find(".wcf_subscription_fee").html(e.cartflows_data.sign_up_fee)),n(e),c.cart_item_key=e.cart_item_key,t.attr("data-options",JSON.stringify(c)),u(document.body).trigger("updated_cart_totals")},error:function(e){u(".woocommerce-checkout-review-order-table").unblock()}})}),u(document).on("change",".wcf-multiple-sel",function(){var e=u(".wcf-multiple-sel:checked"),t=u(this),c=t.closest(".wcf-qty-row"),o=c.data("options"),i=c.find(".wcf-qty input"),a=parseInt(i.val()),r=u("._wcf_checkout_id").val();if((a<=0||isNaN(a))&&(i.val(1),a=1),0==e.length)return t.prop("checked",!0),void t.prop("disabled",!0);1==e.length?e.prop("disabled",!0):e.removeAttr("disabled"),o.checkout_id=r,o.input_quantity=a,o.checked="no",t.is(":checked")&&(o.checked="yes"),s(),u.ajax({url:cartflows.ajax_url,data:{action:"wcf_multiple_selection",option:o,security:cartflows.wcf_multiple_selection_nonce},dataType:"json",type:"POST",success:function(e){e.hasOwnProperty("cartflows_data")&&(c.find(".wcf-display-quantity").html(e.cartflows_data.display_quantity),c.find(".wcf-display-price").html(e.cartflows_data.display_price),c.find(".wcf-display-discount-value").html(e.cartflows_data.display_discount_value),c.find(".wcf-display-discount-percent").html(e.cartflows_data.display_discount_percent),c.find(".wcf_subscription_price").html(e.cartflows_data.subscription_price),c.find(".wcf_subscription_fee").html(e.cartflows_data.sign_up_fee)),n(e),o.cart_item_key=e.cart_item_key,c.attr("data-options",JSON.stringify(o)),u(document.body).trigger("updated_cart_totals")},error:function(e){u(".woocommerce-checkout-review-order-table").unblock()}})}),u(document).on("change",".wcf-var-sel",function(){var t=u(this).closest(".wcf-qty-row"),e=t.find(".wcf-qty input"),c=t.data("options"),o=parseInt(e.val()),i=u("._wcf_checkout_id").val();c.checkout_id=i,c.input_quantity=o,s(),u.ajax({url:cartflows.ajax_url,data:{action:"wcf_variation_selection",option:c,security:cartflows.wcf_variation_selection_nonce},dataType:"json",type:"POST",success:function(e){e.hasOwnProperty("cartflows_data")&&(t.find(".wcf-display-quantity").html(e.cartflows_data.display_quantity),t.find(".wcf-display-price").html(e.cartflows_data.display_price),t.find(".wcf-display-discount-value").html(e.cartflows_data.display_discount_value),t.find(".wcf-display-discount-percent").html(e.cartflows_data.display_discount_percent),t.find(".wcf_subscription_price").html(e.cartflows_data.subscription_price),t.find(".wcf_subscription_fee").html(e.cartflows_data.sign_up_fee)),n(e),u(document.body).trigger("updated_cart_totals")},error:function(e){u(".woocommerce-checkout-review-order-table").unblock()}})}),u(document).on("change",".wcf-qty-selection",function(){var e=u(this),t=e.closest(".wcf-qty-row"),c=t.find(".wcf-item-selector"),o=t.data("options"),i=parseInt(e.val()),a=u("._wcf_checkout_id").val();if(0<c.length){var r=c.find("input");if(0<r.length&&!r.is(":checked"))return}(i<=0||isNaN(i))&&(e.val(1),i=1),o.input_quantity=i,o.checkout_id=a,"undefined"!=typeof data&&(o.cart_item_key=data.cart_item_key),s(),u.ajax({url:cartflows.ajax_url,data:{action:"wcf_quantity_update",option:o,security:cartflows.wcf_quantity_update_nonce},dataType:"json",type:"POST",success:function(e){e.hasOwnProperty("cartflows_data")&&(t.find(".wcf-display-quantity").html(e.cartflows_data.display_quantity),t.find(".wcf-display-price").html(e.cartflows_data.display_price),t.find(".wcf-display-discount-value").html(e.cartflows_data.display_discount_value),t.find(".wcf-display-discount-percent").html(e.cartflows_data.display_discount_percent),t.find(".wcf_subscription_price").html(e.cartflows_data.subscription_price),t.find(".wcf_subscription_fee").html(e.cartflows_data.sign_up_fee)),n(e),u(document.body).trigger("updated_cart_totals")},error:function(e){u(".woocommerce-checkout-review-order-table").unblock()}})}),u("form.woocommerce-checkout").on("checkout_place_order",function(e){var t=u(".wcf-select-variation-attribute.wcf-invalid-variation");if(0<t.length)return e.preventDefault(),c(t),!1}),u(".wcf-select-variation-attribute").on("click",function(e){e.preventDefault(),u(this).closest(".wcf-qty-row").find(".wcf-item-choose-options a").trigger("click")}),a(),function(){var e=u(".wcf-multiple-sel:checked");u(this);if(1==e.length)e.prop("checked",!0),e.prop("disabled",!0)}(),function(){var a=!1;u(document).on("change",".wcf-bump-order-cb",function(e){if(!0===a)return!1;a=!0;var t=u(this),c=t.val(),o=u("[name=_wcf_checkout_id]").val(),i={security:cartflows.wcf_bump_order_process_nonce,_wcf_checkout_id:o,_wcf_product_id:c,action:"wcf_bump_order_process"};return t.is(":checked")?(u("[name=_wcf_bump_product]").val(c),u("[name=_wcf_bump_product_action]").val("add_bump_product"),i._wcf_bump_product_action="add_bump_product"):(u("[name=_wcf_bump_product]").val(""),u("[name=_wcf_bump_product_action]").val("remove_bump_product"),i._wcf_bump_product_action="remove_bump_product"),s(),u.ajax({url:cartflows.ajax_url,data:i,dataType:"json",type:"POST",success:function(e){n(e)},error:function(e){u(".woocommerce-checkout-review-order-table").unblock()}}),a=!1}),u(document.body).on("updated_checkout",function(e,t){u("[name=_wcf_bump_product_action]").val("")})}(),function(){var e=u(".wcf-field-style-one form.woocommerce-checkout").find("input");u(e).each(function(e){var t=u(this),c=t.attr("type"),o=t.closest(".form-row");i(o.hasClass("mt20"),t.val(),c,o)});var t=u(".wcf-field-style-one form.woocommerce-checkout").find("select");function i(e,t,c,o){e&&o.removeClass("mt20"),(""!==t||" "!==t&&"select"===c)&&o.addClass("wcf-anim-label"),"hidden"===c&&(o.removeClass("wcf-anim-label"),o.addClass("wcf-anim-label-fix"))}u(t).each(function(e){var t=u(this),c=t.closest(".form-row");i(c.hasClass("mt20"),t.val(),"select",c)})}(),function(){var e=u(".wcf-field-style-one form.woocommerce-checkout, .wcf-field-style-one form.woocommerce-form-login").find("input"),t=u(".wcf-field-style-one form.woocommerce-checkout").find(".select2"),c=u(".wcf-field-style-one form.woocommerce-checkout").find("textarea");e.on("focus",function(){var e=u(this),t=e.closest(".form-row");has_class=t.hasClass("wcf-anim-label"),field_value=e.val(),""==field_value&&t.addClass("wcf-anim-label")}),e.on("focusout",function(){var e=u(this),t=e.closest(".form-row");has_class=t.hasClass("wcf-anim-label"),field_value=e.val(),""==field_value?t.removeClass("wcf-anim-label"):t.addClass("wcf-anim-label")}),t.on("click",function(){var e=u(this),t=e.closest(".form-row");has_class=t.hasClass("wcf-anim-label"),field_value=e.find(".select2-selection__rendered").text(),""==field_value&&t.addClass("wcf-anim-label")}),t.on("focusout",function(){var e=u(this),t=e.closest(".form-row");has_class=t.hasClass("wcf-anim-label"),field_value=e.find(".select2-selection__rendered").text(),""==field_value?t.removeClass("wcf-anim-label"):t.addClass("wcf-anim-label")}),c.on("click",function(){var e=u(this),t=e.closest(".form-row");has_class=t.hasClass("wcf-anim-label"),field_value=e.val(),""==field_value&&t.addClass("wcf-anim-label")}),c.on("focusout",function(){var e=u(this),t=e.closest(".form-row");has_class=t.hasClass("wcf-anim-label"),field_value=e.val(),""==field_value?t.removeClass("wcf-anim-label"):t.addClass("wcf-anim-label")})}(),0<e(".wcf-embed-checkout-form-two-step").length&&(i(),u(".wcf-embed-checkout-form-two-step .woocommerce").addClass("step-one"),u(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-steps a").on("click",function(e){e.preventDefault(),i()}),u(".wcf-embed-checkout-form-two-step .wcf-embed-checkout-form-nav-btns a").on("click",function(e){e.preventDefault(),o()}))})}(jQuery);