PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.3.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.3.2
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 +123 -477 6.5.15.3.2 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
@@ -222,10 +171,23 @@
222 171 fields = jQuery( object ).find( 'input,select,textarea' );
223 172 if ( fields.length ) {
224 173 for ( n = 0, nl = fields.length; n < nl; n++ ) {
225 174 field = fields[n];
226 - if ( '' !== field.value ) {
227 - validateFieldValue( 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 );
189 + }
228 190 }
229 191 }
230 192 }
231 193
@@ -272,9 +234,19 @@
272 234 errors = checkRequiredField( field, errors );
273 235 }
274 236
275 237 if ( errors.length < 1 ) {
276 - 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 + }
277 249 }
278 250
279 251 removeFieldError( $fieldCont );
280 252 if ( Object.keys( errors ).length > 0 ) {
@@ -283,29 +255,8 @@
283 255 }
284 256 }
285 257 }
286 258
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 259 function checkRequiredField( field, errors ) {
309 260 var checkGroup, tempVal, i, placeholder,
310 261 val = '',
311 262 fieldID = '',
@@ -421,8 +372,9 @@
421 372 if ( ! ( fieldID in errors ) ) {
422 373 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
423 374 }
424 375 }
376 + return errors;
425 377 }
426 378
427 379 function checkEmailField( field, errors ) {
428 380 var fieldID = getFieldId( field, true ),
@@ -433,12 +385,14 @@
433 385 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
434 386 }
435 387
436 388 confirmField( field, errors );
389 + return errors;
437 390 }
438 391
439 392 function checkPasswordField( field, errors ) {
440 393 confirmField( field, errors );
394 + return errors;
441 395 }
442 396
443 397 function confirmField( field, errors ) {
444 398 var value, confirmValue, firstField,
@@ -472,8 +426,9 @@
472 426 if ( ! ( fieldID in errors ) ) {
473 427 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
474 428 }
475 429 }
430 + return errors;
476 431 }
477 432
478 433 function checkPatternField( field, errors ) {
479 434 var fieldID,
@@ -488,47 +443,11 @@
488 443 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
489 444 }
490 445 }
491 446 }
447 + return errors;
492 448 }
493 449
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 450 function hasInvisibleRecaptcha( object ) {
532 451 var recaptcha, recaptchaID, alreadyChecked;
533 452
534 453 if ( isGoingToPrevPage( object ) ) {
@@ -613,9 +532,9 @@
613 532 return validate;
614 533 }
615 534
616 535 function getFormErrors( object, action ) {
617 - var fieldset, data, success, error, shouldTriggerEvent;
536 + var fieldset, data, success, error;
618 537
619 538 if ( typeof action === 'undefined' ) {
620 539 jQuery( object ).find( 'input[name="frm_action"]' ).val();
621 540 }
@@ -622,21 +541,14 @@
622 541
623 542 fieldset = jQuery( object ).find( '.frm_form_field' );
624 543 fieldset.addClass( 'frm_doing_ajax' );
625 544
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' );
545 + data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce;
628 546
629 547 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 -
548 + var formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
549 + $fieldCont, key, inCollapsedSection, frmTrigger,
550 + defaultResponse = { 'content': '', 'errors': {}, 'pass': false };
639 551 if ( response === null ) {
640 552 response = defaultResponse;
641 553 }
642 554
@@ -647,41 +559,17 @@
647 559 response = defaultResponse;
648 560 }
649 561
650 562 if ( typeof response.redirect !== 'undefined' ) {
651 - if ( shouldTriggerEvent ) {
652 - triggerCustomEvent( object, 'frmSubmitEvent' );
653 - return;
654 - }
655 -
656 563 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.
660 - window.location = response.redirect;
661 - return;
662 - }
663 -
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 - }
670 -
671 - if ( response.content !== '' ) {
564 + window.location = response.redirect;
565 + } else if ( response.content !== '' ) {
672 566 // the form or success message was returned
673 567
674 - if ( shouldTriggerEvent ) {
675 - triggerCustomEvent( object, 'frmSubmitEvent' );
676 - return;
677 - }
678 -
679 568 removeSubmitLoading( jQuery( object ) );
680 - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase
569 + if ( frm_js.offset != -1 ) {
681 570 frmFrontForm.scrollMsg( jQuery( object ), false );
682 571 }
683 -
684 572 formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
685 573 response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
686 574 replaceContent = jQuery( object ).closest( '.frm_forms' );
687 575 removeAddedScripts( replaceContent, formID );
@@ -718,8 +606,9 @@
718 606 delay
719 607 );
720 608 } else if ( Object.keys( response.errors ).length ) {
721 609 // errors were returned
610 +
722 611 removeSubmitLoading( jQuery( object ), 'enable' );
723 612
724 613 //show errors
725 614 contSubmit = true;
@@ -749,9 +638,9 @@
749 638 }
750 639 }
751 640 }
752 641
753 - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() {
642 + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
754 643 var $recaptcha = jQuery( this ),
755 644 recaptchaID = $recaptcha.data( 'rid' );
756 645
757 646 if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
@@ -760,11 +649,8 @@
760 649 } else {
761 650 grecaptcha.reset();
762 651 }
763 652 }
764 - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) {
765 - hcaptcha.reset();
766 - }
767 653 });
768 654
769 655 jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
770 656
@@ -796,9 +682,9 @@
796 682
797 683 function postToAjaxUrl( form, data, success, error ) {
798 684 var ajaxUrl, action, ajaxParams;
799 685
800 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
686 + ajaxUrl = frm_js.ajax_url;
801 687 action = form.getAttribute( 'action' );
802 688
803 689 if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
804 690 ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
@@ -899,25 +785,21 @@
899 785 $fieldCont.append(
900 786 jsErrors[key]
901 787 );
902 788 } else {
903 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
789 + roleString = frm_js.include_alert_role ? 'role="alert"' : '';
904 790 $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
905 791 }
906 792
907 793 if ( typeof describedBy === 'undefined' ) {
908 794 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 - }
795 + } else if ( describedBy.indexOf( id ) === -1 ) {
796 + describedBy = describedBy + ' ' + id;
915 797 }
916 -
917 798 input.attr( 'aria-describedby', describedBy );
918 799 }
919 800 input.attr( 'aria-invalid', true );
801 + input.attr( 'aria-describedby', id );
920 802
921 803 jQuery( document ).trigger( 'frmAddFieldError', [ $fieldCont, key, jsErrors ]);
922 804 }
923 805 }
@@ -1047,14 +929,14 @@
1047 929 label.append( '<span class="frm-wait"></span>' );
1048 930
1049 931 jQuery.ajax({
1050 932 type: 'POST',
1051 - url: frm_js.ajax_url, // eslint-disable-line camelcase
933 + url: frm_js.ajax_url,
1052 934 data: {
1053 935 action: 'frm_entries_send_email',
1054 936 entry_id: entryId,
1055 937 form_id: formId,
1056 - nonce: frm_js.nonce // eslint-disable-line camelcase
938 + nonce: frm_js.nonce
1057 939 },
1058 940 success: function( msg ) {
1059 941 var admin = document.getElementById( 'wpbody' );
1060 942 if ( admin === null ) {
@@ -1092,9 +974,32 @@
1092 974 /**********************************************
1093 975 * Fallback functions
1094 976 *********************************************/
1095 977
1096 - 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() {
1097 1002 if ( typeof String.prototype.trim !== 'function' ) {
1098 1003 String.prototype.trim = function() {
1099 1004 return this.replace( /^\s+|\s+$/g, '' );
1100 1005 };
@@ -1100,9 +1005,9 @@
1100 1005 };
1101 1006 }
1102 1007 }
1103 1008
1104 - function addFilterFallbackForIE() {
1009 + function addFilterFallbackForIE8() {
1105 1010 var t, len, res, thisp, i, val;
1106 1011
1107 1012 if ( ! Array.prototype.filter ) {
1108 1013
@@ -1133,8 +1038,26 @@
1133 1038 };
1134 1039 }
1135 1040 }
1136 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 +
1137 1060 /**
1138 1061 * Check for -webkit-box-shadow css value for input:-webkit-autofill selector.
1139 1062 * If this is a match, the User is autofilling the input on a Webkit browser.
1140 1063 * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete.
@@ -1145,37 +1068,8 @@
1145 1068 this.parentNode.removeChild( this );
1146 1069 }
1147 1070 }
1148 1071
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 1072 /**
1179 1073 * Focus on the first sub field when clicking to the primary label of combo field.
1180 1074 *
1181 1075 * @since 4.10.02
@@ -1180,11 +1074,11 @@
1180 1074 *
1181 1075 * @since 4.10.02
1182 1076 */
1183 1077 function changeFocusWhenClickComboFieldLabel() {
1184 - var label;
1078 + let label;
1185 1079
1186 - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1080 + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1187 1081 comboInputsContainer.forEach( function( inputsContainer ) {
1188 1082 if ( ! inputsContainer.closest( '.frm_form_field' ) ) {
1189 1083 return;
1190 1084 }
@@ -1202,9 +1096,9 @@
1202 1096
1203 1097 function checkForErrorsAndMaybeSetFocus() {
1204 1098 var errors, element, timeoutCallback;
1205 1099
1206 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1100 + if ( ! frm_js.focus_first_error ) {
1207 1101 return;
1208 1102 }
1209 1103
1210 1104 errors = document.querySelectorAll( '.frm_form_field .frm_error' );
@@ -1241,246 +1135,10 @@
1241 1135 }
1242 1136 } while ( element.previousSibling );
1243 1137 }
1244 1138
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 1139 return {
1480 1140 init: function() {
1481 - maybeAddPolyfills();
1482 -
1483 1141 jQuery( document ).off( 'submit.formidable', '.frm-show-form' );
1484 1142 jQuery( document ).on( 'submit.formidable', '.frm-show-form', frmFrontForm.submitForm );
1485 1143
1486 1144 jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() {
@@ -1495,11 +1153,11 @@
1495 1153
1496 1154 jQuery( document.getElementById( 'frm_resend_email' ) ).on( 'click', resendEmail );
1497 1155
1498 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 );
1499 1158
1500 1159 jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange );
1501 - maybeMakeHoneypotFieldsUntabbable();
1502 1160
1503 1161 jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick );
1504 1162 jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv );
1505 1163
@@ -1507,23 +1165,13 @@
1507 1165
1508 1166 // Focus on the first sub field when clicking to the primary label of combo field.
1509 1167 changeFocusWhenClickComboFieldLabel();
1510 1168
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 );
1169 + // Add fallbacks for the beloved IE8
1170 + addIndexOfFallbackForIE8();
1171 + addTrimFallbackForIE8();
1172 + addFilterFallbackForIE8();
1173 + addKeysFallbackForIE8();
1526 1174 },
1527 1175
1528 1176 getFieldId: function( field, fullID ) {
1529 1177 return getFieldId( field, fullID );
@@ -1706,12 +1354,12 @@
1706 1354 removeSubmitLoading: function( $object, enable, processesRunning ) {
1707 1355 removeSubmitLoading( $object, enable, processesRunning );
1708 1356 },
1709 1357
1710 - scrollToID: function( id ) {
1711 - var object = jQuery( document.getElementById( id ) );
1712 - frmFrontForm.scrollMsg( object, false );
1713 - },
1358 + scrollToID: function( id ) {
1359 + var object = jQuery( document.getElementById( id ) );
1360 + frmFrontForm.scrollMsg( object, false );
1361 + },
1714 1362
1715 1363 scrollMsg: function( id, object, animate ) {
1716 1364 var newPos, m, b, screenTop, screenBottom,
1717 1365 scrollObj = '';
@@ -1727,12 +1375,12 @@
1727 1375 }
1728 1376
1729 1377 jQuery( scrollObj ).trigger( 'focus' );
1730 1378 newPos = scrollObj.offset().top;
1731 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1379 + if ( ! newPos || frm_js.offset === '-1' ) {
1732 1380 return;
1733 1381 }
1734 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1382 + newPos = newPos - frm_js.offset;
1735 1383
1736 1384 m = jQuery( 'html' ).css( 'margin-top' );
1737 1385 b = jQuery( 'body' ).css( 'margin-top' );
1738 1386 if ( m || b ) {
@@ -1835,11 +1483,9 @@
1835 1483 },
1836 1484
1837 1485 visible: function( classes ) {
1838 1486 jQuery( classes ).css( 'visibility', 'visible' );
1839 - },
1840 -
1841 - triggerCustomEvent: triggerCustomEvent
1487 + }
1842 1488 };
1843 1489 }
1844 1490 frmFrontForm = frmFrontFormJS();
1845 1491
@@ -1862,15 +1508,15 @@
1862 1508 function frmUpdateField( entryId, fieldId, value, message, num ) {
1863 1509 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1864 1510 jQuery.ajax({
1865 1511 type: 'POST',
1866 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1512 + url: frm_js.ajax_url,
1867 1513 data: {
1868 1514 action: 'frm_entries_update_field_ajax',
1869 1515 entry_id: entryId,
1870 1516 field_id: fieldId,
1871 1517 value: value,
1872 - nonce: frm_js.nonce // eslint-disable-line camelcase
1518 + nonce: frm_js.nonce
1873 1519 },
1874 1520 success: function() {
1875 1521 if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1876 1522 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
@@ -1885,13 +1531,13 @@
1885 1531 console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1886 1532 jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1887 1533 jQuery.ajax({
1888 1534 type: 'POST',
1889 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1535 + url: frm_js.ajax_url,
1890 1536 data: {
1891 1537 action: 'frm_entries_destroy',
1892 1538 entry: entryId,
1893 - nonce: frm_js.nonce // eslint-disable-line camelcase
1539 + nonce: frm_js.nonce
1894 1540 },
1895 1541 success: function( html ) {
1896 1542 if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1897 1543 jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
@@ -1912,14 +1558,14 @@
1912 1558 console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1913 1559 $link.append( '<span class="spinner" style="display:inline"></span>' );
1914 1560 jQuery.ajax({
1915 1561 type: 'POST',
1916 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1562 + url: frm_js.ajax_url,
1917 1563 data: {
1918 1564 action: 'frm_entries_send_email',
1919 1565 entry_id: entryId,
1920 1566 form_id: formId,
1921 - nonce: frm_js.nonce // eslint-disable-line camelcase
1567 + nonce: frm_js.nonce
1922 1568 },
1923 1569 success: function( msg ) {
1924 1570 $link.replaceWith( msg );
1925 1571 }