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 +35 -15 6.29 → trunk View file →
@@ -17,38 +17,46 @@
17 17
18 18 function toggleOpts( opt, show, c ) {
19 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
27 29 function toggleGateway() {
28 - if ( ! this.checked ) {
29 - return;
30 - }
31 -
32 30 const gateway = this.value;
33 31 const { checked } = this;
34 32
35 33 toggleOpts( this, checked, `.show_${ gateway }` );
36 34
37 - const toggleOff = 'stripe' === gateway ? 'square' : 'stripe';
35 + const gateways = [ 'stripe', 'square', 'paypal' ];
36 + const toggleOff = gateways.filter( g => g !== gateway );
37 +
38 38 const settings = jQuery( this ).closest( '.frm_form_action_settings' );
39 39 const showClass = `show_${ settings.find( '.frm_gateway_opt input:checked' ).attr( 'value' ) }`;
40 - const gatewaySettings = settings.get( 0 ).querySelectorAll( `.show_${ toggleOff }` );
41 40
42 - gatewaySettings.forEach(
43 - setting => {
44 - if ( ! setting.classList.contains( showClass ) ) {
45 - setting.style.display = 'none';
46 - }
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 + );
47 51 }
48 52 );
49 53
50 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 + } );
51 59 }
52 60
53 61 function frmTransLiteAdminJS() {
54 62 return {
@@ -53,11 +61,23 @@
53 61 function frmTransLiteAdminJS() {
54 62 return {
55 63 init() {
56 64 const actions = document.getElementById( 'frm_notification_settings' );
57 - if ( actions !== null ) {
65 + if ( actions ) {
58 66 jQuery( actions ).on( 'change', '.frm_trans_type', toggleSub );
59 - jQuery( '.frm_form_settings' ).on( 'change', '.frm_gateway_opt input', toggleGateway );
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 + );
60 80 }
61 81
62 82 document.querySelectorAll( '.frm_trans_ajax_link' ).forEach(
63 83 link => link.addEventListener(