function arm_hide_show_subscription_plan_notice(){var a="arm_pp_lock_key",n=(arm_hide_gutenberg_notice("blank_plan_amount"),arm_hide_gutenberg_notice("invalid_plan_amount"),jQuery(".paid_subscription_options_recurring_payment_cycle_label")),_=jQuery(".paid_subscription_options_recurring_payment_cycle_amount"),e=!1,t=!1,i=!1;n.each(function(){""==jQuery(this).val()&&(e=!0)}),_.each(function(){""==jQuery(this).val()?t=!0:ArmPlanNumberValidation(this)||(i=!0)}),e?(arm_lock_postSaving(a),arm_display_gutenber_notice("arm_label_blank")):arm_hide_gutenberg_notice("arm_label_blank"),t?(arm_lock_postSaving(a),arm_display_gutenber_notice("blank_plan_amount")):arm_hide_gutenberg_notice("blank_plan_amount"),i&&(arm_lock_postSaving(a),arm_display_gutenber_notice("invalid_plan_amount")),e||t||i||arm_unlock_postSaving(a)}function ArmPlanNumberValidation(a){a=jQuery(a).val();return!!/^[0-9.]*$/.test(a)}function arm_unlock_postSaving(a){wp.data.select("core/editor").isPostSavingLocked()&&(wp.data.dispatch("core/editor").unlockPostSaving(a),void 0!==wp.data.dispatch("core/editor").unlockPostAutosaving&&wp.data.dispatch("core/editor").unlockPostAutosaving(a))}function arm_lock_postSaving(a){wp.data.dispatch("core/editor").lockPostSaving(a),void 0!==wp.data.dispatch("core/editor").lockPostAutosaving&&wp.data.dispatch("core/editor").lockPostAutosaving(a)}function arm_display_gutenber_notice(a){"blank_plan_amount"==a?wp.data.dispatch("core/notices").createNotice("error",ARMEDITORNOTICELABEL+AMOUNTERROR,{id:"arm_blank_amount_notice"}):"invalid_plan_amount"==a?wp.data.dispatch("core/notices").createNotice("error",ARMEDITORNOTICELABEL+INVALIDAMOUNTERROR,{id:"arm_invalid_amount_notice"}):"arm_label_blank"==a?wp.data.dispatch("core/notices").createNotice("error",ARMEDITORNOTICELABEL+LABELERROR,{id:"arm_blank_label_notice"}):"arm_blank_plans"==a&&wp.data.dispatch("core/notices").createNotice("error",ARMEDITORNOTICELABEL+NO_PLANS,{id:"arm_empty_plan_notice"})}function arm_hide_gutenberg_notice(a){"blank_plan_amount"==a?wp.data.dispatch("core/notices").removeNotice("arm_blank_amount_notice"):"invalid_plan_amount"==a?wp.data.dispatch("core/notices").removeNotice("arm_invalid_amount_notice"):"arm_label_blank"==a?wp.data.dispatch("core/notices").removeNotice("arm_blank_label_notice"):"arm_blank_plans"==a&&wp.data.dispatch("core/notices").removeNotice("arm_empty_plan_notice")}function isNumber(a){a=a.which||a.keyCode;return!(46!=a&&31<a&&(a<48||57<a))}function ArmNumberValidation(a,n){a=a.which||a.keyCode,n=jQuery(n).val();return!(46!=a&&31<a&&(a<48||57<a)&&37!=a&&39!=a)&&!(""!=n&&1<n.split(".").length&&46==a)}jQuery(document).on("change","#arm_enable_paid_post",function(){var a,n,_,e,t="arm_pp_lock_key";jQuery(this).is(":checked")?"buy_now"==jQuery('input[name="paid_post_type"]:checked').val()?(""==jQuery('input[name="arm_paid_post_plan"]').val()?arm_lock_postSaving:arm_unlock_postSaving)(t):(a=jQuery(".paid_subscription_options_recurring_payment_cycle_label"),n=jQuery(".paid_subscription_options_recurring_payment_cycle_amount"),e=_=!1,a.each(function(){""==jQuery(this).val()&&(_=!0)}),n.each(function(){""==jQuery(this).val()&&(e=!0)}),(_||e?arm_lock_postSaving:arm_unlock_postSaving)(t)):arm_unlock_postSaving(t)}),jQuery(document).on("change",'input[name="paid_post_type"]',function(){var a,n="arm_pp_lock_key";jQuery(this).is(":checked")&&("buy_now"==(a=jQuery(this).val())?(arm_hide_gutenberg_notice("arm_label_blank"),""==jQuery('input[name="arm_paid_post_plan"]').val()?(arm_lock_postSaving(n),arm_display_gutenber_notice("blank_plan_amount")):ArmPlanNumberValidation(jQuery('input[name="arm_paid_post_plan"]'))?(arm_unlock_postSaving(n),arm_hide_gutenberg_notice("blank_plan_amount"),arm_hide_gutenberg_notice("invalid_plan_amount")):(arm_lock_postSaving(n),arm_hide_gutenberg_notice("blank_plan_amount"),arm_display_gutenber_notice("invalid_plan_amount"))):"free"==a?(arm_unlock_postSaving(n),arm_hide_gutenberg_notice("blank_plan_amount"),arm_hide_gutenberg_notice("invalid_plan_amount")):arm_hide_show_subscription_plan_notice())}),jQuery(document).on("change",".arm_enable_drip_rule",function(){var a=jQuery(this).attr("data-id"),n="arm_pp_lock_key";jQuery(this).is(":checked")&&(""==jQuery("#arm_drip_rule_plans_"+a).val()?(arm_lock_postSaving(n),arm_display_gutenber_notice("arm_blank_plans")):(arm_unlock_postSaving(n),arm_hide_gutenberg_notice("arm_blank_plans")))}),jQuery(document).on("change","#arm_drip_rule_plans",function(){var a="arm_pp_lock_key";""==jQuery(this).val()?(arm_lock_postSaving(a),arm_display_gutenber_notice("arm_blank_plans")):(arm_unlock_postSaving(a),arm_hide_gutenberg_notice("arm_blank_plans"))}),jQuery(document).on("keyup",".paid_subscription_options_recurring_payment_cycle_label",function(){var a,n="arm_pp_lock_key";""==jQuery(this).val()?(arm_lock_postSaving(n),arm_display_gutenber_notice("arm_label_blank")):1<jQuery(".paid_subscription_options_recurring_payment_cycle_label").length?(a=!1,jQuery(".paid_subscription_options_recurring_payment_cycle_label").each(function(){""==jQuery(this).val()&&(a=!0)}),a?(arm_lock_postSaving(n),arm_display_gutenber_notice("arm_label_blank")):(arm_unlock_postSaving(n),arm_hide_gutenberg_notice("arm_label_blank"))):(arm_unlock_postSaving(n),arm_hide_gutenberg_notice("arm_label_blank"))}),jQuery(document).on("click","#arm_add_payment_cycle_recurring",function(){arm_hide_show_subscription_plan_notice()}),jQuery(document).on("click","#arm_remove_recurring_payment_cycle",function(){arm_hide_show_subscription_plan_notice()}),jQuery(document).on("keyup",".paid_subscription_options_recurring_payment_cycle_amount",function(){var a,n,_="arm_pp_lock_key";""==jQuery(this).val()?(arm_lock_postSaving(_),arm_display_gutenber_notice("blank_plan_amount")):ArmPlanNumberValidation(this)?0<jQuery(".paid_subscription_options_recurring_payment_cycle_amount").length&&(n=a=!1,jQuery(".paid_subscription_options_recurring_payment_cycle_amount").each(function(){""==jQuery(this).val()?a=!0:ArmPlanNumberValidation(this)||(n=!0)}),a?(arm_lock_postSaving(_),arm_display_gutenber_notice("blank_plan_amount")):arm_hide_gutenberg_notice("blank_plan_amount"),n&&(arm_lock_postSaving(_),arm_display_gutenber_notice("invalid_plan_amount")),a||n||(arm_unlock_postSaving(_),arm_hide_gutenberg_notice("blank_plan_amount"),arm_hide_gutenberg_notice("invalid_plan_amount"))):(arm_lock_postSaving(_),arm_hide_gutenberg_notice("blank_plan_amount"),arm_display_gutenber_notice("invalid_plan_amount"))}),jQuery(document).on("keyup",'input[name="arm_paid_post_plan"]',function(a){var n="arm_pp_lock_key";""==jQuery(this).val()?(arm_lock_postSaving(n),arm_display_gutenber_notice("blank_plan_amount")):ArmPlanNumberValidation(this)?(arm_unlock_postSaving(n),arm_hide_gutenberg_notice("blank_plan_amount"),arm_hide_gutenberg_notice("invalid_plan_amount")):(arm_lock_postSaving(n),arm_hide_gutenberg_notice("blank_plan_amount"),arm_display_gutenber_notice("invalid_plan_amount"))}); |