1 line
6.3 KiB
JavaScript
1 line
6.3 KiB
JavaScript
"use strict";var WPMailSMTP=window.WPMailSMTP||{};WPMailSMTP.Admin=WPMailSMTP.Admin||{},WPMailSMTP.Admin.Settings=WPMailSMTP.Admin.Settings||function(i,e,a){var s={pluginSettingsChanged:!1,init:function(){a(i).ready(s.ready)},ready:function(){s.pageHolder=a(".wp-mail-smtp-tab-settings"),a("#screen-meta-links, #screen-meta").prependTo("#wp-mail-smtp-header-temp").show(),s.bindActions()},bindActions:function(){a(".wp-mail-smtp-mailer-image",s.pageHolder).click(function(){a(this).parents(".wp-mail-smtp-mailer").find("input").trigger("click")}),a(".wp-mail-smtp-mailer input",s.pageHolder).click(function(){var t=a(this);if(t.prop("disabled"))return t.hasClass("educate")&&s.education.upgradeMailer(t),!1;a(".wp-mail-smtp-mailer",s.pageHolder).removeClass("active"),a(this).parents(".wp-mail-smtp-mailer").addClass("active"),a(".wp-mail-smtp-mailer-option",s.pageHolder).addClass("hidden").removeClass("active"),a(".wp-mail-smtp-mailer-option-"+a(this).val(),s.pageHolder).addClass("active").removeClass("hidden")}),s.mailers.smtp.bindActions(),a("#wp-mail-smtp-pro-banner-dismiss",s.pageHolder).on("click",function(){a.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"wp_mail_smtp_ajax",task:"pro_banner_dismiss"}}).always(function(){a("#wp-mail-smtp-pro-banner",s.pageHolder).fadeOut("fast")})}),a(".js-wp-mail-smtp-mailer-notice-dismiss",s.pageHolder).on("click",function(t){t.preventDefault();var e=a(this),i=e.parents(".inline-notice");if(e.hasClass("disabled"))return!1;a.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"wp_mail_smtp_ajax",task:"notice_dismiss",notice:i.data("notice"),mailer:i.data("mailer")},beforeSend:function(){e.addClass("disabled")}}).always(function(){i.fadeOut("fast",function(){e.removeClass("disabled")})})}),a("#wp-mail-smtp-debug .error-log-toggle").on("click",function(t){t.preventDefault(),a("#wp-mail-smtp-debug .error-log-toggle").find(".dashicons").toggleClass("dashicons-arrow-right-alt2 dashicons-arrow-down-alt2"),a("#wp-mail-smtp-debug .error-log").slideToggle(),a("#wp-mail-smtp-debug .error-log-note").toggle()}),a(".js-wp-mail-smtp-provider-remove",s.pageHolder).on("click",function(){return confirm(wp_mail_smtp.text_provider_remove)}),a(".wp-mail-smtp-setting-copy",s.pageHolder).click(function(t){t.preventDefault(),a("#"+a(this).data("source_id")).get(0).select(),i.execCommand("Copy");var e=a(this).find(".dashicons");e.removeClass("dashicons-admin-page").addClass("dashicons-yes-alt wp-mail-smtp-success wp-mail-smtp-animate"),setTimeout(function(){e.removeClass("dashicons-yes-alt wp-mail-smtp-success wp-mail-smtp-animate").addClass("dashicons-admin-page")},1e3)}),a("#wp-mail-smtp-notice-bar").on("click",".dismiss",function(){var t=a(this).closest("#wp-mail-smtp-notice-bar");t.addClass("out"),setTimeout(function(){t.remove()},300),a.post(ajaxurl,{action:"wp_mail_smtp_notice_bar_dismiss",nonce:wp_mail_smtp.nonce})}),s.triggerExitNotice(),s.beforeSaveChecks(),a(".js-wp-mail-smtp-setting-mailer-radio-input",s.pageHolder).on("change",this.processMailerSettingsOnChange)},education:{upgradeMailer:function(t){a.alert({backgroundDismiss:!0,escapeKey:!0,animationBounce:1,theme:"modern",type:"blue",animateFromElement:!1,draggable:!1,closeIcon:!0,useBootstrap:!1,title:wp_mail_smtp.education.upgrade_title.replace(/%name%/g,t.siblings("label").text().trim()),icon:'"></i>'+wp_mail_smtp.education.upgrade_icon_lock+'<i class="',content:a(".wp-mail-smtp-mailer-options .wp-mail-smtp-mailer-option-"+t.val()+" .wp-mail-smtp-setting-field").html(),boxWidth:"550px",onOpenBefore:function(){this.$btnc.after('<div class="discount-note">'+wp_mail_smtp.education.upgrade_bonus+wp_mail_smtp.education.upgrade_doc+"</div>")},buttons:{confirm:{text:wp_mail_smtp.education.upgrade_button,btnClass:"btn-confirm",keys:["enter"],action:function(){e.open(wp_mail_smtp.education.upgrade_url+"&utm_content="+encodeURI(t.val()),"_blank")}}}})}},mailers:{smtp:{bindActions:function(){a("#wp-mail-smtp-setting-smtp-auth").change(function(){a("#wp-mail-smtp-setting-row-smtp-user, #wp-mail-smtp-setting-row-smtp-pass").toggleClass("inactive")}),a("#wp-mail-smtp-setting-row-smtp-encryption input").change(function(){var t=a(this),e=a("#wp-mail-smtp-setting-smtp-port",s.pageHolder);"tls"===t.val()?(e.val("587"),a("#wp-mail-smtp-setting-row-smtp-autotls").addClass("inactive")):("ssl"===t.val()?e.val("465"):e.val("25"),a("#wp-mail-smtp-setting-row-smtp-autotls").removeClass("inactive"))})}}},triggerExitNotice:function(){var t=a(".wp-mail-smtp-page-general:not( .wp-mail-smtp-tab-test )");a(e).on("beforeunload",function(){if(s.pluginSettingsChanged)return wp_mail_smtp.text_settings_not_saved}),a(":input:not( #wp-mail-smtp-setting-license-key, .wp-mail-smtp-not-form-input )",t).on("change",function(){s.pluginSettingsChanged=!0}),a("form",t).on("submit",function(){s.pluginSettingsChanged=!1})},beforeSaveChecks:function(){a("form",s.pageHolder).on("submit",function(){if("mail"===a(".wp-mail-smtp-mailer input:checked",s.pageHolder).val()){var t=a(this);return a.alert({backgroundDismiss:!1,escapeKey:!1,animationBounce:1,theme:"modern",type:"orange",animateFromElement:!1,draggable:!1,closeIcon:!1,useBootstrap:!1,icon:'"></i><img src="'+wp_mail_smtp.plugin_url+'/assets/images/font-awesome/exclamation-circle-solid-orange.svg" style="width: 40px; height: 40px;" alt="'+wp_mail_smtp.default_mailer_notice.icon_alt+'"><i class="',title:wp_mail_smtp.default_mailer_notice.title,content:wp_mail_smtp.default_mailer_notice.content,boxWidth:"550px",buttons:{confirm:{text:wp_mail_smtp.default_mailer_notice.save_button,btnClass:"btn-confirm",keys:["enter"],action:function(){t.off("submit").submit()}},cancel:{text:wp_mail_smtp.default_mailer_notice.cancel_button}}}),!1}})},processMailerSettingsOnChange:function(){var t=wp_mail_smtp.all_mailers_supports[a(this).val()];for(var e in t)t.hasOwnProperty(e)&&a(".js-wp-mail-smtp-setting-"+e,s.pageHolder).toggle(t[e]);var i=a(".js-wp-mail-smtp-setting-from_email");i.closest(".wp-mail-smtp-setting-row").toggle(t.from_email||t.from_email_force),i.siblings(".wp-mail-smtp-setting-mid-row-sep").toggle(t.from_email&&t.from_email_force),(i=a(".js-wp-mail-smtp-setting-from_name")).closest(".wp-mail-smtp-setting-row").toggle(t.from_name||t.from_name_force),i.siblings(".wp-mail-smtp-setting-mid-row-sep").toggle(t.from_name&&t.from_name_force)}};return s}(document,window,jQuery),WPMailSMTP.Admin.Settings.init(); |