PluginProbe ʕ •ᴥ•ʔ
WPForms – AI Form Builder for WordPress – Contact Forms, Payment Forms, Survey Form, Quiz & More / 1.9.1.2
WPForms – AI Form Builder for WordPress – Contact Forms, Payment Forms, Survey Form, Quiz & More v1.9.1.2
1.10.2.1 1.10.2 1.10.1.1 1.10.1 1.10.0.5 trunk 1.1.4 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.6.1 1.1.7 1.1.7.1 1.1.7.2 1.1.8 1.1.8.1 1.1.8.2 1.1.8.3 1.1.8.4 1.10.0.1 1.10.0.2 1.10.0.3 1.10.0.4 1.2.0 1.2.0.1 1.2.1 1.2.2 1.2.2.1 1.2.2.2 1.2.3 1.2.3.1 1.2.3.2 1.2.4 1.2.4.1 1.2.5 1.2.5.1 1.2.6 1.2.7 1.2.8 1.2.8.1 1.2.9 1.3.0 1.3.1 1.3.1.1 1.3.1.2 1.3.2 1.3.3 1.3.5 1.3.6 1.3.6.1 1.3.6.2 1.3.7.2 1.3.7.3 1.3.7.4 1.3.8 1.3.9.1 1.4.0.1 1.4.1.1 1.4.2 1.4.2.1 1.4.2.2 1.4.3 1.4.4 1.4.4.1 1.4.5 1.4.5.1 1.4.5.2 1.4.5.3 1.4.6 1.4.7.1 1.4.7.2 1.4.8.1 1.4.9 1.5.0.1 1.5.0.3 1.5.0.4 1.5.1 1.5.1.1 1.5.1.3 1.5.2.1 1.5.2.2 1.5.2.3 1.5.3 1.5.3.1 1.5.4.1 1.5.4.2 1.5.5 1.5.5.1 1.5.6 1.5.6.2 1.5.7 1.5.8.2 1.5.9.1 1.5.9.4 1.5.9.5 1.6.0.1 1.6.0.2 1.6.1 1.6.2.2 1.6.2.3 1.6.3.1 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.7 1.6.7.1 1.6.7.2 1.6.7.3 1.6.8 1.6.8.1 1.6.9 1.7.0 1.7.1.1 1.7.1.2 1.7.2 1.7.2.1 1.7.3 1.7.4 1.7.4.1 1.7.4.2 1.7.5.1 1.7.5.2 1.7.5.3 1.7.5.5 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.7.9.1 1.8.0.1 1.8.0.2 1.8.1.1 1.8.1.2 1.8.1.3 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.3.1 1.8.4 1.8.4.1 1.8.5.2 1.8.5.3 1.8.5.4 1.8.6.2 1.8.6.3 1.8.6.4 1.8.7.2 1.8.8.2 1.8.8.3 1.8.9.1 1.8.9.2 1.8.9.4 1.8.9.5 1.8.9.6 1.9.0.1 1.9.0.2 1.9.0.3 1.9.0.4 1.9.1.1 1.9.1.2 1.9.1.3 1.9.1.4 1.9.1.5 1.9.1.6 1.9.2.1 1.9.2.2 1.9.2.3 1.9.3.1 1.9.3.2 1.9.4.1 1.9.4.2 1.9.5 1.9.5.1 1.9.5.2 1.9.6 1.9.6.1 1.9.6.2 1.9.7.1 1.9.7.2 1.9.7.3 1.9.8.1 1.9.8.2 1.9.8.4 1.9.8.7 1.9.9.2 1.9.9.3 1.9.9.4
wpforms-lite / assets / js / integrations / stripe / admin-builder-stripe-card-field.js
wpforms-lite / assets / js / integrations / stripe Last commit date
admin-builder-modern-stripe.js 1 year ago admin-builder-modern-stripe.min.js 1 year ago admin-builder-stripe-card-field.js 1 year ago admin-builder-stripe-card-field.min.js 1 year ago admin-builder-stripe.js 1 year ago admin-builder-stripe.min.js 1 year ago admin-settings-stripe.js 1 year ago admin-settings-stripe.min.js 1 year ago wpforms-stripe-elements.js 1 year ago wpforms-stripe-elements.min.js 1 year ago wpforms-stripe-payment-element.js 1 year ago wpforms-stripe-payment-element.min.js 1 year ago
admin-builder-stripe-card-field.js
221 lines
1 /* global wpforms_builder, wpforms_builder_stripe_card_field */
2
3 /**
4 * WPForms Stripe Card Field function.
5 *
6 * @since 1.8.2
7 */
8
9 'use strict';
10
11 var WPFormsStripeCardField = window.WPFormsStripeCardField || ( function( document, window, $ ) {
12
13 /**
14 * Public functions and properties.
15 *
16 * @since 1.8.2
17 *
18 * @type {object}
19 */
20 const app = {
21
22 /**
23 * Start the engine.
24 *
25 * @since 1.8.2
26 */
27 init: function() {
28
29 app.bindUIActions();
30 },
31
32 /**
33 * Process various events as a response to UI interactions.
34 *
35 * @since 1.8.2
36 */
37 bindUIActions: function() {
38
39 $( document ).on( 'wpformsSaved', app.ajaxRequiredCheck );
40 $( document ).on( 'wpformsSaved', app.paymentsEnabledCheck );
41
42 $( document ).on( 'click', '#wpforms-add-fields-' + wpforms_builder_stripe_card_field.field_slug, app.stripeKeysCheck );
43 $( document ).on( 'change', '.wpforms-field-option-stripe-credit-card .wpforms-field-option-row-sublabel_position select', app.sublabelPositionChange );
44 $( document ).on( 'change', '.wpforms-field-option-stripe-credit-card .wpforms-field-option-row-link_email select', app.linkEmailChange );
45
46 $( document ).on( 'wpformsFieldAdd', app.disableAddCardButton );
47 $( document ).on( 'wpformsFieldDelete', app.enableAddCardButton );
48 $( document ).on( 'wpformsFieldDelete', app.maybeResetLinkEmailField );
49 },
50
51 /**
52 * On form save notify users if AJAX submission is required.
53 *
54 * @since 1.8.2
55 */
56 ajaxRequiredCheck: function() {
57
58 if ( ! $( '.wpforms-field.wpforms-field-' + wpforms_builder_stripe_card_field.field_slug ).length ||
59 $( '#wpforms-panel-field-settings-ajax_submit' ).is( ':checked' ) ) {
60 return;
61 }
62
63 $.alert( {
64 title: wpforms_builder.heads_up,
65 content: wpforms_builder.stripe_ajax_required,
66 icon: 'fa fa-exclamation-circle',
67 type: 'orange',
68 buttons: {
69 confirm: {
70 text: wpforms_builder.ok,
71 btnClass: 'btn-confirm',
72 keys: [ 'enter' ],
73 },
74 },
75 } );
76 },
77
78 /**
79 * On form save notify users if Stripe payments are not enabled.
80 *
81 * @since 1.8.2
82 */
83 paymentsEnabledCheck: function() {
84
85 if ( ! $( `.wpforms-field.wpforms-field-${ wpforms_builder_stripe_card_field.field_slug }:visible` ).length ||
86 $( '#wpforms-panel-field-stripe-enable' ).is( ':checked' ) ||
87 $( '#wpforms-panel-field-stripe-enable_one_time' ).is( ':checked' ) ||
88 $( '#wpforms-panel-field-stripe-enable_recurring' ).is( ':checked' )
89 ) {
90 return;
91 }
92
93 $.alert( {
94 title: wpforms_builder.heads_up,
95 content: wpforms_builder.payments_enabled_required,
96 icon: 'fa fa-exclamation-circle',
97 type: 'orange',
98 buttons: {
99 confirm: {
100 text: wpforms_builder.ok,
101 btnClass: 'btn-confirm',
102 keys: [ 'enter' ],
103 },
104 },
105 } );
106 },
107
108 /**
109 * On adding Stripe Credit Card field notify users if Stripe keys are missing.
110 *
111 * @since 1.8.2
112 */
113 stripeKeysCheck: function() {
114
115 if ( ! $( this ).hasClass( 'stripe-keys-required' ) ) {
116 return;
117 }
118
119 $.alert( {
120 title: wpforms_builder.heads_up,
121 content: wpforms_builder.stripe_keys_required,
122 icon: 'fa fa-exclamation-circle',
123 type: 'orange',
124 buttons: {
125 confirm: {
126 text: wpforms_builder.ok,
127 btnClass: 'btn-confirm',
128 keys: [ 'enter' ],
129 },
130 },
131 } );
132 },
133
134 /**
135 * Disable "Add Card" button in the fields list.
136 *
137 * @since 1.8.2
138 *
139 * @param {object} e Event object.
140 * @param {number} id Field ID.
141 * @param {string} type Field type.
142 */
143 disableAddCardButton: function( e, id, type ) {
144
145 if ( wpforms_builder_stripe_card_field.field_slug === type ) {
146 $( '#wpforms-add-fields-' + wpforms_builder_stripe_card_field.field_slug )
147 .prop( 'disabled', true );
148 }
149 },
150
151 /**
152 * Enable "Add Card" button in the fields list.
153 *
154 * @since 1.8.2
155 *
156 * @param {object} e Event object.
157 * @param {number} id Field ID.
158 * @param {string} type Field type.
159 */
160 enableAddCardButton: function( e, id, type ) {
161
162 if ( wpforms_builder_stripe_card_field.field_slug === type ) {
163 $( '#wpforms-add-fields-' + wpforms_builder_stripe_card_field.field_slug )
164 .prop( 'disabled', false );
165 }
166 },
167
168 /**
169 * Switch sublabels preview mode.
170 *
171 * @since 1.8.2
172 */
173 sublabelPositionChange: function() {
174
175 const fieldId = $( this ).parent().data( 'field-id' ),
176 $fieldPreview = $( `#wpforms-field-${fieldId}` ).find( '.wpforms-stripe-payment-element' );
177
178 $fieldPreview.toggleClass( 'above' );
179 $fieldPreview.toggleClass( 'floating' );
180 $fieldPreview.find( 'select' ).val( $fieldPreview.hasClass( 'above' ) ? 'empty' : 'country' );
181 },
182
183 /**
184 * Switch Link Email Field mapping.
185 *
186 * @since 1.8.2
187 */
188 linkEmailChange: function() {
189
190 const fieldId = $( this ).parent().data( 'field-id' );
191
192 $( `#wpforms-field-${fieldId}` ).find( '.wpforms-stripe-link-email' ).toggleClass( 'wpforms-hidden', $( this ).val() !== '' );
193 },
194
195 /**
196 * Maybe reset link email field if mapped email was removed.
197 *
198 * @since 1.8.2
199 *
200 * @param {object} e Event object.
201 * @param {number} id Field ID.
202 * @param {string} type Field type.
203 */
204 maybeResetLinkEmailField: function( e, id, type ) {
205
206 if ( type !== 'email' ) {
207 return;
208 }
209
210 $( '.wpforms-field-option-stripe-credit-card .wpforms-field-option-row-link_email select' ).trigger( 'change' );
211 },
212 };
213
214 // Provide access to public functions/properties.
215 return app;
216
217 }( document, window, jQuery ) );
218
219 // Initialize.
220 WPFormsStripeCardField.init();
221