PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.2.07
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.2.07
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 +124 -511 6.5.35.2.07 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
@@ -201,12 +150,11 @@
201 150 $form.find( 'a.frm_save_draft' ).css( 'pointer-events', '' );
202 151 }
203 152
204 153 function validateForm( object ) {
205 - var errors, r, rl, n, nl, fields, field, requiredFields;
154 + var r, rl, n, nl, fields, field, value, requiredFields,
155 + errors = [];
206 156
207 - errors = [];
208 -
209 157 // Make sure required text field is filled in
210 158 requiredFields = jQuery( object ).find(
211 159 '.frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea'
212 160 ).filter( ':not(.frm_optional)' );
@@ -223,18 +171,24 @@
223 171 fields = jQuery( object ).find( 'input,select,textarea' );
224 172 if ( fields.length ) {
225 173 for ( n = 0, nl = fields.length; n < nl; n++ ) {
226 174 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 );
175 + value = field.value;
176 + if ( value !== '' ) {
177 + if ( field.type === 'hidden' ) {
178 + // don't validate
179 + } else if ( field.type === 'number' ) {
180 + errors = checkNumberField( field, errors );
181 + } else if ( field.type === 'email' ) {
182 + errors = checkEmailField( field, errors );
183 + } else if ( field.type === 'password' ) {
184 + errors = checkPasswordField( field, errors );
185 + } else if ( field.type === 'url' ) {
186 + errors = checkUrlField( field, errors );
187 + } else if ( field.pattern !== null ) {
188 + errors = checkPatternField( field, errors );
231 189 }
232 - continue;
233 190 }
234 -
235 - validateFieldValue( field, errors );
236 - checkValidity( field, errors );
237 191 }
238 192 }
239 193
240 194 errors = validateRecaptcha( object, errors );
@@ -242,33 +196,8 @@
242 196 return errors;
243 197 }
244 198
245 199 /**
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 200 * @since 5.0.10
272 201 *
273 202 * @param {object} element
274 203 * @param {string} targetClass
@@ -305,9 +234,19 @@
305 234 errors = checkRequiredField( field, errors );
306 235 }
307 236
308 237 if ( errors.length < 1 ) {
309 - validateFieldValue( field, errors );
238 + if ( field.type === 'email' ) {
239 + errors = checkEmailField( field, errors );
240 + } else if ( field.type === 'password' ) {
241 + errors = checkPasswordField( field, errors );
242 + } else if ( field.type === 'number' ) {
243 + errors = checkNumberField( field, errors );
244 + } else if ( field.type === 'url' ) {
245 + errors = checkUrlField( field, errors );
246 + } else if ( field.pattern !== null ) {
247 + errors = checkPatternField( field, errors );
248 + }
310 249 }
311 250
312 251 removeFieldError( $fieldCont );
313 252 if ( Object.keys( errors ).length > 0 ) {
@@ -316,29 +255,8 @@
316 255 }
317 256 }
318 257 }
319 258
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 259 function checkRequiredField( field, errors ) {
342 260 var checkGroup, tempVal, i, placeholder,
343 261 val = '',
344 262 fieldID = '',
@@ -454,8 +372,9 @@
454 372 if ( ! ( fieldID in errors ) ) {
455 373 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
456 374 }
457 375 }
376 + return errors;
458 377 }
459 378
460 379 function checkEmailField( field, errors ) {
461 380 var fieldID = getFieldId( field, true ),
@@ -466,12 +385,14 @@
466 385 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
467 386 }
468 387
469 388 confirmField( field, errors );
389 + return errors;
470 390 }
471 391
472 392 function checkPasswordField( field, errors ) {
473 393 confirmField( field, errors );
394 + return errors;
474 395 }
475 396
476 397 function confirmField( field, errors ) {
477 398 var value, confirmValue, firstField,
@@ -505,8 +426,9 @@
505 426 if ( ! ( fieldID in errors ) ) {
506 427 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
507 428 }
508 429 }
430 + return errors;
509 431 }
510 432
511 433 function checkPatternField( field, errors ) {
512 434 var fieldID,
@@ -521,47 +443,11 @@
521 443 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
522 444 }
523 445 }
524 446 }
447 + return errors;
525 448 }
526 449
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 450 function hasInvisibleRecaptcha( object ) {
565 451 var recaptcha, recaptchaID, alreadyChecked;
566 452
567 453 if ( isGoingToPrevPage( object ) ) {
@@ -646,9 +532,9 @@
646 532 return validate;
647 533 }
648 534
649 535 function getFormErrors( object, action ) {
650 - var fieldset, data, success, error, shouldTriggerEvent;
536 + var fieldset, data, success, error;
651 537
652 538 if ( typeof action === 'undefined' ) {
653 539 jQuery( object ).find( 'input[name="frm_action"]' ).val();
654 540 }
@@ -655,21 +541,14 @@
655 541
656 542 fieldset = jQuery( object ).find( '.frm_form_field' );
657 543 fieldset.addClass( 'frm_doing_ajax' );
658 544
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' );
545 + data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce;
661 546
662 547 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 -
548 + var formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
549 + $fieldCont, key, inCollapsedSection, frmTrigger,
550 + defaultResponse = { 'content': '', 'errors': {}, 'pass': false };
672 551 if ( response === null ) {
673 552 response = defaultResponse;
674 553 }
675 554
@@ -680,41 +559,17 @@
680 559 response = defaultResponse;
681 560 }
682 561
683 562 if ( typeof response.redirect !== 'undefined' ) {
684 - if ( shouldTriggerEvent ) {
685 - triggerCustomEvent( object, 'frmSubmitEvent' );
686 - return;
687 - }
688 -
689 563 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.
693 - window.location = response.redirect;
694 - return;
695 - }
696 -
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 - }
703 -
704 - if ( response.content !== '' ) {
564 + window.location = response.redirect;
565 + } else if ( response.content !== '' ) {
705 566 // the form or success message was returned
706 567
707 - if ( shouldTriggerEvent ) {
708 - triggerCustomEvent( object, 'frmSubmitEvent' );
709 - return;
710 - }
711 -
712 568 removeSubmitLoading( jQuery( object ) );
713 - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase
569 + if ( frm_js.offset != -1 ) {
714 570 frmFrontForm.scrollMsg( jQuery( object ), false );
715 571 }
716 -
717 572 formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
718 573 response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
719 574 replaceContent = jQuery( object ).closest( '.frm_forms' );
720 575 removeAddedScripts( replaceContent, formID );
@@ -751,8 +606,9 @@
751 606 delay
752 607 );
753 608 } else if ( Object.keys( response.errors ).length ) {
754 609 // errors were returned
610 +
755 611 removeSubmitLoading( jQuery( object ), 'enable' );
756 612
757 613 //show errors
758 614 contSubmit = true;
@@ -782,9 +638,9 @@
782 638 }
783 639 }
784 640 }
785 641
786 - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() {
642 + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
787 643 var $recaptcha = jQuery( this ),
788 644 recaptchaID = $recaptcha.data( 'rid' );
789 645
790 646 if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
@@ -793,11 +649,8 @@
793 649 } else {
794 650 grecaptcha.reset();
795 651 }
796 652 }
797 - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) {
798 - hcaptcha.reset();
799 - }
800 653 });
801 654
802 655 jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
803 656
@@ -829,9 +682,9 @@
829 682
830 683 function postToAjaxUrl( form, data, success, error ) {
831 684 var ajaxUrl, action, ajaxParams;
832 685
833 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
686 + ajaxUrl = frm_js.ajax_url;
834 687 action = form.getAttribute( 'action' );
835 688
836 689 if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
837 690 ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
@@ -932,25 +785,21 @@
932 785 $fieldCont.append(
933 786 jsErrors[key]
934 787 );
935 788 } else {
936 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
789 + roleString = frm_js.include_alert_role ? 'role="alert"' : '';
937 790 $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
938 791 }
939 792
940 793 if ( typeof describedBy === 'undefined' ) {
941 794 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 - }
795 + } else if ( describedBy.indexOf( id ) === -1 ) {
796 + describedBy = describedBy + ' ' + id;
948 797 }
949 -
950 798 input.attr( 'aria-describedby', describedBy );
951 799 }
952 800 input.attr( 'aria-invalid', true );
801 + input.attr( 'aria-describedby', id );
953 802
954 803 jQuery( document ).trigger( 'frmAddFieldError', [ $fieldCont, key, jsErrors ]);
955 804 }
956 805 }
@@ -1080,14 +929,14 @@
1080 929 label.append( '<span class="frm-wait"></span>' );
1081 930
1082 931 jQuery.ajax({
1083 932 type: 'POST',
1084 - url: frm_js.ajax_url, // eslint-disable-line camelcase
933 + url: frm_js.ajax_url,
1085 934 data: {
1086 935 action: 'frm_entries_send_email',
1087 936 entry_id: entryId,
1088 937 form_id: formId,
1089 - nonce: frm_js.nonce // eslint-disable-line camelcase
938 + nonce: frm_js.nonce
1090 939 },
1091 940 success: function( msg ) {
1092 941 var admin = document.getElementById( 'wpbody' );
1093 942 if ( admin === null ) {
@@ -1125,9 +974,32 @@
1125 974 /**********************************************
1126 975 * Fallback functions
1127 976 *********************************************/
1128 977
1129 - function addTrimFallbackForIE() {
978 + function addIndexOfFallbackForIE8() {
979 + var len, from;
980 +
981 + if ( ! Array.prototype.indexOf ) {
982 + Array.prototype.indexOf = function( elt /*, from*/ ) {
983 + len = this.length >>> 0;
984 +
985 + from = Number( arguments[1]) || 0;
986 + from = ( from < 0 ) ? Math.ceil( from ) : Math.floor( from );
987 + if ( from < 0 ) {
988 + from += len;
989 + }
990 +
991 + for ( ; from < len; from++ ) {
992 + if ( from in this && this[from] === elt ) {
993 + return from;
994 + }
995 + }
996 + return -1;
997 + };
998 + }
999 + }
1000 +
1001 + function addTrimFallbackForIE8() {
1130 1002 if ( typeof String.prototype.trim !== 'function' ) {
1131 1003 String.prototype.trim = function() {
1132 1004 return this.replace( /^\s+|\s+$/g, '' );
1133 1005 };
@@ -1133,9 +1005,9 @@
1133 1005 };
1134 1006 }
1135 1007 }
1136 1008
1137 - function addFilterFallbackForIE() {
1009 + function addFilterFallbackForIE8() {
1138 1010 var t, len, res, thisp, i, val;
1139 1011
1140 1012 if ( ! Array.prototype.filter ) {
1141 1013
@@ -1166,8 +1038,26 @@
1166 1038 };
1167 1039 }
1168 1040 }
1169 1041
1042 + function addKeysFallbackForIE8() {
1043 + var keys, i;
1044 +
1045 + if ( ! Object.keys ) {
1046 + Object.keys = function( obj ) {
1047 + keys = [];
1048 +
1049 + for ( i in obj ) {
1050 + if ( obj.hasOwnProperty( i ) ) {
1051 + keys.push( i );
1052 + }
1053 + }
1054 +
1055 + return keys;
1056 + };
1057 + }
1058 + }
1059 +
1170 1060 /**
1171 1061 * Check for -webkit-box-shadow css value for input:-webkit-autofill selector.
1172 1062 * If this is a match, the User is autofilling the input on a Webkit browser.
1173 1063 * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete.
@@ -1178,37 +1068,8 @@
1178 1068 this.parentNode.removeChild( this );
1179 1069 }
1180 1070 }
1181 1071
1182 - function maybeMakeHoneypotFieldsUntabbable() {
1183 - document.addEventListener( 'keydown', handleKeyUp );
1184 -
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 - }
1198 - }
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 - }
1210 -
1211 1072 /**
1212 1073 * Focus on the first sub field when clicking to the primary label of combo field.
1213 1074 *
1214 1075 * @since 4.10.02
@@ -1213,11 +1074,11 @@
1213 1074 *
1214 1075 * @since 4.10.02
1215 1076 */
1216 1077 function changeFocusWhenClickComboFieldLabel() {
1217 - var label;
1078 + let label;
1218 1079
1219 - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1080 + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1220 1081 comboInputsContainer.forEach( function( inputsContainer ) {
1221 1082 if ( ! inputsContainer.closest( '.frm_form_field' ) ) {
1222 1083 return;
1223 1084 }
@@ -1235,9 +1096,9 @@
1235 1096
1236 1097 function checkForErrorsAndMaybeSetFocus() {
1237 1098 var errors, element, timeoutCallback;
1238 1099
1239 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1100 + if ( ! frm_js.focus_first_error ) {
1240 1101 return;
1241 1102 }
1242 1103
1243 1104 errors = document.querySelectorAll( '.frm_form_field .frm_error' );
@@ -1274,246 +1135,10 @@
1274 1135 }
1275 1136 } while ( element.previousSibling );
1276 1137 }
1277 1138
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 1139 return {
1513 1140 init: function() {
1514 - maybeAddPolyfills();
1515 -
1516 1141 jQuery( document ).off( 'submit.formidable', '.frm-show-form' );
1517 1142 jQuery( document ).on( 'submit.formidable', '.frm-show-form', frmFrontForm.submitForm );
1518 1143
1519 1144 jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() {
@@ -1528,11 +1153,11 @@
1528 1153
1529 1154 jQuery( document.getElementById( 'frm_resend_email' ) ).on( 'click', resendEmail );
1530 1155
1531 1156 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 );
1157 + 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 );
1532 1158
1533 1159 jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange );
1534 - maybeMakeHoneypotFieldsUntabbable();
1535 1160
1536 1161 jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick );
1537 1162 jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv );
1538 1163
@@ -1540,23 +1165,13 @@
1540 1165
1541 1166 // Focus on the first sub field when clicking to the primary label of combo field.
1542 1167 changeFocusWhenClickComboFieldLabel();
1543 1168
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 );
1169 + // Add fallbacks for the beloved IE8
1170 + addIndexOfFallbackForIE8();
1171 + addTrimFallbackForIE8();
1172 + addFilterFallbackForIE8();
1173 + addKeysFallbackForIE8();
1559 1174 },
1560 1175
1561 1176 getFieldId: function( field, fullID ) {
1562 1177 return getFieldId( field, fullID );
@@ -1739,12 +1354,12 @@
1739 1354 removeSubmitLoading: function( $object, enable, processesRunning ) {
1740 1355 removeSubmitLoading( $object, enable, processesRunning );
1741 1356 },
1742 1357
1743 - scrollToID: function( id ) {
1744 - var object = jQuery( document.getElementById( id ) );
1745 - frmFrontForm.scrollMsg( object, false );
1746 - },
1358 + scrollToID: function( id ) {
1359 + var object = jQuery( document.getElementById( id ) );
1360 + frmFrontForm.scrollMsg( object, false );
1361 + },
1747 1362
1748 1363 scrollMsg: function( id, object, animate ) {
1749 1364 var newPos, m, b, screenTop, screenBottom,
1750 1365 scrollObj = '';
@@ -1760,12 +1375,12 @@
1760 1375 }
1761 1376
1762 1377 jQuery( scrollObj ).trigger( 'focus' );
1763 1378 newPos = scrollObj.offset().top;
1764 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1379 + if ( ! newPos || frm_js.offset === '-1' ) {
1765 1380 return;
1766 1381 }
1767 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1382 + newPos = newPos - frm_js.offset;
1768 1383
1769 1384 m = jQuery( 'html' ).css( 'margin-top' );
1770 1385 b = jQuery( 'body' ).css( 'margin-top' );
1771 1386 if ( m || b ) {
@@ -1868,11 +1483,9 @@
1868 1483 },
1869 1484
1870 1485 visible: function( classes ) {
1871 1486 jQuery( classes ).css( 'visibility', 'visible' );
1872 - },
1873 -
1874 - triggerCustomEvent: triggerCustomEvent
1487 + }
1875 1488 };
1876 1489 }
1877 1490 frmFrontForm = frmFrontFormJS();
1878 1491
@@ -1895,15 +1508,15 @@
1895 1508 function frmUpdateField( entryId, fieldId, value, message, num ) {
1896 1509 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1897 1510 jQuery.ajax({
1898 1511 type: 'POST',
1899 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1512 + url: frm_js.ajax_url,
1900 1513 data: {
1901 1514 action: 'frm_entries_update_field_ajax',
1902 1515 entry_id: entryId,
1903 1516 field_id: fieldId,
1904 1517 value: value,
1905 - nonce: frm_js.nonce // eslint-disable-line camelcase
1518 + nonce: frm_js.nonce
1906 1519 },
1907 1520 success: function() {
1908 1521 if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1909 1522 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
@@ -1918,13 +1531,13 @@
1918 1531 console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1919 1532 jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1920 1533 jQuery.ajax({
1921 1534 type: 'POST',
1922 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1535 + url: frm_js.ajax_url,
1923 1536 data: {
1924 1537 action: 'frm_entries_destroy',
1925 1538 entry: entryId,
1926 - nonce: frm_js.nonce // eslint-disable-line camelcase
1539 + nonce: frm_js.nonce
1927 1540 },
1928 1541 success: function( html ) {
1929 1542 if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1930 1543 jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
@@ -1945,14 +1558,14 @@
1945 1558 console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1946 1559 $link.append( '<span class="spinner" style="display:inline"></span>' );
1947 1560 jQuery.ajax({
1948 1561 type: 'POST',
1949 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1562 + url: frm_js.ajax_url,
1950 1563 data: {
1951 1564 action: 'frm_entries_send_email',
1952 1565 entry_id: entryId,
1953 1566 form_id: formId,
1954 - nonce: frm_js.nonce // eslint-disable-line camelcase
1567 + nonce: frm_js.nonce
1955 1568 },
1956 1569 success: function( msg ) {
1957 1570 $link.replaceWith( msg );
1958 1571 }