PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.01
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 +231 -677 6.5.15.0.01 View file →
@@ -10,70 +10,19 @@
10 10
11 11 var action = '';
12 12 var jsErrors = [];
13 13
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 - }
14 + function maybeShowLabel() {
15 + /*jshint validthis:true */
16 + var $field = jQuery( this ),
17 + $label = $field.closest( '.frm_inside_container' ).find( '.frm_primary_label' ),
18 + val = $field.val();
25 19
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 );
20 + if ( val !== null && val.length > 0 ) {
21 + $label.addClass( 'frm_visible' );
69 22 } else {
70 - return;
23 + $label.removeClass( 'frm_visible' );
71 24 }
72 -
73 - event.frmData = data;
74 -
75 - el.dispatchEvent( event );
76 25 }
77 26
78 27 /* Get the ID of the field that changed*/
79 28 function getFieldId( field, fullID ) {
@@ -162,9 +111,9 @@
162 111 *
163 112 * @since 2.03.02
164 113 *
165 114 * @param {object} $form
166 - */
115 + */
167 116 function disableSubmitButton( $form ) {
168 117 $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).attr( 'disabled', 'disabled' );
169 118 }
170 119
@@ -173,9 +122,9 @@
173 122 *
174 123 * @since 2.03.02
175 124 *
176 125 * @param {object} $form
177 - */
126 + */
178 127 function enableSubmitButton( $form ) {
179 128 $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).prop( 'disabled', false );
180 129 }
181 130
@@ -210,12 +159,8 @@
210 159 '.frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea'
211 160 ).filter( ':not(.frm_optional)' );
212 161 if ( requiredFields.length ) {
213 162 for ( r = 0, rl = requiredFields.length; r < rl; r++ ) {
214 - if ( hasClass( requiredFields[r], 'ed_button' ) ) {
215 - // skip rich text field buttons.
216 - continue;
217 - }
218 163 errors = checkRequiredField( requiredFields[r], errors );
219 164 }
220 165 }
221 166
@@ -222,10 +167,23 @@
222 167 fields = jQuery( object ).find( 'input,select,textarea' );
223 168 if ( fields.length ) {
224 169 for ( n = 0, nl = fields.length; n < nl; n++ ) {
225 170 field = fields[n];
226 - if ( '' !== field.value ) {
227 - validateFieldValue( field, errors );
171 + value = field.value;
172 + if ( value !== '' ) {
173 + if ( field.type === 'hidden' ) {
174 + // don't validate
175 + } else if ( field.type === 'number' ) {
176 + errors = checkNumberField( field, errors );
177 + } else if ( field.type === 'email' ) {
178 + errors = checkEmailField( field, errors );
179 + } else if ( field.type === 'password' ) {
180 + errors = checkPasswordField( field, errors );
181 + } else if ( field.type === 'url' ) {
182 + errors = checkUrlField( field, errors );
183 + } else if ( field.pattern !== null ) {
184 + errors = checkPatternField( field, errors );
185 + }
228 186 }
229 187 }
230 188 }
231 189
@@ -233,26 +191,14 @@
233 191
234 192 return errors;
235 193 }
236 194
237 - /**
238 - * @since 5.0.10
239 - *
240 - * @param {object} element
241 - * @param {string} targetClass
242 - * @returns {boolean}
243 - */
244 - function hasClass( element, targetClass ) {
245 - var className = ' ' + element.className + ' ';
246 - return -1 !== className.indexOf( ' ' + targetClass + ' ' );
247 - }
248 -
249 - function maybeValidateChange( field ) {
195 + function maybeValidateChange( fieldId, field ) {
250 196 if ( field.type === 'url' ) {
251 197 maybeAddHttpToUrl( field );
252 198 }
253 199 if ( jQuery( field ).closest( 'form' ).hasClass( 'frm_js_validate' ) ) {
254 - validateField( field );
200 + validateField( fieldId, field );
255 201 }
256 202 }
257 203
258 204 function maybeAddHttpToUrl( field ) {
@@ -262,19 +208,29 @@
262 208 field.value = 'http://' + url;
263 209 }
264 210 }
265 211
266 - function validateField( field ) {
212 + function validateField( fieldId, field ) {
267 213 var key,
268 - errors = [],
269 - $fieldCont = jQuery( field ).closest( '.frm_form_field' );
214 + errors = [];
270 215
216 + var $fieldCont = jQuery( field ).closest( '.frm_form_field' );
271 217 if ( $fieldCont.hasClass( 'frm_required_field' ) && ! jQuery( field ).hasClass( 'frm_optional' ) ) {
272 218 errors = checkRequiredField( field, errors );
273 219 }
274 220
275 221 if ( errors.length < 1 ) {
276 - validateFieldValue( field, errors );
222 + if ( field.type === 'email' ) {
223 + errors = checkEmailField( field, errors );
224 + } else if ( field.type === 'password' ) {
225 + errors = checkPasswordField( field, errors );
226 + } else if ( field.type === 'number' ) {
227 + errors = checkNumberField( field, errors );
228 + } else if ( field.type === 'url' ) {
229 + errors = checkUrlField( field, errors );
230 + } else if ( field.pattern !== null ) {
231 + errors = checkPatternField( field, errors );
232 + }
277 233 }
278 234
279 235 removeFieldError( $fieldCont );
280 236 if ( Object.keys( errors ).length > 0 ) {
@@ -283,36 +239,15 @@
283 239 }
284 240 }
285 241 }
286 242
287 - function validateFieldValue( field, errors ) {
288 - if ( field.type === 'hidden' ) {
289 - // don't validate
290 - } else if ( field.type === 'number' ) {
291 - checkNumberField( field, errors );
292 - } else if ( field.type === 'email' ) {
293 - checkEmailField( field, errors );
294 - } else if ( field.type === 'password' ) {
295 - checkPasswordField( field, errors );
296 - } else if ( field.type === 'url' ) {
297 - checkUrlField( field, errors );
298 - } else if ( field.pattern !== null ) {
299 - checkPatternField( field, errors );
300 - }
301 -
302 - triggerCustomEvent( document, 'frm_validate_field_value', {
303 - field: field,
304 - errors: errors
305 - });
306 - }
307 -
308 243 function checkRequiredField( field, errors ) {
309 - var checkGroup, tempVal, i, placeholder,
244 + var checkGroup, fieldClasses, tempVal, i, placeholder,
310 245 val = '',
311 246 fieldID = '',
312 247 fileID = field.getAttribute( 'data-frmfile' );
313 248
314 - if ( field.type === 'hidden' && fileID === null && ! isAppointmentField( field ) && ! isInlineDatepickerField( field ) ) {
249 + if ( field.type === 'hidden' && fileID === null ) {
315 250 return errors;
316 251 }
317 252
318 253 if ( field.type === 'checkbox' || field.type === 'radio' ) {
@@ -330,9 +265,10 @@
330 265 val = getFileVals( fileID );
331 266 }
332 267 fieldID = fileID;
333 268 } else {
334 - if ( hasClass( field, 'frm_pos_none' ) ) {
269 + fieldClasses = field.className;
270 + if ( fieldClasses.indexOf( 'frm_pos_none' ) !== -1 ) {
335 271 // skip hidden other fields
336 272 return errors;
337 273 }
338 274
@@ -348,26 +284,17 @@
348 284 }
349 285 }
350 286 }
351 287
352 - if ( hasClass( field, 'frm_other_input' ) ) {
288 + if ( fieldClasses.indexOf( 'frm_other_input' ) === -1 ) {
289 + fieldID = getFieldId( field, true );
290 + } else {
353 291 fieldID = getFieldId( field, false );
354 -
355 - if ( val === '' ) {
356 - field = document.getElementById( field.id.replace( '-otext', '' ) );
357 - }
358 - } else {
359 - fieldID = getFieldId( field, true );
360 292 }
361 293
362 - if ( hasClass( field, 'frm_time_select' ) ) {
294 + if ( fieldClasses.indexOf( 'frm_time_select' ) !== -1 ) {
363 295 // set id for time field
364 296 fieldID = fieldID.replace( '-H', '' ).replace( '-m', '' );
365 - } else if ( isSignatureField( field ) ) {
366 - if ( val === '' ) {
367 - val = jQuery( field ).closest( '.frm_form_field' ).find( '[name="' + field.getAttribute( 'name' ).replace( '[typed]', '[output]' ) + '"]' ).val();
368 - }
369 - fieldID = fieldID.replace( '-typed', '' );
370 297 }
371 298
372 299 placeholder = field.getAttribute( 'data-frmplaceholder' );
373 300 if ( placeholder !== null && val === placeholder ) {
@@ -386,21 +313,8 @@
386 313
387 314 return errors;
388 315 }
389 316
390 - function isSignatureField( field ) {
391 - var name = field.getAttribute( 'name' );
392 - return 'string' === typeof name && '[typed]' === name.substr( -7 );
393 - }
394 -
395 - function isAppointmentField( field ) {
396 - return hasClass( field, 'ssa_appointment_form_field_appointment_id' );
397 - }
398 -
399 - function isInlineDatepickerField( field ) {
400 - return 'hidden' === field.type && '_alt' === field.id.substr( -4 ) && hasClass( field.nextElementSibling, 'frm_date_inline' );
401 - }
402 -
403 317 function getFileVals( fileID ) {
404 318 var val = '',
405 319 fileFields = jQuery( 'input[name="file' + fileID + '"], input[name="file' + fileID + '[]"], input[name^="item_meta[' + fileID + ']"]' );
406 320
@@ -421,8 +335,9 @@
421 335 if ( ! ( fieldID in errors ) ) {
422 336 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
423 337 }
424 338 }
339 + return errors;
425 340 }
426 341
427 342 function checkEmailField( field, errors ) {
428 343 var fieldID = getFieldId( field, true ),
@@ -433,12 +348,14 @@
433 348 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
434 349 }
435 350
436 351 confirmField( field, errors );
352 + return errors;
437 353 }
438 354
439 355 function checkPasswordField( field, errors ) {
440 356 confirmField( field, errors );
357 + return errors;
441 358 }
442 359
443 360 function confirmField( field, errors ) {
444 361 var value, confirmValue, firstField,
@@ -458,9 +375,9 @@
458 375 if ( '' !== value && '' !== confirmValue && value !== confirmValue ) {
459 376 errors[ 'conf_' + strippedFieldID ] = getFieldValidationMessage( confirmField, 'data-confmsg' );
460 377 }
461 378 } else {
462 - validateField( confirmField );
379 + validateField( 'conf_' + strippedFieldID, confirmField );
463 380 }
464 381 }
465 382
466 383 function checkNumberField( field, errors ) {
@@ -472,8 +389,9 @@
472 389 if ( ! ( fieldID in errors ) ) {
473 390 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
474 391 }
475 392 }
393 + return errors;
476 394 }
477 395
478 396 function checkPatternField( field, errors ) {
479 397 var fieldID,
@@ -488,47 +406,11 @@
488 406 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
489 407 }
490 408 }
491 409 }
410 + return errors;
492 411 }
493 412
494 - /**
495 - * Set color for select placeholders.
496 - *
497 - * @since 6.5.1
498 - */
499 - function setSelectPlaceholderColor() {
500 - var selects = document.querySelectorAll( '.form-field select' ),
501 - styleElement = document.querySelector( '.with_frm_style' ),
502 - textColorDisabled = styleElement ? getComputedStyle( styleElement ).getPropertyValue( '--text-color-disabled' ).trim() : '',
503 - changeSelectColor;
504 -
505 - // Exit if there are no select elements or the textColorDisabled property is missing
506 - if ( ! selects.length || ! textColorDisabled ) {
507 - return;
508 - }
509 -
510 - // Function to change the color of a select element
511 - changeSelectColor = function( select ) {
512 - if ( hasClass( select.options[select.selectedIndex], 'frm-select-placeholder' ) ) {
513 - select.style.setProperty( 'color', textColorDisabled, 'important' );
514 - } else {
515 - select.style.color = '';
516 - }
517 - };
518 -
519 - // Use a loop to iterate through each select element
520 - Array.prototype.forEach.call( selects, function( select ) {
521 - // Apply the color change to each select element
522 - changeSelectColor( select );
523 -
524 - // Add an event listener for future changes
525 - select.addEventListener( 'change', function() {
526 - changeSelectColor( select );
527 - });
528 - });
529 - }
530 -
531 413 function hasInvisibleRecaptcha( object ) {
532 414 var recaptcha, recaptchaID, alreadyChecked;
533 415
534 416 if ( isGoingToPrevPage( object ) ) {
@@ -580,31 +462,15 @@
580 462 return errors;
581 463 }
582 464
583 465 function getFieldValidationMessage( field, messageType ) {
584 - var msg, errorHtml;
585 -
586 - msg = field.getAttribute( messageType );
587 - if ( null === msg ) {
466 + var msg = field.getAttribute( messageType );
467 + if ( msg === null ) {
588 468 msg = '';
589 469 }
590 -
591 - if ( '' !== msg && shouldWrapErrorHtmlAroundMessageType( messageType ) ) {
592 - errorHtml = field.getAttribute( 'data-error-html' );
593 - if ( null !== errorHtml ) {
594 - errorHtml = errorHtml.replace( /\+/g, '%20' );
595 - msg = decodeURIComponent( errorHtml ).replace( '[error]', msg );
596 - msg = msg.replace( '[key]', getFieldId( field, false ) );
597 - }
598 - }
599 -
600 470 return msg;
601 471 }
602 472
603 - function shouldWrapErrorHtmlAroundMessageType( type ) {
604 - return 'pattern' !== type;
605 - }
606 -
607 473 function shouldJSValidate( object ) {
608 474 var validate = jQuery( object ).hasClass( 'frm_js_validate' );
609 475 if ( validate && typeof frmProForm !== 'undefined' && ( frmProForm.savingDraft( object ) || frmProForm.goingToPreviousPage( object ) ) ) {
610 476 validate = false;
@@ -613,9 +479,9 @@
613 479 return validate;
614 480 }
615 481
616 482 function getFormErrors( object, action ) {
617 - var fieldset, data, success, error, shouldTriggerEvent;
483 + var fieldset;
618 484
619 485 if ( typeof action === 'undefined' ) {
620 486 jQuery( object ).find( 'input[name="frm_action"]' ).val();
621 487 }
@@ -621,204 +487,145 @@
621 487 }
622 488
623 489 fieldset = jQuery( object ).find( '.frm_form_field' );
624 490 fieldset.addClass( 'frm_doing_ajax' );
491 + jQuery.ajax({
492 + type: 'POST', url: frm_js.ajax_url,
493 + data: jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce,
494 + success: function( response ) {
495 + var formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
496 + $fieldCont, key, inCollapsedSection, frmTrigger,
497 + defaultResponse = { 'content': '', 'errors': {}, 'pass': false };
498 + if ( response === null ) {
499 + response = defaultResponse;
500 + }
625 501
626 - data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; // eslint-disable-line camelcase
627 - shouldTriggerEvent = object.classList.contains( 'frm_trigger_event_on_submit' );
628 -
629 - success = function( response ) {
630 - var defaultResponse, formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
631 - $fieldCont, key, inCollapsedSection, frmTrigger, newTab;
632 -
633 - defaultResponse = {
634 - content: '',
635 - errors: {},
636 - pass: false
637 - };
638 -
639 - if ( response === null ) {
640 - response = defaultResponse;
641 - }
642 -
643 - response = response.replace( /^\s+|\s+$/g, '' );
644 - if ( response.indexOf( '{' ) === 0 ) {
645 - response = JSON.parse( response );
646 - } else {
647 - response = defaultResponse;
648 - }
649 -
650 - if ( typeof response.redirect !== 'undefined' ) {
651 - if ( shouldTriggerEvent ) {
652 - triggerCustomEvent( object, 'frmSubmitEvent' );
653 - return;
502 + response = response.replace( /^\s+|\s+$/g, '' );
503 + if ( response.indexOf( '{' ) === 0 ) {
504 + response = JSON.parse( response );
505 + } else {
506 + response = defaultResponse;
654 507 }
655 508
656 - jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
657 -
658 - if ( ! response.openInNewTab ) {
659 - // We return here because we're redirecting there is no need to update content.
509 + if ( typeof response.redirect !== 'undefined' ) {
510 + jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
660 511 window.location = response.redirect;
661 - return;
662 - }
512 + } else if ( response.content !== '' ) {
513 + // the form or success message was returned
663 514
664 - // We don't return here because we're opening in a new tab, the old tab will still update.
665 - newTab = window.open( response.redirect, '_blank' );
666 - if ( ! newTab && response.fallbackMsg && response.content ) {
667 - response.content = response.content.trim().replace( /(<\/div><\/div>)$/, ' ' + response.fallbackMsg + '</div></div>' );
668 - }
669 - }
515 + removeSubmitLoading( jQuery( object ) );
516 + if ( frm_js.offset != -1 ) {
517 + frmFrontForm.scrollMsg( jQuery( object ), false );
518 + }
519 + formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
520 + response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
521 + replaceContent = jQuery( object ).closest( '.frm_forms' );
522 + removeAddedScripts( replaceContent, formID );
523 + delay = maybeSlideOut( replaceContent, response.content );
670 524
671 - if ( response.content !== '' ) {
672 - // the form or success message was returned
525 + setTimeout(
526 + function() {
527 + var container, input, previousInput;
673 528
674 - if ( shouldTriggerEvent ) {
675 - triggerCustomEvent( object, 'frmSubmitEvent' );
676 - return;
677 - }
529 + replaceContent.replaceWith( response.content );
678 530
679 - removeSubmitLoading( jQuery( object ) );
680 - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase
681 - frmFrontForm.scrollMsg( jQuery( object ), false );
682 - }
531 + addUrlParam( response );
683 532
684 - formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
685 - response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
686 - replaceContent = jQuery( object ).closest( '.frm_forms' );
687 - removeAddedScripts( replaceContent, formID );
688 - delay = maybeSlideOut( replaceContent, response.content );
533 + if ( typeof frmThemeOverride_frmAfterSubmit === 'function' ) { // eslint-disable-line camelcase
534 + pageOrder = jQuery( 'input[name="frm_page_order_' + formID + '"]' ).val();
535 + formReturned = jQuery( response.content ).find( 'input[name="form_id"]' ).val();
536 + frmThemeOverride_frmAfterSubmit( formReturned, pageOrder, response.content, object );
537 + }
689 538
690 - setTimeout(
691 - function() {
692 - var container, input, previousInput;
539 + if ( typeof response.recaptcha !== 'undefined' ) {
540 + container = jQuery( '#frm_form_' + formID + '_container' ).find( '.frm_fields_container' );
541 + input = '<input type="hidden" name="recaptcha_checked" value="' + response.recaptcha + '">';
542 + previousInput = container.find( 'input[name="recaptcha_checked"]' );
693 543
694 - replaceContent.replaceWith( response.content );
544 + if ( previousInput.length ) {
545 + previousInput.replaceWith( input );
546 + } else {
547 + container.append( input );
548 + }
549 + }
695 550
696 - addUrlParam( response );
551 + afterFormSubmitted( object, response );
552 + },
553 + delay
554 + );
555 + } else if ( Object.keys( response.errors ).length ) {
556 + // errors were returned
697 557
698 - if ( typeof frmThemeOverride_frmAfterSubmit === 'function' ) { // eslint-disable-line camelcase
699 - pageOrder = jQuery( 'input[name="frm_page_order_' + formID + '"]' ).val();
700 - formReturned = jQuery( response.content ).find( 'input[name="form_id"]' ).val();
701 - frmThemeOverride_frmAfterSubmit( formReturned, pageOrder, response.content, object );
702 - }
558 + removeSubmitLoading( jQuery( object ), 'enable' );
703 559
704 - if ( typeof response.recaptcha !== 'undefined' ) {
705 - container = jQuery( '#frm_form_' + formID + '_container' ).find( '.frm_fields_container' );
706 - input = '<input type="hidden" name="recaptcha_checked" value="' + response.recaptcha + '">';
707 - previousInput = container.find( 'input[name="recaptcha_checked"]' );
560 + //show errors
561 + contSubmit = true;
562 + removeAllErrors();
708 563
709 - if ( previousInput.length ) {
710 - previousInput.replaceWith( input );
711 - } else {
712 - container.append( input );
713 - }
714 - }
564 + $fieldCont = null;
715 565
716 - afterFormSubmitted( object, response );
717 - },
718 - delay
719 - );
720 - } else if ( Object.keys( response.errors ).length ) {
721 - // errors were returned
722 - removeSubmitLoading( jQuery( object ), 'enable' );
566 + for ( key in response.errors ) {
567 + $fieldCont = jQuery( object ).find( '#frm_field_' + key + '_container' );
723 568
724 - //show errors
725 - contSubmit = true;
726 - removeAllErrors();
727 -
728 - $fieldCont = null;
729 -
730 - for ( key in response.errors ) {
731 - $fieldCont = jQuery( object ).find( '#frm_field_' + key + '_container' );
732 -
733 - if ( $fieldCont.length ) {
734 - if ( ! $fieldCont.is( ':visible' ) ) {
735 - inCollapsedSection = $fieldCont.closest( '.frm_toggle_container' );
736 - if ( inCollapsedSection.length ) {
737 - frmTrigger = inCollapsedSection.prev();
738 - if ( ! frmTrigger.hasClass( 'frm_trigger' ) ) {
739 - // If the frmTrigger object is the section description, check to see if the previous element is the trigger
740 - frmTrigger = frmTrigger.prev( '.frm_trigger' );
569 + if ( $fieldCont.length ) {
570 + if ( ! $fieldCont.is( ':visible' ) ) {
571 + inCollapsedSection = $fieldCont.closest( '.frm_toggle_container' );
572 + if ( inCollapsedSection.length ) {
573 + frmTrigger = inCollapsedSection.prev();
574 + if ( ! frmTrigger.hasClass( 'frm_trigger' ) ) {
575 + // If the frmTrigger object is the section description, check to see if the previous element is the trigger
576 + frmTrigger = frmTrigger.prev( '.frm_trigger' );
577 + }
578 + frmTrigger.trigger( 'click' );
741 579 }
742 - frmTrigger.trigger( 'click' );
743 580 }
744 - }
745 581
746 - if ( $fieldCont.is( ':visible' ) ) {
747 - addFieldError( $fieldCont, key, response.errors );
748 - contSubmit = false;
582 + if ( $fieldCont.is( ':visible' ) ) {
583 + addFieldError( $fieldCont, key, response.errors );
584 + contSubmit = false;
585 + }
749 586 }
750 587 }
751 - }
752 588
753 - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() {
754 - var $recaptcha = jQuery( this ),
755 - recaptchaID = $recaptcha.data( 'rid' );
589 + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
590 + var $recaptcha = jQuery( this ),
591 + recaptchaID = $recaptcha.data( 'rid' );
756 592
757 - if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
758 - if ( recaptchaID ) {
759 - grecaptcha.reset( recaptchaID );
760 - } else {
761 - grecaptcha.reset();
593 + if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
594 + if ( recaptchaID ) {
595 + grecaptcha.reset( recaptchaID );
596 + } else {
597 + grecaptcha.reset();
598 + }
762 599 }
763 - }
764 - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) {
765 - hcaptcha.reset();
766 - }
767 - });
600 + });
768 601
769 - jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
602 + jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
770 603
771 - fieldset.removeClass( 'frm_doing_ajax' );
772 - scrollToFirstField( object );
604 + fieldset.removeClass( 'frm_doing_ajax' );
605 + scrollToFirstField( object );
773 606
774 - if ( contSubmit ) {
775 - object.submit();
607 + if ( contSubmit ) {
608 + object.submit();
609 + } else {
610 + jQuery( object ).prepend( response.error_message );
611 + checkForErrorsAndMaybeSetFocus();
612 + }
776 613 } else {
777 - jQuery( object ).prepend( response.error_message );
778 - checkForErrorsAndMaybeSetFocus();
779 - }
780 - } else {
781 - // there may have been a plugin conflict, or the form is not set to submit with ajax
614 + // there may have been a plugin conflict, or the form is not set to submit with ajax
782 615
783 - showFileLoading( object );
616 + showFileLoading( object );
784 617
618 + object.submit();
619 + }
620 + },
621 + error: function() {
622 + jQuery( object ).find( 'input[type="submit"], input[type="button"]' ).prop( 'disabled', false );
785 623 object.submit();
786 624 }
787 - };
788 -
789 - error = function() {
790 - jQuery( object ).find( 'input[type="submit"], input[type="button"]' ).prop( 'disabled', false );
791 - object.submit();
792 - };
793 -
794 - postToAjaxUrl( object, data, success, error );
625 + });
795 626 }
796 627
797 - function postToAjaxUrl( form, data, success, error ) {
798 - var ajaxUrl, action, ajaxParams;
799 -
800 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
801 - action = form.getAttribute( 'action' );
802 -
803 - if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
804 - ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
805 - }
806 -
807 - ajaxParams = {
808 - type: 'POST',
809 - url: ajaxUrl,
810 - data: data,
811 - success: success
812 - };
813 -
814 - if ( 'function' === typeof error ) {
815 - ajaxParams.error = error;
816 - }
817 -
818 - jQuery.ajax( ajaxParams );
819 - }
820 -
821 628 function afterFormSubmitted( object, response ) {
822 629 var formCompleted = jQuery( response.content ).find( '.frm_message' );
823 630 if ( formCompleted.length ) {
824 631 jQuery( document ).trigger( 'frmFormComplete', [ object, response ]);
@@ -884,9 +691,9 @@
884 691 return kvp.join( '&' );
885 692 }
886 693
887 694 function addFieldError( $fieldCont, key, jsErrors ) {
888 - var input, id, describedBy, roleString;
695 + var input, id, describedBy;
889 696 if ( $fieldCont.length && $fieldCont.is( ':visible' ) ) {
890 697 $fieldCont.addClass( 'frm_blank_field' );
891 698 input = $fieldCont.find( 'input, select, textarea' );
892 699 id = 'frm_error_field_' + key;
@@ -894,27 +701,15 @@
894 701
895 702 if ( typeof frmThemeOverride_frmPlaceError === 'function' ) { // eslint-disable-line camelcase
896 703 frmThemeOverride_frmPlaceError( key, jsErrors );
897 704 } else {
898 - if ( -1 !== jsErrors[key].indexOf( '<div' ) ) {
899 - $fieldCont.append(
900 - jsErrors[key]
901 - );
902 - } else {
903 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
904 - $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
905 - }
705 + $fieldCont.append( '<div class="frm_error" id="' + id + '">' + jsErrors[key] + '</div>' );
906 706
907 707 if ( typeof describedBy === 'undefined' ) {
908 708 describedBy = id;
909 - } else if ( describedBy.indexOf( id ) === -1 && describedBy.indexOf( 'frm_error_field_' ) === -1 ) {
910 - if ( input.data( 'error-first' ) === 0 ) {
911 - describedBy = describedBy + ' ' + id;
912 - } else {
913 - describedBy = id + ' ' + describedBy;
914 - }
709 + } else if ( describedBy.indexOf( id ) === -1 ) {
710 + describedBy = describedBy + ' ' + id;
915 711 }
916 -
917 712 input.attr( 'aria-describedby', describedBy );
918 713 }
919 714 input.attr( 'aria-invalid', true );
920 715
@@ -930,9 +725,8 @@
930 725
931 726 $fieldCont.removeClass( 'frm_blank_field has-error' );
932 727 errorMessage.remove();
933 728 input.attr( 'aria-invalid', false );
934 - input.removeAttr( 'aria-describedby' );
935 729
936 730 if ( typeof describedBy !== 'undefined' ) {
937 731 describedBy = describedBy.replace( errorId, '' );
938 732 input.attr( 'aria-describedby', describedBy );
@@ -1047,14 +841,14 @@
1047 841 label.append( '<span class="frm-wait"></span>' );
1048 842
1049 843 jQuery.ajax({
1050 844 type: 'POST',
1051 - url: frm_js.ajax_url, // eslint-disable-line camelcase
845 + url: frm_js.ajax_url,
1052 846 data: {
1053 847 action: 'frm_entries_send_email',
1054 848 entry_id: entryId,
1055 849 form_id: formId,
1056 - nonce: frm_js.nonce // eslint-disable-line camelcase
850 + nonce: frm_js.nonce
1057 851 },
1058 852 success: function( msg ) {
1059 853 var admin = document.getElementById( 'wpbody' );
1060 854 if ( admin === null ) {
@@ -1092,9 +886,32 @@
1092 886 /**********************************************
1093 887 * Fallback functions
1094 888 *********************************************/
1095 889
1096 - function addTrimFallbackForIE() {
890 + function addIndexOfFallbackForIE8() {
891 + var len, from;
892 +
893 + if ( ! Array.prototype.indexOf ) {
894 + Array.prototype.indexOf = function( elt /*, from*/ ) {
895 + len = this.length >>> 0;
896 +
897 + from = Number( arguments[1]) || 0;
898 + from = ( from < 0 ) ? Math.ceil( from ) : Math.floor( from );
899 + if ( from < 0 ) {
900 + from += len;
901 + }
902 +
903 + for ( ; from < len; from++ ) {
904 + if ( from in this && this[from] === elt ) {
905 + return from;
906 + }
907 + }
908 + return -1;
909 + };
910 + }
911 + }
912 +
913 + function addTrimFallbackForIE8() {
1097 914 if ( typeof String.prototype.trim !== 'function' ) {
1098 915 String.prototype.trim = function() {
1099 916 return this.replace( /^\s+|\s+$/g, '' );
1100 917 };
@@ -1100,9 +917,9 @@
1100 917 };
1101 918 }
1102 919 }
1103 920
1104 - function addFilterFallbackForIE() {
921 + function addFilterFallbackForIE8() {
1105 922 var t, len, res, thisp, i, val;
1106 923
1107 924 if ( ! Array.prototype.filter ) {
1108 925
@@ -1133,8 +950,26 @@
1133 950 };
1134 951 }
1135 952 }
1136 953
954 + function addKeysFallbackForIE8() {
955 + var keys, i;
956 +
957 + if ( ! Object.keys ) {
958 + Object.keys = function( obj ) {
959 + keys = [];
960 +
961 + for ( i in obj ) {
962 + if ( obj.hasOwnProperty( i ) ) {
963 + keys.push( i );
964 + }
965 + }
966 +
967 + return keys;
968 + };
969 + }
970 + }
971 +
1137 972 /**
1138 973 * Check for -webkit-box-shadow css value for input:-webkit-autofill selector.
1139 974 * If this is a match, the User is autofilling the input on a Webkit browser.
1140 975 * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete.
@@ -1145,37 +980,8 @@
1145 980 this.parentNode.removeChild( this );
1146 981 }
1147 982 }
1148 983
1149 - function maybeMakeHoneypotFieldsUntabbable() {
1150 - document.addEventListener( 'keydown', handleKeyUp );
1151 -
1152 - function handleKeyUp( event ) {
1153 - var code;
1154 -
1155 - if ( 'undefined' !== typeof event.key ) {
1156 - code = event.key;
1157 - } else if ( 'undefined' !== typeof event.keyCode && 9 === event.keyCode ) {
1158 - code = 'Tab';
1159 - }
1160 -
1161 - if ( 'Tab' === code ) {
1162 - makeHoneypotFieldsUntabbable();
1163 - document.removeEventListener( 'keydown', handleKeyUp );
1164 - }
1165 - }
1166 -
1167 - function makeHoneypotFieldsUntabbable() {
1168 - document.querySelectorAll( '.frm_verify' ).forEach(
1169 - function( input ) {
1170 - if ( input.id && 0 === input.id.indexOf( 'frm_email_' ) ) {
1171 - input.setAttribute( 'tabindex', -1 );
1172 - }
1173 - }
1174 - );
1175 - }
1176 - }
1177 -
1178 984 /**
1179 985 * Focus on the first sub field when clicking to the primary label of combo field.
1180 986 *
1181 987 * @since 4.10.02
@@ -1180,11 +986,11 @@
1180 986 *
1181 987 * @since 4.10.02
1182 988 */
1183 989 function changeFocusWhenClickComboFieldLabel() {
1184 - var label;
990 + let label;
1185 991
1186 - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
992 + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1187 993 comboInputsContainer.forEach( function( inputsContainer ) {
1188 994 if ( ! inputsContainer.closest( '.frm_form_field' ) ) {
1189 995 return;
1190 996 }
@@ -1202,12 +1008,8 @@
1202 1008
1203 1009 function checkForErrorsAndMaybeSetFocus() {
1204 1010 var errors, element, timeoutCallback;
1205 1011
1206 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1207 - return;
1208 - }
1209 -
1210 1012 errors = document.querySelectorAll( '.frm_form_field .frm_error' );
1211 1013 if ( ! errors.length ) {
1212 1014 return;
1213 1015 }
@@ -1241,246 +1043,10 @@
1241 1043 }
1242 1044 } while ( element.previousSibling );
1243 1045 }
1244 1046
1245 - /**
1246 - * Checks if is on IE browser.
1247 - *
1248 - * @since 5.4
1249 - *
1250 - * @return {Boolean}
1251 - */
1252 - function isIE() {
1253 - return navigator.userAgent.indexOf( 'MSIE' ) > -1 || navigator.userAgent.indexOf( 'Trident' ) > -1;
1254 - }
1255 -
1256 - /**
1257 - * Does the same as jQuery( document ).on( 'event', 'selector', handler ).
1258 - *
1259 - * @since 5.4
1260 - *
1261 - * @param {String} event Event name.
1262 - * @param {String} selector Selector.
1263 - * @param {Function} handler Handler.
1264 - * @param {Boolean|Object} options Options to be added to `addEventListener()` method. Default is `false`.
1265 - */
1266 - function documentOn( event, selector, handler, options ) {
1267 - if ( 'undefined' === typeof options ) {
1268 - options = false;
1269 - }
1270 -
1271 - document.addEventListener( event, function( e ) {
1272 - var target;
1273 -
1274 - // loop parent nodes from the target to the delegation node.
1275 - for ( target = e.target; target && target != this; target = target.parentNode ) {
1276 - if ( target && target.matches && target.matches( selector ) ) {
1277 - handler.call( target, e );
1278 - break;
1279 - }
1280 - }
1281 - }, options );
1282 - }
1283 -
1284 - function initFloatingLabels() {
1285 - var checkFloatLabel, checkDropdownLabel, checkPlaceholderIE, runOnLoad, selector, floatClass;
1286 -
1287 - selector = '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea';
1288 - floatClass = 'frm_label_float_top';
1289 -
1290 - checkFloatLabel = function( input ) {
1291 - var container, shouldFloatTop, firstOpt;
1292 -
1293 - container = input.closest( '.frm_inside_container' );
1294 - if ( ! container ) {
1295 - return;
1296 - }
1297 -
1298 - shouldFloatTop = input.value || document.activeElement === input;
1299 -
1300 - container.classList.toggle( floatClass, shouldFloatTop );
1301 -
1302 - if ( 'SELECT' === input.tagName ) {
1303 - firstOpt = input.querySelector( 'option:first-child' );
1304 -
1305 - if ( shouldFloatTop ) {
1306 - if ( firstOpt.hasAttribute( 'data-label' ) ) {
1307 - firstOpt.textContent = firstOpt.getAttribute( 'data-label' );
1308 - firstOpt.removeAttribute( 'data-label' );
1309 - }
1310 - } else {
1311 - if ( firstOpt.textContent ) {
1312 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1313 - firstOpt.textContent = '';
1314 - }
1315 - }
1316 - } else if ( isIE() ) {
1317 - checkPlaceholderIE( input );
1318 - }
1319 - };
1320 -
1321 - checkDropdownLabel = function() {
1322 - document.querySelectorAll( '.frm-show-form .frm_inside_container:not(.' + floatClass + ') select' ).forEach( function( input ) {
1323 - var firstOpt = input.querySelector( 'option:first-child' );
1324 -
1325 - if ( firstOpt.textContent ) {
1326 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1327 - firstOpt.textContent = '';
1328 - }
1329 - });
1330 - };
1331 -
1332 - checkPlaceholderIE = function( input ) {
1333 - if ( input.value ) {
1334 - // Don't need to handle this case because placeholder isn't shown.
1335 - return;
1336 - }
1337 -
1338 - if ( document.activeElement === input ) {
1339 - if ( input.hasAttribute( 'data-placeholder' ) ) {
1340 - input.placeholder = input.getAttribute( 'data-placeholder' );
1341 - input.removeAttribute( 'data-placeholder' );
1342 - }
1343 - } else {
1344 - if ( input.placeholder ) {
1345 - input.setAttribute( 'data-placeholder', input.placeholder );
1346 - input.placeholder = '';
1347 - }
1348 - }
1349 - };
1350 -
1351 - [ 'focus', 'blur', 'change' ].forEach( function( eventName ) {
1352 - documentOn(
1353 - eventName,
1354 - selector,
1355 - function( event ) {
1356 - checkFloatLabel( event.target );
1357 - },
1358 - true
1359 - );
1360 - });
1361 -
1362 - jQuery( document ).on( 'change', selector, function( event ) {
1363 - checkFloatLabel( event.target );
1364 - });
1365 -
1366 - runOnLoad = function( firstLoad ) {
1367 - if ( firstLoad && document.activeElement && -1 !== [ 'INPUT', 'SELECT', 'TEXTAREA' ].indexOf( document.activeElement.tagName ) ) {
1368 - checkFloatLabel( document.activeElement );
1369 - } else if ( firstLoad ) {
1370 - document.querySelectorAll( '.frm_inside_container' ).forEach(
1371 - function( container ) {
1372 - var input = container.querySelector( 'input, select, textarea' );
1373 - if ( input && '' !== input.value ) {
1374 - checkFloatLabel( input );
1375 - }
1376 - }
1377 - );
1378 - }
1379 -
1380 - checkDropdownLabel();
1381 -
1382 - if ( isIE() ) {
1383 - document.querySelectorAll( selector ).forEach( function( input ) {
1384 - checkPlaceholderIE( input );
1385 - });
1386 - }
1387 - };
1388 -
1389 - runOnLoad( true );
1390 -
1391 - jQuery( document ).on( 'frmPageChanged', function( event ) {
1392 - runOnLoad();
1393 - });
1394 -
1395 - document.addEventListener( 'frm_after_start_over', function( event ) {
1396 - runOnLoad();
1397 - });
1398 - }
1399 -
1400 - function shouldUpdateValidityMessage( target ) {
1401 - if ( 'INPUT' !== target.nodeName ) {
1402 - return false;
1403 - }
1404 -
1405 - if ( ! target.dataset.invmsg ) {
1406 - return false;
1407 - }
1408 -
1409 - if ( 'text' !== target.getAttribute( 'type' ) ) {
1410 - return false;
1411 - }
1412 -
1413 - if ( target.classList.contains( 'frm_verify' ) ) {
1414 - return false;
1415 - }
1416 -
1417 - return true;
1418 - }
1419 -
1420 - function maybeClearCustomValidityMessage( event, field ) {
1421 - var key,
1422 - isInvalid = false;
1423 -
1424 - if ( ! shouldUpdateValidityMessage( field ) ) {
1425 - return;
1426 - }
1427 -
1428 - for ( key in field.validity ) {
1429 - if ( 'customError' === key ) {
1430 - continue;
1431 - }
1432 - if ( 'valid' !== key && field.validity[ key ] === true ) {
1433 - isInvalid = true;
1434 - break;
1435 - }
1436 - };
1437 -
1438 - if ( ! isInvalid ) {
1439 - field.setCustomValidity( '' );
1440 - }
1441 - }
1442 -
1443 - function maybeShowNewTabFallbackMessage() {
1444 - var messageEl;
1445 -
1446 - if ( ! window.frmShowNewTabFallback ) {
1447 - return;
1448 - }
1449 -
1450 - messageEl = document.querySelector( '#frm_form_' + frmShowNewTabFallback.formId + '_container .frm_message' );
1451 - if ( ! messageEl ) {
1452 - return;
1453 - }
1454 -
1455 - messageEl.insertAdjacentHTML( 'beforeend', ' ' + frmShowNewTabFallback.message );
1456 - }
1457 -
1458 - function setCustomValidityMessage() {
1459 - var forms, length, index;
1460 -
1461 - forms = document.getElementsByClassName( 'frm-show-form' );
1462 - length = forms.length;
1463 -
1464 - for ( index = 0; index < length; ++index ) {
1465 - forms[ index ].addEventListener(
1466 - 'invalid',
1467 - function( event ) {
1468 - var target = event.target;
1469 -
1470 - if ( shouldUpdateValidityMessage( target ) ) {
1471 - target.setCustomValidity( target.dataset.invmsg );
1472 - }
1473 - },
1474 - true
1475 - );
1476 - }
1477 - }
1478 -
1479 1047 return {
1480 1048 init: function() {
1481 - maybeAddPolyfills();
1482 -
1483 1049 jQuery( document ).off( 'submit.formidable', '.frm-show-form' );
1484 1050 jQuery( document ).on( 'submit.formidable', '.frm-show-form', frmFrontForm.submitForm );
1485 1051
1486 1052 jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() {
@@ -1495,11 +1061,11 @@
1495 1061
1496 1062 jQuery( document.getElementById( 'frm_resend_email' ) ).on( 'click', resendEmail );
1497 1063
1498 1064 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 );
1065 + 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 );
1499 1066
1500 1067 jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange );
1501 - maybeMakeHoneypotFieldsUntabbable();
1502 1068
1503 1069 jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick );
1504 1070 jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv );
1505 1071
@@ -1507,23 +1073,13 @@
1507 1073
1508 1074 // Focus on the first sub field when clicking to the primary label of combo field.
1509 1075 changeFocusWhenClickComboFieldLabel();
1510 1076
1511 - // Add fallbacks for IE.
1512 - addTrimFallbackForIE(); // Trim only works in IE10+.
1513 - addFilterFallbackForIE(); // Filter is not supported in any version of IE.
1514 -
1515 - initFloatingLabels();
1516 - maybeShowNewTabFallbackMessage();
1517 -
1518 - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage );
1519 - setCustomValidityMessage();
1520 - jQuery( document ).on( 'frmFieldChanged', maybeClearCustomValidityMessage );
1521 -
1522 - setSelectPlaceholderColor();
1523 -
1524 - // Elementor popup show event. Fix Elementor Popup && FF Captcha field conflicts
1525 - jQuery( document ).on( 'elementor/popup/show', frmRecaptcha );
1077 + // Add fallbacks for the beloved IE8
1078 + addIndexOfFallbackForIE8();
1079 + addTrimFallbackForIE8();
1080 + addFilterFallbackForIE8();
1081 + addKeysFallbackForIE8();
1526 1082 },
1527 1083
1528 1084 getFieldId: function( field, fullID ) {
1529 1085 return getFieldId( field, fullID );
@@ -1706,12 +1262,12 @@
1706 1262 removeSubmitLoading: function( $object, enable, processesRunning ) {
1707 1263 removeSubmitLoading( $object, enable, processesRunning );
1708 1264 },
1709 1265
1710 - scrollToID: function( id ) {
1711 - var object = jQuery( document.getElementById( id ) );
1712 - frmFrontForm.scrollMsg( object, false );
1713 - },
1266 + scrollToID: function( id ) {
1267 + var object = jQuery( document.getElementById( id ) );
1268 + frmFrontForm.scrollMsg( object, false );
1269 + },
1714 1270
1715 1271 scrollMsg: function( id, object, animate ) {
1716 1272 var newPos, m, b, screenTop, screenBottom,
1717 1273 scrollObj = '';
@@ -1727,12 +1283,12 @@
1727 1283 }
1728 1284
1729 1285 jQuery( scrollObj ).trigger( 'focus' );
1730 1286 newPos = scrollObj.offset().top;
1731 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1287 + if ( ! newPos || frm_js.offset === '-1' ) {
1732 1288 return;
1733 1289 }
1734 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1290 + newPos = newPos - frm_js.offset;
1735 1291
1736 1292 m = jQuery( 'html' ).css( 'margin-top' );
1737 1293 b = jQuery( 'body' ).css( 'margin-top' );
1738 1294 if ( m || b ) {
@@ -1769,9 +1325,9 @@
1769 1325
1770 1326 jQuery( document ).trigger( 'frmFieldChanged', [ this, fieldId, e ]);
1771 1327
1772 1328 if ( e.selfTriggered !== true ) {
1773 - maybeValidateChange( this );
1329 + maybeValidateChange( fieldId, this );
1774 1330 }
1775 1331 },
1776 1332
1777 1333 savingDraft: function( object ) {
@@ -1835,11 +1391,9 @@
1835 1391 },
1836 1392
1837 1393 visible: function( classes ) {
1838 1394 jQuery( classes ).css( 'visibility', 'visible' );
1839 - },
1840 -
1841 - triggerCustomEvent: triggerCustomEvent
1395 + }
1842 1396 };
1843 1397 }
1844 1398 frmFrontForm = frmFrontFormJS();
1845 1399
@@ -1862,15 +1416,15 @@
1862 1416 function frmUpdateField( entryId, fieldId, value, message, num ) {
1863 1417 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1864 1418 jQuery.ajax({
1865 1419 type: 'POST',
1866 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1420 + url: frm_js.ajax_url,
1867 1421 data: {
1868 1422 action: 'frm_entries_update_field_ajax',
1869 1423 entry_id: entryId,
1870 1424 field_id: fieldId,
1871 1425 value: value,
1872 - nonce: frm_js.nonce // eslint-disable-line camelcase
1426 + nonce: frm_js.nonce
1873 1427 },
1874 1428 success: function() {
1875 1429 if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1876 1430 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
@@ -1885,13 +1439,13 @@
1885 1439 console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1886 1440 jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1887 1441 jQuery.ajax({
1888 1442 type: 'POST',
1889 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1443 + url: frm_js.ajax_url,
1890 1444 data: {
1891 1445 action: 'frm_entries_destroy',
1892 1446 entry: entryId,
1893 - nonce: frm_js.nonce // eslint-disable-line camelcase
1447 + nonce: frm_js.nonce
1894 1448 },
1895 1449 success: function( html ) {
1896 1450 if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1897 1451 jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
@@ -1912,14 +1466,14 @@
1912 1466 console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1913 1467 $link.append( '<span class="spinner" style="display:inline"></span>' );
1914 1468 jQuery.ajax({
1915 1469 type: 'POST',
1916 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1470 + url: frm_js.ajax_url,
1917 1471 data: {
1918 1472 action: 'frm_entries_send_email',
1919 1473 entry_id: entryId,
1920 1474 form_id: formId,
1921 - nonce: frm_js.nonce // eslint-disable-line camelcase
1475 + nonce: frm_js.nonce
1922 1476 },
1923 1477 success: function( msg ) {
1924 1478 $link.replaceWith( msg );
1925 1479 }