geno/wp-content/plugins/wp-mail-smtp/assets/js/smtp-admin.min.js
2024-02-01 11:54:18 +00:00

1 line
No EOL
8.2 KiB
JavaScript

"use strict";var WPMailSMTP=window.WPMailSMTP||{};WPMailSMTP.Admin=WPMailSMTP.Admin||{},WPMailSMTP.Admin.Settings=WPMailSMTP.Admin.Settings||function(a,m,p){var n={pluginSettingsChanged:!1,init:function(){p(n.ready)},ready:function(){n.pageHolder=p(".wp-mail-smtp-tab-settings"),n.settingsForm=p(".wp-mail-smtp-connection-settings-form"),p("#screen-meta-links, #screen-meta").prependTo("#wp-mail-smtp-header-temp").show(),n.bindActions(),n.setJQueryConfirmDefaults(),n.initFlyoutMenu()},bindActions:function(){p(".wp-mail-smtp-mailer-image",n.settingsForm).on("click",function(){p(this).parents(".wp-mail-smtp-mailer").find("input").trigger("click")}),p(".wp-mail-smtp-mailer input",n.settingsForm).on("click",function(){var t=p(this);if(t.prop("disabled"))return t.hasClass("educate")&&n.education.upgradeMailer(t),!1;p(".wp-mail-smtp-mailer",n.settingsForm).removeClass("active"),p(this).parents(".wp-mail-smtp-mailer").addClass("active"),p(".wp-mail-smtp-mailer-option",n.settingsForm).addClass("hidden").removeClass("active"),p(".wp-mail-smtp-mailer-option-"+p(this).val(),n.settingsForm).addClass("active").removeClass("hidden")}),n.mailers.smtp.bindActions(),p("#wp-mail-smtp-pro-banner-dismiss",n.pageHolder).on("click",function(){p.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"wp_mail_smtp_ajax",task:"pro_banner_dismiss",nonce:wp_mail_smtp.nonce}}).always(function(){p("#wp-mail-smtp-pro-banner",n.pageHolder).fadeOut("fast")})}),p(".js-wp-mail-smtp-mailer-notice-dismiss",n.settingsForm).on("click",function(t){t.preventDefault();var e=p(this),i=e.parents(".inline-notice");if(e.hasClass("disabled"))return!1;p.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"wp_mail_smtp_ajax",nonce:wp_mail_smtp.nonce,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")})})}),p("#wp-mail-smtp-debug .error-log-toggle").on("click",function(t){t.preventDefault(),p("#wp-mail-smtp-debug .error-log").slideToggle()}),p("#wp-mail-smtp-debug .error-log-copy").on("click",function(t){t.preventDefault();var e=p(this),i=p("#wp-mail-smtp-debug .error-log");i.is(":visible")||i.addClass("error-log-selection");t=a.createRange();t.selectNode(i[0]),m.getSelection().removeAllRanges(),m.getSelection().addRange(t),a.execCommand("Copy"),m.getSelection().removeAllRanges(),i.removeClass("error-log-selection"),e.addClass("error-log-copy-copied"),setTimeout(function(){e.removeClass("error-log-copy-copied")},1500)}),p(".js-wp-mail-smtp-provider-remove",n.settingsForm).on("click",function(){return confirm(wp_mail_smtp.text_provider_remove)}),p(".wp-mail-smtp-setting-copy",n.settingsForm).on("click",function(t){t.preventDefault(),p("#"+p(this).data("source_id")).get(0).select(),a.execCommand("Copy");var e=p(this).find(".dashicons");e.removeClass("dashicons-admin-page").addClass("wp-mail-smtp-dashicons-yes-alt-green wp-mail-smtp-success wp-mail-smtp-animate"),setTimeout(function(){e.removeClass("wp-mail-smtp-dashicons-yes-alt-green wp-mail-smtp-success wp-mail-smtp-animate").addClass("dashicons-admin-page")},1e3)}),p("#wp-mail-smtp-notice-bar").on("click",".dismiss",function(){var t=p(this).closest("#wp-mail-smtp-notice-bar");t.addClass("out"),setTimeout(function(){t.remove()},300),p.post(ajaxurl,{action:"wp_mail_smtp_notice_bar_dismiss",nonce:wp_mail_smtp.nonce})}),n.triggerExitNotice(),n.beforeSaveChecks(),p(".js-wp-mail-smtp-setting-mailer-radio-input",n.settingsForm).on("change",this.processMailerSettingsOnChange),p(".wp-mail-smtp-tab-tools-test #email-test-form").on("submit",function(){var t=p(this).find(".wp-mail-smtp-btn");t.attr("disabled",!0),t.find("span").hide(),t.find(".wp-mail-smtp-loading").show()}),p(".email_test_tab_removal_notice").on("click",".notice-dismiss",function(){var t=p(this);p.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"wp_mail_smtp_ajax",nonce:wp_mail_smtp.nonce,task:"email_test_tab_removal_notice_dismiss"},beforeSend:function(){t.prop("disabled",!0)}})}),p("#wp-mail-smtp-setting-gmail-one_click_setup_enabled-lite").on("click",function(t){t.preventDefault(),n.education.gmailOneClickSetupUpgrade()})},education:{upgradeMailer:function(t){var e=t.data("title").trim();n.education.upgradeModal(wp_mail_smtp.education.upgrade_title.replace(/%name%/g,e),wp_mail_smtp.education.upgrade_content.replace(/%name%/g,e),t.val())},gmailOneClickSetupUpgrade:function(){n.education.upgradeModal(wp_mail_smtp.education.gmail.one_click_setup_upgrade_title,wp_mail_smtp.education.gmail.one_click_setup_upgrade_content,"gmail-one-click-setup")},upgradeModal:function(t,e,i){p.alert({backgroundDismiss:!0,escapeKey:!0,animationBounce:1,type:"blue",closeIcon:!0,title:t,icon:'"></i>'+wp_mail_smtp.education.upgrade_icon_lock+'<i class="',content:e,boxWidth:"550px",onOpenBefore:function(){this.$btnc.after('<div class="discount-note">'+wp_mail_smtp.education.upgrade_bonus+wp_mail_smtp.education.upgrade_doc+"</div>"),this.$body.addClass("wp-mail-smtp-upgrade-mailer-education-modal")},buttons:{confirm:{text:wp_mail_smtp.education.upgrade_button,btnClass:"btn-confirm",keys:["enter"],action:function(){var t=/(\?)/.test(wp_mail_smtp.education.upgrade_url)?"&":"?",t=wp_mail_smtp.education.upgrade_url+t+"utm_content="+encodeURIComponent(i);m.open(t,"_blank")}}}})}},mailers:{smtp:{bindActions:function(){p("#wp-mail-smtp-setting-smtp-auth").on("change",function(){p("#wp-mail-smtp-setting-row-smtp-user, #wp-mail-smtp-setting-row-smtp-pass").toggleClass("inactive")}),p("#wp-mail-smtp-setting-row-smtp-encryption input").on("change",function(){var t=p(this),e=p("#wp-mail-smtp-setting-smtp-port",n.settingsForm);"tls"===t.val()?(e.val("587"),p("#wp-mail-smtp-setting-row-smtp-autotls").addClass("inactive")):("ssl"===t.val()?e.val("465"):e.val("25"),p("#wp-mail-smtp-setting-row-smtp-autotls").removeClass("inactive"))})}}},triggerExitNotice:function(){var t=p(".wp-mail-smtp-page-general");p(m).on("beforeunload",function(){if(n.pluginSettingsChanged)return wp_mail_smtp.text_settings_not_saved}),p(":input:not( #wp-mail-smtp-setting-license-key, .wp-mail-smtp-not-form-input, #wp-mail-smtp-setting-gmail-one_click_setup_enabled )",t).on("change",function(){n.pluginSettingsChanged=!0}),p("form",t).on("submit",function(){n.pluginSettingsChanged=!1})},beforeSaveChecks:function(){n.settingsForm.on("submit",function(){if("mail"===p(".wp-mail-smtp-mailer input:checked",n.settingsForm).val()){var t=p(this);return p.alert({backgroundDismiss:!1,escapeKey:!1,animationBounce:1,type:"orange",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").trigger("submit")}},cancel:{text:wp_mail_smtp.default_mailer_notice.cancel_button,btnClass:"btn-cancel"}}}),!1}})},processMailerSettingsOnChange:function(){var t,e=wp_mail_smtp.all_mailers_supports[p(this).val()];for(t in e)e.hasOwnProperty(t)&&p(".js-wp-mail-smtp-setting-"+t,n.settingsForm).toggle(e[t]);var i=p(".js-wp-mail-smtp-setting-from_email");i.toggle(e.from_email||e.from_email_force),(i=p(".js-wp-mail-smtp-setting-from_name")).toggle(e.from_name||e.from_name_force)},setJQueryConfirmDefaults:function(){jconfirm.defaults={typeAnimated:!1,draggable:!1,animateFromElement:!1,theme:"modern",boxWidth:"400px",useBootstrap:!1}},initFlyoutMenu:function(){var s,o,l=p("#wp-mail-smtp-flyout");0!==l.length&&(l.find(".wp-mail-smtp-flyout-head").on("click",function(t){t.preventDefault(),l.toggleClass("opened")}),0!==(s=p("#wpfooter")).length&&(o=p(".wp-mail-smtp-page-logs-archive, .wp-mail-smtp-tab-tools-action-scheduler, .wp-mail-smtp-page-reports, .wp-mail-smtp-tab-tools-debug-events, .wp-mail-smtp-tab-connections"),p(m).on("resize scroll",_.debounce(function(){var t=s.offset().top,e=t+s.height(),i=0<o.length?o.offset().top+o.height()+85:0,a=p(m).scrollTop(),n=a+p(m).height();e<=n&&a<=t&&n<i?l.addClass("out"):l.removeClass("out")},50)),p(m).trigger("scroll")))}};return n}(document,window,jQuery),WPMailSMTP.Admin.Settings.init();