PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
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 | js/formidable.js +525 -1279 6.5.33.06.06 View file →
@@ -1,107 +1,40 @@
1 -/* exported frmRecaptcha, frmAfterRecaptcha, frmUpdateField, frmDeleteEntry, frmOnSubmit, frm_resend_email */
2 -
3 -var frmFrontForm;
4 -
5 -function frmFrontFormJS() {
1 +function frmFrontFormJS(){
6 2 'use strict';
7 3
8 - /*global jQuery:false, frm_js, grecaptcha, frmProForm, tinyMCE */
9 - /*global frmThemeOverride_jsErrors, frmThemeOverride_frmPlaceError, frmThemeOverride_frmAfterSubmit */
4 + /*global jQuery:false, frm_js */
10 5
11 6 var action = '';
12 7 var jsErrors = [];
13 8
14 - /**
15 - * Maybe add polyfills.
16 - *
17 - * @since 5.4
18 - */
19 - function maybeAddPolyfills() {
20 - var i;
21 - if ( ! Element.prototype.matches ) {
22 - // IE9 supports matches but as msMatchesSelector instead.
23 - Element.prototype.matches = Element.prototype.msMatchesSelector;
24 - }
9 + function maybeShowLabel(){
10 + /*jshint validthis:true */
11 + var $field = jQuery(this);
12 + var $label = $field.closest('.frm_inside_container').find('.frm_primary_label');
25 13
26 - if ( ! Element.prototype.closest ) {
27 - Element.prototype.closest = function( s ) {
28 - var el = this;
29 -
30 - do {
31 - if ( el.matches( s ) ) {
32 - return el;
33 - }
34 - el = el.parentElement || el.parentNode;
35 - } while ( el !== null && el.nodeType === 1 );
36 -
37 - return null;
38 - };
39 - }
40 -
41 - // NodeList.forEach().
42 - if ( window.NodeList && ! NodeList.prototype.forEach ) {
43 - NodeList.prototype.forEach = function( callback, thisArg ) {
44 - thisArg = thisArg || window;
45 - for ( i = 0; i < this.length; i++ ) {
46 - callback.call( thisArg, this[ i ], i, this );
47 - }
48 - };
49 - }
50 - }
51 -
52 - /**
53 - * Triggers custom JS event.
54 - *
55 - * @since 5.5.3
56 - *
57 - * @param {HTMLElement} el The HTML element.
58 - * @param {String} eventName Event name.
59 - * @param {mixed} data The passed data.
60 - */
61 - function triggerCustomEvent( el, eventName, data ) {
62 - var event;
63 -
64 - if ( typeof window.CustomEvent === 'function' ) {
65 - event = new CustomEvent( eventName );
66 - } else if ( document.createEvent ) {
67 - event = document.createEvent( 'HTMLEvents' );
68 - event.initEvent( eventName, false, true );
14 + if ( $field.val().length > 0 ) {
15 + $label.addClass('frm_visible');
69 16 } else {
70 - return;
17 + $label.removeClass('frm_visible');
71 18 }
72 -
73 - event.frmData = data;
74 -
75 - el.dispatchEvent( event );
76 19 }
77 20
78 21 /* Get the ID of the field that changed*/
79 22 function getFieldId( field, fullID ) {
80 - var nameParts, fieldId,
81 - isRepeating = false,
82 - fieldName = '';
23 + var fieldName = '';
83 24 if ( field instanceof jQuery ) {
84 - fieldName = field.attr( 'name' );
25 + fieldName = field.attr('name');
85 26 } else {
86 27 fieldName = field.name;
87 28 }
88 29
89 - if ( typeof fieldName === 'undefined' ) {
90 - fieldName = '';
91 - }
92 -
93 30 if ( fieldName === '' ) {
94 31 if ( field instanceof jQuery ) {
95 - fieldName = field.data( 'name' );
32 + fieldName = field.data('name');
96 33 } else {
97 - fieldName = field.getAttribute( 'data-name' );
34 + fieldName = field.getAttribute('data-name');
98 35 }
99 36
100 - if ( typeof fieldName === 'undefined' ) {
101 - fieldName = '';
102 - }
103 -
104 37 if ( fieldName !== '' && fieldName ) {
105 38 return fieldName;
106 39 }
107 40 return 0;
@@ -106,21 +39,20 @@
106 39 }
107 40 return 0;
108 41 }
109 42
110 - nameParts = fieldName.replace( 'item_meta[', '' ).replace( '[]', '' ).split( ']' );
43 + var nameParts = fieldName.replace('item_meta[', '').replace('[]', '').split(']');
111 44 //TODO: Fix this for checkboxes and address fields
112 45 if ( nameParts.length < 1 ) {
113 46 return 0;
114 47 }
115 - nameParts = nameParts.filter( function( n ) {
116 - return n !== '';
117 - });
48 + nameParts = nameParts.filter(function(n){ return n !== ''; });
118 49
119 - fieldId = nameParts[0];
50 + var field_id = nameParts[0];
51 + var isRepeating = false;
120 52
121 53 if ( nameParts.length === 1 ) {
122 - return fieldId;
54 + return field_id;
123 55 }
124 56
125 57 if ( nameParts[1] === '[form' || nameParts[1] === '[row_ids' ) {
126 58 return 0;
@@ -125,37 +57,38 @@
125 57 if ( nameParts[1] === '[form' || nameParts[1] === '[row_ids' ) {
126 58 return 0;
127 59 }
128 60
61 +
129 62 // Check if 'this' is in a repeating section
130 - if ( jQuery( 'input[name="item_meta[' + fieldId + '][form]"]' ).length ) {
63 + if ( jQuery('input[name="item_meta['+ field_id +'][form]"]').length ) {
131 64
132 65 // this is a repeatable section with name: item_meta[repeating-section-id][row-id][field-id]
133 - fieldId = nameParts[2].replace( '[', '' );
66 + field_id = nameParts[2].replace('[', '');
134 67 isRepeating = true;
135 68 }
136 69
137 70 // Check if 'this' is an other text field and get field ID for it
138 - if ( 'other' === fieldId ) {
71 + if ( 'other' === field_id ) {
139 72 if ( isRepeating ) {
140 73 // name for other fields: item_meta[370][0][other][414]
141 - fieldId = nameParts[3].replace( '[', '' );
74 + field_id = nameParts[3].replace('[', '');
142 75 } else {
143 76 // Other field name: item_meta[other][370]
144 - fieldId = nameParts[1].replace( '[', '' );
77 + field_id = nameParts[1].replace('[', '');
145 78 }
146 79 }
147 80
148 81 if ( fullID === true ) {
149 82 // For use in the container div id
150 - if ( fieldId === nameParts[0]) {
151 - fieldId = fieldId + '-' + nameParts[1].replace( '[', '' );
83 + if ( field_id === nameParts[0] ) {
84 + field_id = field_id +'-'+ nameParts[1].replace('[', '');
152 85 } else {
153 - fieldId = fieldId + '-' + nameParts[0] + '-' + nameParts[1].replace( '[', '' );
86 + field_id = field_id +'-'+ nameParts[0] +'-'+ nameParts[1].replace('[', '');
154 87 }
155 88 }
156 89
157 - return fieldId;
90 + return field_id;
158 91 }
159 92
160 93 /**
161 94 * Disable the submit button for a given jQuery form object
@@ -162,11 +95,11 @@
162 95 *
163 96 * @since 2.03.02
164 97 *
165 98 * @param {object} $form
166 - */
99 + */
167 100 function disableSubmitButton( $form ) {
168 - $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).attr( 'disabled', 'disabled' );
101 + $form.find('input[type="submit"], input[type="button"], button[type="submit"]').attr('disabled','disabled');
169 102 }
170 103
171 104 /**
172 105 * Enable the submit button for a given jQuery form object
@@ -173,68 +106,43 @@
173 106 *
174 107 * @since 2.03.02
175 108 *
176 109 * @param {object} $form
177 - */
110 + */
178 111 function enableSubmitButton( $form ) {
179 - $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).prop( 'disabled', false );
112 + $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).removeAttr( 'disabled' );
180 113 }
181 114
182 - /**
183 - * Disable the save draft link for a given jQuery form object
184 - *
185 - * @since 4.04.03
186 - *
187 - * @param {object} $form
188 - */
189 - function disableSaveDraft( $form ) {
190 - $form.find( 'a.frm_save_draft' ).css( 'pointer-events', 'none' );
191 - }
192 -
193 - /**
194 - * Enable the save draft link for a given jQuery form object
195 - *
196 - * @since 4.04.03
197 - *
198 - * @param {object} $form
199 - */
200 - function enableSaveDraft( $form ) {
201 - $form.find( 'a.frm_save_draft' ).css( 'pointer-events', '' );
202 - }
203 -
204 115 function validateForm( object ) {
205 - var errors, r, rl, n, nl, fields, field, requiredFields;
116 + var errors = [];
206 117
207 - errors = [];
208 -
209 118 // Make sure required text field is filled in
210 - requiredFields = jQuery( object ).find(
119 + var requiredFields = jQuery(object).find(
211 120 '.frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea'
212 - ).filter( ':not(.frm_optional)' );
121 + ).filter(':not(.frm_optional)');
213 122 if ( requiredFields.length ) {
214 - for ( r = 0, rl = requiredFields.length; r < rl; r++ ) {
215 - if ( hasClass( requiredFields[r], 'ed_button' ) ) {
216 - // skip rich text field buttons.
217 - continue;
218 - }
123 + for ( var r = 0, rl = requiredFields.length; r < rl; r++ ) {
219 124 errors = checkRequiredField( requiredFields[r], errors );
220 125 }
221 126 }
222 127
223 - fields = jQuery( object ).find( 'input,select,textarea' );
128 + var emailFields = jQuery(object).find('input[type=email]').filter(':visible');
129 + var fields = jQuery(object).find('input,select,textarea');
224 130 if ( fields.length ) {
225 - for ( n = 0, nl = fields.length; n < nl; n++ ) {
226 - field = fields[n];
227 - if ( '' === field.value ) {
228 - if ( 'number' === field.type ) {
229 - // A number field will return an empty string when it is invalid.
230 - checkValidity( field, errors );
131 + for ( var n = 0, nl = fields.length; n < nl; n++ ) {
132 + var field = fields[n];
133 + var value = field.value;
134 + if ( value !== '' ) {
135 + if ( field.type === 'hidden' ) {
136 + // don't validate
137 + } else if ( field.type === 'number' ) {
138 + errors = checkNumberField( field, errors );
139 + } else if ( field.type === 'email' ) {
140 + errors = checkEmailField( field, errors, emailFields );
141 + } else if ( field.pattern !== null ) {
142 + errors = checkPatternField( field, errors );
231 143 }
232 - continue;
233 144 }
234 -
235 - validateFieldValue( field, errors );
236 - checkValidity( field, errors );
237 145 }
238 146 }
239 147
240 148 errors = validateRecaptcha( object, errors );
@@ -241,51 +149,14 @@
241 149
242 150 return errors;
243 151 }
244 152
245 - /**
246 - * Check the ValidityState interface for the field.
247 - * If it is invalid, show an error for it.
248 - *
249 - * @param {HTMLElement} field
250 - * @param {Array} errors
251 - * @returns
252 - */
253 - function checkValidity( field, errors ) {
254 - var fieldID;
255 - if ( 'object' !== typeof field.validity || false !== field.validity.valid ) {
256 - return;
257 - }
258 -
259 - fieldID = getFieldId( field, true );
260 - if ( 'undefined' === typeof errors[ fieldID ]) {
261 - errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
262 - }
263 -
264 - if ( 'function' === typeof field.reportValidity ) {
265 - // This triggers an error pop up.
266 - field.reportValidity();
267 - }
268 - }
269 -
270 - /**
271 - * @since 5.0.10
272 - *
273 - * @param {object} element
274 - * @param {string} targetClass
275 - * @returns {boolean}
276 - */
277 - function hasClass( element, targetClass ) {
278 - var className = ' ' + element.className + ' ';
279 - return -1 !== className.indexOf( ' ' + targetClass + ' ' );
280 - }
281 -
282 - function maybeValidateChange( field ) {
153 + function maybeValidateChange( field_id, field ) {
283 154 if ( field.type === 'url' ) {
284 155 maybeAddHttpToUrl( field );
285 156 }
286 - if ( jQuery( field ).closest( 'form' ).hasClass( 'frm_js_validate' ) ) {
287 - validateField( field );
157 + if ( jQuery(field).closest('form').hasClass('frm_js_validate') ) {
158 + validateField( field_id, field );
288 159 }
289 160 }
290 161
291 162 function maybeAddHttpToUrl( field ) {
@@ -295,69 +166,52 @@
295 166 field.value = 'http://' + url;
296 167 }
297 168 }
298 169
299 - function validateField( field ) {
300 - var key,
301 - errors = [],
302 - $fieldCont = jQuery( field ).closest( '.frm_form_field' );
170 + function validateField( fieldId, field ) {
171 + var errors = [];
303 172
304 - if ( $fieldCont.hasClass( 'frm_required_field' ) && ! jQuery( field ).hasClass( 'frm_optional' ) ) {
173 + var $fieldCont = jQuery(field).closest('.frm_form_field');
174 + if ( $fieldCont.hasClass('frm_required_field') && ! jQuery(field).hasClass('frm_optional') ) {
305 175 errors = checkRequiredField( field, errors );
306 176 }
307 177
308 178 if ( errors.length < 1 ) {
309 - validateFieldValue( field, errors );
179 + if ( field.type === 'email' ) {
180 + var emailFields = jQuery(field).closest('form').find('input[type=email]');
181 + errors = checkEmailField( field, errors, emailFields );
182 + } else if ( field.type === 'number' ) {
183 + errors = checkNumberField( field, errors );
184 + } else if ( field.pattern !== null ) {
185 + errors = checkPatternField( field, errors );
186 + }
310 187 }
311 188
312 189 removeFieldError( $fieldCont );
313 - if ( Object.keys( errors ).length > 0 ) {
314 - for ( key in errors ) {
190 + if ( Object.keys(errors).length > 0 ) {
191 + for ( var key in errors ) {
315 192 addFieldError( $fieldCont, key, errors );
316 193 }
317 194 }
318 195 }
319 196
320 - function validateFieldValue( field, errors ) {
321 - if ( field.type === 'hidden' ) {
322 - // don't validate
323 - } else if ( field.type === 'number' ) {
324 - checkNumberField( field, errors );
325 - } else if ( field.type === 'email' ) {
326 - checkEmailField( field, errors );
327 - } else if ( field.type === 'password' ) {
328 - checkPasswordField( field, errors );
329 - } else if ( field.type === 'url' ) {
330 - checkUrlField( field, errors );
331 - } else if ( field.pattern !== null ) {
332 - checkPatternField( field, errors );
333 - }
334 -
335 - triggerCustomEvent( document, 'frm_validate_field_value', {
336 - field: field,
337 - errors: errors
338 - });
339 - }
340 -
341 197 function checkRequiredField( field, errors ) {
342 - var checkGroup, tempVal, i, placeholder,
343 - val = '',
344 - fieldID = '',
345 - fileID = field.getAttribute( 'data-frmfile' );
346 -
347 - if ( field.type === 'hidden' && fileID === null && ! isAppointmentField( field ) && ! isInlineDatepickerField( field ) ) {
198 + var fileID = field.getAttribute('data-frmfile');
199 + if ( field.type === 'hidden' && fileID === null ) {
348 200 return errors;
349 201 }
350 202
203 + var val = '';
204 + var fieldID = '';
351 205 if ( field.type === 'checkbox' || field.type === 'radio' ) {
352 - checkGroup = jQuery( 'input[name="' + field.name + '"]' ).closest( '.frm_required_field' ).find( 'input:checked' );
353 - jQuery( checkGroup ).each( function() {
354 - val = this.value;
206 + var checkGroup = jQuery('input[name="'+field.name+'"]').closest('.frm_required_field').find('input:checked');
207 + jQuery(checkGroup).each(function() {
208 + val = this.value;
355 209 });
356 210 } else if ( field.type === 'file' || fileID ) {
357 211 if ( typeof fileID === 'undefined' ) {
358 212 fileID = getFieldId( field, true );
359 - fileID = fileID.replace( 'file', '' );
213 + fileID = fileID.replace('file', '');
360 214 }
361 215
362 216 if ( typeof errors[ fileID ] === 'undefined' ) {
363 217 val = getFileVals( fileID );
@@ -363,20 +217,21 @@
363 217 val = getFileVals( fileID );
364 218 }
365 219 fieldID = fileID;
366 220 } else {
367 - if ( hasClass( field, 'frm_pos_none' ) ) {
221 + var fieldClasses = field.className;
222 + if ( fieldClasses.indexOf('frm_pos_none') !== -1 ) {
368 223 // skip hidden other fields
369 224 return errors;
370 225 }
371 226
372 - val = jQuery( field ).val();
227 + val = jQuery(field).val();
373 228 if ( val === null ) {
374 229 val = '';
375 230 } else if ( typeof val !== 'string' ) {
376 - tempVal = val;
231 + var tempVal = val;
377 232 val = '';
378 - for ( i = 0; i < tempVal.length; i++ ) {
233 + for ( var i = 0; i < tempVal.length; i++ ) {
379 234 if ( tempVal[i] !== '' ) {
380 235 val = tempVal[i];
381 236 }
382 237 }
@@ -381,29 +236,20 @@
381 236 }
382 237 }
383 238 }
384 239
385 - if ( hasClass( field, 'frm_other_input' ) ) {
240 + if ( fieldClasses.indexOf('frm_other_input') === -1 ) {
241 + fieldID = getFieldId( field, true );
242 + } else {
386 243 fieldID = getFieldId( field, false );
387 -
388 - if ( val === '' ) {
389 - field = document.getElementById( field.id.replace( '-otext', '' ) );
390 - }
391 - } else {
392 - fieldID = getFieldId( field, true );
393 244 }
394 245
395 - if ( hasClass( field, 'frm_time_select' ) ) {
246 + if ( fieldClasses.indexOf('frm_time_select') !== -1 ) {
396 247 // set id for time field
397 - fieldID = fieldID.replace( '-H', '' ).replace( '-m', '' );
398 - } else if ( isSignatureField( field ) ) {
399 - if ( val === '' ) {
400 - val = jQuery( field ).closest( '.frm_form_field' ).find( '[name="' + field.getAttribute( 'name' ).replace( '[typed]', '[output]' ) + '"]' ).val();
401 - }
402 - fieldID = fieldID.replace( '-typed', '' );
248 + fieldID = fieldID.replace('-H', '').replace('-m', '');
403 249 }
404 250
405 - placeholder = field.getAttribute( 'data-frmplaceholder' );
251 + var placeholder = field.getAttribute('data-frmplaceholder');
406 252 if ( placeholder !== null && val === placeholder ) {
407 253 val = '';
408 254 }
409 255 }
@@ -411,9 +257,9 @@
411 257 if ( val === '' ) {
412 258 if ( fieldID === '' ) {
413 259 fieldID = getFieldId( field, true );
414 260 }
415 - if ( ! ( fieldID in errors ) ) {
261 + if ( !(fieldID in errors) ) {
416 262 errors[ fieldID ] = getFieldValidationMessage( field, 'data-reqmsg' );
417 263 }
418 264 }
419 265
@@ -419,26 +265,12 @@
419 265
420 266 return errors;
421 267 }
422 268
423 - function isSignatureField( field ) {
424 - var name = field.getAttribute( 'name' );
425 - return 'string' === typeof name && '[typed]' === name.substr( -7 );
426 - }
427 -
428 - function isAppointmentField( field ) {
429 - return hasClass( field, 'ssa_appointment_form_field_appointment_id' );
430 - }
431 -
432 - function isInlineDatepickerField( field ) {
433 - return 'hidden' === field.type && '_alt' === field.id.substr( -4 ) && hasClass( field.nextElementSibling, 'frm_date_inline' );
434 - }
435 -
436 269 function getFileVals( fileID ) {
437 - var val = '',
438 - fileFields = jQuery( 'input[name="file' + fileID + '"], input[name="file' + fileID + '[]"], input[name^="item_meta[' + fileID + ']"]' );
439 -
440 - fileFields.each( function() {
270 + var val = '';
271 + var fileFields = jQuery('input[name="file'+ fileID +'"], input[name="file'+ fileID +'[]"], input[name^="item_meta['+ fileID +']"]');
272 + fileFields.each(function(){
441 273 if ( val === '' ) {
442 274 val = this.value;
443 275 }
444 276 });
@@ -444,135 +276,72 @@
444 276 });
445 277 return val;
446 278 }
447 279
448 - function checkUrlField( field, errors ) {
449 - var fieldID,
450 - url = field.value;
451 -
452 - if ( url !== '' && ! /^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i.test( url ) ) {
453 - fieldID = getFieldId( field, true );
454 - if ( ! ( fieldID in errors ) ) {
455 - errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
456 - }
280 + function checkEmailField( field, errors, emailFields ) {
281 + var emailAddress = field.value;
282 + var fieldID = getFieldId( field, true );
283 + if ( fieldID in errors ) {
284 + return errors;
457 285 }
458 - }
459 286
460 - function checkEmailField( field, errors ) {
461 - var fieldID = getFieldId( field, true ),
462 - pattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
463 -
464 - // validate the current field we're editing first
465 - if ( '' !== field.value && pattern.test( field.value ) === false ) {
466 - errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
467 - }
468 -
469 - confirmField( field, errors );
470 - }
471 -
472 - function checkPasswordField( field, errors ) {
473 - confirmField( field, errors );
474 - }
475 -
476 - function confirmField( field, errors ) {
477 - var value, confirmValue, firstField,
478 - fieldID = getFieldId( field, true ),
479 - strippedId = field.id.replace( 'conf_', '' ),
480 - strippedFieldID = fieldID.replace( 'conf_', '' ),
481 - confirmField = document.getElementById( strippedId.replace( 'field_', 'field_conf_' ) );
482 -
483 - if ( confirmField === null || typeof errors[ 'conf_' + strippedFieldID ] !== 'undefined' ) {
484 - return;
485 - }
486 -
487 - if ( fieldID !== strippedFieldID ) {
488 - firstField = document.getElementById( strippedId );
489 - value = firstField.value;
490 - confirmValue = confirmField.value;
491 - if ( '' !== value && '' !== confirmValue && value !== confirmValue ) {
492 - errors[ 'conf_' + strippedFieldID ] = getFieldValidationMessage( confirmField, 'data-confmsg' );
287 + var isConf = (fieldID.indexOf('conf_') === 0);
288 + if ( emailAddress !== '' || isConf ) {
289 + var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
290 + var invalidMsg = getFieldValidationMessage( field, 'data-invmsg' );
291 + if ( emailAddress !== '' && re.test( emailAddress ) === false ) {
292 + errors[ fieldID ] = invalidMsg;
293 + if ( isConf ) {
294 + errors[ fieldID.replace('conf_', '') ] = '';
295 + }
296 + } else if ( isConf ) {
297 + var confName = field.name.replace('conf_', '');
298 + var match = emailFields.filter('[name="'+ confName +'"]').val();
299 + if ( match !== emailAddress ) {
300 + errors[ fieldID ] = '';
301 + errors[ fieldID.replace('conf_', '') ] = '';
302 + }
493 303 }
494 - } else {
495 - validateField( confirmField );
496 304 }
305 + return errors;
497 306 }
498 307
499 308 function checkNumberField( field, errors ) {
500 - var fieldID,
501 - number = field.value;
502 -
503 - if ( number !== '' && isNaN( number / 1 ) !== false ) {
504 - fieldID = getFieldId( field, true );
505 - if ( ! ( fieldID in errors ) ) {
309 + var number = field.value;
310 + if ( number !== '' && isNaN(number / 1) !== false ) {
311 + var fieldID = getFieldId( field, true );
312 + if ( !(fieldID in errors) ) {
506 313 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
507 314 }
508 315 }
316 + return errors;
509 317 }
510 318
511 319 function checkPatternField( field, errors ) {
512 - var fieldID,
513 - text = field.value,
514 - format = getFieldValidationMessage( field, 'pattern' );
320 + var text = field.value;
321 + var format = getFieldValidationMessage( field, 'pattern' );
515 322
516 323 if ( format !== '' && text !== '' ) {
517 - fieldID = getFieldId( field, true );
518 - if ( ! ( fieldID in errors ) ) {
519 - format = new RegExp( '^' + format + '$', 'i' );
324 + var fieldID = getFieldId( field, true );
325 + if ( !(fieldID in errors) ) {
326 + format = new RegExp( '^'+ format +'$', 'i' );
520 327 if ( format.test( text ) === false ) {
521 328 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
522 329 }
523 330 }
524 331 }
332 + return errors;
525 333 }
526 334
527 - /**
528 - * Set color for select placeholders.
529 - *
530 - * @since 6.5.1
531 - */
532 - function setSelectPlaceholderColor() {
533 - var selects = document.querySelectorAll( '.form-field select' ),
534 - styleElement = document.querySelector( '.with_frm_style' ),
535 - textColorDisabled = styleElement ? getComputedStyle( styleElement ).getPropertyValue( '--text-color-disabled' ).trim() : '',
536 - changeSelectColor;
537 -
538 - // Exit if there are no select elements or the textColorDisabled property is missing
539 - if ( ! selects.length || ! textColorDisabled ) {
540 - return;
541 - }
542 -
543 - // Function to change the color of a select element
544 - changeSelectColor = function( select ) {
545 - if ( hasClass( select.options[select.selectedIndex], 'frm-select-placeholder' ) ) {
546 - select.style.setProperty( 'color', textColorDisabled, 'important' );
547 - } else {
548 - select.style.color = '';
549 - }
550 - };
551 -
552 - // Use a loop to iterate through each select element
553 - Array.prototype.forEach.call( selects, function( select ) {
554 - // Apply the color change to each select element
555 - changeSelectColor( select );
556 -
557 - // Add an event listener for future changes
558 - select.addEventListener( 'change', function() {
559 - changeSelectColor( select );
560 - });
561 - });
562 - }
563 -
564 335 function hasInvisibleRecaptcha( object ) {
565 - var recaptcha, recaptchaID, alreadyChecked;
566 -
567 - if ( isGoingToPrevPage( object ) ) {
336 + if ( typeof frmProForm !== 'undefined' && frmProForm.goingToPreviousPage( object ) ) {
568 337 return false;
569 338 }
570 339
571 - recaptcha = jQuery( object ).find( '.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]' );
340 + var recaptcha = jQuery(object).find('.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]');
572 341 if ( recaptcha.length ) {
573 - recaptchaID = recaptcha.data( 'rid' );
574 - alreadyChecked = grecaptcha.getResponse( recaptchaID );
342 + var recaptchaID = recaptcha.data('rid');
343 + var alreadyChecked = grecaptcha.getResponse( recaptchaID );
575 344 if ( alreadyChecked.length === 0 ) {
576 345 return recaptcha;
577 346 } else {
578 347 return false;
@@ -582,32 +351,22 @@
582 351 }
583 352 }
584 353
585 354 function executeInvisibleRecaptcha( invisibleRecaptcha ) {
586 - var recaptchaID = invisibleRecaptcha.data( 'rid' );
355 + var recaptchaID = invisibleRecaptcha.data('rid');
587 356 grecaptcha.reset( recaptchaID );
588 357 grecaptcha.execute( recaptchaID );
589 358 }
590 359
591 360 function validateRecaptcha( form, errors ) {
592 - var recaptchaID, response, fieldContainer, fieldID,
593 - $recaptcha = jQuery( form ).find( '.frm-g-recaptcha' );
361 + var $recaptcha = jQuery(form).find('.frm-g-recaptcha');
594 362 if ( $recaptcha.length ) {
595 - recaptchaID = $recaptcha.data( 'rid' );
363 + var recaptchaID = $recaptcha.data('rid');
364 + var response = grecaptcha.getResponse( recaptchaID );
596 365
597 - try {
598 - response = grecaptcha.getResponse( recaptchaID );
599 - } catch ( e ) {
600 - if ( jQuery( form ).find( 'input[name="recaptcha_checked"]' ).length ) {
601 - return errors;
602 - } else {
603 - response = '';
604 - }
605 - }
606 -
607 366 if ( response.length === 0 ) {
608 - fieldContainer = $recaptcha.closest( '.frm_form_field' );
609 - fieldID = fieldContainer.attr( 'id' ).replace( 'frm_field_', '' ).replace( '_container', '' );
367 + var fieldContainer = $recaptcha.closest('.frm_form_field');
368 + var fieldID = fieldContainer.attr('id').replace('frm_field_', '').replace('_container', '');
610 369 errors[ fieldID ] = '';
611 370 }
612 371 }
613 372 return errors;
@@ -613,33 +372,17 @@
613 372 return errors;
614 373 }
615 374
616 375 function getFieldValidationMessage( field, messageType ) {
617 - var msg, errorHtml;
618 -
619 - msg = field.getAttribute( messageType );
620 - if ( null === msg ) {
376 + var msg = field.getAttribute(messageType);
377 + if ( msg === null ) {
621 378 msg = '';
622 379 }
623 -
624 - if ( '' !== msg && shouldWrapErrorHtmlAroundMessageType( messageType ) ) {
625 - errorHtml = field.getAttribute( 'data-error-html' );
626 - if ( null !== errorHtml ) {
627 - errorHtml = errorHtml.replace( /\+/g, '%20' );
628 - msg = decodeURIComponent( errorHtml ).replace( '[error]', msg );
629 - msg = msg.replace( '[key]', getFieldId( field, false ) );
630 - }
631 - }
632 -
633 380 return msg;
634 381 }
635 382
636 - function shouldWrapErrorHtmlAroundMessageType( type ) {
637 - return 'pattern' !== type;
638 - }
639 -
640 383 function shouldJSValidate( object ) {
641 - var validate = jQuery( object ).hasClass( 'frm_js_validate' );
384 + var validate = jQuery(object).hasClass('frm_js_validate');
642 385 if ( validate && typeof frmProForm !== 'undefined' && ( frmProForm.savingDraft( object ) || frmProForm.goingToPreviousPage( object ) ) ) {
643 386 validate = false;
644 387 }
645 388
@@ -645,219 +388,142 @@
645 388
646 389 return validate;
647 390 }
648 391
649 - function getFormErrors( object, action ) {
650 - var fieldset, data, success, error, shouldTriggerEvent;
651 -
652 - if ( typeof action === 'undefined' ) {
653 - jQuery( object ).find( 'input[name="frm_action"]' ).val();
392 + function getFormErrors(object, action){
393 + if(typeof action === 'undefined'){
394 + jQuery(object).find('input[name="frm_action"]').val();
654 395 }
655 396
656 - fieldset = jQuery( object ).find( '.frm_form_field' );
657 - fieldset.addClass( 'frm_doing_ajax' );
397 + var fieldset = jQuery(object).find('.frm_form_field');
398 + fieldset.addClass('frm_doing_ajax');
399 + jQuery.ajax({
400 + type:'POST',url:frm_js.ajax_url,
401 + data:jQuery(object).serialize() +'&action=frm_entries_'+ action +'&nonce='+frm_js.nonce,
402 + success:function(response){
403 + var defaultResponse = {'content':'', 'errors':{}, 'pass':false };
404 + if ( response === null ) {
405 + response = defaultResponse;
406 + }
658 407
659 - data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; // eslint-disable-line camelcase
660 - shouldTriggerEvent = object.classList.contains( 'frm_trigger_event_on_submit' );
661 -
662 - success = function( response ) {
663 - var defaultResponse, formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
664 - $fieldCont, key, inCollapsedSection, frmTrigger, newTab;
665 -
666 - defaultResponse = {
667 - content: '',
668 - errors: {},
669 - pass: false
670 - };
671 -
672 - if ( response === null ) {
673 - response = defaultResponse;
674 - }
675 -
676 - response = response.replace( /^\s+|\s+$/g, '' );
677 - if ( response.indexOf( '{' ) === 0 ) {
678 - response = JSON.parse( response );
679 - } else {
680 - response = defaultResponse;
681 - }
682 -
683 - if ( typeof response.redirect !== 'undefined' ) {
684 - if ( shouldTriggerEvent ) {
685 - triggerCustomEvent( object, 'frmSubmitEvent' );
686 - return;
408 + response = response.replace(/^\s+|\s+$/g,'');
409 + if ( response.indexOf('{') === 0 ) {
410 + response = jQuery.parseJSON(response);
411 + }else{
412 + response = defaultResponse;
687 413 }
688 414
689 - jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
690 -
691 - if ( ! response.openInNewTab ) {
692 - // We return here because we're redirecting there is no need to update content.
415 + if ( typeof response.redirect !== 'undefined' ) {
416 + jQuery(document).trigger( 'frmBeforeFormRedirect', [ object, response ] );
693 417 window.location = response.redirect;
694 - return;
695 - }
418 + } else if ( response.content !== '' ) {
419 + // the form or success message was returned
696 420
697 - // We don't return here because we're opening in a new tab, the old tab will still update.
698 - newTab = window.open( response.redirect, '_blank' );
699 - if ( ! newTab && response.fallbackMsg && response.content ) {
700 - response.content = response.content.trim().replace( /(<\/div><\/div>)$/, ' ' + response.fallbackMsg + '</div></div>' );
701 - }
702 - }
421 + removeSubmitLoading( jQuery(object) );
422 + if ( frm_js.offset != -1 ) {
423 + frmFrontForm.scrollMsg( jQuery(object), false );
424 + }
425 + var formID = jQuery(object).find('input[name="form_id"]').val();
426 + response.content = response.content.replace(/ frm_pro_form /g, ' frm_pro_form frm_no_hide ');
427 + var replaceContent = jQuery( object ).closest( '.frm_forms' );
428 + removeAddedScripts( replaceContent, formID );
429 + replaceContent.replaceWith( response.content );
703 430
704 - if ( response.content !== '' ) {
705 - // the form or success message was returned
431 + addUrlParam(response);
706 432
707 - if ( shouldTriggerEvent ) {
708 - triggerCustomEvent( object, 'frmSubmitEvent' );
709 - return;
710 - }
433 + if(typeof(frmThemeOverride_frmAfterSubmit) === 'function'){
434 + var pageOrder = jQuery('input[name="frm_page_order_'+ formID +'"]').val();
435 + var formReturned = jQuery(response.content).find('input[name="form_id"]').val();
436 + frmThemeOverride_frmAfterSubmit(formReturned, pageOrder, response.content, object);
437 + }
711 438
712 - removeSubmitLoading( jQuery( object ) );
713 - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase
714 - frmFrontForm.scrollMsg( jQuery( object ), false );
715 - }
439 + afterFormSubmitted( object, response );
716 440
717 - formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
718 - response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
719 - replaceContent = jQuery( object ).closest( '.frm_forms' );
720 - removeAddedScripts( replaceContent, formID );
721 - delay = maybeSlideOut( replaceContent, response.content );
441 + } else if ( Object.keys(response.errors).length ) {
442 + // errors were returned
722 443
723 - setTimeout(
724 - function() {
725 - var container, input, previousInput;
444 + removeSubmitLoading( jQuery(object), 'enable' );
726 445
727 - replaceContent.replaceWith( response.content );
446 + //show errors
447 + var cont_submit = true;
448 + removeAllErrors();
728 449
729 - addUrlParam( response );
450 + var show_captcha = false;
451 + var $fieldCont = null;
730 452
731 - if ( typeof frmThemeOverride_frmAfterSubmit === 'function' ) { // eslint-disable-line camelcase
732 - pageOrder = jQuery( 'input[name="frm_page_order_' + formID + '"]' ).val();
733 - formReturned = jQuery( response.content ).find( 'input[name="form_id"]' ).val();
734 - frmThemeOverride_frmAfterSubmit( formReturned, pageOrder, response.content, object );
735 - }
453 + for ( var key in response.errors ) {
454 + $fieldCont = jQuery(object).find('#frm_field_'+key+'_container');
736 455
737 - if ( typeof response.recaptcha !== 'undefined' ) {
738 - container = jQuery( '#frm_form_' + formID + '_container' ).find( '.frm_fields_container' );
739 - input = '<input type="hidden" name="recaptcha_checked" value="' + response.recaptcha + '">';
740 - previousInput = container.find( 'input[name="recaptcha_checked"]' );
741 -
742 - if ( previousInput.length ) {
743 - previousInput.replaceWith( input );
744 - } else {
745 - container.append( input );
456 + if ( $fieldCont.length ) {
457 + if ( ! $fieldCont.is(':visible') ) {
458 + var inCollapsedSection = $fieldCont.closest('.frm_toggle_container');
459 + if ( inCollapsedSection.length ) {
460 + var frmTrigger = inCollapsedSection.prev();
461 + if ( ! frmTrigger.hasClass('frm_trigger') ) {
462 + // If the frmTrigger object is the section description, check to see if the previous element is the trigger
463 + frmTrigger = frmTrigger.prev('.frm_trigger');
464 + }
465 + frmTrigger.click();
466 + }
746 467 }
747 - }
748 468
749 - afterFormSubmitted( object, response );
750 - },
751 - delay
752 - );
753 - } else if ( Object.keys( response.errors ).length ) {
754 - // errors were returned
755 - removeSubmitLoading( jQuery( object ), 'enable' );
469 + if ( $fieldCont.is(':visible') ) {
470 + addFieldError( $fieldCont, key, response.errors );
756 471
757 - //show errors
758 - contSubmit = true;
759 - removeAllErrors();
472 + cont_submit = false;
760 473
761 - $fieldCont = null;
762 -
763 - for ( key in response.errors ) {
764 - $fieldCont = jQuery( object ).find( '#frm_field_' + key + '_container' );
765 -
766 - if ( $fieldCont.length ) {
767 - if ( ! $fieldCont.is( ':visible' ) ) {
768 - inCollapsedSection = $fieldCont.closest( '.frm_toggle_container' );
769 - if ( inCollapsedSection.length ) {
770 - frmTrigger = inCollapsedSection.prev();
771 - if ( ! frmTrigger.hasClass( 'frm_trigger' ) ) {
772 - // If the frmTrigger object is the section description, check to see if the previous element is the trigger
773 - frmTrigger = frmTrigger.prev( '.frm_trigger' );
474 + var $recaptcha = jQuery(object).find('#frm_field_'+key+'_container .frm-g-recaptcha, #frm_field_'+key+'_container .g-recaptcha');
475 + if ( $recaptcha.length ) {
476 + show_captcha = true;
477 + var recaptchaID = $recaptcha.data('rid');
478 + if ( jQuery().grecaptcha ) {
479 + if ( recaptchaID ) {
480 + grecaptcha.reset( recaptchaID );
481 + } else {
482 + grecaptcha.reset();
483 + }
484 + }
774 485 }
775 - frmTrigger.trigger( 'click' );
776 486 }
777 487 }
488 + }
778 489
779 - if ( $fieldCont.is( ':visible' ) ) {
780 - addFieldError( $fieldCont, key, response.errors );
781 - contSubmit = false;
782 - }
783 - }
784 - }
490 + jQuery(document).trigger( 'frmFormErrors', [ object, response ] );
785 491
786 - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() {
787 - var $recaptcha = jQuery( this ),
788 - recaptchaID = $recaptcha.data( 'rid' );
492 + fieldset.removeClass('frm_doing_ajax');
493 + scrollToFirstField( object );
789 494
790 - if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
791 - if ( recaptchaID ) {
792 - grecaptcha.reset( recaptchaID );
793 - } else {
794 - grecaptcha.reset();
795 - }
495 + if(show_captcha !== true){
496 + replaceCheckedRecaptcha( object, false );
796 497 }
797 - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) {
798 - hcaptcha.reset();
498 +
499 + if(cont_submit){
500 + object.submit();
501 + }else{
502 + jQuery(object).prepend(response.error_message);
799 503 }
800 - });
504 + } else {
505 + // there may have been a plugin conflict, or the form is not set to submit with ajax
801 506
802 - jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
507 + showFileLoading( object );
508 + replaceCheckedRecaptcha( object, true );
803 509
804 - fieldset.removeClass( 'frm_doing_ajax' );
805 - scrollToFirstField( object );
806 -
807 - if ( contSubmit ) {
808 510 object.submit();
809 - } else {
810 - jQuery( object ).prepend( response.error_message );
811 - checkForErrorsAndMaybeSetFocus();
812 511 }
813 - } else {
814 - // there may have been a plugin conflict, or the form is not set to submit with ajax
815 -
816 - showFileLoading( object );
817 -
512 + },
513 + error:function(){
514 + jQuery(object).find('input[type="submit"], input[type="button"]').removeAttr('disabled');
818 515 object.submit();
819 516 }
820 - };
821 -
822 - error = function() {
823 - jQuery( object ).find( 'input[type="submit"], input[type="button"]' ).prop( 'disabled', false );
824 - object.submit();
825 - };
826 -
827 - postToAjaxUrl( object, data, success, error );
517 + });
828 518 }
829 519
830 - function postToAjaxUrl( form, data, success, error ) {
831 - var ajaxUrl, action, ajaxParams;
832 -
833 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
834 - action = form.getAttribute( 'action' );
835 -
836 - if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
837 - ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
838 - }
839 -
840 - ajaxParams = {
841 - type: 'POST',
842 - url: ajaxUrl,
843 - data: data,
844 - success: success
845 - };
846 -
847 - if ( 'function' === typeof error ) {
848 - ajaxParams.error = error;
849 - }
850 -
851 - jQuery.ajax( ajaxParams );
852 - }
853 -
854 520 function afterFormSubmitted( object, response ) {
855 - var formCompleted = jQuery( response.content ).find( '.frm_message' );
521 + var formCompleted = jQuery(response.content).find('.frm_message');
856 522 if ( formCompleted.length ) {
857 - jQuery( document ).trigger( 'frmFormComplete', [ object, response ]);
523 + jQuery(document).trigger( 'frmFormComplete', [ object, response ] );
858 524 } else {
859 - jQuery( document ).trigger( 'frmPageChanged', [ object, response ]);
525 + jQuery(document).trigger( 'frmPageChanged', [ object, response ] );
860 526 }
861 527 }
862 528
863 529 function removeAddedScripts( formContainer, formID ) {
@@ -867,105 +533,72 @@
867 533 endReplace.remove();
868 534 }
869 535 }
870 536
871 - function maybeSlideOut( oldContent, newContent ) {
872 - var c,
873 - newClass = 'frm_slideout';
874 - if ( newContent.indexOf( ' frm_slide' ) !== -1 ) {
875 - c = oldContent.children();
876 - if ( newContent.indexOf( ' frm_going_back' ) !== -1 ) {
877 - newClass += ' frm_going_back';
878 - }
879 - c.removeClass( 'frm_going_back' );
880 - c.addClass( newClass );
881 - return 300;
882 - }
883 - return 0;
884 - }
885 -
886 - function addUrlParam( response ) {
887 - var url;
537 + function addUrlParam(response){
888 538 if ( history.pushState && typeof response.page !== 'undefined' ) {
889 - url = addQueryVar( 'frm_page', response.page );
890 - window.history.pushState({ 'html': response.html }, '', '?' + url );
539 + var url = addQueryVar('frm_page', response.page);
540 + window.history.pushState({"html":response.html}, '', '?'+ url);
891 541 }
892 542 }
893 543
894 - function addQueryVar( key, value ) {
895 - var kvp, i, x;
544 + function addQueryVar(key, value) {
545 + key = encodeURI(key);
546 + value = encodeURI(value);
896 547
897 - key = encodeURI( key );
898 - value = encodeURI( value );
548 + var kvp = document.location.search.substr(1).split('&');
899 549
900 - kvp = document.location.search.substr( 1 ).split( '&' );
550 + var i=kvp.length; var x; while(i--) {
551 + x = kvp[i].split('=');
901 552
902 - i = kvp.length;
903 - while ( i-- ) {
904 - x = kvp[i].split( '=' );
905 -
906 - if ( x[0] == key ) {
553 + if (x[0]==key) {
907 554 x[1] = value;
908 - kvp[i] = x.join( '=' );
555 + kvp[i] = x.join('=');
909 556 break;
910 557 }
911 558 }
912 559
913 - if ( i < 0 ) {
914 - kvp[ kvp.length ] = [ key, value ].join( '=' );
560 + if (i<0) {
561 + kvp[kvp.length] = [key,value].join('=');
915 562 }
916 563
917 - return kvp.join( '&' );
564 + return kvp.join('&');
918 565 }
919 566
920 567 function addFieldError( $fieldCont, key, jsErrors ) {
921 - var input, id, describedBy, roleString;
922 - if ( $fieldCont.length && $fieldCont.is( ':visible' ) ) {
923 - $fieldCont.addClass( 'frm_blank_field' );
924 - input = $fieldCont.find( 'input, select, textarea' );
925 - id = 'frm_error_field_' + key;
926 - describedBy = input.attr( 'aria-describedby' );
568 + if ( $fieldCont.length && $fieldCont.is(':visible') ) {
569 + $fieldCont.addClass('frm_blank_field');
570 + var input = $fieldCont.find( 'input, select, textarea' ),
571 + id = 'frm_error_field_' + key,
572 + describedBy = input.attr( 'aria-describedby' );
927 573
928 - if ( typeof frmThemeOverride_frmPlaceError === 'function' ) { // eslint-disable-line camelcase
574 + if ( typeof frmThemeOverride_frmPlaceError === 'function' ) {
929 575 frmThemeOverride_frmPlaceError( key, jsErrors );
930 576 } else {
931 - if ( -1 !== jsErrors[key].indexOf( '<div' ) ) {
932 - $fieldCont.append(
933 - jsErrors[key]
934 - );
935 - } else {
936 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
937 - $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
938 - }
577 + $fieldCont.append( '<div class="frm_error" id="' + id + '">'+ jsErrors[key] +'</div>' );
939 578
940 579 if ( typeof describedBy === 'undefined' ) {
941 580 describedBy = id;
942 - } else if ( describedBy.indexOf( id ) === -1 && describedBy.indexOf( 'frm_error_field_' ) === -1 ) {
943 - if ( input.data( 'error-first' ) === 0 ) {
944 - describedBy = describedBy + ' ' + id;
945 - } else {
946 - describedBy = id + ' ' + describedBy;
947 - }
581 + } else if ( describedBy.indexOf( id ) === -1 ) {
582 + describedBy = describedBy + ' ' + id;
948 583 }
949 -
950 584 input.attr( 'aria-describedby', describedBy );
951 585 }
952 586 input.attr( 'aria-invalid', true );
953 587
954 - jQuery( document ).trigger( 'frmAddFieldError', [ $fieldCont, key, jsErrors ]);
588 + jQuery(document).trigger('frmAddFieldError', [ $fieldCont, key, jsErrors ] );
955 589 }
956 590 }
957 591
958 592 function removeFieldError( $fieldCont ) {
959 - var errorMessage = $fieldCont.find( '.frm_error' ),
960 - errorId = errorMessage.attr( 'id' ),
593 + var errorMessage = $fieldCont.find('.frm_error'),
594 + errorId = errorMessage.attr('id'),
961 595 input = $fieldCont.find( 'input, select, textarea' ),
962 596 describedBy = input.attr( 'aria-describedby' );
963 597
964 - $fieldCont.removeClass( 'frm_blank_field has-error' );
598 + $fieldCont.removeClass('frm_blank_field has-error');
965 599 errorMessage.remove();
966 600 input.attr( 'aria-invalid', false );
967 - input.removeAttr( 'aria-describedby' );
968 601
969 602 if ( typeof describedBy !== 'undefined' ) {
970 603 describedBy = describedBy.replace( errorId, '' );
971 604 input.attr( 'aria-describedby', describedBy );
@@ -972,15 +605,15 @@
972 605 }
973 606 }
974 607
975 608 function removeAllErrors() {
976 - jQuery( '.form-field' ).removeClass( 'frm_blank_field has-error' );
977 - jQuery( '.form-field .frm_error' ).replaceWith( '' );
978 - jQuery( '.frm_error_style' ).remove();
609 + jQuery('.form-field').removeClass('frm_blank_field has-error');
610 + jQuery('.form-field .frm_error').replaceWith('');
611 + jQuery('.frm_error_style').remove();
979 612 }
980 613
981 614 function scrollToFirstField( object ) {
982 - var field = jQuery( object ).find( '.frm_blank_field' ).first();
615 + var field = jQuery(object).find('.frm_blank_field:first');
983 616 if ( field.length ) {
984 617 frmFrontForm.scrollMsg( field, object, true );
985 618 }
986 619 }
@@ -987,116 +620,95 @@
987 620
988 621 function showSubmitLoading( $object ) {
989 622 showLoadingIndicator( $object );
990 623 disableSubmitButton( $object );
991 - disableSaveDraft( $object );
992 624 }
993 625
994 626 function showLoadingIndicator( $object ) {
995 - if ( ! $object.hasClass( 'frm_loading_form' ) && ! $object.hasClass( 'frm_loading_prev' ) ) {
996 - addLoadingClass( $object );
627 + if ( !$object.hasClass('frm_loading_form') ) {
628 + $object.addClass('frm_loading_form');
629 +
997 630 $object.trigger( 'frmStartFormLoading' );
998 631 }
999 632 }
1000 633
1001 - function addLoadingClass( $object ) {
1002 - var loadingClass = isGoingToPrevPage( $object ) ? 'frm_loading_prev' : 'frm_loading_form';
1003 -
1004 - $object.addClass( loadingClass );
1005 - }
1006 -
1007 - function isGoingToPrevPage( $object ) {
1008 - return ( typeof frmProForm !== 'undefined' && frmProForm.goingToPreviousPage( $object ) );
1009 - }
1010 -
1011 634 function removeSubmitLoading( $object, enable, processesRunning ) {
1012 - var loadingForm;
1013 -
1014 635 if ( processesRunning > 0 ) {
1015 636 return;
1016 637 }
1017 638
1018 - loadingForm = jQuery( '.frm_loading_form' );
1019 - loadingForm.removeClass( 'frm_loading_form' );
1020 - loadingForm.removeClass( 'frm_loading_prev' );
639 + $object.removeClass('frm_loading_form');
1021 640
1022 - loadingForm.trigger( 'frmEndFormLoading' );
641 + $object.trigger( 'frmEndFormLoading' );
1023 642
1024 643 if ( enable === 'enable' ) {
1025 - enableSubmitButton( loadingForm );
1026 - enableSaveDraft( loadingForm );
644 + enableSubmitButton( $object );
1027 645 }
1028 646 }
1029 647
1030 648 function showFileLoading( object ) {
1031 - var fileval,
1032 - loading = document.getElementById( 'frm_loading' );
649 + var loading = document.getElementById('frm_loading');
1033 650 if ( loading !== null ) {
1034 - fileval = jQuery( object ).find( 'input[type=file]' ).val();
1035 - if ( typeof fileval !== 'undefined' && fileval !== '' ) {
1036 - setTimeout( function() {
1037 - jQuery( loading ).fadeIn( 'slow' );
1038 - }, 2000 );
651 + var file_val = jQuery(object).find('input[type=file]').val();
652 + if ( typeof file_val !== 'undefined' && file_val !== '' ) {
653 + setTimeout(function(){
654 + jQuery(loading).fadeIn('slow');
655 + },2000);
1039 656 }
1040 657 }
1041 658 }
1042 659
1043 - function clearDefault() {
660 + function replaceCheckedRecaptcha( object, checkPage ) {
661 + var $recapField = jQuery(object).find('.frm-g-recaptcha, .g-recaptcha');
662 + if($recapField.length ){
663 + if ( checkPage ) {
664 + var morePages = jQuery(object).find('.frm_next_page').length < 1 || jQuery(object).find('.frm_next_page').val() < 1;
665 + if ( ! morePages ) {
666 + return;
667 + }
668 + }
669 + $recapField.closest('.frm_form_field').replaceWith('<input type="hidden" name="recaptcha_checked" value="'+ frm_js.nonce +'">');
670 + }
671 + }
672 +
673 + function clearDefault(){
1044 674 /*jshint validthis:true */
1045 - toggleDefault( jQuery( this ), 'clear' );
675 + toggleDefault(jQuery(this), 'clear');
1046 676 }
1047 677
1048 - function replaceDefault() {
678 + function replaceDefault(){
1049 679 /*jshint validthis:true */
1050 - toggleDefault( jQuery( this ), 'replace' );
680 + toggleDefault(jQuery(this), 'replace');
1051 681 }
1052 -
1053 - function toggleDefault( $thisField, e ) {
682 +
683 + function toggleDefault($thisField, e){
1054 684 // TODO: Fix this for a default value that is a number or array
1055 - var thisVal,
1056 - v = $thisField.data( 'frmval' ).replace( /(\n|\r\n)/g, '\r' );
685 + var v = $thisField.data('frmval').replace(/(\n|\r\n)/g, '\r');
1057 686 if ( v === '' || typeof v === 'undefined' ) {
1058 687 return false;
1059 688 }
1060 - thisVal = $thisField.val().replace( /(\n|\r\n)/g, '\r' );
1061 -
1062 - if ( 'replace' === e ) {
689 + var thisVal = $thisField.val().replace(/(\n|\r\n)/g, '\r');
690 +
691 + if ( 'replace' == e ) {
1063 692 if ( thisVal === '' ) {
1064 - $thisField.addClass( 'frm_default' ).val( v );
693 + $thisField.addClass('frm_default').val(v);
1065 694 }
1066 695 } else if ( thisVal == v ) {
1067 - $thisField.removeClass( 'frm_default' ).val( '' );
696 + $thisField.removeClass('frm_default').val('');
1068 697 }
1069 698 }
1070 699
1071 - function resendEmail() {
700 + function resendEmail(){
1072 701 /*jshint validthis:true */
1073 - var $link = jQuery( this ),
1074 - entryId = this.getAttribute( 'data-eid' ),
1075 - formId = this.getAttribute( 'data-fid' ),
1076 - label = $link.find( '.frm_link_label' );
1077 - if ( label.length < 1 ) {
1078 - label = $link;
1079 - }
1080 - label.append( '<span class="frm-wait"></span>' );
1081 -
702 + var $link = jQuery(this);
703 + var entry_id = $link.data('eid');
704 + var form_id = $link.data('fid');
705 + $link.append('<span class="spinner" style="display:inline"></span>');
1082 706 jQuery.ajax({
1083 - type: 'POST',
1084 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1085 - data: {
1086 - action: 'frm_entries_send_email',
1087 - entry_id: entryId,
1088 - form_id: formId,
1089 - nonce: frm_js.nonce // eslint-disable-line camelcase
1090 - },
1091 - success: function( msg ) {
1092 - var admin = document.getElementById( 'wpbody' );
1093 - if ( admin === null ) {
1094 - label.html( msg );
1095 - } else {
1096 - label.html( '' );
1097 - $link.after( msg );
1098 - }
707 + type:'POST',url:frm_js.ajax_url,
708 + data:{action:'frm_entries_send_email', entry_id:entry_id, form_id:form_id, nonce:frm_js.nonce},
709 + success:function(msg){
710 + $link.replaceWith(msg);
1099 711 }
1100 712 });
1101 713 return false;
1102 714 }
@@ -1106,13 +718,13 @@
1106 718 *********************************************/
1107 719
1108 720 function confirmClick() {
1109 721 /*jshint validthis:true */
1110 - var message = jQuery( this ).data( 'frmconfirm' );
1111 - return confirm( message );
722 + var message = jQuery(this).data('frmconfirm');
723 + return confirm(message);
1112 724 }
1113 725
1114 - function toggleDiv() {
726 + function toggleDiv(){
1115 727 /*jshint validthis:true */
1116 728 var div = jQuery( this ).data( 'frmtoggle' );
1117 729 if ( jQuery( div ).is( ':visible' ) ) {
1118 730 jQuery( div ).slideUp( 'fast' );
@@ -1125,41 +737,59 @@
1125 737 /**********************************************
1126 738 * Fallback functions
1127 739 *********************************************/
1128 740
1129 - function addTrimFallbackForIE() {
741 + function addIndexOfFallbackForIE8() {
742 + if ( !Array.prototype.indexOf ) {
743 + Array.prototype.indexOf = function(elt /*, from*/) {
744 + var len = this.length >>> 0;
745 +
746 + var from = Number(arguments[1]) || 0;
747 + from = (from < 0) ? Math.ceil(from) : Math.floor(from);
748 + if (from < 0) {
749 + from += len;
750 + }
751 +
752 + for (; from < len; from++) {
753 + if ( from in this && this[from] === elt ) {
754 + return from;
755 + }
756 + }
757 + return -1;
758 + };
759 + }
760 + }
761 +
762 + function addTrimFallbackForIE8(){
1130 763 if ( typeof String.prototype.trim !== 'function' ) {
1131 764 String.prototype.trim = function() {
1132 - return this.replace( /^\s+|\s+$/g, '' );
765 + return this.replace(/^\s+|\s+$/g, '');
1133 766 };
1134 767 }
1135 768 }
1136 769
1137 - function addFilterFallbackForIE() {
1138 - var t, len, res, thisp, i, val;
770 + function addFilterFallbackForIE8(){
771 + if ( !Array.prototype.filter ) {
1139 772
1140 - if ( ! Array.prototype.filter ) {
773 + Array.prototype.filter = function(fun /*, thisp */) {
1141 774
1142 - Array.prototype.filter = function( fun /*, thisp */ ) {
1143 -
1144 775 if ( this === void 0 || this === null ) {
1145 776 throw new TypeError();
1146 777 }
1147 778
1148 - t = Object( this );
1149 - len = t.length >>> 0;
779 + var t = Object( this );
780 + var len = t.length >>> 0;
1150 781 if ( typeof fun !== 'function' ) {
1151 782 throw new TypeError();
1152 783 }
1153 784
1154 - res = [];
1155 - thisp = arguments[1];
1156 - for ( i = 0; i < len; i++ ) {
785 + var res = [];
786 + var thisp = arguments[1];
787 + for (var i = 0; i < len; i++) {
1157 788 if ( i in t ) {
1158 - val = t[i]; // in case fun mutates this
1159 - if ( fun.call( thisp, val, i, t ) ) {
1160 - res.push( val );
1161 - }
789 + var val = t[i]; // in case fun mutates this
790 + if (fun.call(thisp, val, i, t))
791 + res.push(val);
1162 792 }
1163 793 }
1164 794
1165 795 return res;
@@ -1166,397 +796,52 @@
1166 796 };
1167 797 }
1168 798 }
1169 799
1170 - /**
1171 - * Check for -webkit-box-shadow css value for input:-webkit-autofill selector.
1172 - * If this is a match, the User is autofilling the input on a Webkit browser.
1173 - * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete.
1174 - */
1175 - function onHoneypotFieldChange() {
1176 - var css = jQuery( this ).css( 'box-shadow' );
1177 - if ( css.match( /inset/ ) ) {
1178 - this.parentNode.removeChild( this );
1179 - }
1180 - }
800 + function addKeysFallbackForIE8(){
801 + if ( !Object.keys ) {
802 + Object.keys = function(obj) {
803 + var keys = [];
1181 804
1182 - function maybeMakeHoneypotFieldsUntabbable() {
1183 - document.addEventListener( 'keydown', handleKeyUp );
805 + for (var i in obj) {
806 + if (obj.hasOwnProperty(i)) {
807 + keys.push(i);
808 + }
809 + }
1184 810
1185 - function handleKeyUp( event ) {
1186 - var code;
1187 -
1188 - if ( 'undefined' !== typeof event.key ) {
1189 - code = event.key;
1190 - } else if ( 'undefined' !== typeof event.keyCode && 9 === event.keyCode ) {
1191 - code = 'Tab';
1192 - }
1193 -
1194 - if ( 'Tab' === code ) {
1195 - makeHoneypotFieldsUntabbable();
1196 - document.removeEventListener( 'keydown', handleKeyUp );
1197 - }
811 + return keys;
812 + };
1198 813 }
1199 -
1200 - function makeHoneypotFieldsUntabbable() {
1201 - document.querySelectorAll( '.frm_verify' ).forEach(
1202 - function( input ) {
1203 - if ( input.id && 0 === input.id.indexOf( 'frm_email_' ) ) {
1204 - input.setAttribute( 'tabindex', -1 );
1205 - }
1206 - }
1207 - );
1208 - }
1209 814 }
1210 815
1211 - /**
1212 - * Focus on the first sub field when clicking to the primary label of combo field.
1213 - *
1214 - * @since 4.10.02
1215 - */
1216 - function changeFocusWhenClickComboFieldLabel() {
1217 - var label;
816 + return{
817 + init: function(){
818 + jQuery(document).off('submit.formidable','.frm-show-form');
819 + jQuery(document).on('submit.formidable','.frm-show-form', frmFrontForm.submitForm);
1218 820
1219 - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1220 - comboInputsContainer.forEach( function( inputsContainer ) {
1221 - if ( ! inputsContainer.closest( '.frm_form_field' ) ) {
1222 - return;
1223 - }
1224 -
1225 - label = inputsContainer.closest( '.frm_form_field' ).querySelector( '.frm_primary_label' );
1226 - if ( ! label ) {
1227 - return;
1228 - }
1229 -
1230 - label.addEventListener( 'click', function( e ) {
1231 - inputsContainer.querySelector( '.frm_form_field:first-child input, .frm_form_field:first-child select, .frm_form_field:first-child textarea' ).focus();
1232 - });
1233 - });
1234 - }
1235 -
1236 - function checkForErrorsAndMaybeSetFocus() {
1237 - var errors, element, timeoutCallback;
1238 -
1239 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1240 - return;
1241 - }
1242 -
1243 - errors = document.querySelectorAll( '.frm_form_field .frm_error' );
1244 - if ( ! errors.length ) {
1245 - return;
1246 - }
1247 -
1248 - element = errors[0];
1249 - do {
1250 - element = element.previousSibling;
1251 - if ( -1 !== [ 'input', 'select', 'textarea' ].indexOf( element.nodeName.toLowerCase() ) ) {
1252 - element.focus();
1253 - break;
1254 - }
1255 -
1256 - if ( 'undefined' !== typeof element.classList ) {
1257 - if ( element.classList.contains( 'html-active' ) ) {
1258 - timeoutCallback = function() {
1259 - var textarea = element.querySelector( 'textarea' );
1260 - if ( null !== textarea ) {
1261 - textarea.focus();
1262 - }
1263 - };
1264 - } else if ( element.classList.contains( 'tmce-active' ) ) {
1265 - timeoutCallback = function() {
1266 - tinyMCE.activeEditor.focus();
1267 - };
1268 - }
1269 -
1270 - if ( 'function' === typeof timeoutCallback ) {
1271 - setTimeout( timeoutCallback, 0 );
1272 - break;
1273 - }
1274 - }
1275 - } while ( element.previousSibling );
1276 - }
1277 -
1278 - /**
1279 - * Checks if is on IE browser.
1280 - *
1281 - * @since 5.4
1282 - *
1283 - * @return {Boolean}
1284 - */
1285 - function isIE() {
1286 - return navigator.userAgent.indexOf( 'MSIE' ) > -1 || navigator.userAgent.indexOf( 'Trident' ) > -1;
1287 - }
1288 -
1289 - /**
1290 - * Does the same as jQuery( document ).on( 'event', 'selector', handler ).
1291 - *
1292 - * @since 5.4
1293 - *
1294 - * @param {String} event Event name.
1295 - * @param {String} selector Selector.
1296 - * @param {Function} handler Handler.
1297 - * @param {Boolean|Object} options Options to be added to `addEventListener()` method. Default is `false`.
1298 - */
1299 - function documentOn( event, selector, handler, options ) {
1300 - if ( 'undefined' === typeof options ) {
1301 - options = false;
1302 - }
1303 -
1304 - document.addEventListener( event, function( e ) {
1305 - var target;
1306 -
1307 - // loop parent nodes from the target to the delegation node.
1308 - for ( target = e.target; target && target != this; target = target.parentNode ) {
1309 - if ( target && target.matches && target.matches( selector ) ) {
1310 - handler.call( target, e );
1311 - break;
1312 - }
1313 - }
1314 - }, options );
1315 - }
1316 -
1317 - function initFloatingLabels() {
1318 - var checkFloatLabel, checkDropdownLabel, checkPlaceholderIE, runOnLoad, selector, floatClass;
1319 -
1320 - selector = '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea';
1321 - floatClass = 'frm_label_float_top';
1322 -
1323 - checkFloatLabel = function( input ) {
1324 - var container, shouldFloatTop, firstOpt;
1325 -
1326 - container = input.closest( '.frm_inside_container' );
1327 - if ( ! container ) {
1328 - return;
1329 - }
1330 -
1331 - shouldFloatTop = input.value || document.activeElement === input;
1332 -
1333 - container.classList.toggle( floatClass, shouldFloatTop );
1334 -
1335 - if ( 'SELECT' === input.tagName ) {
1336 - firstOpt = input.querySelector( 'option:first-child' );
1337 -
1338 - if ( shouldFloatTop ) {
1339 - if ( firstOpt.hasAttribute( 'data-label' ) ) {
1340 - firstOpt.textContent = firstOpt.getAttribute( 'data-label' );
1341 - firstOpt.removeAttribute( 'data-label' );
1342 - }
1343 - } else {
1344 - if ( firstOpt.textContent ) {
1345 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1346 - firstOpt.textContent = '';
1347 - }
1348 - }
1349 - } else if ( isIE() ) {
1350 - checkPlaceholderIE( input );
1351 - }
1352 - };
1353 -
1354 - checkDropdownLabel = function() {
1355 - document.querySelectorAll( '.frm-show-form .frm_inside_container:not(.' + floatClass + ') select' ).forEach( function( input ) {
1356 - var firstOpt = input.querySelector( 'option:first-child' );
1357 -
1358 - if ( firstOpt.textContent ) {
1359 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1360 - firstOpt.textContent = '';
1361 - }
1362 - });
1363 - };
1364 -
1365 - checkPlaceholderIE = function( input ) {
1366 - if ( input.value ) {
1367 - // Don't need to handle this case because placeholder isn't shown.
1368 - return;
1369 - }
1370 -
1371 - if ( document.activeElement === input ) {
1372 - if ( input.hasAttribute( 'data-placeholder' ) ) {
1373 - input.placeholder = input.getAttribute( 'data-placeholder' );
1374 - input.removeAttribute( 'data-placeholder' );
1375 - }
1376 - } else {
1377 - if ( input.placeholder ) {
1378 - input.setAttribute( 'data-placeholder', input.placeholder );
1379 - input.placeholder = '';
1380 - }
1381 - }
1382 - };
1383 -
1384 - [ 'focus', 'blur', 'change' ].forEach( function( eventName ) {
1385 - documentOn(
1386 - eventName,
1387 - selector,
1388 - function( event ) {
1389 - checkFloatLabel( event.target );
1390 - },
1391 - true
1392 - );
1393 - });
1394 -
1395 - jQuery( document ).on( 'change', selector, function( event ) {
1396 - checkFloatLabel( event.target );
1397 - });
1398 -
1399 - runOnLoad = function( firstLoad ) {
1400 - if ( firstLoad && document.activeElement && -1 !== [ 'INPUT', 'SELECT', 'TEXTAREA' ].indexOf( document.activeElement.tagName ) ) {
1401 - checkFloatLabel( document.activeElement );
1402 - } else if ( firstLoad ) {
1403 - document.querySelectorAll( '.frm_inside_container' ).forEach(
1404 - function( container ) {
1405 - var input = container.querySelector( 'input, select, textarea' );
1406 - if ( input && '' !== input.value ) {
1407 - checkFloatLabel( input );
1408 - }
1409 - }
1410 - );
1411 - }
1412 -
1413 - checkDropdownLabel();
1414 -
1415 - if ( isIE() ) {
1416 - document.querySelectorAll( selector ).forEach( function( input ) {
1417 - checkPlaceholderIE( input );
1418 - });
1419 - }
1420 - };
1421 -
1422 - runOnLoad( true );
1423 -
1424 - jQuery( document ).on( 'frmPageChanged', function( event ) {
1425 - runOnLoad();
1426 - });
1427 -
1428 - document.addEventListener( 'frm_after_start_over', function( event ) {
1429 - runOnLoad();
1430 - });
1431 - }
1432 -
1433 - function shouldUpdateValidityMessage( target ) {
1434 - if ( 'INPUT' !== target.nodeName ) {
1435 - return false;
1436 - }
1437 -
1438 - if ( ! target.dataset.invmsg ) {
1439 - return false;
1440 - }
1441 -
1442 - if ( 'text' !== target.getAttribute( 'type' ) ) {
1443 - return false;
1444 - }
1445 -
1446 - if ( target.classList.contains( 'frm_verify' ) ) {
1447 - return false;
1448 - }
1449 -
1450 - return true;
1451 - }
1452 -
1453 - function maybeClearCustomValidityMessage( event, field ) {
1454 - var key,
1455 - isInvalid = false;
1456 -
1457 - if ( ! shouldUpdateValidityMessage( field ) ) {
1458 - return;
1459 - }
1460 -
1461 - for ( key in field.validity ) {
1462 - if ( 'customError' === key ) {
1463 - continue;
1464 - }
1465 - if ( 'valid' !== key && field.validity[ key ] === true ) {
1466 - isInvalid = true;
1467 - break;
1468 - }
1469 - };
1470 -
1471 - if ( ! isInvalid ) {
1472 - field.setCustomValidity( '' );
1473 - }
1474 - }
1475 -
1476 - function maybeShowNewTabFallbackMessage() {
1477 - var messageEl;
1478 -
1479 - if ( ! window.frmShowNewTabFallback ) {
1480 - return;
1481 - }
1482 -
1483 - messageEl = document.querySelector( '#frm_form_' + frmShowNewTabFallback.formId + '_container .frm_message' );
1484 - if ( ! messageEl ) {
1485 - return;
1486 - }
1487 -
1488 - messageEl.insertAdjacentHTML( 'beforeend', ' ' + frmShowNewTabFallback.message );
1489 - }
1490 -
1491 - function setCustomValidityMessage() {
1492 - var forms, length, index;
1493 -
1494 - forms = document.getElementsByClassName( 'frm-show-form' );
1495 - length = forms.length;
1496 -
1497 - for ( index = 0; index < length; ++index ) {
1498 - forms[ index ].addEventListener(
1499 - 'invalid',
1500 - function( event ) {
1501 - var target = event.target;
1502 -
1503 - if ( shouldUpdateValidityMessage( target ) ) {
1504 - target.setCustomValidity( target.dataset.invmsg );
1505 - }
1506 - },
1507 - true
1508 - );
1509 - }
1510 - }
1511 -
1512 - return {
1513 - init: function() {
1514 - maybeAddPolyfills();
1515 -
1516 - jQuery( document ).off( 'submit.formidable', '.frm-show-form' );
1517 - jQuery( document ).on( 'submit.formidable', '.frm-show-form', frmFrontForm.submitForm );
1518 -
1519 821 jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() {
1520 822 if ( jQuery( this ).val() === '' ) {
1521 - jQuery( this ).trigger( 'blur' );
823 + jQuery( this ).blur();
1522 824 }
1523 - });
825 + } );
826 +
827 + jQuery(document).on('focus', '.frm_toggle_default', clearDefault);
828 + jQuery(document).on('blur', '.frm_toggle_default', replaceDefault);
829 + jQuery('.frm_toggle_default').blur();
1524 830
1525 - jQuery( document ).on( 'focus', '.frm_toggle_default', clearDefault );
1526 - jQuery( document ).on( 'blur', '.frm_toggle_default', replaceDefault );
1527 - jQuery( '.frm_toggle_default' ).trigger( 'blur' );
831 + jQuery(document.getElementById('frm_resend_email')).click(resendEmail);
1528 832
1529 - jQuery( document.getElementById( 'frm_resend_email' ) ).on( 'click', resendEmail );
833 + jQuery(document).on('change', '.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]', frmFrontForm.fieldValueChanged );
834 + jQuery(document).on('change keyup', '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea', maybeShowLabel);
1530 835
1531 - jQuery( document ).on( 'change', '.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]', frmFrontForm.fieldValueChanged );
836 + jQuery(document).on('click', 'a[data-frmconfirm]', confirmClick);
837 + jQuery('a[data-frmtoggle]').click(toggleDiv);
1532 838
1533 - jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange );
1534 - maybeMakeHoneypotFieldsUntabbable();
1535 -
1536 - jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick );
1537 - jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv );
1538 -
1539 - checkForErrorsAndMaybeSetFocus();
1540 -
1541 - // Focus on the first sub field when clicking to the primary label of combo field.
1542 - changeFocusWhenClickComboFieldLabel();
1543 -
1544 - // Add fallbacks for IE.
1545 - addTrimFallbackForIE(); // Trim only works in IE10+.
1546 - addFilterFallbackForIE(); // Filter is not supported in any version of IE.
1547 -
1548 - initFloatingLabels();
1549 - maybeShowNewTabFallbackMessage();
1550 -
1551 - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage );
1552 - setCustomValidityMessage();
1553 - jQuery( document ).on( 'frmFieldChanged', maybeClearCustomValidityMessage );
1554 -
1555 - setSelectPlaceholderColor();
1556 -
1557 - // Elementor popup show event. Fix Elementor Popup && FF Captcha field conflicts
1558 - jQuery( document ).on( 'elementor/popup/show', frmRecaptcha );
839 + // Add fallbacks for the beloved IE8
840 + addIndexOfFallbackForIE8();
841 + addTrimFallbackForIE8();
842 + addFilterFallbackForIE8();
843 + addKeysFallbackForIE8();
1559 844 },
1560 845
1561 846 getFieldId: function( field, fullID ) {
1562 847 return getFieldId( field, fullID );
@@ -1562,61 +847,53 @@
1562 847 return getFieldId( field, fullID );
1563 848 },
1564 849
1565 850 renderRecaptcha: function( captcha ) {
1566 - var formID, recaptchaID,
1567 - size = captcha.getAttribute( 'data-size' ),
1568 - rendered = captcha.getAttribute( 'data-rid' ) !== null,
1569 - params = {
1570 - 'sitekey': captcha.getAttribute( 'data-sitekey' ),
1571 - 'size': size,
1572 - 'theme': captcha.getAttribute( 'data-theme' )
1573 - };
1574 -
1575 - if ( rendered ) {
1576 - return;
1577 - }
1578 -
851 + var size = captcha.getAttribute('data-size');
852 + var params = {
853 + 'sitekey': captcha.getAttribute('data-sitekey'),
854 + 'size': size,
855 + 'theme': captcha.getAttribute('data-theme')
856 + };
1579 857 if ( size === 'invisible' ) {
1580 - formID = jQuery( captcha ).closest( 'form' ).find( 'input[name="form_id"]' ).val();
1581 - jQuery( captcha ).closest( '.frm_form_field .frm_primary_label' ).hide();
1582 - params.callback = function( token ) {
1583 - frmFrontForm.afterRecaptcha( token, formID );
858 + var formID = jQuery(captcha).closest('form').find('input[name="form_id"]').val();
859 + jQuery(captcha).closest('.frm_form_field').hide();
860 + params.callback = function(token) {
861 + frmFrontForm.afterRecaptcha(token, formID);
1584 862 };
1585 863 }
1586 864
1587 - recaptchaID = grecaptcha.render( captcha.id, params );
865 + var recaptchaID = grecaptcha.render( captcha.id, params );
1588 866
1589 - captcha.setAttribute( 'data-rid', recaptchaID );
867 + captcha.setAttribute('data-rid', recaptchaID);
1590 868 },
1591 869
1592 - afterSingleRecaptcha: function() {
1593 - var object = jQuery( '.frm-show-form .g-recaptcha' ).closest( 'form' )[0];
870 + afterSingleRecaptcha: function(token){
871 + var object = jQuery('.frm-show-form .g-recaptcha').closest('form')[0];
1594 872 frmFrontForm.submitFormNow( object );
1595 873 },
1596 874
1597 - afterRecaptcha: function( token, formID ) {
1598 - var object = jQuery( '#frm_form_' + formID + '_container form' )[0];
875 + afterRecaptcha: function(token, formID){
876 + var object = jQuery('#frm_form_'+ formID +'_container form')[0];
1599 877 frmFrontForm.submitFormNow( object );
1600 878 },
1601 879
1602 - submitForm: function( e ) {
880 + submitForm: function(e){
1603 881 frmFrontForm.submitFormManual( e, this );
1604 882 },
1605 883
1606 - submitFormManual: function( e, object ) {
1607 - var isPro, errors,
1608 - invisibleRecaptcha = hasInvisibleRecaptcha( object ),
1609 - classList = object.className.trim().split( /\s+/gi );
884 + submitFormManual: function(e, object){
885 + var invisibleRecaptcha = hasInvisibleRecaptcha(object);
1610 886
887 + var classList = object.className.trim().split(/\s+/gi);
1611 888 if ( classList && invisibleRecaptcha.length < 1 ) {
1612 - isPro = classList.indexOf( 'frm_pro_form' ) > -1;
889 + var isPro = classList.indexOf('frm_pro_form') > -1;
1613 890 if ( ! isPro ) {
1614 891 return;
1615 892 }
1616 893 }
1617 894
1618 - if ( jQuery( 'body' ).hasClass( 'wp-admin' ) && jQuery( object ).closest( '.frmapi-form' ).length < 1 ) {
895 + if ( jQuery('body').hasClass('wp-admin') && jQuery(object).closest('.frmapi-form').length < 1 ) {
1619 896 return;
1620 897 }
1621 898
1622 899 e.preventDefault();
@@ -1627,16 +904,16 @@
1627 904 }
1628 905 }
1629 906
1630 907 if ( invisibleRecaptcha.length ) {
1631 - showLoadingIndicator( jQuery( object ) );
908 + showLoadingIndicator( jQuery(object) );
1632 909 executeInvisibleRecaptcha( invisibleRecaptcha );
1633 910 } else {
1634 911
1635 - errors = frmFrontForm.validateFormSubmit( object );
912 + var errors = frmFrontForm.validateFormSubmit( object );
1636 913
1637 - if ( Object.keys( errors ).length === 0 ) {
1638 - showSubmitLoading( jQuery( object ) );
914 + if ( Object.keys(errors).length === 0 ) {
915 + showSubmitLoading( jQuery(object) );
1639 916
1640 917 frmFrontForm.submitFormNow( object, classList );
1641 918 }
1642 919 }
@@ -1641,27 +918,16 @@
1641 918 }
1642 919 }
1643 920 },
1644 921
1645 - submitFormNow: function( object ) {
1646 - var hasFileFields, antispamInput,
1647 - classList = object.className.trim().split( /\s+/gi );
1648 -
1649 - if ( object.hasAttribute( 'data-token' ) && null === object.querySelector( '[name="antispam_token"]' ) ) {
1650 - // include the antispam token on form submit.
1651 - antispamInput = document.createElement( 'input' );
1652 - antispamInput.type = 'hidden';
1653 - antispamInput.name = 'antispam_token';
1654 - antispamInput.value = object.getAttribute( 'data-token' );
1655 - object.appendChild( antispamInput );
1656 - }
1657 -
1658 - if ( classList.indexOf( 'frm_ajax_submit' ) > -1 ) {
1659 - hasFileFields = jQuery( object ).find( 'input[type="file"]' ).filter( function() {
1660 - return !! this.value;
922 + submitFormNow: function(object) {
923 + var classList = object.className.trim().split(/\s+/gi);
924 + if ( classList.indexOf('frm_ajax_submit') > -1 ) {
925 + var hasFileFields = jQuery(object).find('input[type="file"]').filter(function () {
926 + return !!this.value;
1661 927 }).length;
1662 928 if ( hasFileFields < 1 ) {
1663 - action = jQuery( object ).find( 'input[name="frm_action"]' ).val();
929 + action = jQuery(object).find('input[name="frm_action"]').val();
1664 930 frmFrontForm.checkFormErrors( object, action );
1665 931 } else {
1666 932 object.submit();
1667 933 }
@@ -1669,10 +935,10 @@
1669 935 object.submit();
1670 936 }
1671 937 },
1672 938
1673 - validateFormSubmit: function( object ) {
1674 - if ( typeof tinyMCE !== 'undefined' && jQuery( object ).find( '.wp-editor-wrap' ).length ) {
939 + validateFormSubmit: function( object ){
940 + if ( typeof tinyMCE !== 'undefined' && jQuery(object).find('.wp-editor-wrap').length ) {
1675 941 tinyMCE.triggerSave();
1676 942 }
1677 943
1678 944 jsErrors = [];
@@ -1679,9 +945,9 @@
1679 945
1680 946 if ( shouldJSValidate( object ) ) {
1681 947 frmFrontForm.getAjaxFormErrors( object );
1682 948
1683 - if ( Object.keys( jsErrors ).length ) {
949 + if ( Object.keys(jsErrors).length ) {
1684 950 frmFrontForm.addAjaxFormErrors( object );
1685 951 }
1686 952 }
1687 953
@@ -1688,16 +954,14 @@
1688 954 return jsErrors;
1689 955 },
1690 956
1691 957 getAjaxFormErrors: function( object ) {
1692 - var customErrors, key;
1693 -
1694 958 jsErrors = validateForm( object );
1695 - if ( typeof frmThemeOverride_jsErrors === 'function' ) { // eslint-disable-line camelcase
1696 - action = jQuery( object ).find( 'input[name="frm_action"]' ).val();
1697 - customErrors = frmThemeOverride_jsErrors( action, object );
1698 - if ( Object.keys( customErrors ).length ) {
1699 - for ( key in customErrors ) {
959 + if ( typeof frmThemeOverride_jsErrors === 'function' ) {
960 + action = jQuery(object).find('input[name="frm_action"]').val();
961 + var customErrors = frmThemeOverride_jsErrors( action, object );
962 + if ( Object.keys(customErrors).length ) {
963 + for ( var key in customErrors ) {
1700 964 jsErrors[ key ] = customErrors[ key ];
1701 965 }
1702 966 }
1703 967 }
@@ -1705,13 +969,12 @@
1705 969 return jsErrors;
1706 970 },
1707 971
1708 972 addAjaxFormErrors: function( object ) {
1709 - var key, $fieldCont;
1710 973 removeAllErrors();
1711 974
1712 - for ( key in jsErrors ) {
1713 - $fieldCont = jQuery( object ).find( '#frm_field_' + key + '_container' );
975 + for ( var key in jsErrors ) {
976 + var $fieldCont = jQuery(object).find('#frm_field_'+key+'_container');
1714 977
1715 978 if ( $fieldCont.length ) {
1716 979 addFieldError( $fieldCont, key, jsErrors );
1717 980 } else {
@@ -1720,69 +983,66 @@
1720 983 }
1721 984 }
1722 985
1723 986 scrollToFirstField( object );
1724 - checkForErrorsAndMaybeSetFocus();
1725 987 },
1726 988
1727 - checkFormErrors: function( object, action ) {
989 + checkFormErrors: function(object, action){
1728 990 getFormErrors( object, action );
1729 991 },
1730 992
1731 - checkRequiredField: function( field, errors ) {
993 + checkRequiredField: function( field, errors ){
1732 994 return checkRequiredField( field, errors );
1733 995 },
1734 996
1735 - showSubmitLoading: function( $object ) {
997 + showSubmitLoading: function( $object ){
1736 998 showSubmitLoading( $object );
1737 999 },
1738 1000
1739 - removeSubmitLoading: function( $object, enable, processesRunning ) {
1001 + removeSubmitLoading: function( $object, enable, processesRunning ){
1740 1002 removeSubmitLoading( $object, enable, processesRunning );
1741 1003 },
1742 1004
1743 - scrollToID: function( id ) {
1744 - var object = jQuery( document.getElementById( id ) );
1745 - frmFrontForm.scrollMsg( object, false );
1746 - },
1005 + scrollToID: function(id){
1006 + var object = jQuery(document.getElementById(id));
1007 + frmFrontForm.scrollMsg( object, false );
1008 + },
1747 1009
1748 1010 scrollMsg: function( id, object, animate ) {
1749 - var newPos, m, b, screenTop, screenBottom,
1750 - scrollObj = '';
1751 - if ( typeof object === 'undefined' ) {
1752 - scrollObj = jQuery( document.getElementById( 'frm_form_' + id + '_container' ) );
1753 - if ( scrollObj.length < 1 ) {
1011 + var scrollObj = '';
1012 + if(typeof(object) === 'undefined'){
1013 + scrollObj = jQuery(document.getElementById('frm_form_'+id+'_container'));
1014 + if(scrollObj.length < 1 ){
1754 1015 return;
1755 1016 }
1756 1017 } else if ( typeof id === 'string' ) {
1757 - scrollObj = jQuery( object ).find( '#frm_field_' + id + '_container' );
1018 + scrollObj = jQuery(object).find('#frm_field_'+id+'_container');
1758 1019 } else {
1759 1020 scrollObj = id;
1760 1021 }
1761 1022
1762 - jQuery( scrollObj ).trigger( 'focus' );
1763 - newPos = scrollObj.offset().top;
1764 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1023 + var newPos = scrollObj.offset().top;
1024 + if ( !newPos ){
1765 1025 return;
1766 1026 }
1767 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1027 + newPos = newPos-frm_js.offset;
1768 1028
1769 - m = jQuery( 'html' ).css( 'margin-top' );
1770 - b = jQuery( 'body' ).css( 'margin-top' );
1771 - if ( m || b ) {
1772 - newPos = newPos - parseInt( m ) - parseInt( b );
1029 + var m=jQuery('html').css('margin-top');
1030 + var b=jQuery('body').css('margin-top');
1031 + if(m || b){
1032 + newPos = newPos - parseInt(m) - parseInt(b);
1773 1033 }
1774 1034
1775 1035 if ( newPos && window.innerHeight ) {
1776 - screenTop = document.documentElement.scrollTop || document.body.scrollTop;
1777 - screenBottom = screenTop + window.innerHeight;
1036 + var screenTop = document.documentElement.scrollTop || document.body.scrollTop;
1037 + var screenBottom = screenTop + window.innerHeight;
1778 1038
1779 - if ( newPos > screenBottom || newPos < screenTop ) {
1039 + if( newPos > screenBottom || newPos < screenTop ) {
1780 1040 // Not in view
1781 1041 if ( typeof animate === 'undefined' ) {
1782 - jQuery( window ).scrollTop( newPos );
1783 - } else {
1784 - jQuery( 'html,body' ).animate({ scrollTop: newPos }, 500 );
1042 + jQuery(window).scrollTop(newPos);
1043 + }else{
1044 + jQuery('html,body').animate({scrollTop: newPos}, 500);
1785 1045 }
1786 1046 return false;
1787 1047 }
1788 1048 }
@@ -1787,174 +1047,160 @@
1787 1047 }
1788 1048 }
1789 1049 },
1790 1050
1791 - fieldValueChanged: function( e ) {
1051 + fieldValueChanged: function(e){
1792 1052 /*jshint validthis:true */
1793 1053
1794 - var fieldId = frmFrontForm.getFieldId( this, false );
1795 - if ( ! fieldId || typeof fieldId === 'undefined' ) {
1054 + var field_id = frmFrontForm.getFieldId( this, false );
1055 + if ( ! field_id || typeof field_id === 'undefined' ) {
1796 1056 return;
1797 1057 }
1798 1058
1799 - if ( e.frmTriggered && e.frmTriggered == fieldId ) {
1059 + if ( e.frmTriggered && e.frmTriggered == field_id ) {
1800 1060 return;
1801 1061 }
1802 1062
1803 - jQuery( document ).trigger( 'frmFieldChanged', [ this, fieldId, e ]);
1063 + jQuery(document).trigger( 'frmFieldChanged', [ this, field_id, e ] );
1804 1064
1805 1065 if ( e.selfTriggered !== true ) {
1806 - maybeValidateChange( this );
1066 + maybeValidateChange( field_id, this );
1807 1067 }
1808 1068 },
1809 1069
1810 - savingDraft: function( object ) {
1811 - console.warn( 'DEPRECATED: function frmFrontForm.savingDraft in v3.0 use frmProForm.savingDraft' );
1070 + savingDraft: function(object){
1071 + console.warn('DEPRECATED: function frmFrontForm.savingDraft in v3.0 use frmProForm.savingDraft');
1812 1072 if ( typeof frmProForm !== 'undefined' ) {
1813 - return frmProForm.savingDraft( object );
1073 + return frmProForm.savingDraft(object);
1814 1074 }
1815 1075 },
1816 1076
1817 - goingToPreviousPage: function( object ) {
1818 - console.warn( 'DEPRECATED: function frmFrontForm.goingToPreviousPage in v3.0 use frmProForm.goingToPreviousPage' );
1077 + goingToPreviousPage: function(object){
1078 + console.warn('DEPRECATED: function frmFrontForm.goingToPreviousPage in v3.0 use frmProForm.goingToPreviousPage');
1819 1079 if ( typeof frmProForm !== 'undefined' ) {
1820 - return frmProForm.goingToPreviousPage( object );
1080 + return frmProForm.goingToPreviousPage(object);
1821 1081 }
1822 1082 },
1823 1083
1824 - hideOrShowFields: function() {
1825 - console.warn( 'DEPRECATED: function frmFrontForm.hideOrShowFields in v3.0 use frmProForm.hideOrShowFields' );
1084 + hideOrShowFields: function(ids, event ){
1085 + console.warn('DEPRECATED: function frmFrontForm.hideOrShowFields in v3.0 use frmProForm.hideOrShowFields');
1826 1086 if ( typeof frmProForm !== 'undefined' ) {
1827 1087 frmProForm.hideOrShowFields();
1828 1088 }
1829 1089 },
1830 1090
1831 - hidePreviouslyHiddenFields: function() {
1832 - console.warn( 'DEPRECATED: function frmFrontForm.hidePreviouslyHiddenFields in v3.0 use frmProForm.hidePreviouslyHiddenFields' );
1091 + hidePreviouslyHiddenFields: function(){
1092 + console.warn('DEPRECATED: function frmFrontForm.hidePreviouslyHiddenFields in v3.0 use frmProForm.hidePreviouslyHiddenFields');
1833 1093 if ( typeof frmProForm !== 'undefined' ) {
1834 1094 frmProForm.hidePreviouslyHiddenFields();
1835 1095 }
1836 1096 },
1837 1097
1838 - checkDependentDynamicFields: function( ids ) {
1839 - console.warn( 'DEPRECATED: function frmFrontForm.checkDependentDynamicFields in v3.0 use frmProForm.checkDependentDynamicFields' );
1098 + checkDependentDynamicFields: function(ids){
1099 + console.warn('DEPRECATED: function frmFrontForm.checkDependentDynamicFields in v3.0 use frmProForm.checkDependentDynamicFields');
1840 1100 if ( typeof frmProForm !== 'undefined' ) {
1841 - frmProForm.checkDependentDynamicFields( ids );
1101 + frmProForm.checkDependentDynamicFields(ids);
1842 1102 }
1843 1103 },
1844 1104
1845 - checkDependentLookupFields: function( ids ) {
1846 - console.warn( 'DEPRECATED: function frmFrontForm.checkDependentLookupFields in v3.0 use frmProForm.checkDependentLookupFields' );
1105 + checkDependentLookupFields: function(ids){
1106 + console.warn('DEPRECATED: function frmFrontForm.checkDependentLookupFields in v3.0 use frmProForm.checkDependentLookupFields');
1847 1107 if ( typeof frmProForm !== 'undefined' ) {
1848 - frmProForm.checkDependentLookupFields( ids );
1108 + frmProForm.checkDependentLookupFields(ids);
1849 1109 }
1850 1110 },
1851 1111
1852 - loadGoogle: function() {
1853 - console.warn( 'DEPRECATED: function frmFrontForm.loadGoogle in v3.0 use frmProForm.loadGoogle' );
1112 + loadGoogle: function(){
1113 + console.warn('DEPRECATED: function frmFrontForm.loadGoogle in v3.0 use frmProForm.loadGoogle');
1854 1114 frmProForm.loadGoogle();
1855 1115 },
1856 1116
1857 - escapeHtml: function( text ) {
1117 + removeUsedTimes: function( obj, timeField ) {
1118 + console.warn('DEPRECATED: function frmFrontForm.removeUsedTimes in v3.0 use frmProForm.removeUsedTimes');
1119 + if ( typeof frmProForm !== 'undefined' ) {
1120 + frmProForm.removeUsedTimes();
1121 + }
1122 + },
1123 +
1124 + escapeHtml: function(text){
1858 1125 return text
1859 - .replace( /&/g, '&amp;' )
1860 - .replace( /</g, '&lt;' )
1861 - .replace( />/g, '&gt;' )
1862 - .replace( /"/g, '&quot;' )
1863 - .replace( /'/g, '&#039;' );
1126 + .replace(/&/g, '&amp;')
1127 + .replace(/</g, '&lt;')
1128 + .replace(/>/g, '&gt;')
1129 + .replace(/"/g, '&quot;')
1130 + .replace(/'/g, '&#039;');
1864 1131 },
1865 1132
1866 - invisible: function( classes ) {
1867 - jQuery( classes ).css( 'visibility', 'hidden' );
1133 + invisible: function(classes) {
1134 + jQuery(classes).css('visibility', 'hidden');
1868 1135 },
1869 -
1870 - visible: function( classes ) {
1871 - jQuery( classes ).css( 'visibility', 'visible' );
1872 - },
1873 -
1874 - triggerCustomEvent: triggerCustomEvent
1136 +
1137 + visible: function(classes) {
1138 + jQuery(classes).css('visibility', 'visible');
1139 + }
1875 1140 };
1876 1141 }
1877 -frmFrontForm = frmFrontFormJS();
1142 +var frmFrontForm = frmFrontFormJS();
1878 1143
1879 -jQuery( document ).ready( function() {
1144 +jQuery(document).ready(function($){
1880 1145 frmFrontForm.init();
1881 1146 });
1882 1147
1883 1148 function frmRecaptcha() {
1884 - var c, cl,
1885 - captchas = jQuery( '.frm-g-recaptcha' );
1886 - for ( c = 0, cl = captchas.length; c < cl; c++ ) {
1887 - frmFrontForm.renderRecaptcha( captchas[c]);
1149 + var captchas = jQuery('.frm-g-recaptcha');
1150 + for ( var c = 0, cl = captchas.length; c < cl; c++ ) {
1151 + frmFrontForm.renderRecaptcha( captchas[c] );
1888 1152 }
1889 1153 }
1890 1154
1891 -function frmAfterRecaptcha( token ) {
1892 - frmFrontForm.afterSingleRecaptcha( token );
1155 +function frmAfterRecaptcha(token){
1156 + frmFrontForm.afterSingleRecaptcha(token);
1893 1157 }
1894 1158
1895 -function frmUpdateField( entryId, fieldId, value, message, num ) {
1896 - jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1159 +function frmUpdateField(entry_id,field_id,value,message,num){
1160 + jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).html('<span class="frm-loading-img"></span>');
1897 1161 jQuery.ajax({
1898 - type: 'POST',
1899 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1900 - data: {
1901 - action: 'frm_entries_update_field_ajax',
1902 - entry_id: entryId,
1903 - field_id: fieldId,
1904 - value: value,
1905 - nonce: frm_js.nonce // eslint-disable-line camelcase
1906 - },
1907 - success: function() {
1908 - if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1909 - jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
1910 - } else {
1911 - jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).replaceWith( message );
1162 + type:'POST',url:frm_js.ajax_url,
1163 + data:{action:'frm_entries_update_field_ajax', entry_id:entry_id, field_id:field_id, value:value, nonce:frm_js.nonce},
1164 + success:function(){
1165 + if(message.replace(/^\s+|\s+$/g,'') === ''){
1166 + jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).fadeOut('slow');
1167 + }else{
1168 + jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).replaceWith(message);
1912 1169 }
1913 1170 }
1914 1171 });
1915 1172 }
1916 1173
1917 -function frmDeleteEntry( entryId, prefix ) {
1918 - console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1919 - jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1174 +function frmDeleteEntry(entry_id,prefix){
1175 + console.warn('DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry');
1176 + jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+entry_id+'"></span>');
1920 1177 jQuery.ajax({
1921 - type: 'POST',
1922 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1923 - data: {
1924 - action: 'frm_entries_destroy',
1925 - entry: entryId,
1926 - nonce: frm_js.nonce // eslint-disable-line camelcase
1927 - },
1928 - success: function( html ) {
1929 - if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1930 - jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
1931 - } else {
1932 - jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( html );
1933 - }
1178 + type:'POST',url:frm_js.ajax_url,
1179 + data:{action:'frm_entries_destroy', entry:entry_id, nonce:frm_js.nonce},
1180 + success:function(html){
1181 + if(html.replace(/^\s+|\s+$/g,'') === 'success')
1182 + jQuery(document.getElementById(prefix+entry_id)).fadeOut('slow');
1183 + else
1184 + jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith(html);
1185 +
1934 1186 }
1935 1187 });
1936 1188 }
1937 1189
1938 -function frmOnSubmit( e ) {
1939 - console.warn( 'DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm' );
1940 - frmFrontForm.submitForm( e, this );
1190 +function frmOnSubmit(e){
1191 + console.warn('DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm');
1192 + frmFrontForm.submitForm(e, this);
1941 1193 }
1942 1194
1943 -function frm_resend_email( entryId, formId ) { // eslint-disable-line camelcase
1944 - var $link = jQuery( document.getElementById( 'frm_resend_email' ) );
1945 - console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1946 - $link.append( '<span class="spinner" style="display:inline"></span>' );
1195 +function frm_resend_email(entry_id,form_id){
1196 + console.warn('DEPRECATED: function frm_resend_email in v2.0');
1197 + var $link = jQuery(document.getElementById('frm_resend_email'));
1198 + $link.append('<span class="spinner" style="display:inline"></span>');
1947 1199 jQuery.ajax({
1948 - type: 'POST',
1949 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1950 - data: {
1951 - action: 'frm_entries_send_email',
1952 - entry_id: entryId,
1953 - form_id: formId,
1954 - nonce: frm_js.nonce // eslint-disable-line camelcase
1955 - },
1956 - success: function( msg ) {
1957 - $link.replaceWith( msg );
1200 + type:'POST',url:frm_js.ajax_url,
1201 + data:{action:'frm_entries_send_email', entry_id:entry_id, form_id:form_id, nonce:frm_js.nonce},
1202 + success:function(msg){
1203 + $link.replaceWith(msg);
1958 1204 }
1959 1205 });
1960 1206 }