You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
4.3 KiB
JavaScript

const WPFormsStripeModernBuilder=window.WPFormsStripeModernBuilder||function(l){let o={};const i={init(){l(i.ready)},ready(){var e,n;i.isLegacySettings()||(o={$alert:l("#wpforms-stripe-credit-card-alert"),$panelContent:l("#wpforms-panel-content-section-payment-stripe"),$feeNotice:l(".wpforms-stripe-notice-info")},i.bindUIActions(),wpforms_builder_stripe.is_pro)||(n=".wpforms-panel-content-section-payment-plan-name input",l(e=".wpforms-panel-content-section-payment-toggle input").each(i.toggleContent),l(n).each(i.checkPlanName),l("#wpforms-panel-payments").on("click",e,i.toggleContent).on("click",".wpforms-panel-content-section-payment-plan-head-buttons-toggle",i.togglePlan).on("click",".wpforms-panel-content-section-payment-plan-head-buttons-delete",i.deletePlan).on("input",n,i.renamePlan).on("focusout",n,i.checkPlanName))},bindUIActions(){l("#wpforms-builder").on("wpformsFieldDelete",i.disableNotifications).on("wpformsSaved",i.requiredFieldsCheck).on("wpformsFieldAdd",i.fieldAdded).on("wpformsFieldDelete",i.fieldDeleted).on("wpformsPaymentsPlanCreated",i.toggleMultiplePlansWarning).on("wpformsPaymentsPlanDeleted",i.toggleMultiplePlansWarning)},requiredFieldsCheck(){l("#wpforms-panel-field-stripe-enable_recurring").is(":checked")&&!o.$panelContent.hasClass("wpforms-hidden")&&o.$panelContent.find(".wpforms-panel-content-section-payment-plan").each(function(){var e=l(this),n=e.data("plan-id");if(!e.find(`#wpforms-panel-field-stripe-recurring-${n}-email`).val())return i.recurringEmailAlert(),!1})},recurringEmailAlert(){l.alert({title:wpforms_builder.heads_up,content:wpforms_builder.stripe_recurring_email,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}})},disableNotifications(e,n,t){i.isStripeField(t)&&((t=l('.wpforms-panel-content-section-notifications [id*="-stripe-wrap"]')).find('input[id*="-stripe"]').prop("checked",!1),t.addClass("wpforms-hidden"))},isLegacySettings(){return l("#wpforms-panel-field-stripe-enable").length},fieldAdded(e,n,t){i.isStripeField(t)&&(i.settingsToggle(!0),o.$feeNotice.toggleClass("wpforms-hidden"))},fieldDeleted(e,n,t){i.isStripeField(t)&&(i.settingsToggle(!1),o.$feeNotice.toggleClass("wpforms-hidden"))},isStripeField(e){return wpforms_builder_stripe.field_slugs.includes(e)},toggleMultiplePlansWarning(){o.$panelContent.find(".wpforms-stripe-multiple-plans-warning").toggleClass("wpforms-hidden",1===o.$panelContent.find(".wpforms-panel-content-section-payment-plan").length)},settingsToggle(e){(o.$alert.length||o.$panelContent.length)&&(o.$alert.toggleClass("wpforms-hidden",e),o.$panelContent.toggleClass("wpforms-hidden",!e))},toggleContent(){var e=l(this),n=(l("#wpforms-panel-field-stripe-enable_recurring").is(":checked")&&l("#wpforms-panel-field-stripe-enable_one_time").is(":checked")&&(e.prop("checked",!1),l.alert({title:wpforms_builder.heads_up,content:"wpforms-panel-field-stripe-enable_recurring"===e.attr("id")?wpforms_builder_stripe.disabled_recurring:wpforms_builder_stripe.disabled_one_time,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}}),e.prop("checked",!1)),e.closest(".wpforms-panel-content-section-payment")),e=e.prop("checked")&&!l("#wpforms-panel-field-settings-disable_entries").prop("checked");n.find(".wpforms-panel-content-section-payment-toggled-body").toggle(e),n.toggleClass("wpforms-panel-content-section-payment-open",e)},togglePlan(){var e=l(this).closest(".wpforms-panel-content-section-payment-plan"),n=e.find(".wpforms-panel-content-section-payment-plan-head-buttons-toggle");n.toggleClass("fa-chevron-circle-up fa-chevron-circle-down"),e.find(".wpforms-panel-content-section-payment-plan-body").toggle(n.hasClass("fa-chevron-circle-down"))},deletePlan(){l(".wpforms-panel-content-section-payment-button-add-plan").click()},checkPlanName(){var e,n=l(this),t=n.closest(".wpforms-panel-content-section-payment-plan").find(".wpforms-panel-content-section-payment-plan-head-title");n.val()?t.html(n.val()):(e=wpforms_builder_stripe.plan_placeholder,t.html(e),n.val(e))},renamePlan(){var e=l(this),n=e.closest(".wpforms-panel-content-section-payment-plan").find(".wpforms-panel-content-section-payment-plan-head-title");e.val()?n.html(e.val()):n.html("")}};return i}((document,window,jQuery));WPFormsStripeModernBuilder.init();