Initial commit

This commit is contained in:
2020-04-07 13:03:04 +00:00
committed by Gitium
commit 00f842d9bf
1673 changed files with 471161 additions and 0 deletions

View File

@ -0,0 +1,388 @@
/**
* jquery-match-height 0.7.2 by @liabru
* http://brm.io/jquery-match-height/
* License: MIT
*/
;(function(factory) { // eslint-disable-line no-extra-semi
'use strict';
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof module !== 'undefined' && module.exports) {
// CommonJS
module.exports = factory(require('jquery'));
} else {
// Global
factory(jQuery);
}
})(function($) {
/*
* internal
*/
var _previousResizeWidth = -1,
_updateTimeout = -1;
/*
* _parse
* value parse utility function
*/
var _parse = function(value) {
// parse value and convert NaN to 0
return parseFloat(value) || 0;
};
/*
* _rows
* utility function returns array of jQuery selections representing each row
* (as displayed after float wrapping applied by browser)
*/
var _rows = function(elements) {
var tolerance = 1,
$elements = $(elements),
lastTop = null,
rows = [];
// group elements by their top position
$elements.each(function(){
var $that = $(this),
top = $that.offset().top - _parse($that.css('margin-top')),
lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
if (lastRow === null) {
// first item on the row, so just push it
rows.push($that);
} else {
// if the row top is the same, add to the row group
if (Math.floor(Math.abs(lastTop - top)) <= tolerance) {
rows[rows.length - 1] = lastRow.add($that);
} else {
// otherwise start a new row group
rows.push($that);
}
}
// keep track of the last row top
lastTop = top;
});
return rows;
};
/*
* _parseOptions
* handle plugin options
*/
var _parseOptions = function(options) {
var opts = {
byRow: true,
property: 'height',
target: null,
remove: false
};
if (typeof options === 'object') {
return $.extend(opts, options);
}
if (typeof options === 'boolean') {
opts.byRow = options;
} else if (options === 'remove') {
opts.remove = true;
}
return opts;
};
/*
* matchHeight
* plugin definition
*/
var matchHeight = $.fn.matchHeight = function(options) {
var opts = _parseOptions(options);
// handle remove
if (opts.remove) {
var that = this;
// remove fixed height from all selected elements
this.css(opts.property, '');
// remove selected elements from all groups
$.each(matchHeight._groups, function(key, group) {
group.elements = group.elements.not(that);
});
// TODO: cleanup empty groups
return this;
}
if (this.length <= 1 && !opts.target) {
return this;
}
// keep track of this group so we can re-apply later on load and resize events
matchHeight._groups.push({
elements: this,
options: opts
});
// match each element's height to the tallest element in the selection
matchHeight._apply(this, opts);
return this;
};
/*
* plugin global options
*/
matchHeight.version = '0.7.2';
matchHeight._groups = [];
matchHeight._throttle = 80;
matchHeight._maintainScroll = false;
matchHeight._beforeUpdate = null;
matchHeight._afterUpdate = null;
matchHeight._rows = _rows;
matchHeight._parse = _parse;
matchHeight._parseOptions = _parseOptions;
/*
* matchHeight._apply
* apply matchHeight to given elements
*/
matchHeight._apply = function(elements, options) {
var opts = _parseOptions(options),
$elements = $(elements),
rows = [$elements];
// take note of scroll position
var scrollTop = $(window).scrollTop(),
htmlHeight = $('html').outerHeight(true);
// get hidden parents
var $hiddenParents = $elements.parents().filter(':hidden');
// cache the original inline style
$hiddenParents.each(function() {
var $that = $(this);
$that.data('style-cache', $that.attr('style'));
});
// temporarily must force hidden parents visible
$hiddenParents.css('display', 'block');
// get rows if using byRow, otherwise assume one row
if (opts.byRow && !opts.target) {
// must first force an arbitrary equal height so floating elements break evenly
$elements.each(function() {
var $that = $(this),
display = $that.css('display');
// temporarily force a usable display value
if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
display = 'block';
}
// cache the original inline style
$that.data('style-cache', $that.attr('style'));
$that.css({
'display': display,
'padding-top': '0',
'padding-bottom': '0',
'margin-top': '0',
'margin-bottom': '0',
'border-top-width': '0',
'border-bottom-width': '0',
'height': '100px',
'overflow': 'hidden'
});
});
// get the array of rows (based on element top position)
rows = _rows($elements);
// revert original inline styles
$elements.each(function() {
var $that = $(this);
$that.attr('style', $that.data('style-cache') || '');
});
}
$.each(rows, function(key, row) {
var $row = $(row),
targetHeight = 0;
if (!opts.target) {
// skip apply to rows with only one item
if (opts.byRow && $row.length <= 1) {
$row.css(opts.property, '');
return;
}
// iterate the row and find the max height
$row.each(function(){
var $that = $(this),
style = $that.attr('style'),
display = $that.css('display');
// temporarily force a usable display value
if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
display = 'block';
}
// ensure we get the correct actual height (and not a previously set height value)
var css = { 'display': display };
css[opts.property] = '';
$that.css(css);
// find the max height (including padding, but not margin)
if ($that.outerHeight(false) > targetHeight) {
targetHeight = $that.outerHeight(false);
}
// revert styles
if (style) {
$that.attr('style', style);
} else {
$that.css('display', '');
}
});
} else {
// if target set, use the height of the target element
targetHeight = opts.target.outerHeight(false);
}
// iterate the row and apply the height to all elements
$row.each(function(){
var $that = $(this),
verticalPadding = 0;
// don't apply to a target
if (opts.target && $that.is(opts.target)) {
return;
}
// handle padding and border correctly (required when not using border-box)
if ($that.css('box-sizing') !== 'border-box') {
verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
}
// set the height (accounting for padding and border)
$that.css(opts.property, (targetHeight - verticalPadding) + 'px');
});
});
// revert hidden parents
$hiddenParents.each(function() {
var $that = $(this);
$that.attr('style', $that.data('style-cache') || null);
});
// restore scroll position if enabled
if (matchHeight._maintainScroll) {
$(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));
}
return this;
};
/*
* matchHeight._applyDataApi
* applies matchHeight to all elements with a data-match-height attribute
*/
matchHeight._applyDataApi = function() {
var groups = {};
// generate groups by their groupId set by elements using data-match-height
$('[data-match-height], [data-mh]').each(function() {
var $this = $(this),
groupId = $this.attr('data-mh') || $this.attr('data-match-height');
if (groupId in groups) {
groups[groupId] = groups[groupId].add($this);
} else {
groups[groupId] = $this;
}
});
// apply matchHeight to each group
$.each(groups, function() {
this.matchHeight(true);
});
};
/*
* matchHeight._update
* updates matchHeight on all current groups with their correct options
*/
var _update = function(event) {
if (matchHeight._beforeUpdate) {
matchHeight._beforeUpdate(event, matchHeight._groups);
}
$.each(matchHeight._groups, function() {
matchHeight._apply(this.elements, this.options);
});
if (matchHeight._afterUpdate) {
matchHeight._afterUpdate(event, matchHeight._groups);
}
};
matchHeight._update = function(throttle, event) {
// prevent update if fired from a resize event
// where the viewport width hasn't actually changed
// fixes an event looping bug in IE8
if (event && event.type === 'resize') {
var windowWidth = $(window).width();
if (windowWidth === _previousResizeWidth) {
return;
}
_previousResizeWidth = windowWidth;
}
// throttle updates
if (!throttle) {
_update(event);
} else if (_updateTimeout === -1) {
_updateTimeout = setTimeout(function() {
_update(event);
_updateTimeout = -1;
}, matchHeight._throttle);
}
};
/*
* bind events
*/
// apply on DOM ready event
$(matchHeight._applyDataApi);
// use on or bind where supported
var on = $.fn.on ? 'on' : 'bind';
// update heights on load and resize events
$(window)[on]('load', function(event) {
matchHeight._update(false, event);
});
// throttled update heights on resize events
$(window)[on]('resize orientationchange', function(event) {
matchHeight._update(true, event);
});
});

View File

@ -0,0 +1 @@
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(l){function h(t){return parseFloat(t)||0}function c(t){var e=l(t),n=null,a=[];return e.each(function(){var t=l(this),e=t.offset().top-h(t.css("margin-top")),o=0<a.length?a[a.length-1]:null;null===o?a.push(t):Math.floor(Math.abs(n-e))<=1?a[a.length-1]=o.add(t):a.push(t),n=e}),a}function p(t){var e={byRow:!0,property:"height",target:null,remove:!1};return"object"==typeof t?l.extend(e,t):("boolean"==typeof t?e.byRow=t:"remove"===t&&(e.remove=!0),e)}var n=-1,a=-1,u=l.fn.matchHeight=function(t){var e=p(t);if(e.remove){var o=this;return this.css(e.property,""),l.each(u._groups,function(t,e){e.elements=e.elements.not(o)}),this}return this.length<=1&&!e.target||(u._groups.push({elements:this,options:e}),u._apply(this,e)),this};u.version="0.7.2",u._groups=[],u._throttle=80,u._maintainScroll=!1,u._beforeUpdate=null,u._afterUpdate=null,u._rows=c,u._parse=h,u._parseOptions=p,u._apply=function(t,e){var i=p(e),o=l(t),n=[o],a=l(window).scrollTop(),r=l("html").outerHeight(!0),s=o.parents().filter(":hidden");return s.each(function(){var t=l(this);t.data("style-cache",t.attr("style"))}),s.css("display","block"),i.byRow&&!i.target&&(o.each(function(){var t=l(this),e=t.css("display");"inline-block"!==e&&"flex"!==e&&"inline-flex"!==e&&(e="block"),t.data("style-cache",t.attr("style")),t.css({display:e,"padding-top":"0","padding-bottom":"0","margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px",overflow:"hidden"})}),n=c(o),o.each(function(){var t=l(this);t.attr("style",t.data("style-cache")||"")})),l.each(n,function(t,e){var o=l(e),a=0;if(i.target)a=i.target.outerHeight(!1);else{if(i.byRow&&o.length<=1)return void o.css(i.property,"");o.each(function(){var t=l(this),e=t.attr("style"),o=t.css("display");"inline-block"!==o&&"flex"!==o&&"inline-flex"!==o&&(o="block");var n={display:o};n[i.property]="",t.css(n),t.outerHeight(!1)>a&&(a=t.outerHeight(!1)),e?t.attr("style",e):t.css("display","")})}o.each(function(){var t=l(this),e=0;i.target&&t.is(i.target)||("border-box"!==t.css("box-sizing")&&(e+=h(t.css("border-top-width"))+h(t.css("border-bottom-width")),e+=h(t.css("padding-top"))+h(t.css("padding-bottom"))),t.css(i.property,a-e+"px"))})}),s.each(function(){var t=l(this);t.attr("style",t.data("style-cache")||null)}),u._maintainScroll&&l(window).scrollTop(a/r*l("html").outerHeight(!0)),this},u._applyDataApi=function(){var o={};l("[data-match-height], [data-mh]").each(function(){var t=l(this),e=t.attr("data-mh")||t.attr("data-match-height");o[e]=e in o?o[e].add(t):t}),l.each(o,function(){this.matchHeight(!0)})};function i(t){u._beforeUpdate&&u._beforeUpdate(t,u._groups),l.each(u._groups,function(){u._apply(this.elements,this.options)}),u._afterUpdate&&u._afterUpdate(t,u._groups)}u._update=function(t,e){if(e&&"resize"===e.type){var o=l(window).width();if(o===n)return;n=o}t?-1===a&&(a=setTimeout(function(){i(e),a=-1},u._throttle)):i(e)},l(u._applyDataApi);var t=l.fn.on?"on":"bind";l(window)[t]("load",function(t){u._update(!1,t)}),l(window)[t]("resize orientationchange",function(t){u._update(!0,t)})});

View File

@ -0,0 +1,190 @@
/* global WPMailSMTP, jQuery, wp_mail_smtp_about */
var WPMailSMTP = window.WPMailSMTP || {};
WPMailSMTP.Admin = WPMailSMTP.Admin || {};
/**
* WP Mail SMTP Admin area About module.
*
* @since 1.5.0
*/
WPMailSMTP.Admin.About = WPMailSMTP.Admin.About || (function ( document, window, $ ) {
'use strict';
/**
* Private functions and properties.
*
* @since 1.5.0
*
* @type {Object}
*/
var __private = {};
/**
* Public functions and properties.
*
* @since 1.5.0
*
* @type {Object}
*/
var app = {
/**
* Start the engine. DOM is not ready yet, use only to init something.
*
* @since 1.5.0
*/
init: function () {
// Do that when DOM is ready.
$( document ).ready( app.ready );
},
/**
* DOM is fully loaded.
*
* @since 1.5.0
*/
ready: function () {
app.pageHolder = $( '.wp-mail-smtp-page-about' );
app.bindActions();
$( '.wp-mail-smtp-page' ).trigger( 'WPMailSMTP.Admin.About.ready' );
},
/**
* Process all generic actions/events, mostly custom that were fired by our API.
*
* @since 1.5.0
*/
bindActions: function () {
/*
* Make plugins description the same height.
*/
jQuery('.wp-mail-smtp-admin-about-plugins .plugin-item .details').matchHeight();
/*
* Install/Active the plugins.
*/
$( document ).on( 'click', '.wp-mail-smtp-admin-about-plugins .plugin-item .action-button .button', function( e ) {
e.preventDefault();
var $btn = $( this );
if ( $btn.hasClass( 'disabled' ) || $btn.hasClass( 'loading' ) ) {
return false;
}
var $plugin = $btn.closest( '.plugin-item' ),
plugin = $btn.attr( 'data-plugin' ),
task,
cssClass,
statusText,
buttonText,
errorText,
successText;
$btn.addClass( 'loading disabled' );
$btn.text( wp_mail_smtp_about.plugin_processing );
if ( $btn.hasClass( 'status-inactive' ) ) {
// Activate.
task = 'about_plugin_activate';
cssClass = 'status-active button button-secondary disabled';
statusText = wp_mail_smtp_about.plugin_active;
buttonText = wp_mail_smtp_about.plugin_activated;
errorText = wp_mail_smtp_about.plugin_activate;
} else if ( $btn.hasClass( 'status-download' ) ) {
// Install & Activate.
task = 'about_plugin_install';
cssClass = 'status-active button disabled';
statusText = wp_mail_smtp_about.plugin_active;
buttonText = wp_mail_smtp_about.plugin_activated;
errorText = wp_mail_smtp_about.plugin_activate;
} else {
return;
}
// Setup ajax POST data.
var data = {
action: 'wp_mail_smtp_ajax',
task: task,
nonce : wp_mail_smtp_about.nonce,
plugin: plugin
};
$.post( wp_mail_smtp_about.ajax_url, data, function( res ) {
var is_install_successful;
if ( res.success ) {
is_install_successful = true;
if ( 'about_plugin_install' === task ) {
$btn.attr( 'data-plugin', res.data.basename );
successText = res.data.msg;
if ( ! res.data.is_activated ) {
cssClass = 'button';
statusText = wp_mail_smtp_about.plugin_inactive;
buttonText = wp_mail_smtp_about.plugin_activate;
}
} else {
successText = res.data;
}
$plugin.find( '.actions' ).append( '<div class="msg success">'+successText+'</div>' );
$plugin.find( 'span.status-label' )
.removeClass( 'status-active status-inactive status-download' )
.addClass( cssClass )
.removeClass( 'button button-primary button-secondary disabled' )
.text( statusText );
$btn
.removeClass( 'status-active status-inactive status-download' )
.removeClass( 'button button-primary button-secondary disabled' )
.addClass( cssClass ).html( buttonText );
} else {
is_install_successful = false;
if (
res.hasOwnProperty( 'data' ) &&
res.data.hasOwnProperty( 0 ) &&
res.data[ 0 ].hasOwnProperty( 'code' ) &&
res.data[ 0 ].code === 'download_failed'
) {
// Specific server-returned error.
$plugin.find( '.actions' ).append( '<div class="msg error">' + wp_mail_smtp_about.plugin_install_error + '</div>' );
}
else {
// Generic error.
$plugin.find( '.actions' ).append( '<div class="msg error">' + res.data + '</div>' );
}
$btn.html( wp_mail_smtp_about.plugin_download_btn );
}
if ( ! is_install_successful ) {
$btn.removeClass( 'disabled' );
}
$btn.removeClass( 'loading' );
// Automatically clear plugin messages after 3 seconds.
setTimeout( function () {
$( '.plugin-item .msg' ).remove();
}, 3000 );
}).fail( function( xhr ) {
console.log( xhr.responseText );
});
});
}
};
// Provide access to public functions/properties.
return app;
})( document, window, jQuery );
// Initialize.
WPMailSMTP.Admin.About.init();

View File

@ -0,0 +1 @@
var WPMailSMTP=window.WPMailSMTP||{};WPMailSMTP.Admin=WPMailSMTP.Admin||{},WPMailSMTP.Admin.About=WPMailSMTP.Admin.About||function(a,t,p){"use strict";var i={init:function(){p(a).ready(i.ready)},ready:function(){i.pageHolder=p(".wp-mail-smtp-page-about"),i.bindActions(),p(".wp-mail-smtp-page").trigger("WPMailSMTP.Admin.About.ready")},bindActions:function(){jQuery(".wp-mail-smtp-admin-about-plugins .plugin-item .details").matchHeight(),p(a).on("click",".wp-mail-smtp-admin-about-plugins .plugin-item .action-button .button",function(a){a.preventDefault();var i=p(this);if(i.hasClass("disabled")||i.hasClass("loading"))return!1;var s,n,l,e,o,u=i.closest(".plugin-item"),t=i.attr("data-plugin");if(i.addClass("loading disabled"),i.text(wp_mail_smtp_about.plugin_processing),i.hasClass("status-inactive"))s="about_plugin_activate",n="status-active button button-secondary disabled",l=wp_mail_smtp_about.plugin_active,e=wp_mail_smtp_about.plugin_activated,wp_mail_smtp_about.plugin_activate;else{if(!i.hasClass("status-download"))return;s="about_plugin_install",n="status-active button disabled",l=wp_mail_smtp_about.plugin_active,e=wp_mail_smtp_about.plugin_activated,wp_mail_smtp_about.plugin_activate}var d={action:"wp_mail_smtp_ajax",task:s,nonce:wp_mail_smtp_about.nonce,plugin:t};p.post(wp_mail_smtp_about.ajax_url,d,function(a){var t;a.success?(t=!0,"about_plugin_install"===s?(i.attr("data-plugin",a.data.basename),o=a.data.msg,a.data.is_activated||(n="button",l=wp_mail_smtp_about.plugin_inactive,e=wp_mail_smtp_about.plugin_activate)):o=a.data,u.find(".actions").append('<div class="msg success">'+o+"</div>"),u.find("span.status-label").removeClass("status-active status-inactive status-download").addClass(n).removeClass("button button-primary button-secondary disabled").text(l),i.removeClass("status-active status-inactive status-download").removeClass("button button-primary button-secondary disabled").addClass(n).html(e)):(t=!1,a.hasOwnProperty("data")&&a.data.hasOwnProperty(0)&&a.data[0].hasOwnProperty("code")&&"download_failed"===a.data[0].code?u.find(".actions").append('<div class="msg error">'+wp_mail_smtp_about.plugin_install_error+"</div>"):u.find(".actions").append('<div class="msg error">'+a.data+"</div>"),i.html(wp_mail_smtp_about.plugin_download_btn)),t||i.removeClass("disabled"),i.removeClass("loading"),setTimeout(function(){p(".plugin-item .msg").remove()},3e3)}).fail(function(a){console.log(a.responseText)})})}};return i}(document,window,jQuery),WPMailSMTP.Admin.About.init();

View File

@ -0,0 +1,282 @@
/* globals jQuery, wp_mail_smtp */
var WPMailSMTP = window.WPMailSMTP || {};
WPMailSMTP.Admin = WPMailSMTP.Admin || {};
/**
* WP Mail SMTP Admin area module.
*
* @since 1.6.0
*/
WPMailSMTP.Admin.Settings = WPMailSMTP.Admin.Settings || (function ( document, window, $ ) {
'use strict';
/**
* Private functions and properties.
*
* @since 1.6.0
*
* @type {Object}
*/
var __private = {};
/**
* Public functions and properties.
*
* @since 1.6.0
*
* @type {Object}
*/
var app = {
/**
* State attribute showing if one of the plugin settings
* changed and was not yet saved.
*
* @since {VERSION}
*
* @type {boolean}
*/
pluginSettingsChanged: false,
/**
* Start the engine. DOM is not ready yet, use only to init something.
*
* @since 1.6.0
*/
init: function () {
// Do that when DOM is ready.
$( document ).ready( app.ready );
},
/**
* DOM is fully loaded.
*
* @since 1.6.0
*/
ready: function () {
app.pageHolder = $( '.wp-mail-smtp-tab-settings' );
// If there are screen options we have to move them.
$( '#screen-meta-links, #screen-meta' ).prependTo( '#wp-mail-smtp-header-temp' ).show();
app.bindActions();
},
/**
* Process all generic actions/events, mostly custom that were fired by our API.
*
* @since 1.6.0
*/
bindActions: function () {
// Mailer selection.
$( '.wp-mail-smtp-mailer-image', app.pageHolder ).click( function () {
$( this ).parents( '.wp-mail-smtp-mailer' ).find( 'input' ).trigger( 'click' );
} );
$( '.wp-mail-smtp-mailer input', app.pageHolder ).click( function () {
var $input = $( this );
if ( $input.prop( 'disabled' ) ) {
// Educational Popup.
if ( $input.hasClass( 'educate' ) ) {
app.education.upgradeMailer( $input );
}
return false;
}
// Deselect the current mailer.
$( '.wp-mail-smtp-mailer', app.pageHolder ).removeClass( 'active' );
// Select the correct one.
$( this ).parents( '.wp-mail-smtp-mailer' ).addClass( 'active' );
// Hide all mailers options and display for a currently clicked one.
$( '.wp-mail-smtp-mailer-option', app.pageHolder ).addClass( 'hidden' ).removeClass( 'active' );
$( '.wp-mail-smtp-mailer-option-' + $( this ).val(), app.pageHolder ).addClass( 'active' ).removeClass( 'hidden' );
} );
app.mailers.smtp.bindActions();
// Dismiss Pro banner at the bottom of the page.
$( '#wp-mail-smtp-pro-banner-dismiss', app.pageHolder ).on( 'click', function () {
$.ajax( {
url: ajaxurl,
dataType: 'json',
type: 'POST',
data: {
action: 'wp_mail_smtp_ajax',
task: 'pro_banner_dismiss'
}
} )
.always( function () {
$( '#wp-mail-smtp-pro-banner', app.pageHolder ).fadeOut( 'fast' );
} );
} );
// Dismis educational notices for certain mailers.
$( '.js-wp-mail-smtp-mailer-notice-dismiss', app.pageHolder ).on( 'click', function ( e ) {
e.preventDefault();
var $btn = $( this ),
$notice = $btn.parents( '.inline-notice' );
if ( $btn.hasClass( 'disabled' ) ) {
return false;
}
$.ajax( {
url: ajaxurl,
dataType: 'json',
type: 'POST',
data: {
action: 'wp_mail_smtp_ajax',
task: 'notice_dismiss',
notice: $notice.data( 'notice' ),
mailer: $notice.data( 'mailer' )
},
beforeSend: function () {
$btn.addClass( 'disabled' );
}
} )
.always( function () {
$notice.fadeOut( 'fast', function () {
$btn.removeClass( 'disabled' );
} );
} );
} );
// Show/hide debug output.
$( '#wp-mail-smtp-debug .error-log-toggle' ).on( 'click', function ( e ) {
e.preventDefault();
$( '#wp-mail-smtp-debug .error-log-toggle' ).find( '.dashicons' ).toggleClass( 'dashicons-arrow-right-alt2 dashicons-arrow-down-alt2' );
$( '#wp-mail-smtp-debug .error-log' ).slideToggle();
$( '#wp-mail-smtp-debug .error-log-note' ).toggle();
} );
// Remove mailer connection.
$( '.js-wp-mail-smtp-provider-remove', app.pageHolder ).on( 'click', function () {
return confirm( wp_mail_smtp.text_provider_remove );
} );
// Copy input text to clipboard.
$( '.wp-mail-smtp-setting-copy', app.pageHolder ).click( function ( e ) {
e.preventDefault();
var target = $( '#' + $( this ).data( 'source_id' ) ).get( 0 );
target.select();
document.execCommand( 'Copy' );
} );
app.triggerExitNotice();
},
education: {
upgradeMailer: function ( $input ) {
$.alert( {
backgroundDismiss: true,
escapeKey: true,
animationBounce: 1,
theme: 'modern',
animateFromElement: false,
draggable: false,
closeIcon: true,
useBootstrap: false,
title: wp_mail_smtp.education.upgrade_title.replace( /%name%/g, $input.siblings( 'label' ).text().trim() ),
icon: '"></i>' + wp_mail_smtp.education.upgrade_icon_lock + '<i class="',
content: $( '.wp-mail-smtp-mailer-options .wp-mail-smtp-mailer-option-' + $input.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 () {
window.open( wp_mail_smtp.education.upgrade_url + '&utm_content=' + encodeURI( $input.val() ), '_blank' );
}
}
}
} );
}
},
/**
* Individual mailers specific js code.
*
* @since 1.6.0
*/
mailers: {
smtp: {
bindActions: function () {
// Hide SMTP-specific user/pass when Auth disabled.
$( '#wp-mail-smtp-setting-smtp-auth' ).change( function () {
$( '#wp-mail-smtp-setting-row-smtp-user, #wp-mail-smtp-setting-row-smtp-pass' ).toggleClass( 'inactive' );
} );
// Port default values based on encryption type.
$( '#wp-mail-smtp-setting-row-smtp-encryption input' ).change( function () {
var $input = $( this ),
$smtpPort = $( '#wp-mail-smtp-setting-smtp-port', app.pageHolder );
if ( 'tls' === $input.val() ) {
$smtpPort.val( '587' );
$( '#wp-mail-smtp-setting-row-smtp-autotls' ).addClass( 'inactive' );
}
else if ( 'ssl' === $input.val() ) {
$smtpPort.val( '465' );
$( '#wp-mail-smtp-setting-row-smtp-autotls' ).removeClass( 'inactive' );
}
else {
$smtpPort.val( '25' );
$( '#wp-mail-smtp-setting-row-smtp-autotls' ).removeClass( 'inactive' );
}
} );
}
}
},
/**
* Exit notice JS code when plugin settings are not saved.
*
* @since {VERSION}
*/
triggerExitNotice: function () {
var $settingPages = $( '.wp-mail-smtp-page-general:not( .wp-mail-smtp-tab-test )' );
// Display an exit notice, if settings are not saved.
$( window ).on( 'beforeunload', function () {
if ( app.pluginSettingsChanged ) {
return wp_mail_smtp.text_settings_not_saved;
}
} );
// Set settings changed attribute, if any input was changed.
$( ':input:not( #wp-mail-smtp-setting-license-key )', $settingPages ).on( 'change', function () {
app.pluginSettingsChanged = true;
} );
// Clear the settings changed attribute, if the settings are about to be saved.
$( 'form', $settingPages ).on( 'submit', function () {
app.pluginSettingsChanged = false;
} );
}
};
// Provide access to public functions/properties.
return app;
})( document, window, jQuery );
// Initialize.
WPMailSMTP.Admin.Settings.init();

View File

@ -0,0 +1 @@
var WPMailSMTP=window.WPMailSMTP||{};WPMailSMTP.Admin=WPMailSMTP.Admin||{},WPMailSMTP.Admin.Settings=WPMailSMTP.Admin.Settings||function(i,e,a){"use strict";var n={pluginSettingsChanged:!1,init:function(){a(i).ready(n.ready)},ready:function(){n.pageHolder=a(".wp-mail-smtp-tab-settings"),a("#screen-meta-links, #screen-meta").prependTo("#wp-mail-smtp-header-temp").show(),n.bindActions()},bindActions:function(){a(".wp-mail-smtp-mailer-image",n.pageHolder).click(function(){a(this).parents(".wp-mail-smtp-mailer").find("input").trigger("click")}),a(".wp-mail-smtp-mailer input",n.pageHolder).click(function(){var t=a(this);if(t.prop("disabled"))return t.hasClass("educate")&&n.education.upgradeMailer(t),!1;a(".wp-mail-smtp-mailer",n.pageHolder).removeClass("active"),a(this).parents(".wp-mail-smtp-mailer").addClass("active"),a(".wp-mail-smtp-mailer-option",n.pageHolder).addClass("hidden").removeClass("active"),a(".wp-mail-smtp-mailer-option-"+a(this).val(),n.pageHolder).addClass("active").removeClass("hidden")}),n.mailers.smtp.bindActions(),a("#wp-mail-smtp-pro-banner-dismiss",n.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",n.pageHolder).fadeOut("fast")})}),a(".js-wp-mail-smtp-mailer-notice-dismiss",n.pageHolder).on("click",function(t){t.preventDefault();var i=a(this),e=i.parents(".inline-notice");if(i.hasClass("disabled"))return!1;a.ajax({url:ajaxurl,dataType:"json",type:"POST",data:{action:"wp_mail_smtp_ajax",task:"notice_dismiss",notice:e.data("notice"),mailer:e.data("mailer")},beforeSend:function(){i.addClass("disabled")}}).always(function(){e.fadeOut("fast",function(){i.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",n.pageHolder).on("click",function(){return confirm(wp_mail_smtp.text_provider_remove)}),a(".wp-mail-smtp-setting-copy",n.pageHolder).click(function(t){t.preventDefault(),a("#"+a(this).data("source_id")).get(0).select(),i.execCommand("Copy")}),n.triggerExitNotice()},education:{upgradeMailer:function(t){a.alert({backgroundDismiss:!0,escapeKey:!0,animationBounce:1,theme:"modern",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),i=a("#wp-mail-smtp-setting-smtp-port",n.pageHolder);"tls"===t.val()?(i.val("587"),a("#wp-mail-smtp-setting-row-smtp-autotls").addClass("inactive")):("ssl"===t.val()?i.val("465"):i.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(n.pluginSettingsChanged)return wp_mail_smtp.text_settings_not_saved}),a(":input:not( #wp-mail-smtp-setting-license-key )",t).on("change",function(){n.pluginSettingsChanged=!0}),a("form",t).on("submit",function(){n.pluginSettingsChanged=!1})}};return n}(document,window,jQuery),WPMailSMTP.Admin.Settings.init();