Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
/* global wpforms_admin, WPFormsFormTemplates, wpforms_admin_form_templates */
|
||||
|
||||
/**
|
||||
* Admin Sub-page Form Templates function.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsAdminFormTemplates = window.WPFormsAdminFormTemplates || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
let app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
$( '.wpforms-form-setup-content' )
|
||||
.on( 'keyup', '#wpforms-setup-template-search', WPFormsFormTemplates.searchTemplate )
|
||||
.on( 'click', '.wpforms-setup-templates-categories li div', WPFormsFormTemplates.selectCategory )
|
||||
.on( 'click', '.wpforms-setup-templates-subcategories li', WPFormsFormTemplates.selectSubCategory )
|
||||
.on( 'click', '.wpforms-template-select', app.selectTemplate )
|
||||
.on( 'click', '.wpforms-trigger-blank', app.selectBlankTemplate );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {object} e Event object.
|
||||
*/
|
||||
selectTemplate: function( e ) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
let $button = $( this ),
|
||||
spinner = '<i class="wpforms-loading-spinner wpforms-loading-white wpforms-loading-inline"></i>';
|
||||
|
||||
// Don't do anything for templates that trigger education modal OR addons-modal.
|
||||
if ( $button.hasClass( 'education-modal' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$( '.wpforms-form-setup-content' ).find( '.wpforms-template' ).removeClass( 'active' );
|
||||
$button.closest( '.wpforms-template' ).addClass( 'active' );
|
||||
|
||||
// Save original label.
|
||||
$button.data( 'labelOriginal', $button.html() );
|
||||
|
||||
// Display loading indicator.
|
||||
$button.html( spinner + wpforms_admin.loading );
|
||||
|
||||
WPFormsFormTemplates.selectTemplateProcess( $button.data( 'template-name-raw' ), $button.data( 'template' ), $button, app.selectTemplateProcessAjax );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select Blank template.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {object} e Event object.
|
||||
*/
|
||||
selectBlankTemplate: function( e ) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
app.selectTemplateProcessAjax( 'Blank Form', 'blank' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template. Create or update form AJAX call.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {string} formName Name of the form.
|
||||
* @param {string} template Template slug.
|
||||
*/
|
||||
selectTemplateProcessAjax: function( formName, template ) {
|
||||
|
||||
let data = {
|
||||
title: formName,
|
||||
action: 'wpforms_new_form',
|
||||
template: template,
|
||||
// eslint-disable-next-line camelcase
|
||||
form_id: 0,
|
||||
nonce: wpforms_admin_form_templates.nonce,
|
||||
};
|
||||
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
|
||||
if ( res.success ) {
|
||||
window.location.href = res.data.redirect;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( res.data.error_type === 'invalid_template' ) {
|
||||
app.selectTemplateProcessInvalidTemplateError( res.data.message, formName );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app.selectTemplateProcessError( res.data.message );
|
||||
} )
|
||||
.fail( function( xhr, textStatus, e ) {
|
||||
|
||||
app.selectTemplateProcessError( '' );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template AJAX call error modal for invalid template using.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {string} errorMessage Error message.
|
||||
* @param {string} formName Name of the form.
|
||||
*/
|
||||
selectTemplateProcessInvalidTemplateError: function( errorMessage, formName ) {
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_admin.heads_up,
|
||||
content: errorMessage,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
boxWidth: '600px',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.use_simple_contact_form,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action: function() {
|
||||
|
||||
app.selectTemplateProcessAjax( formName, 'simple-contact-form-template' );
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
text: wpforms_admin.cancel,
|
||||
action: function() {
|
||||
|
||||
WPFormsFormTemplates.selectTemplateCancel();
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template AJAX call error modal.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {string} error Error message.
|
||||
*/
|
||||
selectTemplateProcessError: function( error ) {
|
||||
|
||||
var content = error && error.length ? '<p>' + error + '</p>' : '';
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_admin.heads_up,
|
||||
content: wpforms_admin.error_select_template + content,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action: function() {
|
||||
|
||||
WPFormsFormTemplates.selectTemplateCancel();
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsAdminFormTemplates.init();
|
1
wp-content/plugins/wpforms-lite/assets/js/components/admin/pages/form-templates.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/js/components/admin/pages/form-templates.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var WPFormsAdminFormTemplates=window.WPFormsAdminFormTemplates||function(a,s){let o={init:function(){s(o.ready)},ready:function(){o.events()},events:function(){s(".wpforms-form-setup-content").on("keyup","#wpforms-setup-template-search",WPFormsFormTemplates.searchTemplate).on("click",".wpforms-setup-templates-categories li div",WPFormsFormTemplates.selectCategory).on("click",".wpforms-setup-templates-subcategories li",WPFormsFormTemplates.selectSubCategory).on("click",".wpforms-template-select",o.selectTemplate).on("click",".wpforms-trigger-blank",o.selectBlankTemplate)},selectTemplate:function(e){e.preventDefault();e=s(this);e.hasClass("education-modal")||(s(".wpforms-form-setup-content").find(".wpforms-template").removeClass("active"),e.closest(".wpforms-template").addClass("active"),e.data("labelOriginal",e.html()),e.html('<i class="wpforms-loading-spinner wpforms-loading-white wpforms-loading-inline"></i>'+wpforms_admin.loading),WPFormsFormTemplates.selectTemplateProcess(e.data("template-name-raw"),e.data("template"),e,o.selectTemplateProcessAjax))},selectBlankTemplate:function(e){e.preventDefault(),o.selectTemplateProcessAjax("Blank Form","blank")},selectTemplateProcessAjax:function(t,e){e={title:t,action:"wpforms_new_form",template:e,form_id:0,nonce:wpforms_admin_form_templates.nonce};s.post(wpforms_admin.ajax_url,e).done(function(e){e.success?a.location.href=e.data.redirect:"invalid_template"===e.data.error_type?o.selectTemplateProcessInvalidTemplateError(e.data.message,t):o.selectTemplateProcessError(e.data.message)}).fail(function(e,t,a){o.selectTemplateProcessError("")})},selectTemplateProcessInvalidTemplateError:function(e,t){s.alert({title:wpforms_admin.heads_up,content:e,icon:"fa fa-exclamation-circle",type:"orange",boxWidth:"600px",buttons:{confirm:{text:wpforms_admin.use_simple_contact_form,btnClass:"btn-confirm",keys:["enter"],action:function(){o.selectTemplateProcessAjax(t,"simple-contact-form-template")}},cancel:{text:wpforms_admin.cancel,action:function(){WPFormsFormTemplates.selectTemplateCancel()}}}})},selectTemplateProcessError:function(e){e=e&&e.length?"<p>"+e+"</p>":"";s.alert({title:wpforms_admin.heads_up,content:wpforms_admin.error_select_template+e,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_admin.ok,btnClass:"btn-confirm",keys:["enter"],action:function(){WPFormsFormTemplates.selectTemplateCancel()}}}})}};return o}((document,window),jQuery);WPFormsAdminFormTemplates.init();
|
@@ -0,0 +1,259 @@
|
||||
/* global wpforms_pluginlanding, wpforms_admin */
|
||||
|
||||
/**
|
||||
* Analytics Sub-page.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsPagesAnalytics = window.WPFormsPagesAnalytics || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Elements.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var el = {};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
app.initVars();
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init variables.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
initVars: function() {
|
||||
|
||||
el = {
|
||||
$stepInstall: $( 'section.step-install' ),
|
||||
$stepInstallNum: $( 'section.step-install .num img' ),
|
||||
$stepSetup: $( 'section.step-setup' ),
|
||||
$stepSetupNum: $( 'section.step-setup .num img' ),
|
||||
$stepAddon: $( 'section.step-addon' ),
|
||||
$stepAddonNum: $( 'section.step-addon .num img' ),
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
// Step 'Install' button click.
|
||||
el.$stepInstall.on( 'click', 'button', app.stepInstallClick );
|
||||
|
||||
// Step 'Setup' button click.
|
||||
el.$stepSetup.on( 'click', 'button', app.gotoURL );
|
||||
|
||||
// Step 'Addon' button click.
|
||||
el.$stepAddon.on( 'click', 'button', app.gotoURL );
|
||||
},
|
||||
|
||||
/**
|
||||
* Step 'Install' button click.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
*/
|
||||
stepInstallClick: function() {
|
||||
|
||||
var $btn = $( this ),
|
||||
action = $btn.attr( 'data-action' ),
|
||||
plugin = $btn.attr( 'data-plugin' ),
|
||||
ajaxAction = '';
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( action ) {
|
||||
case 'activate':
|
||||
ajaxAction = 'wpforms_activate_addon';
|
||||
$btn.text( wpforms_pluginlanding.activating );
|
||||
break;
|
||||
|
||||
case 'install':
|
||||
ajaxAction = 'wpforms_install_addon';
|
||||
$btn.text( wpforms_pluginlanding.installing );
|
||||
break;
|
||||
|
||||
case 'goto-url':
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$btn.addClass( 'disabled' );
|
||||
app.showSpinner( el.$stepInstallNum );
|
||||
|
||||
var data = {
|
||||
action: ajaxAction,
|
||||
nonce : wpforms_admin.nonce,
|
||||
plugin: plugin,
|
||||
type : 'plugin',
|
||||
};
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
app.stepInstallDone( res, $btn, action );
|
||||
} )
|
||||
.always( function() {
|
||||
app.hideSpinner( el.$stepInstallNum );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the step 'Install'.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {object} res Result of $.post() query.
|
||||
* @param {jQuery} $btn Button.
|
||||
* @param {string} action Action (for more info look at the app.stepInstallClick() function).
|
||||
*/
|
||||
stepInstallDone: function( res, $btn, action ) {
|
||||
|
||||
var success = 'install' === action ? res.success && res.data.is_activated : res.success;
|
||||
|
||||
if ( success ) {
|
||||
el.$stepInstallNum.attr( 'src', el.$stepInstallNum.attr( 'src' ).replace( 'step-1.', 'step-complete.' ) );
|
||||
$btn.addClass( 'grey' ).removeClass( 'button-primary' ).text( wpforms_pluginlanding.activated );
|
||||
app.stepInstallPluginStatus();
|
||||
} else {
|
||||
var activationFail = ( 'install' === action && res.success && ! res.data.is_activated ) || 'activate' === action,
|
||||
url = ! activationFail ? wpforms_pluginlanding.mi_manual_install_url : wpforms_pluginlanding.mi_manual_activate_url,
|
||||
msg = ! activationFail ? wpforms_pluginlanding.error_could_not_install : wpforms_pluginlanding.error_could_not_activate,
|
||||
btn = ! activationFail ? wpforms_pluginlanding.download_now : wpforms_pluginlanding.plugins_page;
|
||||
|
||||
$btn.removeClass( 'grey disabled' ).text( btn ).attr( 'data-action', 'goto-url' ).attr( 'data-url', url );
|
||||
$btn.after( '<p class="error">' + msg + '</p>' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
stepInstallPluginStatus: function() {
|
||||
|
||||
var data = {
|
||||
action: 'wpforms_analytics_page_check_plugin_status',
|
||||
nonce : wpforms_admin.nonce,
|
||||
};
|
||||
$.post( wpforms_admin.ajax_url, data ).done( app.stepInstallPluginStatusDone );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {object} res Result of $.post() query.
|
||||
*/
|
||||
stepInstallPluginStatusDone: function( res ) {
|
||||
|
||||
if ( ! res.success ) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.$stepSetup.removeClass( 'grey' );
|
||||
el.$stepSetupBtn = el.$stepSetup.find( 'button' );
|
||||
|
||||
if ( res.data.setup_status > 0 ) {
|
||||
el.$stepSetupNum.attr( 'src', el.$stepSetupNum.attr( 'src' ).replace( 'step-2.svg', 'step-complete.svg' ) );
|
||||
el.$stepAddon.removeClass( 'grey' );
|
||||
el.$stepAddon.find( 'button' ).attr( 'data-url', res.data.step3_button_url ).removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
|
||||
if ( res.data.license_level === 'pro' ) {
|
||||
var buttonText = res.data.addon_installed > 0 ? wpforms_pluginlanding.activate_now : wpforms_pluginlanding.install_now;
|
||||
el.$stepAddon.find( 'button' ).text( buttonText );
|
||||
}
|
||||
} else {
|
||||
el.$stepSetupBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Go to URL by click on the button.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
gotoURL: function() {
|
||||
|
||||
var $btn = $( this );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Display spinner.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {jQuery} $el Section number image jQuery object.
|
||||
*/
|
||||
showSpinner: function( $el ) {
|
||||
|
||||
$el.siblings( '.loader' ).removeClass( 'hidden' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide spinner.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {jQuery} $el Section number image jQuery object.
|
||||
*/
|
||||
hideSpinner: function( $el ) {
|
||||
|
||||
$el.siblings( '.loader' ).addClass( 'hidden' );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsPagesAnalytics.init();
|
1
wp-content/plugins/wpforms-lite/assets/js/components/admin/pages/mi-analytics.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/js/components/admin/pages/mi-analytics.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var WPFormsPagesAnalytics=window.WPFormsPagesAnalytics||function(e,l){var i={},o={init:function(){l(o.ready)},ready:function(){o.initVars(),o.events()},initVars:function(){i={$stepInstall:l("section.step-install"),$stepInstallNum:l("section.step-install .num img"),$stepSetup:l("section.step-setup"),$stepSetupNum:l("section.step-setup .num img"),$stepAddon:l("section.step-addon"),$stepAddonNum:l("section.step-addon .num img")}},events:function(){i.$stepInstall.on("click","button",o.stepInstallClick),i.$stepSetup.on("click","button",o.gotoURL),i.$stepAddon.on("click","button",o.gotoURL)},stepInstallClick:function(){var n=l(this),s=n.attr("data-action"),t=n.attr("data-plugin"),a="";if(!n.hasClass("disabled")){switch(s){case"activate":a="wpforms_activate_addon",n.text(wpforms_pluginlanding.activating);break;case"install":a="wpforms_install_addon",n.text(wpforms_pluginlanding.installing);break;case"goto-url":return void(e.location.href=n.attr("data-url"));default:return}n.addClass("disabled"),o.showSpinner(i.$stepInstallNum);t={action:a,nonce:wpforms_admin.nonce,plugin:t,type:"plugin"};l.post(wpforms_admin.ajax_url,t).done(function(t){o.stepInstallDone(t,n,s)}).always(function(){o.hideSpinner(i.$stepInstallNum)})}},stepInstallDone:function(t,n,s){var a;("install"===s?t.success&&t.data.is_activated:t.success)?(i.$stepInstallNum.attr("src",i.$stepInstallNum.attr("src").replace("step-1.","step-complete.")),n.addClass("grey").removeClass("button-primary").text(wpforms_pluginlanding.activated),o.stepInstallPluginStatus()):(s=(t="install"===s&&t.success&&!t.data.is_activated||"activate"===s)?wpforms_pluginlanding.mi_manual_activate_url:wpforms_pluginlanding.mi_manual_install_url,a=t?wpforms_pluginlanding.error_could_not_activate:wpforms_pluginlanding.error_could_not_install,t=t?wpforms_pluginlanding.plugins_page:wpforms_pluginlanding.download_now,n.removeClass("grey disabled").text(t).attr("data-action","goto-url").attr("data-url",s),n.after('<p class="error">'+a+"</p>"))},stepInstallPluginStatus:function(){var t={action:"wpforms_analytics_page_check_plugin_status",nonce:wpforms_admin.nonce};l.post(wpforms_admin.ajax_url,t).done(o.stepInstallPluginStatusDone)},stepInstallPluginStatusDone:function(t){t.success&&(i.$stepSetup.removeClass("grey"),i.$stepSetupBtn=i.$stepSetup.find("button"),0<t.data.setup_status?(i.$stepSetupNum.attr("src",i.$stepSetupNum.attr("src").replace("step-2.svg","step-complete.svg")),i.$stepAddon.removeClass("grey"),i.$stepAddon.find("button").attr("data-url",t.data.step3_button_url).removeClass("grey disabled").addClass("button-primary"),"pro"===t.data.license_level&&(t=0<t.data.addon_installed?wpforms_pluginlanding.activate_now:wpforms_pluginlanding.install_now,i.$stepAddon.find("button").text(t))):i.$stepSetupBtn.removeClass("grey disabled").addClass("button-primary"))},gotoURL:function(){var t=l(this);t.hasClass("disabled")||(e.location.href=t.attr("data-url"))},showSpinner:function(t){t.siblings(".loader").removeClass("hidden")},hideSpinner:function(t){t.siblings(".loader").addClass("hidden")}};return o}((document,window),jQuery);WPFormsPagesAnalytics.init();
|
@@ -0,0 +1,254 @@
|
||||
/* global wpforms_pluginlanding, wpforms_admin */
|
||||
|
||||
/**
|
||||
* SMTP Sub-page.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsPagesSMTP = window.WPFormsPagesSMTP || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Elements.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var el = {};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
app.initVars();
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init variables.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
initVars: function() {
|
||||
|
||||
el = {
|
||||
$stepInstall: $( 'section.step-install' ),
|
||||
$stepInstallNum: $( 'section.step-install .num img' ),
|
||||
$stepSetup: $( 'section.step-setup' ),
|
||||
$stepSetupNum: $( 'section.step-setup .num img' ),
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
// Step 'Install' button click.
|
||||
el.$stepInstall.on( 'click', 'button', app.stepInstallClick );
|
||||
|
||||
// Step 'Setup' button click.
|
||||
el.$stepSetup.on( 'click', 'button', app.gotoURL );
|
||||
},
|
||||
|
||||
/**
|
||||
* Step 'Install' button click.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
stepInstallClick: function() {
|
||||
|
||||
var $btn = $( this ),
|
||||
action = $btn.attr( 'data-action' ),
|
||||
plugin = $btn.attr( 'data-plugin' ),
|
||||
ajaxAction = '';
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( action ) {
|
||||
case 'activate':
|
||||
ajaxAction = 'wpforms_activate_addon';
|
||||
$btn.text( wpforms_pluginlanding.activating );
|
||||
break;
|
||||
|
||||
case 'install':
|
||||
ajaxAction = 'wpforms_install_addon';
|
||||
$btn.text( wpforms_pluginlanding.installing );
|
||||
break;
|
||||
|
||||
case 'goto-url':
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$btn.addClass( 'disabled' );
|
||||
app.showSpinner( el.$stepInstallNum );
|
||||
|
||||
var data = {
|
||||
action: ajaxAction,
|
||||
nonce : wpforms_admin.nonce,
|
||||
plugin: plugin,
|
||||
type : 'plugin',
|
||||
};
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
app.stepInstallDone( res, $btn, action );
|
||||
} )
|
||||
.always( function() {
|
||||
app.hideSpinner( el.$stepInstallNum );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the 'Install' step.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {object} res Result of $.post() query.
|
||||
* @param {jQuery} $btn Button.
|
||||
* @param {string} action Action (for more info look at the app.stepInstallClick() function).
|
||||
*/
|
||||
stepInstallDone: function( res, $btn, action ) {
|
||||
|
||||
var success = 'install' === action ? res.success && res.data.is_activated : res.success;
|
||||
|
||||
if ( success ) {
|
||||
el.$stepInstallNum.attr( 'src', el.$stepInstallNum.attr( 'src' ).replace( 'step-1.', 'step-complete.' ) );
|
||||
$btn.addClass( 'grey' ).removeClass( 'button-primary' ).text( wpforms_pluginlanding.activated );
|
||||
app.stepInstallPluginStatus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var activationFail = ( 'install' === action && res.success && ! res.data.is_activated ) || 'activate' === action,
|
||||
url = ! activationFail ? wpforms_pluginlanding.manual_install_url : wpforms_pluginlanding.manual_activate_url,
|
||||
msg = ! activationFail ? wpforms_pluginlanding.error_could_not_install : wpforms_pluginlanding.error_could_not_activate,
|
||||
btn = ! activationFail ? wpforms_pluginlanding.download_now : wpforms_pluginlanding.plugins_page;
|
||||
|
||||
$btn.removeClass( 'grey disabled' ).text( btn ).attr( 'data-action', 'goto-url' ).attr( 'data-url', url );
|
||||
$btn.after( '<p class="error">' + msg + '</p>' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
stepInstallPluginStatus: function() {
|
||||
|
||||
var data = {
|
||||
action: 'wpforms_smtp_page_check_plugin_status',
|
||||
nonce : wpforms_admin.nonce,
|
||||
};
|
||||
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( app.stepInstallPluginStatusDone );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {object} res Result of $.post() query.
|
||||
*/
|
||||
stepInstallPluginStatusDone: function( res ) {
|
||||
|
||||
if ( ! res.success ) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.$stepSetup.removeClass( 'grey' );
|
||||
el.$stepSetupBtn = el.$stepSetup.find( 'button' );
|
||||
el.$stepSetupBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
|
||||
if ( res.data.setup_status > 0 ) {
|
||||
el.$stepSetupNum.attr( 'src', el.$stepSetupNum.attr( 'src' ).replace( 'step-2.svg', 'step-complete.svg' ) );
|
||||
el.$stepSetupBtn.attr( 'data-url', wpforms_pluginlanding.smtp_settings_url ).text( wpforms_pluginlanding.smtp_settings );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
el.$stepSetupBtn.attr( 'data-url', wpforms_pluginlanding.smtp_wizard_url ).text( wpforms_pluginlanding.smtp_wizard );
|
||||
},
|
||||
|
||||
/**
|
||||
* Go to URL by click on the button.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
gotoURL: function() {
|
||||
|
||||
var $btn = $( this );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Display spinner.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {jQuery} $el Section number image jQuery object.
|
||||
*/
|
||||
showSpinner: function( $el ) {
|
||||
|
||||
$el.siblings( '.loader' ).removeClass( 'hidden' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide spinner.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {jQuery} $el Section number image jQuery object.
|
||||
*/
|
||||
hideSpinner: function( $el ) {
|
||||
|
||||
$el.siblings( '.loader' ).addClass( 'hidden' );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsPagesSMTP.init();
|
1
wp-content/plugins/wpforms-lite/assets/js/components/admin/pages/smtp.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/js/components/admin/pages/smtp.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var WPFormsPagesSMTP=window.WPFormsPagesSMTP||function(e,l){var i={},p={init:function(){l(p.ready)},ready:function(){p.initVars(),p.events()},initVars:function(){i={$stepInstall:l("section.step-install"),$stepInstallNum:l("section.step-install .num img"),$stepSetup:l("section.step-setup"),$stepSetupNum:l("section.step-setup .num img")}},events:function(){i.$stepInstall.on("click","button",p.stepInstallClick),i.$stepSetup.on("click","button",p.gotoURL)},stepInstallClick:function(){var s=l(this),n=s.attr("data-action"),t=s.attr("data-plugin"),a="";if(!s.hasClass("disabled")){switch(n){case"activate":a="wpforms_activate_addon",s.text(wpforms_pluginlanding.activating);break;case"install":a="wpforms_install_addon",s.text(wpforms_pluginlanding.installing);break;case"goto-url":return void(e.location.href=s.attr("data-url"));default:return}s.addClass("disabled"),p.showSpinner(i.$stepInstallNum);t={action:a,nonce:wpforms_admin.nonce,plugin:t,type:"plugin"};l.post(wpforms_admin.ajax_url,t).done(function(t){p.stepInstallDone(t,s,n)}).always(function(){p.hideSpinner(i.$stepInstallNum)})}},stepInstallDone:function(t,s,n){var a;("install"===n?t.success&&t.data.is_activated:t.success)?(i.$stepInstallNum.attr("src",i.$stepInstallNum.attr("src").replace("step-1.","step-complete.")),s.addClass("grey").removeClass("button-primary").text(wpforms_pluginlanding.activated),p.stepInstallPluginStatus()):(n=(t="install"===n&&t.success&&!t.data.is_activated||"activate"===n)?wpforms_pluginlanding.manual_activate_url:wpforms_pluginlanding.manual_install_url,a=t?wpforms_pluginlanding.error_could_not_activate:wpforms_pluginlanding.error_could_not_install,t=t?wpforms_pluginlanding.plugins_page:wpforms_pluginlanding.download_now,s.removeClass("grey disabled").text(t).attr("data-action","goto-url").attr("data-url",n),s.after('<p class="error">'+a+"</p>"))},stepInstallPluginStatus:function(){var t={action:"wpforms_smtp_page_check_plugin_status",nonce:wpforms_admin.nonce};l.post(wpforms_admin.ajax_url,t).done(p.stepInstallPluginStatusDone)},stepInstallPluginStatusDone:function(t){t.success&&(i.$stepSetup.removeClass("grey"),i.$stepSetupBtn=i.$stepSetup.find("button"),i.$stepSetupBtn.removeClass("grey disabled").addClass("button-primary"),0<t.data.setup_status?(i.$stepSetupNum.attr("src",i.$stepSetupNum.attr("src").replace("step-2.svg","step-complete.svg")),i.$stepSetupBtn.attr("data-url",wpforms_pluginlanding.smtp_settings_url).text(wpforms_pluginlanding.smtp_settings)):i.$stepSetupBtn.attr("data-url",wpforms_pluginlanding.smtp_wizard_url).text(wpforms_pluginlanding.smtp_wizard))},gotoURL:function(){var t=l(this);t.hasClass("disabled")||(e.location.href=t.attr("data-url"))},showSpinner:function(t){t.siblings(".loader").removeClass("hidden")},hideSpinner:function(t){t.siblings(".loader").addClass("hidden")}};return p}((document,window),jQuery);WPFormsPagesSMTP.init();
|
Reference in New Issue
Block a user