芝麻web文件管理V1.00
' );
this.$body.addClass( 'easy-wp-smtp-upgrade-mailer-education-modal' );
},
buttons: {
confirm: {
text: easy_wp_smtp.education.upgrade_button,
btnClass: 'easy-wp-smtp-btn easy-wp-smtp-btn--green',
keys: [ 'enter' ],
action: function() {
var appendChar = /(\?)/.test( easy_wp_smtp.education.upgrade_url ) ? '&' : '?',
upgradeURL = easy_wp_smtp.education.upgrade_url + appendChar + 'utm_content=' + encodeURIComponent( upgradeUrlUtmContent );
window.open( upgradeURL, '_blank' );
}
}
}
} );
},
upgradeMailer: function( $input ) {
this.upgradeModal(
easy_wp_smtp.education.upgrade_title.replace( /%name%/g, $input.data( 'title' ) ),
easy_wp_smtp.education.upgrade_content.replace( /%name%/g, $input.data( 'title' ) ) + easy_wp_smtp.education.upgrade_bonus,
$input.val()
);
},
rateLimitUpgrade: function() {
this.upgradeModal(
easy_wp_smtp.education.rate_limit.upgrade_title,
easy_wp_smtp.education.rate_limit.upgrade_content + easy_wp_smtp.education.upgrade_bonus,
'rate-limit-setting'
);
},
},
/**
* Individual mailers specific js code.
*
* @since 2.0.0
*/
mailers: {
smtp: {
bindActions: function() {
// Hide SMTP-specific user/pass when Auth disabled.
$( '#easy-wp-smtp-setting-smtp-auth' ).on( 'change', function() {
$( '#easy-wp-smtp-setting-row-smtp-user, #easy-wp-smtp-setting-row-smtp-pass' ).toggleClass( 'easy-wp-smtp-hidden' );
} );
// Port default values based on encryption type.
$( '#easy-wp-smtp-setting-row-smtp-encryption input' ).on( 'change', function() {
var $input = $( this ),
$smtpPort = $( '#easy-wp-smtp-setting-smtp-port', app.settingsForm );
if ( 'tls' === $input.val() ) {
$smtpPort.val( '587' );
$( '#easy-wp-smtp-setting-row-smtp-autotls' ).addClass( 'easy-wp-smtp-hidden' );
} else if ( 'ssl' === $input.val() ) {
$smtpPort.val( '465' );
$( '#easy-wp-smtp-setting-row-smtp-autotls' ).removeClass( 'easy-wp-smtp-hidden' );
} else {
$smtpPort.val( '25' );
$( '#easy-wp-smtp-setting-row-smtp-autotls' ).removeClass( 'easy-wp-smtp-hidden' );
}
} );
}
}
},
/**
* Exit notice JS code when plugin settings are not saved.
*
* @since 2.0.0
*/
triggerExitNotice: function() {
var $settingPages = $( '.easy-wp-smtp-page-general' );
// Display an exit notice, if settings are not saved.
$( window ).on( 'beforeunload', function() {
if ( app.pluginSettingsChanged ) {
return easy_wp_smtp.text_settings_not_saved;
}
} );
// Set settings changed attribute, if any input was changed.
$( ':input:not( #easy-wp-smtp-setting-license-key, .easy-wp-smtp-not-form-input, #easy-wp-smtp-setting-outlook-one_click_setup_enabled )', $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;
} );
},
/**
* Perform any checks before the settings are saved.
*
* Checks:
* - warn users if they try to save the settings with the default (PHP) mailer selected.
*
* @since 2.0.0
*/
beforeSaveChecks: function() {
app.settingsForm.on( 'submit', function() {
if ( $( '.easy-wp-smtp-mailers-picker__input:checked', app.settingsForm ).val() === 'mail' ) {
var $thisForm = $( this );
$.alert( {
backgroundDismiss: false,
escapeKey: false,
animationBounce: 1,
type: 'orange',
icon: app.getModalIcon( 'exclamation-triangle-orange' ),
title: easy_wp_smtp.default_mailer_notice.title,
content: easy_wp_smtp.default_mailer_notice.content,
boxWidth: '550px',
buttons: {
confirm: {
text: easy_wp_smtp.default_mailer_notice.save_button,
btnClass: 'btn-confirm',
keys: [ 'enter' ],
action: function() {
$thisForm.off( 'submit' ).trigger( 'submit' );
}
},
cancel: {
text: easy_wp_smtp.default_mailer_notice.cancel_button,
btnClass: 'btn-cancel',
},
}
} );
return false;
}
} );
},
/**
* On change callback for showing/hiding plugin supported settings for currently selected mailer.
*
* @since 2.0.0
*/
processMailerSettingsOnChange: function() {
var mailerSupportedSettings = easy_wp_smtp.all_mailers_supports[ $( this ).val() ];
for ( var setting in mailerSupportedSettings ) {
// eslint-disable-next-line no-prototype-builtins
if ( mailerSupportedSettings.hasOwnProperty( setting ) ) {
$( '.js-easy-wp-smtp-setting-' + setting, app.settingsForm ).toggle( mailerSupportedSettings[ setting ] );
}
}
// Special case: "from email" (group settings).
var $mainSettingInGroup = $( '.js-easy-wp-smtp-setting-from_email' );
$mainSettingInGroup.closest( '.easy-wp-smtp-setting-row' ).toggle(
mailerSupportedSettings[ 'from_email' ] || mailerSupportedSettings[ 'from_email_force' ]
);
// Special case: "from name" (group settings).
$mainSettingInGroup = $( '.js-easy-wp-smtp-setting-from_name' );
$mainSettingInGroup.closest( '.easy-wp-smtp-setting-row' ).toggle(
mailerSupportedSettings[ 'from_name' ] || mailerSupportedSettings[ 'from_name_force' ]
);
},
/**
* Set jQuery-Confirm default options.
*
* @since 2.0.0
*/
setJQueryConfirmDefaults: function() {
jconfirm.defaults = {
typeAnimated: false,
draggable: false,
animateFromElement: false,
theme: 'modern',
boxWidth: '450px',
useBootstrap: false
};
},
/**
* Display the modal with provided text and icon.
*
* @since 2.0.0
*
* @param {string} message The message to be displayed in the modal.
* @param {string} icon The icon name from /assets/images/icons/ to be used in modal.
* @param {string} type The type of the message (red, green, orange, blue, purple, dark).
* @param {Function} actionCallback The action callback function.
*/
displayAlertModal: function( message, icon, type, actionCallback = undefined ) {
type = type || 'default';
actionCallback = actionCallback || function() {
};
$.alert( {
backgroundDismiss: true,
escapeKey: true,
animationBounce: 1,
type: type,
closeIcon: true,
title: false,
icon: icon ? app.getModalIcon( icon ) : '',
content: message,
buttons: {
confirm: {
text: easy_wp_smtp.ok_text,
btnClass: 'easy-wp-smtp-btn easy-wp-smtp-btn-md',
keys: [ 'enter' ],
action: actionCallback
}
}
} );
},
/**
* Returns prepared modal icon.
*
* @since 2.0.0
*
* @param {string} icon The icon name from /assets/images/icons/ to be used in modal.
*
* @returns {string} Modal icon HTML.
*/
getModalIcon: function( icon ) {
return '">