관리-도구
편집 파일: kkart-setup.min.js
jQuery(function(a){function t(){a(".kkart-setup-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function i(){a("form.activate-jetpack").submit()}function s(){wp.ajax.post("setup_wizard_check_jetpack").then(function(e){return e&&e.is_active&&"yes"!==e.is_active?void setTimeout(s,3e3):i()}).fail(function(){i()})}function c(e,i,t){var s,c=i.data("plugins");for(s in Array.isArray(c)?c:[]){var n=c[s].slug;e[n]=e[n]||a('<span class="plugin-install-info-list-item">').append('<a href="https://wordpress.org/plugins/'+n+'/" target="_blank">'+c[s].name+"</a>"),e[n].find("a").on("mouseenter mouseleave",function(e,i){e.toggleClass("plugin-install-source","mouseenter"===i.type)}.bind(null,t?i.closest(t):i))}}function e(){var i={},t=[];a(".kkart-wizard-service-enable input:checked").each(function(){c(i,a(this),".kkart-wizard-service-item");var e=a(this).closest(".kkart-wizard-service-item");e.find("input.payment-checkbox-input:checked").each(function(){t.push(a(this).attr("id")),c(i,a(this),".kkart-wizard-service-settings")}),e.find(".kkart-wizard-shipping-method-select .method").each(function(){var e=a(this);"live_rates"===e.val()&&c(i,e,".kkart-wizard-service-item")})}),a(".recommended-item input:checked").each(function(){c(i,a(this),".recommended-item")});var e,s=a("span.plugin-install-info-list").empty();for(e in i)s.append(i[e]);t&&kkart_setup_params.current_step&&kkart_setup_params.i18n.extra_plugins[kkart_setup_params.current_step]&&kkart_setup_params.i18n.extra_plugins[kkart_setup_params.current_step][t.join(",")]&&s.append(kkart_setup_params.i18n.extra_plugins[kkart_setup_params.current_step][t.join(",")]),a("span.plugin-install-info").toggle(0<s.children().length)}a(".button-next").on("click",function(){var e=a(this).parents("form").get(0);return"function"==typeof e.checkValidity&&!e.checkValidity()||t(),!0}),a("form.address-step").on("submit",function(e){var i=a(this);return"function"==typeof i.checkValidity&&!i.checkValidity()||t(),e.preventDefault(),a(".kkart-setup-content").unblock(),a(this).KKARTBackboneModal({template:"kkart-modal-tracking-setup"}),a(document.body).on("kkart_backbone_modal_response",function(){i.unbind("submit").submit()}),a("#kkart_tracker_checkbox_dialog").on("change",function(e){e=a(e.target);a("#kkart_tracker_checkbox").prop("checked",e.prop("checked"))}),a("#kkart_tracker_submit").on("click",function(){i.unbind("submit").submit()}),!0}),a("#store_country").on("change",function(){var e,i,t;null!==kkart_setup_params.states&&(e=a(this).val(),i=a("#store_state"),a.isEmptyObject(kkart_setup_params.states[e])?(a(".store-state-container").hide(),i.empty().val("").change().prop("required",!1)):(t=kkart_setup_params.states[e],i.empty(),a.each(t,function(e){i.append(a('<option value="'+e+'">'+t[e]+"</option>"))}),a(".store-state-container").show(),i.selectWoo().val(kkart_base_state).change().prop("required",!0)),a("#currency_code").val(kkart_setup_currencies[e]).change())}),a("#store_country").on("change",function(){var e,i;kkart_setup_params.postcodes&&(i=a(this).val(),e=a("#store_postcode"),i=kkart_setup_params.postcodes[i],a.isEmptyObject(i)||i.required?e.attr("required","true"):e.removeAttr("required"))}),a("#store_country").change(),a(".kkart-wizard-services").on("change",".kkart-wizard-service-enable input",function(){a(this).is(":checked")?(a(this).closest(".kkart-wizard-service-toggle").removeClass("disabled"),a(this).closest(".kkart-wizard-service-item").addClass("checked"),a(this).closest(".kkart-wizard-service-item").find(".kkart-wizard-service-settings").removeClass("hide")):(a(this).closest(".kkart-wizard-service-toggle").addClass("disabled"),a(this).closest(".kkart-wizard-service-item").removeClass("checked"),a(this).closest(".kkart-wizard-service-item").find(".kkart-wizard-service-settings").addClass("hide"))}),a(".kkart-wizard-services").on("keyup",function(e){var i=e.keyCode||e.which,e=a(document.activeElement);!e.is(".kkart-wizard-service-toggle, .kkart-wizard-service-enable")||13!==i&&32!==i||e.find(":input").click()}),a(".kkart-wizard-services").on("click",".kkart-wizard-service-enable",function(e){a(e.target).is("input")?e.stopPropagation():(e=a(this).find('input[type="checkbox"]')).prop("checked",!e.prop("checked")).change()}),a(".kkart-wizard-services-list-toggle").on("click",function(){a(this).closest(".kkart-wizard-services-list-toggle").toggleClass("closed"),a(this).closest(".kkart-wizard-services").find(".kkart-wizard-service-item").slideToggle().css("display","flex")}),a(".kkart-wizard-services").on("change",".kkart-wizard-shipping-method-select .method",function(e){var i=a(this).closest(".kkart-wizard-service-description"),t=e.target.value,e=i.find(".shipping-method-descriptions");e.find(".shipping-method-description").addClass("hide"),e.find("."+t).removeClass("hide");e=i.parent().find('input[type="checkbox"]'),i=i.find(".shipping-method-settings");i.find(".shipping-method-setting").addClass("hide").find(".shipping-method-required-field").prop("required",!1),i.find("."+t).removeClass("hide").find(".shipping-method-required-field").prop("required",e.prop("checked"))}).find(".kkart-wizard-shipping-method-select .method").change(),a(".kkart-wizard-services").on("change",".kkart-wizard-shipping-method-enable",function(){var e=a(this).is(":checked"),i=a(this).closest(".kkart-wizard-service-item").find(".kkart-wizard-shipping-method-select .method").val();a(this).closest(".kkart-wizard-service-item").find("."+i).find(".shipping-method-required-field").prop("required",e)}),a(".activate-jetpack").on("click",".button-primary",function(e){return t(),"no"===kkart_setup_params.pending_jetpack_install||(e.preventDefault(),void s())}),a(".activate-new-onboarding").on("click",".button-primary",function(){t()}),a(".kkart-wizard-services").on("change","input#stripe_create_account, input#ppec_paypal_reroute_requests",function(){a(this).is(":checked")?a(this).closest(".kkart-wizard-service-settings").find("input.payment-email-input").attr("type","email").prop("disabled",!1).prop("required",!0):a(this).closest(".kkart-wizard-service-settings").find("input.payment-email-input").attr("type",null).prop("disabled",!0).prop("required",!1)}).find("input#stripe_create_account, input#ppec_paypal_reroute_requests").change(),e(),a(".kkart-setup-content").on("change","[data-plugins]",e),a(document.body).on("init_tooltips",function(){a(".help_tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200,defaultPosition:"top"})}).trigger("init_tooltips")});