woocommerce/assets/js/admin/wc-setup.min.js

1 line
4.8 KiB
JavaScript

jQuery(function(e){function i(){e(".wc-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function t(){e("form.activate-jetpack").submit()}function s(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){if(!e||!e.is_active||"yes"===e.is_active)return t();setTimeout(s,3e3)}).fail(function(){t()})}function c(i,t,s){var c=t.data("plugins");for(var n in Array.isArray(c)?c:[]){var a=c[n].slug;i[a]=i[a]||e('<span class="plugin-install-info-list-item">').append('<a href="https://wordpress.org/plugins/'+a+'/" target="_blank">'+c[n].name+"</a>"),i[a].find("a").on("mouseenter mouseleave",function(e,i){e.toggleClass("plugin-install-source","mouseenter"===i.type)}.bind(null,s?t.closest(s):t))}}function n(){var i={};e(".wc-wizard-service-enable input:checked").each(function(){c(i,e(this),".wc-wizard-service-item");var t=e(this).closest(".wc-wizard-service-item");t.find("input.payment-checkbox-input:checked").each(function(){c(i,e(this),".wc-wizard-service-settings")}),t.find(".wc-wizard-shipping-method-select .method").each(function(){var t=e(this);"live_rates"===t.val()&&c(i,t,".wc-wizard-service-item")})}),e(".recommended-item input:checked").each(function(){c(i,e(this),".recommended-item")});var t=e("span.plugin-install-info-list").empty();for(var s in i)t.append(i[s]);e("span.plugin-install-info").toggle(t.children().length>0)}e(".button-next").on("click",function(){var t=e(this).parents("form").get(0);return("function"!=typeof t.checkValidity||t.checkValidity())&&i(),!0}),e("#store_country").on("change",function(){if(null!==wc_setup_params.states){var i=e(this).val(),t=e("#store_state");if(e.isEmptyObject(wc_setup_params.states[i]))e(".store-state-container").hide(),t.empty().val("").change().prop("required",!1);else{var s=wc_setup_params.states[i];t.empty(),e.each(s,function(i){t.append(e('<option value="'+i+'">'+s[i]+"</option>"))}),e(".store-state-container").show(),t.selectWoo().val(wc_base_state).change().prop("required",!0)}e("#currency_code").val(wc_setup_currencies[i]).change()}}),e("#store_country").change(),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){if(e(i.target).is("input"))i.stopPropagation();else{var t=e(this).find('input[type="checkbox"]');t.prop("checked",!t.prop("checked")).change()}}),e(".wc-wizard-services-list-toggle").on("click",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 t=e(this).closest(".wc-wizard-service-description"),s=i.target.value,c=t.find(".shipping-method-descriptions");c.find(".shipping-method-description").addClass("hide"),c.find("."+s).removeClass("hide");var n=t.find(".shipping-method-settings");n.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),n.find("."+s).removeClass("hide").find(".shipping-method-required-field").prop("required",!0)}).find(".wc-wizard-shipping-method-select .method").change(),e(".wc-wizard-services").on("change",".wc-wizard-shipping-method-enable",function(){var i=e(this).is(":checked"),t=e(".wc-wizard-shipping-method-select .method").val();e(this).closest(".wc-wizard-service-item").find("."+t).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(),s()}),e(".wc-wizard-services").on("change","input#stripe_create_account, input#ppec_paypal_reroute_requests",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, .wc-wizard-service-setting-ppec_paypal_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, .wc-wizard-service-setting-ppec_paypal_email").hide())}).find("input#stripe_create_account, input#ppec_paypal_reroute_requests").change(),n(),e(".wc-setup-content").on("change","[data-plugins]",n)});