/* globals wp_mail_smtp_connect */
/**
* Connect functionality - Upgrade plugin from Lite to Pro version.
*
* @since 2.6.0
*/
'use strict';
var WPMailSMTPConnect = window.WPMailSMTPConnect || ( function( document, window, $ ) {
/**
* Elements reference.
*
* @since 2.6.0
*
* @type {object}
*/
var el = {
$connectBtn: $( '#wp-mail-smtp-setting-upgrade-license-button' ),
$connectKey: $( '#wp-mail-smtp-setting-upgrade-license-key' )
};
/**
* Public functions and properties.
*
* @since 2.6.0
*
* @type {object}
*/
var app = {
/**
* Start the engine.
*
* @since 2.6.0
*/
init: function() {
$( app.ready );
},
/**
* Document ready.
*
* @since 2.6.0
*/
ready: function() {
app.events();
},
/**
* Register JS events.
*
* @since 2.6.0
*/
events: function() {
app.connectBtnClick();
},
/**
* Register connect button event.
*
* @since 2.6.0
*/
connectBtnClick: function() {
el.$connectBtn.on( 'click', function() {
app.gotoUpgradeUrl();
} );
},
/**
* Get the alert arguments in case of Pro already installed.
*
* @since 2.6.0
*
* @param {object} res Ajax query result object.
*
* @returns {object} Alert arguments.
*/
proAlreadyInstalled: function( res ) {
return {
title: wp_mail_smtp_connect.text.almost_done,
content: res.data.message,
icon: '">