Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
/* global wpforms_builder_lite, wpforms_builder */
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsBuilderLite = window.WPFormsBuilderLite || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
// Document ready
|
||||
$( app.ready() );
|
||||
|
||||
app.bindUIActions();
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
ready: function() {},
|
||||
|
||||
/**
|
||||
* Element bindings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
bindUIActions: function() {
|
||||
|
||||
// Warn users if they disable email notifications.
|
||||
$( document ).on( 'change', '#wpforms-panel-field-settings-notification_enable', function() {
|
||||
|
||||
app.formBuilderNotificationAlert( $( this ).is( ':checked' ) );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Warn users if they disable email notifications.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param {bool} value Whether notifications enabled or not. 0 is disabled, 1 is enabled.
|
||||
*/
|
||||
formBuilderNotificationAlert: function( value ) {
|
||||
|
||||
if ( value !== false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_builder.heads_up,
|
||||
content: wpforms_builder_lite.disable_notifications,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_builder.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
WPFormsBuilderLite.init();
|
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin-builder-lite.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin-builder-lite.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var WPFormsBuilderLite=window.WPFormsBuilderLite||function(i,t){var n={init:function(){t(n.ready()),n.bindUIActions()},ready:function(){},bindUIActions:function(){t(i).on("change","#wpforms-panel-field-settings-notification_enable",function(){n.formBuilderNotificationAlert(t(this).is(":checked"))})},formBuilderNotificationAlert:function(i){!1===i&&t.alert({title:wpforms_builder.heads_up,content:wpforms_builder_lite.disable_notifications,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}})}};return n}(document,(window,jQuery));WPFormsBuilderLite.init();
|
181
wp-content/plugins/wpforms-lite/assets/lite/js/admin/connect.js
Normal file
181
wp-content/plugins/wpforms-lite/assets/lite/js/admin/connect.js
Normal file
@@ -0,0 +1,181 @@
|
||||
/* global wpforms_admin */
|
||||
/**
|
||||
* Connect functionality.
|
||||
*
|
||||
* @since 1.5.4
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsConnect = window.WPFormsConnect || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Elements reference.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var el = {
|
||||
$connectBtn: $( '#wpforms-settings-connect-btn' ),
|
||||
$connectKey: $( '#wpforms-settings-upgrade-license-key' ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
app.connectBtnClick();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register connect button event.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
connectBtnClick: function() {
|
||||
el.$connectBtn.on( 'click', function( event ) {
|
||||
event.preventDefault();
|
||||
app.gotoUpgradeUrl();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the alert arguments in case of Pro already installed.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @param {object} res Ajax query result object.
|
||||
*
|
||||
* @returns {object} Alert arguments.
|
||||
*/
|
||||
proAlreadyInstalled: function( res ) {
|
||||
|
||||
var buttons = {
|
||||
confirm: {
|
||||
text: wpforms_admin.plugin_activate_btn,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action: function() {
|
||||
window.location.reload();
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
title: wpforms_admin.almost_done,
|
||||
content: res.data.message,
|
||||
icon: 'fa fa-check-circle',
|
||||
type: 'green',
|
||||
buttons: buttons,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Go to upgrade url.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
gotoUpgradeUrl: function() {
|
||||
|
||||
var data = {
|
||||
action: 'wpforms_connect_url',
|
||||
key: el.$connectKey.val(),
|
||||
nonce: wpforms_admin.nonce,
|
||||
};
|
||||
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
|
||||
if ( res.success ) {
|
||||
if ( res.data.reload ) {
|
||||
$.alert( app.proAlreadyInstalled( res ) );
|
||||
return;
|
||||
}
|
||||
window.location.href = res.data.url;
|
||||
return;
|
||||
}
|
||||
$.alert( {
|
||||
title: wpforms_admin.oops,
|
||||
content: res.data.message,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
} )
|
||||
.fail( function( xhr ) {
|
||||
|
||||
app.failAlert( xhr );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Alert in case of server error.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @param {object} xhr XHR object.
|
||||
*/
|
||||
failAlert: function( xhr ) {
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_admin.oops,
|
||||
content: wpforms_admin.server_error + '<br>' + xhr.status + ' ' + xhr.statusText + ' ' + xhr.responseText,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsConnect.init();
|
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/connect.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/connect.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var WPFormsConnect=window.WPFormsConnect||function(e,t){var o={$connectBtn:t("#wpforms-settings-connect-btn"),$connectKey:t("#wpforms-settings-upgrade-license-key")},r={init:function(){t(r.ready)},ready:function(){r.events()},events:function(){r.connectBtnClick()},connectBtnClick:function(){o.$connectBtn.on("click",function(n){n.preventDefault(),r.gotoUpgradeUrl()})},proAlreadyInstalled:function(n){var t={confirm:{text:wpforms_admin.plugin_activate_btn,btnClass:"btn-confirm",keys:["enter"],action:function(){e.location.reload()}}};return{title:wpforms_admin.almost_done,content:n.data.message,icon:"fa fa-check-circle",type:"green",buttons:t}},gotoUpgradeUrl:function(){var n={action:"wpforms_connect_url",key:o.$connectKey.val(),nonce:wpforms_admin.nonce};t.post(wpforms_admin.ajax_url,n).done(function(n){if(n.success)return n.data.reload?void t.alert(r.proAlreadyInstalled(n)):void(e.location.href=n.data.url);t.alert({title:wpforms_admin.oops,content:n.data.message,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_admin.ok,btnClass:"btn-confirm",keys:["enter"]}}})}).fail(function(n){r.failAlert(n)})},failAlert:function(n){t.alert({title:wpforms_admin.oops,content:wpforms_admin.server_error+"<br>"+n.status+" "+n.statusText+" "+n.responseText,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_admin.ok,btnClass:"btn-confirm",keys:["enter"]}}})}};return r}((document,window),jQuery);WPFormsConnect.init();
|
@@ -0,0 +1,339 @@
|
||||
/* global wpforms_dashboard_widget, moment, Chart, ajaxurl */
|
||||
/**
|
||||
* WPForms Dashboard Widget function.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsDashboardWidget = window.WPFormsDashboardWidget || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Elements reference.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var el = {
|
||||
$widget: $( '#wpforms_reports_widget_lite' ),
|
||||
$settingsBtn: $( '#wpforms-dash-widget-settings-button' ),
|
||||
$canvas: $( '#wpforms-dash-widget-chart' ),
|
||||
$dismissBtn: $( '.wpforms-dash-widget-dismiss-chart-upgrade' ),
|
||||
$recomBlockDismissBtn: $( '#wpforms-dash-widget-dismiss-recommended-plugin-block' ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Chart.js functions and properties.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var chart = {
|
||||
|
||||
/**
|
||||
* Chart.js instance.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
instance: null,
|
||||
|
||||
/**
|
||||
* Chart.js settings.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
settings: {
|
||||
type : 'line',
|
||||
data : {
|
||||
labels : [],
|
||||
datasets: [ {
|
||||
label : wpforms_dashboard_widget.i18n.entries,
|
||||
data : [],
|
||||
backgroundColor : 'rgba(255, 129, 0, 0.135)',
|
||||
borderColor : 'rgba(211, 126, 71, 1)',
|
||||
borderWidth : 2,
|
||||
pointRadius : 4,
|
||||
pointBorderWidth : 1,
|
||||
pointBackgroundColor: 'rgba(255, 255, 255, 1)',
|
||||
} ],
|
||||
},
|
||||
options: {
|
||||
scales : {
|
||||
xAxes: [ {
|
||||
type : 'time',
|
||||
time : {
|
||||
unit: 'day',
|
||||
},
|
||||
distribution: 'series',
|
||||
ticks : {
|
||||
beginAtZero: true,
|
||||
source : 'labels',
|
||||
padding : 10,
|
||||
minRotation: 25,
|
||||
maxRotation: 25,
|
||||
callback : function( value, index, values ) {
|
||||
|
||||
// Distribute the ticks equally starting from a right side of xAxis.
|
||||
var gap = Math.floor( values.length / 7 );
|
||||
|
||||
if ( gap < 1 ) {
|
||||
return value;
|
||||
}
|
||||
if ( ( values.length - index - 1 ) % gap === 0 ) {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
},
|
||||
} ],
|
||||
yAxes: [ {
|
||||
ticks: {
|
||||
beginAtZero : true,
|
||||
maxTicksLimit: 6,
|
||||
padding : 20,
|
||||
callback : function( value ) {
|
||||
|
||||
// Make sure the tick value has no decimals.
|
||||
if ( Math.floor( value ) === value ) {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
},
|
||||
} ],
|
||||
},
|
||||
elements : {
|
||||
line: {
|
||||
tension: 0,
|
||||
},
|
||||
},
|
||||
animation : {
|
||||
duration: 0,
|
||||
},
|
||||
hover : {
|
||||
animationDuration: 0,
|
||||
},
|
||||
legend : {
|
||||
display: false,
|
||||
},
|
||||
tooltips : {
|
||||
displayColors: false,
|
||||
},
|
||||
responsiveAnimationDuration: 0,
|
||||
maintainAspectRatio: false,
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Init Chart.js.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
var ctx;
|
||||
|
||||
if ( ! el.$canvas.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = el.$canvas[ 0 ].getContext( '2d' );
|
||||
|
||||
chart.instance = new Chart( ctx, chart.settings );
|
||||
|
||||
chart.updateUI();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update Chart.js canvas.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
updateUI: function() {
|
||||
|
||||
chart.updateWithDummyData();
|
||||
|
||||
chart.instance.data.labels = chart.settings.data.labels;
|
||||
chart.instance.data.datasets[ 0 ].data = chart.settings.data.datasets[ 0 ].data;
|
||||
|
||||
chart.instance.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update Chart.js settings with dummy data.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
updateWithDummyData: function() {
|
||||
|
||||
var end = moment().endOf( 'day' );
|
||||
var date;
|
||||
|
||||
var minY = 5;
|
||||
var maxY = 20;
|
||||
var i;
|
||||
|
||||
for ( i = 1; i <= 7; i++ ) {
|
||||
|
||||
date = end.clone().subtract( i, 'days' );
|
||||
|
||||
chart.settings.data.labels.push( date );
|
||||
chart.settings.data.datasets[ 0 ].data.push( {
|
||||
t: date,
|
||||
y: Math.floor( Math.random() * ( maxY - minY + 1 ) ) + minY,
|
||||
} );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
chart.init();
|
||||
app.events();
|
||||
app.graphSettings();
|
||||
},
|
||||
|
||||
/**
|
||||
* Graph settings related events.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
graphSettings: function() {
|
||||
|
||||
el.$settingsBtn.on( 'click', function() {
|
||||
|
||||
$( this ).siblings( '.wpforms-dash-widget-settings-menu' ).toggle();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
app.formsListEvents();
|
||||
app.handleChartClose();
|
||||
app.handleRecommendedPluginsClose();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register forms list area JS events.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
formsListEvents: function() {
|
||||
|
||||
el.$widget.on( 'click', '#wpforms-dash-widget-forms-more', function() {
|
||||
|
||||
app.toggleCompleteFormsList();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle chart close.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
handleChartClose: function() {
|
||||
|
||||
el.$dismissBtn.on( 'click', function( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
app.saveWidgetMeta( 'hide_graph', 1 );
|
||||
$( '.wpforms-dash-widget.wpforms-lite' ).addClass( 'wpforms-dash-widget-no-graph' );
|
||||
$( this ).closest( '.wpforms-dash-widget-chart-block-container' ).remove();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle recommended plugins block close.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
handleRecommendedPluginsClose: function() {
|
||||
|
||||
el.$recomBlockDismissBtn.on( 'click', function() {
|
||||
app.dismissRecommendedBlock();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Save dashboard widget meta on a backend.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {string} meta Meta name to save.
|
||||
* @param {number} value Value to save.
|
||||
*/
|
||||
saveWidgetMeta: function( meta, value ) {
|
||||
|
||||
const data = {
|
||||
_wpnonce: wpforms_dashboard_widget.nonce,
|
||||
action : 'wpforms_' + wpforms_dashboard_widget.slug + '_save_widget_meta',
|
||||
meta : meta,
|
||||
value : value,
|
||||
};
|
||||
|
||||
$.post( ajaxurl, data );
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle forms list hidden entries.
|
||||
*
|
||||
* @since 1.5.0.4
|
||||
*/
|
||||
toggleCompleteFormsList: function() {
|
||||
|
||||
$( '#wpforms-dash-widget-forms-list-table .wpforms-dash-widget-forms-list-hidden-el' ).toggle();
|
||||
$( '#wpforms-dash-widget-forms-more' ).html( function( i, html ) {
|
||||
|
||||
return html === wpforms_dashboard_widget.show_less_html ? wpforms_dashboard_widget.show_more_html : wpforms_dashboard_widget.show_less_html;
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Dismiss recommended plugin block.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
dismissRecommendedBlock: function() {
|
||||
|
||||
$( '.wpforms-dash-widget-recommended-plugin-block' ).remove();
|
||||
app.saveWidgetMeta( 'hide_recommended_block', 1 );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsDashboardWidget.init();
|
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/dashboard-widget.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/dashboard-widget.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var WPFormsDashboardWidget=window.WPFormsDashboardWidget||function(s){var e={$widget:s("#wpforms_reports_widget_lite"),$settingsBtn:s("#wpforms-dash-widget-settings-button"),$canvas:s("#wpforms-dash-widget-chart"),$dismissBtn:s(".wpforms-dash-widget-dismiss-chart-upgrade"),$recomBlockDismissBtn:s("#wpforms-dash-widget-dismiss-recommended-plugin-block")},i={instance:null,settings:{type:"line",data:{labels:[],datasets:[{label:wpforms_dashboard_widget.i18n.entries,data:[],backgroundColor:"rgba(255, 129, 0, 0.135)",borderColor:"rgba(211, 126, 71, 1)",borderWidth:2,pointRadius:4,pointBorderWidth:1,pointBackgroundColor:"rgba(255, 255, 255, 1)"}]},options:{scales:{xAxes:[{type:"time",time:{unit:"day"},distribution:"series",ticks:{beginAtZero:!0,source:"labels",padding:10,minRotation:25,maxRotation:25,callback:function(t,e,s){var i=Math.floor(s.length/7);return i<1||(s.length-e-1)%i==0?t:void 0}}}],yAxes:[{ticks:{beginAtZero:!0,maxTicksLimit:6,padding:20,callback:function(t){if(Math.floor(t)===t)return t}}}]},elements:{line:{tension:0}},animation:{duration:0},hover:{animationDuration:0},legend:{display:!1},tooltips:{displayColors:!1},responsiveAnimationDuration:0,maintainAspectRatio:!1}},init:function(){var t;e.$canvas.length&&(t=e.$canvas[0].getContext("2d"),i.instance=new Chart(t,i.settings),i.updateUI())},updateUI:function(){i.updateWithDummyData(),i.instance.data.labels=i.settings.data.labels,i.instance.data.datasets[0].data=i.settings.data.datasets[0].data,i.instance.update()},updateWithDummyData:function(){for(var t,e=moment().endOf("day"),s=1;s<=7;s++)t=e.clone().subtract(s,"days"),i.settings.data.labels.push(t),i.settings.data.datasets[0].data.push({t:t,y:Math.floor(16*Math.random())+5})}},a={init:function(){s(a.ready)},ready:function(){i.init(),a.events(),a.graphSettings()},graphSettings:function(){e.$settingsBtn.on("click",function(){s(this).siblings(".wpforms-dash-widget-settings-menu").toggle()})},events:function(){a.formsListEvents(),a.handleChartClose(),a.handleRecommendedPluginsClose()},formsListEvents:function(){e.$widget.on("click","#wpforms-dash-widget-forms-more",function(){a.toggleCompleteFormsList()})},handleChartClose:function(){e.$dismissBtn.on("click",function(t){t.preventDefault(),a.saveWidgetMeta("hide_graph",1),s(".wpforms-dash-widget.wpforms-lite").addClass("wpforms-dash-widget-no-graph"),s(this).closest(".wpforms-dash-widget-chart-block-container").remove()})},handleRecommendedPluginsClose:function(){e.$recomBlockDismissBtn.on("click",function(){a.dismissRecommendedBlock()})},saveWidgetMeta:function(t,e){t={_wpnonce:wpforms_dashboard_widget.nonce,action:"wpforms_"+wpforms_dashboard_widget.slug+"_save_widget_meta",meta:t,value:e};s.post(ajaxurl,t)},toggleCompleteFormsList:function(){s("#wpforms-dash-widget-forms-list-table .wpforms-dash-widget-forms-list-hidden-el").toggle(),s("#wpforms-dash-widget-forms-more").html(function(t,e){return e===wpforms_dashboard_widget.show_less_html?wpforms_dashboard_widget.show_more_html:wpforms_dashboard_widget.show_less_html})},dismissRecommendedBlock:function(){s(".wpforms-dash-widget-recommended-plugin-block").remove(),a.saveWidgetMeta("hide_recommended_block",1)}};return a}((document,window,jQuery));WPFormsDashboardWidget.init();
|
File diff suppressed because one or more lines are too long
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/edit-post-education.es5.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/edit-post-education.es5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,413 @@
|
||||
/* global wpforms_edit_post_education */
|
||||
|
||||
/**
|
||||
* WPForms Edit Post Education function.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const WPFormsEditPostEducation = window.WPFormsEditPostEducation || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Determine if the notice was showed before.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
isNoticeVisible: false,
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( window ).on( 'load', function() {
|
||||
|
||||
// In the case of jQuery 3.+, we need to wait for a ready event first.
|
||||
if ( typeof $.ready.then === 'function' ) {
|
||||
$.ready.then( app.load );
|
||||
} else {
|
||||
app.load();
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Page load.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
load: function() {
|
||||
|
||||
if ( ! app.isGutenbergEditor() ) {
|
||||
app.maybeShowClassicNotice();
|
||||
app.bindClassicEvents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const blockLoadedInterval = setInterval( function() {
|
||||
|
||||
if ( ! document.querySelector( '.editor-post-title__input, iframe[name="editor-canvas"]' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearInterval( blockLoadedInterval );
|
||||
|
||||
if ( ! app.isFse() ) {
|
||||
|
||||
app.maybeShowGutenbergNotice();
|
||||
app.bindGutenbergEvents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const iframe = document.querySelector( 'iframe[name="editor-canvas"]' );
|
||||
const observer = new MutationObserver( function() {
|
||||
|
||||
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document || {};
|
||||
|
||||
if ( iframeDocument.readyState === 'complete' && iframeDocument.querySelector( '.editor-post-title__input' ) ) {
|
||||
app.maybeShowGutenbergNotice();
|
||||
app.bindFseEvents();
|
||||
|
||||
observer.disconnect();
|
||||
}
|
||||
} );
|
||||
observer.observe( document.body, { subtree: true, childList: true } );
|
||||
}, 200 );
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind events for Classic Editor.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
bindClassicEvents: function() {
|
||||
|
||||
const $document = $( document );
|
||||
|
||||
if ( ! app.isNoticeVisible ) {
|
||||
$document.on( 'input', '#title', app.maybeShowClassicNotice );
|
||||
}
|
||||
|
||||
$document.on( 'click', '.wpforms-edit-post-education-notice-close', app.closeNotice );
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind events for Gutenberg Editor.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
bindGutenbergEvents: function() {
|
||||
|
||||
const $document = $( document );
|
||||
|
||||
$document
|
||||
.on( 'DOMSubtreeModified', '.edit-post-layout', app.distractionFreeModeToggle );
|
||||
|
||||
if ( app.isNoticeVisible ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$document
|
||||
.on( 'input', '.editor-post-title__input', app.maybeShowGutenbergNotice )
|
||||
.on( 'DOMSubtreeModified', '.editor-post-title__input', app.maybeShowGutenbergNotice );
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind events for Gutenberg Editor in FSE mode.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
bindFseEvents: function() {
|
||||
|
||||
const $iframe = $( 'iframe[name="editor-canvas"]' );
|
||||
|
||||
$( document )
|
||||
.on( 'DOMSubtreeModified', '.edit-post-layout', app.distractionFreeModeToggle );
|
||||
|
||||
$iframe.contents()
|
||||
.on( 'DOMSubtreeModified', '.editor-post-title__input', app.maybeShowGutenbergNotice );
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if the editor is Gutenberg.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*
|
||||
* @returns {boolean} True if the editor is Gutenberg.
|
||||
*/
|
||||
isGutenbergEditor: function() {
|
||||
|
||||
return typeof wp !== 'undefined' && typeof wp.blocks !== 'undefined';
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if the editor is Gutenberg in FSE mode.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*
|
||||
* @returns {boolean} True if the Gutenberg editor in FSE mode.
|
||||
*/
|
||||
isFse: function() {
|
||||
|
||||
return Boolean( $( 'iframe[name="editor-canvas"]' ).length );
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a notice for Gutenberg.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
showGutenbergNotice: function() {
|
||||
|
||||
wp.data.dispatch( 'core/notices' ).createInfoNotice(
|
||||
wpforms_edit_post_education.gutenberg_notice.template,
|
||||
app.getGutenbergNoticeSettings()
|
||||
);
|
||||
|
||||
// The notice component doesn't have a way to add HTML id or class to the notice.
|
||||
// Also, the notice became visible with a delay on old Gutenberg versions.
|
||||
const hasNotice = setInterval( function() {
|
||||
|
||||
const noticeBody = $( '.wpforms-edit-post-education-notice-body' );
|
||||
if ( ! noticeBody.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $notice = noticeBody.closest( '.components-notice' );
|
||||
$notice.addClass( 'wpforms-edit-post-education-notice' );
|
||||
$notice.find( '.is-secondary, .is-link' ).removeClass( 'is-secondary' ).removeClass( 'is-link' ).addClass( 'is-primary' );
|
||||
|
||||
clearInterval( hasNotice );
|
||||
}, 100 );
|
||||
},
|
||||
|
||||
/**
|
||||
* Get settings for the Gutenberg notice.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*
|
||||
* @returns {object} Notice settings.
|
||||
*/
|
||||
getGutenbergNoticeSettings: function() {
|
||||
|
||||
const pluginName = 'wpforms-edit-post-product-education-guide';
|
||||
const noticeSettings = {
|
||||
id: pluginName,
|
||||
isDismissible: true,
|
||||
HTML: true,
|
||||
__unstableHTML: true,
|
||||
actions: [
|
||||
{
|
||||
className: 'wpforms-edit-post-education-notice-guide-button',
|
||||
variant: 'primary',
|
||||
label: wpforms_edit_post_education.gutenberg_notice.button,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
if ( ! wpforms_edit_post_education.gutenberg_guide ) {
|
||||
|
||||
noticeSettings.actions[0].url = wpforms_edit_post_education.gutenberg_notice.url;
|
||||
|
||||
return noticeSettings;
|
||||
}
|
||||
|
||||
const Guide = wp.components.Guide;
|
||||
const useState = wp.element.useState;
|
||||
const registerPlugin = wp.plugins.registerPlugin;
|
||||
const unregisterPlugin = wp.plugins.unregisterPlugin;
|
||||
const GutenbergTutorial = function() {
|
||||
|
||||
const [ isOpen, setIsOpen ] = useState( true );
|
||||
|
||||
if ( ! isOpen ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
// eslint-disable-next-line react/react-in-jsx-scope
|
||||
<Guide
|
||||
className="edit-post-welcome-guide"
|
||||
onFinish={ () => {
|
||||
unregisterPlugin( pluginName );
|
||||
setIsOpen( false );
|
||||
} }
|
||||
pages={ app.getGuidePages() }
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
noticeSettings.onDismiss = app.updateUserMeta;
|
||||
noticeSettings.actions[0].onClick = () => registerPlugin( pluginName, { render: GutenbergTutorial } );
|
||||
|
||||
return noticeSettings;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get Guide pages in proper format.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*
|
||||
* @returns {Array} Guide Pages.
|
||||
*/
|
||||
getGuidePages: function() {
|
||||
|
||||
const pages = [];
|
||||
|
||||
wpforms_edit_post_education.gutenberg_guide.forEach( function( page ) {
|
||||
pages.push(
|
||||
{
|
||||
/* eslint-disable react/react-in-jsx-scope */
|
||||
content: (
|
||||
<>
|
||||
<h1 className="edit-post-welcome-guide__heading">{ page.title }</h1>
|
||||
<p className="edit-post-welcome-guide__text">{ page.content }</p>
|
||||
</>
|
||||
),
|
||||
image: <img className="edit-post-welcome-guide__image" src={ page.image } alt={ page.title } />,
|
||||
/* eslint-enable react/react-in-jsx-scope */
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
return pages;
|
||||
},
|
||||
|
||||
/**
|
||||
* Show notice if the page title matches some keywords for Classic Editor.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
maybeShowClassicNotice: function() {
|
||||
|
||||
if ( app.isNoticeVisible ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( app.isTitleMatchKeywords( $( '#title' ).val() ) ) {
|
||||
app.isNoticeVisible = true;
|
||||
|
||||
$( '.wpforms-edit-post-education-notice' ).removeClass( 'wpforms-hidden' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show notice if the page title matches some keywords for Gutenberg Editor.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
maybeShowGutenbergNotice: function() {
|
||||
|
||||
if ( app.isNoticeVisible ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $postTitle = app.isFse() ?
|
||||
$( 'iframe[name="editor-canvas"]' ).contents().find( '.editor-post-title__input' ) :
|
||||
$( '.editor-post-title__input' );
|
||||
const tagName = $postTitle.prop( 'tagName' );
|
||||
const title = tagName === 'TEXTAREA' ? $postTitle.val() : $postTitle.text();
|
||||
|
||||
if ( app.isTitleMatchKeywords( title ) ) {
|
||||
app.isNoticeVisible = true;
|
||||
|
||||
app.showGutenbergNotice();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add notice class when the distraction mode is enabled.
|
||||
*
|
||||
* @since 1.8.1.2
|
||||
*/
|
||||
distractionFreeModeToggle: function() {
|
||||
|
||||
if ( ! app.isNoticeVisible ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $document = $( document );
|
||||
const isDistractionFreeMode = Boolean( $document.find( '.is-distraction-free' ).length );
|
||||
|
||||
if ( ! isDistractionFreeMode ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isNoticeHasClass = Boolean( $( '.wpforms-edit-post-education-notice' ).length );
|
||||
|
||||
if ( isNoticeHasClass ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $noticeBody = $document.find( '.wpforms-edit-post-education-notice-body' );
|
||||
const $notice = $noticeBody.closest( '.components-notice' );
|
||||
|
||||
$notice.addClass( 'wpforms-edit-post-education-notice' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if the title matches keywords.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*
|
||||
* @param {string} titleValue Page title value.
|
||||
*
|
||||
* @returns {boolean} True if the title matches some keywords.
|
||||
*/
|
||||
isTitleMatchKeywords: function( titleValue ) {
|
||||
|
||||
const expectedTitleRegex = new RegExp( /\b(contact|form)\b/i );
|
||||
|
||||
return expectedTitleRegex.test( titleValue );
|
||||
},
|
||||
|
||||
/**
|
||||
* Close a notice.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
closeNotice: function() {
|
||||
|
||||
$( this ).closest( '.wpforms-edit-post-education-notice' ).remove();
|
||||
|
||||
app.updateUserMeta();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update user meta and don't show the notice next time.
|
||||
*
|
||||
* @since 1.8.1
|
||||
*/
|
||||
updateUserMeta() {
|
||||
|
||||
$.post(
|
||||
wpforms_edit_post_education.ajax_url,
|
||||
{
|
||||
action: 'wpforms_education_dismiss',
|
||||
nonce: wpforms_edit_post_education.education_nonce,
|
||||
section: 'edit-post-notice',
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
WPFormsEditPostEducation.init();
|
@@ -0,0 +1,201 @@
|
||||
/* 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:not(.wpforms-add-fields-button)', app.openModalButtonHandler )
|
||||
.on( 'mousedown', '.education-modal.wpforms-add-fields-button', app.openModalButtonHandler );
|
||||
},
|
||||
|
||||
/**
|
||||
* Open education modal handler.
|
||||
*
|
||||
* @since 1.8.0
|
||||
*
|
||||
* @param {Event} event Event.
|
||||
*/
|
||||
openModalButtonHandler: function( event ) {
|
||||
|
||||
const $this = $( this );
|
||||
|
||||
if ( $this.data( 'action' ) && [ 'activate', 'install' ].includes( $this.data( 'action' ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
let name = $this.data( 'name' );
|
||||
|
||||
if ( $this.hasClass( 'wpforms-add-fields-button' ) ) {
|
||||
name = $this.text();
|
||||
name += name.indexOf( wpforms_builder.field ) < 0 ? ' ' + wpforms_builder.field : '';
|
||||
}
|
||||
|
||||
const utmContent = WPFormsEducation.core.getUTMContentValue( $this );
|
||||
|
||||
app.upgradeModal( name, utmContent, $this.data( 'license' ), $this.data( 'video' ), $this.data( 'plural' ) );
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param {boolean} isPlural Is feature name plural.
|
||||
*/
|
||||
upgradeModal( feature, utmContent, type, video, isPlural ) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
const message = wpforms_education.upgrade[ type ].message.replace( /%name%/g, feature );
|
||||
const isVideoModal = ! _.isEmpty( video );
|
||||
const titleMessage = isPlural ? wpforms_education.upgrade[ type ].title_plural : wpforms_education.upgrade[ type ].title;
|
||||
|
||||
let modalWidth = WPFormsEducation.core.getUpgradeModalWidth( isVideoModal );
|
||||
|
||||
const modal = $.alert( {
|
||||
backgroundDismiss: true,
|
||||
title : feature + ' ' + titleMessage,
|
||||
icon : 'fa fa-lock',
|
||||
content : message,
|
||||
boxWidth : modalWidth,
|
||||
theme : 'modern,wpforms-education',
|
||||
closeIcon : true,
|
||||
onOpenBefore: function() {
|
||||
|
||||
if ( isVideoModal ) {
|
||||
this.$el.addClass( 'has-video' );
|
||||
}
|
||||
|
||||
var videoHtml = isVideoModal ? '<iframe src="' + video + '" class="feature-video" frameborder="0" allowfullscreen="" width="475" height="267"></iframe>' : '';
|
||||
|
||||
this.$btnc.after( '<div class="discount-note">' + wpforms_education.upgrade_bonus + '</div>' );
|
||||
this.$btnc.after( wpforms_education.upgrade[type].doc.replace( /%25name%25/g, feature ) );
|
||||
this.$btnc.after( videoHtml );
|
||||
|
||||
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 );
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
|
||||
$( window ).on( 'resize', function() {
|
||||
|
||||
modalWidth = WPFormsEducation.core.getUpgradeModalWidth( isVideoModal );
|
||||
|
||||
if ( modal.isOpen() ) {
|
||||
modal.setBoxWidth( modalWidth );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Upgrade modal second state.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*
|
||||
* @param {string} type Feature license type: pro or elite.
|
||||
*/
|
||||
upgradeModalThankYou: function( type ) {
|
||||
|
||||
$.alert( {
|
||||
title : wpforms_education.thanks_for_interest,
|
||||
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/assets/lite/js/admin/education/core.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/lite/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,c,u){var l={init:function(){u(l.ready)},ready:function(){l.events()},events:function(){l.openModalButtonClick()},openModalButtonClick:function(){u(t).on("click",".education-modal:not(.wpforms-add-fields-button)",l.openModalButtonHandler).on("mousedown",".education-modal.wpforms-add-fields-button",l.openModalButtonHandler)},openModalButtonHandler:function(o){var e=u(this);if(!e.data("action")||!["activate","install"].includes(e.data("action"))){o.preventDefault(),o.stopImmediatePropagation();let t=e.data("name");e.hasClass("wpforms-add-fields-button")&&(t=e.text(),t+=t.indexOf(wpforms_builder.field)<0?" "+wpforms_builder.field:"");o=WPFormsEducation.core.getUTMContentValue(e);l.upgradeModal(t,o,e.data("license"),e.data("video"),e.data("plural"))}},upgradeModal(o,e,n,a,i){if(void 0!==n&&0!==n.length||(n="pro"),!(u.inArray(n,["pro","elite"])<0)){var d=wpforms_education.upgrade[n].message.replace(/%name%/g,o);const r=!_.isEmpty(a);i=i?wpforms_education.upgrade[n].title_plural:wpforms_education.upgrade[n].title;let t=WPFormsEducation.core.getUpgradeModalWidth(r);const s=u.alert({backgroundDismiss:!0,title:o+" "+i,icon:"fa fa-lock",content:d,boxWidth:t,theme:"modern,wpforms-education",closeIcon:!0,onOpenBefore:function(){r&&this.$el.addClass("has-video");var t=r?'<iframe src="'+a+'" class="feature-video" frameborder="0" allowfullscreen="" width="475" height="267"></iframe>':"";this.$btnc.after('<div class="discount-note">'+wpforms_education.upgrade_bonus+"</div>"),this.$btnc.after(wpforms_education.upgrade[n].doc.replace(/%25name%25/g,o)),this.$btnc.after(t),this.$body.find(".jconfirm-content").addClass("lite-upgrade")},buttons:{confirm:{text:wpforms_education.upgrade[n].button,btnClass:"btn-confirm",keys:["enter"],action:function(){c.open(WPFormsEducation.core.getUpgradeURL(e,n),"_blank"),l.upgradeModalThankYou(n)}}}});u(c).on("resize",function(){t=WPFormsEducation.core.getUpgradeModalWidth(r),s.isOpen()&&s.setBoxWidth(t)})}},upgradeModalThankYou:function(t){u.alert({title:wpforms_education.thanks_for_interest,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 l}(document,window,jQuery),WPFormsEducation.liteCore.init();
|
@@ -0,0 +1,472 @@
|
||||
/* global wpforms_education_lite_connect, WPFormsChallenge */
|
||||
/**
|
||||
* WPForms Education for Lite.
|
||||
*
|
||||
* Lite Connect feature.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsEducation = window.WPFormsEducation || {};
|
||||
|
||||
WPFormsEducation.liteConnect = window.WPFormsEducation.liteConnect || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
|
||||
// Page load.
|
||||
$( window ).on( 'load', function() {
|
||||
|
||||
// In the case of jQuery 3.+, we need to wait for a ready event first.
|
||||
if ( typeof $.ready.then === 'function' ) {
|
||||
$.ready.then( app.load );
|
||||
} else {
|
||||
app.load();
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Page load.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
load: function() {
|
||||
|
||||
app.events();
|
||||
app.initLiteConnectToggle();
|
||||
app.maybeRevealBuilderTopBar();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
app.enableLiteConnectToggleClick();
|
||||
app.enableLiteConnectButtonClick();
|
||||
app.dismissBuilderTopBarClick();
|
||||
app.autoSaveToggleChange();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init Lite Connect toggle.
|
||||
*
|
||||
* @since 1.7.5
|
||||
*/
|
||||
initLiteConnectToggle: function() {
|
||||
$( '.wpforms-toggle-control.wpforms-setting-lite-connect-auto-save-toggle input' ).prop( 'disabled', false );
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Lite Connect toggle mousedown handler.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
enableLiteConnectToggleClick: function() {
|
||||
|
||||
$( document ).on(
|
||||
'mousedown touchstart',
|
||||
'.wpforms-toggle-control.wpforms-setting-lite-connect-auto-save-toggle',
|
||||
function( event ) {
|
||||
|
||||
var $input = $( this ).find( 'input' ),
|
||||
isEnabled = $input.is( ':checked' ),
|
||||
isTouchDevice = 'ontouchstart' in document.documentElement;
|
||||
|
||||
if ( ! isTouchDevice ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if ( $input.prop( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
app.openSettingsLiteConnectModal( isEnabled, function() {
|
||||
|
||||
$input
|
||||
.trigger( 'click' )
|
||||
.prop( 'disabled', true );
|
||||
} );
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Lite Connect button click handler.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
enableLiteConnectButtonClick: function() {
|
||||
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.wpforms-dyk-lite-connect .button-primary',
|
||||
function( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var $button = $( this );
|
||||
|
||||
if ( $button.hasClass( 'wpforms-is-enabled' ) ) {
|
||||
window.open( $button.attr( 'href' ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app.openSettingsLiteConnectModal(
|
||||
false,
|
||||
app.enableLiteConnectButtonModalConfirm
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Lite Connect button modal confirm Callback.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
enableLiteConnectButtonModalConfirm: function() {
|
||||
|
||||
var $toggle = $( '.wpforms-dyk-lite-connect .button-primary' );
|
||||
|
||||
app.saveSettingAjaxPost( true, $toggle, function() {
|
||||
|
||||
app.switchSettingView( true, $toggle );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Form Entry Backups information modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} isEnabled Current setting state.
|
||||
* @param {Function} confirmCallback Confirm button action.
|
||||
*/
|
||||
openSettingsLiteConnectModal: function( isEnabled, confirmCallback ) {
|
||||
|
||||
if ( isEnabled ) {
|
||||
app.openSettingsLiteConnectDisableModal( confirmCallback );
|
||||
} else {
|
||||
app.openSettingsLiteConnectEnableModal( confirmCallback );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Form Entry Backups enable information modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {Function} confirmCallback Confirm button action.
|
||||
*/
|
||||
openSettingsLiteConnectEnableModal: function( confirmCallback ) {
|
||||
|
||||
$.alert( {
|
||||
title: false,
|
||||
content: wp.template( 'wpforms-settings-lite-connect-modal-content' )(),
|
||||
icon: false,
|
||||
type: 'orange',
|
||||
boxWidth: '550px',
|
||||
theme: 'modern',
|
||||
useBootstrap: false,
|
||||
scrollToPreviousElement: false,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_education_lite_connect.enable_modal.confirm,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action: function() {
|
||||
|
||||
if ( typeof confirmCallback === 'function' ) {
|
||||
confirmCallback();
|
||||
}
|
||||
|
||||
// Maybe close Challenge popup.
|
||||
if ( window.WPFormsChallenge ) {
|
||||
var completeChallenge = WPFormsChallenge.embed && WPFormsChallenge.embed.completeChallenge;
|
||||
}
|
||||
|
||||
if ( typeof completeChallenge === 'function' ) {
|
||||
completeChallenge();
|
||||
}
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
text: wpforms_education_lite_connect.enable_modal.cancel,
|
||||
action: function() {
|
||||
|
||||
$( '.wpforms-challenge-popup-container' ).removeClass( 'wpforms-invisible' );
|
||||
},
|
||||
},
|
||||
},
|
||||
onOpenBefore: function() {
|
||||
|
||||
$( 'body' ).addClass( 'wpforms-setting-lite-connect-modal' );
|
||||
$( '.wpforms-challenge-popup-container' ).addClass( 'wpforms-invisible' );
|
||||
},
|
||||
onDestroy: function() {
|
||||
|
||||
$( 'body' ).removeClass( 'wpforms-setting-lite-connect-modal' );
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Form Entry Backups disable information modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {Function} confirmCallback Confirm button action.
|
||||
*/
|
||||
openSettingsLiteConnectDisableModal: function( confirmCallback ) {
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_education_lite_connect.disable_modal.title,
|
||||
content: wpforms_education_lite_connect.disable_modal.content,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'red',
|
||||
boxWidth: '400px',
|
||||
theme: 'modern',
|
||||
useBootstrap: false,
|
||||
animateFromElement: false,
|
||||
scrollToPreviousElement: false,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: wpforms_education_lite_connect.disable_modal.cancel,
|
||||
keys: [ 'enter' ],
|
||||
btnClass: 'btn-confirm',
|
||||
},
|
||||
confirm: {
|
||||
text: wpforms_education_lite_connect.disable_modal.confirm,
|
||||
action: function() {
|
||||
|
||||
if ( typeof confirmCallback === 'function' ) {
|
||||
confirmCallback();
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Save Lite Connect Enabled setting AJAX post call.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} isEnabled Lite Connect setting flag.
|
||||
* @param {jQuery|undefined} $toggle Toggle control outer element.
|
||||
* @param {Function} successCallback Success result callback.
|
||||
*/
|
||||
saveSettingAjaxPost: function( isEnabled, $toggle, successCallback ) {
|
||||
|
||||
$toggle = $toggle || $();
|
||||
|
||||
var $input = $toggle.find( 'input' );
|
||||
|
||||
// Perform AJAX request.
|
||||
$.post(
|
||||
wpforms_education_lite_connect.ajax_url,
|
||||
{
|
||||
action: 'wpforms_update_lite_connect_enabled_setting',
|
||||
value: isEnabled ? 1 : 0,
|
||||
nonce: wpforms_education_lite_connect.nonce,
|
||||
}
|
||||
).done( function( res ) {
|
||||
|
||||
if ( ! res.success ) {
|
||||
$input.prop( 'checked', ! isEnabled );
|
||||
app.updateResultModal( 'error' );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app.updateResultModal( isEnabled ? 'enabled' : 'disabled' );
|
||||
|
||||
if ( typeof successCallback === 'function' ) {
|
||||
successCallback();
|
||||
}
|
||||
|
||||
} ).fail( function( xhr, textStatus, e ) {
|
||||
|
||||
$input.prop( 'checked', ! isEnabled );
|
||||
app.updateResultModal( 'error' );
|
||||
|
||||
} ).always( function( xhr, textStatus, e ) {
|
||||
$input.prop( 'disabled', false );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Lite Connect toggle `change` event handler with "auto save" feature.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
autoSaveToggleChange: function() {
|
||||
|
||||
$( document ).on(
|
||||
'change',
|
||||
'.wpforms-toggle-control.wpforms-setting-lite-connect-auto-save-toggle input',
|
||||
function() {
|
||||
|
||||
var $input = $( this ),
|
||||
$toggle = $input.closest( '.wpforms-toggle-control' ),
|
||||
isEnabled = $input.is( ':checked' );
|
||||
|
||||
app.saveSettingAjaxPost( isEnabled, $toggle, function() {
|
||||
app.switchSettingView( isEnabled, $toggle );
|
||||
} );
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* After updating setting via AJAX we should hide toggle container and show info container.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} isEnabled Toggle state.
|
||||
* @param {jQuery} $toggle Toggle control.
|
||||
*/
|
||||
switchSettingView: function( isEnabled, $toggle ) {
|
||||
|
||||
var $wrapper = $toggle.closest( '.wpforms-education-lite-connect-wrapper' ),
|
||||
$setting = $wrapper.find( '.wpforms-education-lite-connect-setting' ),
|
||||
$enabledInfo = $wrapper.find( '.wpforms-education-lite-connect-enabled-info' );
|
||||
|
||||
$setting.toggleClass( 'wpforms-hidden', isEnabled );
|
||||
$enabledInfo.toggleClass( 'wpforms-hidden', ! isEnabled );
|
||||
},
|
||||
|
||||
/**
|
||||
* Update result message modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {string} msg Message slug.
|
||||
*/
|
||||
updateResultModal: function( msg ) {
|
||||
|
||||
if ( ! wpforms_education_lite_connect.update_result[ msg ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_education_lite_connect.update_result[ msg + '_title' ],
|
||||
content: wpforms_education_lite_connect.update_result[ msg ],
|
||||
icon: 'fa fa-check-circle',
|
||||
type: msg === 'error' ? 'red' : 'green',
|
||||
theme: 'modern',
|
||||
boxWidth: '400px',
|
||||
useBootstrap: false,
|
||||
animation: 'scale',
|
||||
closeAnimation: 'scale',
|
||||
animateFromElement: false,
|
||||
scrollToPreviousElement: false,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text : wpforms_education_lite_connect.update_result.close,
|
||||
btnClass: 'btn-confirm',
|
||||
keys : [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Reveal top bar in the Form Builder.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
maybeRevealBuilderTopBar: function() {
|
||||
|
||||
// Skip it is not Form Builder or Entry Backups is already enabled or top bar is dismissed.
|
||||
if (
|
||||
! window.wpforms_builder ||
|
||||
wpforms_education_lite_connect.is_enabled === '1' ||
|
||||
$( '#wpforms-builder-lite-connect-top-bar' ).length === 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout( function() {
|
||||
app.toggleBuilderTopBar( true );
|
||||
}, 3000 );
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle top bar in the Form Builder.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} open True for open, false for close.
|
||||
*/
|
||||
toggleBuilderTopBar: function( open ) {
|
||||
|
||||
var cssVar = '--wpforms-admin-bar-height',
|
||||
root = document.documentElement,
|
||||
adminBarHeight = parseInt( getComputedStyle( root ).getPropertyValue( cssVar ), 10 ),
|
||||
topBarHeight = 45;
|
||||
|
||||
adminBarHeight += open ? topBarHeight : -topBarHeight;
|
||||
|
||||
root.setAttribute(
|
||||
'style',
|
||||
cssVar + ': ' + ( adminBarHeight ) + 'px!important;'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Dismiss top bar in the Form Builder.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
dismissBuilderTopBarClick: function() {
|
||||
|
||||
$( document ).on(
|
||||
'click',
|
||||
'#wpforms-builder-lite-connect-top-bar .wpforms-dismiss-button',
|
||||
function() {
|
||||
app.toggleBuilderTopBar( false );
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsEducation.liteConnect.init();
|
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/education/lite-connect.min.js
vendored
Normal file
1
wp-content/plugins/wpforms-lite/assets/lite/js/admin/education/lite-connect.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user