PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | stripe/js/frmtrans_admin.js +68 -15 6.5.2 → trunk View file →
@@ -1,14 +1,14 @@
1 1 ( function() {
2 2 function toggleSub() {
3 - var val = this.value;
4 - var show = val === 'recurring';
3 + const val = this.value;
4 + const show = val === 'recurring';
5 5 slideOpts( this, show, '.frm_trans_sub_opts' );
6 6 toggleOpts( this, ! show, '.frm_gateway_no_recur' );
7 7 }
8 8
9 9 function slideOpts( opt, show, c ) {
10 - var opts = jQuery( opt ).closest( '.frm_form_action_settings' ).find( c );
10 + const opts = jQuery( opt ).closest( '.frm_form_action_settings' ).find( c );
11 11 if ( show ) {
12 12 opts.slideDown( 'fast' );
13 13 } else {
14 14 opts.slideUp( 'fast' );
@@ -15,22 +15,69 @@
15 15 }
16 16 }
17 17
18 18 function toggleOpts( opt, show, c ) {
19 - var opts = jQuery( opt ).closest( '.frm_form_action_settings' ).find( c );
19 + const opts = jQuery( opt ).closest( '.frm_form_action_settings' ).find( c );
20 20 if ( show ) {
21 - opts.show();
21 + opts.css( 'display', '' );
22 + opts.removeClass( 'frm_hidden' );
22 23 } else {
23 - opts.hide();
24 + opts.css( 'display', 'none' );
25 + opts.addClass( 'frm_hidden' );
24 26 }
25 27 }
26 28
29 + function toggleGateway() {
30 + const gateway = this.value;
31 + const { checked } = this;
32 +
33 + toggleOpts( this, checked, `.show_${ gateway }` );
34 +
35 + const gateways = [ 'stripe', 'square', 'paypal' ];
36 + const toggleOff = gateways.filter( g => g !== gateway );
37 +
38 + const settings = jQuery( this ).closest( '.frm_form_action_settings' );
39 + const showClass = `show_${ settings.find( '.frm_gateway_opt input:checked' ).attr( 'value' ) }`;
40 +
41 + toggleOff.forEach(
42 + function( gateway ) {
43 + const gatewaySettings = settings.get( 0 ).querySelectorAll( `.show_${ gateway }` );
44 + gatewaySettings.forEach(
45 + setting => {
46 + if ( ! setting.classList.contains( showClass ) ) {
47 + setting.style.display = 'none';
48 + }
49 + }
50 + );
51 + }
52 + );
53 +
54 + wp.hooks.doAction( 'frm_trans_toggled_gateway', { gateway, checked, settings } );
55 +
56 + document.querySelectorAll( '.frm-billing-section-heading' ).forEach( function( el ) {
57 + el.textContent = gateway === 'paypal' ? el.dataset.billingLabel : el.dataset.customerLabel;
58 + } );
59 + }
60 +
27 61 function frmTransLiteAdminJS() {
28 62 return {
29 - init: function() {
30 - var actions = document.getElementById( 'frm_notification_settings' );
31 - if ( actions !== null ) {
63 + init() {
64 + const actions = document.getElementById( 'frm_notification_settings' );
65 + if ( actions ) {
32 66 jQuery( actions ).on( 'change', '.frm_trans_type', toggleSub );
67 +
68 + document.addEventListener(
69 + 'change',
70 + function( event ) {
71 + if ( ! event.target || ! event.target.checked || 'radio' !== event.target.type ) {
72 + return;
73 + }
74 +
75 + if ( event.target.closest( '.frm-long-icon-buttons' ) && event.target.closest( '.frm_form_action_settings' ) ) {
76 + toggleGateway.call( event.target );
77 + }
78 + }
79 + );
33 80 }
34 81
35 82 document.querySelectorAll( '.frm_trans_ajax_link' ).forEach(
36 83 link => link.addEventListener(
@@ -46,34 +93,40 @@
46 93
47 94 function runAjaxLink( e ) {
48 95 e.preventDefault();
49 96
50 - const $link = jQuery( this );
97 + const $link = jQuery( this );
51 98 const handleConfirmedClick = e => {
52 99 e.preventDefault();
53 100
54 - const href = $link.attr( 'href' );
55 - const loadingImage = document.createElement( 'span' );
101 + const href = $link.attr( 'href' );
102 + const loadingImage = document.createElement( 'span' );
56 103 loadingImage.className = 'frm-loading-img';
57 104
58 105 $link.replaceWith( loadingImage );
59 - jQuery.ajax({
106 + jQuery.ajax( {
60 107 type: 'GET',
61 108 url: href,
62 109 data: {
63 110 nonce: frm_trans_vars.nonce
64 111 },
65 - success: function( html ) {
112 + success( html ) {
66 113 jQuery( loadingImage ).replaceWith( html );
67 114 }
68 - });
115 + } );
69 116 };
70 117
118 + if ( ! e.currentTarget.dataset.frmverify ) {
119 + handleConfirmedClick( e );
120 + return;
121 + }
122 +
71 123 jQuery( '#frm-confirmed-click' ).one( 'click', handleConfirmedClick );
72 124
73 125 // Prevent handleConfirmedClick from triggering when the current modal is closed so that it won't be run by other elements.
74 126 const unbindHandleConfirmedClick = e => {
75 127 if ( e.target.matches( '.ui-widget-overlay, .dismiss' ) ) {
128 + // eslint-disable-next-line no-jquery/no-bind
76 129 jQuery( '#frm-confirmed-click' ).unbind( 'click', handleConfirmedClick );
77 130 document.removeEventListener( 'click', unbindHandleConfirmedClick );
78 131 }
79 132 };