first commit
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
/* global wpforms_builder, wpforms_education */
|
||||
/**
|
||||
* WPForms Education core for Lite.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsEducation = window.WPFormsEducation || {};
|
||||
|
||||
WPFormsEducation.liteCore = window.WPFormsEducation.liteCore || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
app.openModalButtonClick();
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers click events that should open upgrade modal.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
openModalButtonClick: function() {
|
||||
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.education-modal',
|
||||
function( event ) {
|
||||
|
||||
var $this = $( this ),
|
||||
name = $this.data( 'name' ),
|
||||
utmContent = WPFormsEducation.core.getUTMContentValue( $this );
|
||||
|
||||
if ( $this.data( 'action' ) && [ 'activate', 'install' ].includes( $this.data( 'action' ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
if ( $this.hasClass( 'wpforms-add-fields-button' ) ) {
|
||||
name = $this.text();
|
||||
name += name.indexOf( wpforms_builder.field ) < 0 ? ' ' + wpforms_builder.field : '';
|
||||
}
|
||||
|
||||
app.upgradeModal( name, utmContent, $this.data( 'license' ), $this.data( 'video' ) );
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Upgrade modal.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*
|
||||
* @param {string} feature Feature name.
|
||||
* @param {string} utmContent UTM content.
|
||||
* @param {string} type Feature license type: pro or elite.
|
||||
* @param {string} video Feature video URL.
|
||||
*/
|
||||
upgradeModal: function( feature, utmContent, type, video ) {
|
||||
|
||||
// Provide a default value.
|
||||
if ( typeof type === 'undefined' || type.length === 0 ) {
|
||||
type = 'pro';
|
||||
}
|
||||
|
||||
// Make sure we received only supported type.
|
||||
if ( $.inArray( type, [ 'pro', 'elite' ] ) < 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var message = wpforms_education.upgrade[ type ].message.replace( /%name%/g, feature );
|
||||
|
||||
$.alert( {
|
||||
title: feature + ' ' + wpforms_education.upgrade[type].title,
|
||||
icon: 'fa fa-lock',
|
||||
content: message,
|
||||
boxWidth: '550px',
|
||||
theme: 'modern,wpforms-education',
|
||||
closeIcon: true,
|
||||
onOpenBefore: function() {
|
||||
|
||||
var videoHtml = ! _.isEmpty( video ) ? '<iframe src="' + video + '" class="feature-video" frameborder="0" allowfullscreen="" width="490" height="276"></iframe>' : '';
|
||||
|
||||
this.$btnc.after( '<div class="discount-note">' + wpforms_education.upgrade_bonus + videoHtml + wpforms_education.upgrade[type].doc + '</div>' );
|
||||
this.$body.find( '.jconfirm-content' ).addClass( 'lite-upgrade' );
|
||||
},
|
||||
buttons : {
|
||||
confirm: {
|
||||
text : wpforms_education.upgrade[type].button,
|
||||
btnClass: 'btn-confirm',
|
||||
keys : [ 'enter' ],
|
||||
action: function() {
|
||||
|
||||
window.open( WPFormsEducation.core.getUpgradeURL( utmContent, type ), '_blank' );
|
||||
app.upgradeModalThankYou( type );
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Upgrade modal second state.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*
|
||||
* @param {string} type Feature license type: pro or elite.
|
||||
*/
|
||||
upgradeModalThankYou: function( type ) {
|
||||
|
||||
$.alert( {
|
||||
title : false,
|
||||
content : wpforms_education.upgrade[type].modal,
|
||||
icon : 'fa fa-info-circle',
|
||||
type : 'blue',
|
||||
boxWidth: '565px',
|
||||
buttons : {
|
||||
confirm: {
|
||||
text : wpforms_education.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys : [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsEducation.liteCore.init();
|
||||
1
wp-content/plugins/wpforms-lite/lite/assets/js/admin/education/core.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/lite/assets/js/admin/education/core.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var WPFormsEducation=window.WPFormsEducation||{};WPFormsEducation.liteCore=window.WPFormsEducation.liteCore||function(t,i,r){var d={init:function(){r(d.ready)},ready:function(){d.events()},events:function(){d.openModalButtonClick()},openModalButtonClick:function(){r(t).on("click",".education-modal",function(t){var o=r(this),e=o.data("name"),n=WPFormsEducation.core.getUTMContentValue(o);o.data("action")&&["activate","install"].includes(o.data("action"))||(t.preventDefault(),t.stopImmediatePropagation(),o.hasClass("wpforms-add-fields-button")&&(e=o.text(),e+=e.indexOf(wpforms_builder.field)<0?" "+wpforms_builder.field:""),d.upgradeModal(e,n,o.data("license"),o.data("video")))})},upgradeModal:function(t,o,e,n){var a;void 0!==e&&0!==e.length||(e="pro"),r.inArray(e,["pro","elite"])<0||(a=wpforms_education.upgrade[e].message.replace(/%name%/g,t),r.alert({title:t+" "+wpforms_education.upgrade[e].title,icon:"fa fa-lock",content:a,boxWidth:"550px",theme:"modern,wpforms-education",closeIcon:!0,onOpenBefore:function(){var t=_.isEmpty(n)?"":'<iframe src="'+n+'" class="feature-video" frameborder="0" allowfullscreen="" width="490" height="276"></iframe>';this.$btnc.after('<div class="discount-note">'+wpforms_education.upgrade_bonus+t+wpforms_education.upgrade[e].doc+"</div>"),this.$body.find(".jconfirm-content").addClass("lite-upgrade")},buttons:{confirm:{text:wpforms_education.upgrade[e].button,btnClass:"btn-confirm",keys:["enter"],action:function(){i.open(WPFormsEducation.core.getUpgradeURL(o,e),"_blank"),d.upgradeModalThankYou(e)}}}}))},upgradeModalThankYou:function(t){r.alert({title:!1,content:wpforms_education.upgrade[t].modal,icon:"fa fa-info-circle",type:"blue",boxWidth:"565px",buttons:{confirm:{text:wpforms_education.ok,btnClass:"btn-confirm",keys:["enter"]}}})}};return d}(document,window,jQuery),WPFormsEducation.liteCore.init();
|
||||
Reference in New Issue
Block a user