PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4
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 +119 -372 6.35.4 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,8 +443,9 @@
488 443 errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
489 444 }
490 445 }
491 446 }
447 + return errors;
492 448 }
493 449
494 450 function hasInvisibleRecaptcha( object ) {
495 451 var recaptcha, recaptchaID, alreadyChecked;
@@ -576,9 +532,9 @@
576 532 return validate;
577 533 }
578 534
579 535 function getFormErrors( object, action ) {
580 - var fieldset, data, success, error, shouldTriggerEvent;
536 + var fieldset, data, success, error;
581 537
582 538 if ( typeof action === 'undefined' ) {
583 539 jQuery( object ).find( 'input[name="frm_action"]' ).val();
584 540 }
@@ -585,21 +541,14 @@
585 541
586 542 fieldset = jQuery( object ).find( '.frm_form_field' );
587 543 fieldset.addClass( 'frm_doing_ajax' );
588 544
589 - data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; // eslint-disable-line camelcase
590 - shouldTriggerEvent = object.classList.contains( 'frm_trigger_event_on_submit' );
545 + data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce;
591 546
592 547 success = function( response ) {
593 - var defaultResponse, formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
594 - $fieldCont, key, inCollapsedSection, frmTrigger;
595 -
596 - defaultResponse = {
597 - content: '',
598 - errors: {},
599 - pass: false
600 - };
601 -
548 + var formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
549 + $fieldCont, key, inCollapsedSection, frmTrigger,
550 + defaultResponse = { 'content': '', 'errors': {}, 'pass': false };
602 551 if ( response === null ) {
603 552 response = defaultResponse;
604 553 }
605 554
@@ -610,28 +559,17 @@
610 559 response = defaultResponse;
611 560 }
612 561
613 562 if ( typeof response.redirect !== 'undefined' ) {
614 - if ( shouldTriggerEvent ) {
615 - triggerCustomEvent( object, 'frmSubmitEvent' );
616 - return;
617 - }
618 -
619 563 jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
620 564 window.location = response.redirect;
621 565 } else if ( response.content !== '' ) {
622 566 // the form or success message was returned
623 567
624 - if ( shouldTriggerEvent ) {
625 - triggerCustomEvent( object, 'frmSubmitEvent' );
626 - return;
627 - }
628 -
629 568 removeSubmitLoading( jQuery( object ) );
630 - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase
569 + if ( frm_js.offset != -1 ) {
631 570 frmFrontForm.scrollMsg( jQuery( object ), false );
632 571 }
633 -
634 572 formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
635 573 response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
636 574 replaceContent = jQuery( object ).closest( '.frm_forms' );
637 575 removeAddedScripts( replaceContent, formID );
@@ -668,8 +606,9 @@
668 606 delay
669 607 );
670 608 } else if ( Object.keys( response.errors ).length ) {
671 609 // errors were returned
610 +
672 611 removeSubmitLoading( jQuery( object ), 'enable' );
673 612
674 613 //show errors
675 614 contSubmit = true;
@@ -699,9 +638,9 @@
699 638 }
700 639 }
701 640 }
702 641
703 - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() {
642 + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
704 643 var $recaptcha = jQuery( this ),
705 644 recaptchaID = $recaptcha.data( 'rid' );
706 645
707 646 if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
@@ -710,11 +649,8 @@
710 649 } else {
711 650 grecaptcha.reset();
712 651 }
713 652 }
714 - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) {
715 - hcaptcha.reset();
716 - }
717 653 });
718 654
719 655 jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
720 656
@@ -746,9 +682,9 @@
746 682
747 683 function postToAjaxUrl( form, data, success, error ) {
748 684 var ajaxUrl, action, ajaxParams;
749 685
750 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
686 + ajaxUrl = frm_js.ajax_url;
751 687 action = form.getAttribute( 'action' );
752 688
753 689 if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
754 690 ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
@@ -849,22 +785,17 @@
849 785 $fieldCont.append(
850 786 jsErrors[key]
851 787 );
852 788 } else {
853 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
789 + roleString = frm_js.include_alert_role ? 'role="alert"' : '';
854 790 $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
855 791 }
856 792
857 793 if ( typeof describedBy === 'undefined' ) {
858 794 describedBy = id;
859 - } else if ( describedBy.indexOf( id ) === -1 && describedBy.indexOf( 'frm_error_field_' ) === -1 ) {
860 - if ( input.data( 'error-first' ) === 0 ) {
861 - describedBy = describedBy + ' ' + id;
862 - } else {
863 - describedBy = id + ' ' + describedBy;
864 - }
795 + } else if ( describedBy.indexOf( id ) === -1 ) {
796 + describedBy = describedBy + ' ' + id;
865 797 }
866 -
867 798 input.attr( 'aria-describedby', describedBy );
868 799 }
869 800 input.attr( 'aria-invalid', true );
870 801
@@ -997,14 +928,14 @@
997 928 label.append( '<span class="frm-wait"></span>' );
998 929
999 930 jQuery.ajax({
1000 931 type: 'POST',
1001 - url: frm_js.ajax_url, // eslint-disable-line camelcase
932 + url: frm_js.ajax_url,
1002 933 data: {
1003 934 action: 'frm_entries_send_email',
1004 935 entry_id: entryId,
1005 936 form_id: formId,
1006 - nonce: frm_js.nonce // eslint-disable-line camelcase
937 + nonce: frm_js.nonce
1007 938 },
1008 939 success: function( msg ) {
1009 940 var admin = document.getElementById( 'wpbody' );
1010 941 if ( admin === null ) {
@@ -1042,9 +973,32 @@
1042 973 /**********************************************
1043 974 * Fallback functions
1044 975 *********************************************/
1045 976
1046 - function addTrimFallbackForIE() {
977 + function addIndexOfFallbackForIE8() {
978 + var len, from;
979 +
980 + if ( ! Array.prototype.indexOf ) {
981 + Array.prototype.indexOf = function( elt /*, from*/ ) {
982 + len = this.length >>> 0;
983 +
984 + from = Number( arguments[1]) || 0;
985 + from = ( from < 0 ) ? Math.ceil( from ) : Math.floor( from );
986 + if ( from < 0 ) {
987 + from += len;
988 + }
989 +
990 + for ( ; from < len; from++ ) {
991 + if ( from in this && this[from] === elt ) {
992 + return from;
993 + }
994 + }
995 + return -1;
996 + };
997 + }
998 + }
999 +
1000 + function addTrimFallbackForIE8() {
1047 1001 if ( typeof String.prototype.trim !== 'function' ) {
1048 1002 String.prototype.trim = function() {
1049 1003 return this.replace( /^\s+|\s+$/g, '' );
1050 1004 };
@@ -1050,9 +1004,9 @@
1050 1004 };
1051 1005 }
1052 1006 }
1053 1007
1054 - function addFilterFallbackForIE() {
1008 + function addFilterFallbackForIE8() {
1055 1009 var t, len, res, thisp, i, val;
1056 1010
1057 1011 if ( ! Array.prototype.filter ) {
1058 1012
@@ -1083,8 +1037,26 @@
1083 1037 };
1084 1038 }
1085 1039 }
1086 1040
1041 + function addKeysFallbackForIE8() {
1042 + var keys, i;
1043 +
1044 + if ( ! Object.keys ) {
1045 + Object.keys = function( obj ) {
1046 + keys = [];
1047 +
1048 + for ( i in obj ) {
1049 + if ( obj.hasOwnProperty( i ) ) {
1050 + keys.push( i );
1051 + }
1052 + }
1053 +
1054 + return keys;
1055 + };
1056 + }
1057 + }
1058 +
1087 1059 /**
1088 1060 * Check for -webkit-box-shadow css value for input:-webkit-autofill selector.
1089 1061 * If this is a match, the User is autofilling the input on a Webkit browser.
1090 1062 * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete.
@@ -1095,38 +1067,8 @@
1095 1067 this.parentNode.removeChild( this );
1096 1068 }
1097 1069 }
1098 1070
1099 - function maybeMakeHoneypotFieldsUntabbable() {
1100 - document.addEventListener( 'keydown', handleKeyUp );
1101 -
1102 - function handleKeyUp( event ) {
1103 - var code;
1104 -
1105 - if ( 'undefined' !== typeof event.key ) {
1106 - code = event.key;
1107 - } else if ( 'undefined' !== typeof event.keyCode && 9 === event.keyCode ) {
1108 - code = 'Tab';
1109 - }
1110 -
1111 - if ( 'Tab' === code ) {
1112 - makeHoneypotFieldsUntabbable();
1113 - document.removeEventListener( 'keydown', handleKeyUp );
1114 - }
1115 - }
1116 -
1117 - function makeHoneypotFieldsUntabbable() {
1118 - document.querySelectorAll( '.frm_verify' ).forEach(
1119 - function( wrapper ) {
1120 - var input = wrapper.querySelector( 'input[id^=frm_email]' );
1121 - if ( input ) {
1122 - input.setAttribute( 'tabindex', -1 );
1123 - }
1124 - }
1125 - );
1126 - }
1127 - }
1128 -
1129 1071 /**
1130 1072 * Focus on the first sub field when clicking to the primary label of combo field.
1131 1073 *
1132 1074 * @since 4.10.02
@@ -1131,11 +1073,11 @@
1131 1073 *
1132 1074 * @since 4.10.02
1133 1075 */
1134 1076 function changeFocusWhenClickComboFieldLabel() {
1135 - var label;
1077 + let label;
1136 1078
1137 - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1079 + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1138 1080 comboInputsContainer.forEach( function( inputsContainer ) {
1139 1081 if ( ! inputsContainer.closest( '.frm_form_field' ) ) {
1140 1082 return;
1141 1083 }
@@ -1153,9 +1095,9 @@
1153 1095
1154 1096 function checkForErrorsAndMaybeSetFocus() {
1155 1097 var errors, element, timeoutCallback;
1156 1098
1157 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1099 + if ( ! frm_js.focus_first_error ) {
1158 1100 return;
1159 1101 }
1160 1102
1161 1103 errors = document.querySelectorAll( '.frm_form_field .frm_error' );
@@ -1192,202 +1134,10 @@
1192 1134 }
1193 1135 } while ( element.previousSibling );
1194 1136 }
1195 1137
1196 - /**
1197 - * Checks if is on IE browser.
1198 - *
1199 - * @since 5.4
1200 - *
1201 - * @return {Boolean}
1202 - */
1203 - function isIE() {
1204 - return navigator.userAgent.indexOf( 'MSIE' ) > -1 || navigator.userAgent.indexOf( 'Trident' ) > -1;
1205 - }
1206 -
1207 - /**
1208 - * Does the same as jQuery( document ).on( 'event', 'selector', handler ).
1209 - *
1210 - * @since 5.4
1211 - *
1212 - * @param {String} event Event name.
1213 - * @param {String} selector Selector.
1214 - * @param {Function} handler Handler.
1215 - * @param {Boolean|Object} options Options to be added to `addEventListener()` method. Default is `false`.
1216 - */
1217 - function documentOn( event, selector, handler, options ) {
1218 - if ( 'undefined' === typeof options ) {
1219 - options = false;
1220 - }
1221 -
1222 - document.addEventListener( event, function( e ) {
1223 - var target;
1224 -
1225 - // loop parent nodes from the target to the delegation node.
1226 - for ( target = e.target; target && target != this; target = target.parentNode ) {
1227 - if ( target && target.matches && target.matches( selector ) ) {
1228 - handler.call( target, e );
1229 - break;
1230 - }
1231 - }
1232 - }, options );
1233 - }
1234 -
1235 - function initFloatingLabels() {
1236 - var checkFloatLabel, checkDropdownLabel, checkPlaceholderIE, runOnLoad, selector, floatClass;
1237 -
1238 - selector = '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea';
1239 - floatClass = 'frm_label_float_top';
1240 -
1241 - checkFloatLabel = function( input ) {
1242 - var container, shouldFloatTop, firstOpt;
1243 -
1244 - container = input.closest( '.frm_inside_container' );
1245 - if ( ! container ) {
1246 - return;
1247 - }
1248 -
1249 - shouldFloatTop = input.value || document.activeElement === input;
1250 -
1251 - container.classList.toggle( floatClass, shouldFloatTop );
1252 -
1253 - if ( 'SELECT' === input.tagName ) {
1254 - firstOpt = input.querySelector( 'option:first-child' );
1255 -
1256 - if ( shouldFloatTop ) {
1257 - if ( firstOpt.hasAttribute( 'data-label' ) ) {
1258 - firstOpt.textContent = firstOpt.getAttribute( 'data-label' );
1259 - firstOpt.removeAttribute( 'data-label' );
1260 - }
1261 - } else {
1262 - if ( firstOpt.textContent ) {
1263 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1264 - firstOpt.textContent = '';
1265 - }
1266 - }
1267 - } else if ( isIE() ) {
1268 - checkPlaceholderIE( input );
1269 - }
1270 - };
1271 -
1272 - checkDropdownLabel = function() {
1273 - document.querySelectorAll( '.frm-show-form .frm_inside_container:not(.' + floatClass + ') select' ).forEach( function( input ) {
1274 - var firstOpt = input.querySelector( 'option:first-child' );
1275 -
1276 - if ( firstOpt.textContent ) {
1277 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1278 - firstOpt.textContent = '';
1279 - }
1280 - });
1281 - };
1282 -
1283 - checkPlaceholderIE = function( input ) {
1284 - if ( input.value ) {
1285 - // Don't need to handle this case because placeholder isn't shown.
1286 - return;
1287 - }
1288 -
1289 - if ( document.activeElement === input ) {
1290 - if ( input.hasAttribute( 'data-placeholder' ) ) {
1291 - input.placeholder = input.getAttribute( 'data-placeholder' );
1292 - input.removeAttribute( 'data-placeholder' );
1293 - }
1294 - } else {
1295 - if ( input.placeholder ) {
1296 - input.setAttribute( 'data-placeholder', input.placeholder );
1297 - input.placeholder = '';
1298 - }
1299 - }
1300 - };
1301 -
1302 - [ 'focus', 'blur', 'change' ].forEach( function( eventName ) {
1303 - documentOn(
1304 - eventName,
1305 - selector,
1306 - function( event ) {
1307 - checkFloatLabel( event.target );
1308 - },
1309 - true
1310 - );
1311 - });
1312 -
1313 - jQuery( document ).on( 'change', selector, function( event ) {
1314 - checkFloatLabel( event.target );
1315 - });
1316 -
1317 - runOnLoad = function( firstLoad ) {
1318 - if ( firstLoad && document.activeElement && -1 !== [ 'INPUT', 'SELECT', 'TEXTAREA' ].indexOf( document.activeElement.tagName ) ) {
1319 - checkFloatLabel( document.activeElement );
1320 - } else if ( firstLoad ) {
1321 - document.querySelectorAll( '.frm_inside_container' ).forEach(
1322 - function( container ) {
1323 - var input = container.querySelector( 'input, select, textarea' );
1324 - if ( input && '' !== input.value ) {
1325 - checkFloatLabel( input );
1326 - }
1327 - }
1328 - );
1329 - }
1330 -
1331 - checkDropdownLabel();
1332 -
1333 - if ( isIE() ) {
1334 - document.querySelectorAll( selector ).forEach( function( input ) {
1335 - checkPlaceholderIE( input );
1336 - });
1337 - }
1338 - };
1339 -
1340 - runOnLoad( true );
1341 -
1342 - jQuery( document ).on( 'frmPageChanged', function( event ) {
1343 - runOnLoad();
1344 - });
1345 -
1346 - document.addEventListener( 'frm_after_start_over', function( event ) {
1347 - runOnLoad();
1348 - });
1349 - }
1350 -
1351 - function setCustomValidityMessage() {
1352 - var forms, length, index;
1353 -
1354 - forms = document.getElementsByClassName( 'frm-show-form' );
1355 - length = forms.length;
1356 -
1357 - for ( index = 0; index < length; ++index ) {
1358 - forms[ index ].addEventListener(
1359 - 'invalid',
1360 - function( event ) {
1361 - var target = event.target;
1362 -
1363 - if ( 'INPUT' !== target.nodeName ) {
1364 - return;
1365 - }
1366 -
1367 - if ( ! target.dataset.invmsg ) {
1368 - return;
1369 - }
1370 -
1371 - if ( 'text' !== target.getAttribute( 'type' ) ) {
1372 - return;
1373 - }
1374 -
1375 - if ( target.classList.contains( 'frm_verify' ) ) {
1376 - return;
1377 - }
1378 -
1379 - target.setCustomValidity( target.dataset.invmsg );
1380 - },
1381 - true
1382 - );
1383 - }
1384 - }
1385 -
1386 1138 return {
1387 1139 init: function() {
1388 - maybeAddPolyfills();
1389 -
1390 1140 jQuery( document ).off( 'submit.formidable', '.frm-show-form' );
1391 1141 jQuery( document ).on( 'submit.formidable', '.frm-show-form', frmFrontForm.submitForm );
1392 1142
1393 1143 jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() {
@@ -1402,11 +1152,11 @@
1402 1152
1403 1153 jQuery( document.getElementById( 'frm_resend_email' ) ).on( 'click', resendEmail );
1404 1154
1405 1155 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 );
1156 + 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 );
1406 1157
1407 1158 jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange );
1408 - maybeMakeHoneypotFieldsUntabbable();
1409 1159
1410 1160 jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick );
1411 1161 jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv );
1412 1162
@@ -1414,16 +1164,13 @@
1414 1164
1415 1165 // Focus on the first sub field when clicking to the primary label of combo field.
1416 1166 changeFocusWhenClickComboFieldLabel();
1417 1167
1418 - // Add fallbacks for IE.
1419 - addTrimFallbackForIE(); // Trim only works in IE10+.
1420 - addFilterFallbackForIE(); // Filter is not supported in any version of IE.
1421 -
1422 - initFloatingLabels();
1423 -
1424 - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage );
1425 - setCustomValidityMessage();
1168 + // Add fallbacks for the beloved IE8
1169 + addIndexOfFallbackForIE8();
1170 + addTrimFallbackForIE8();
1171 + addFilterFallbackForIE8();
1172 + addKeysFallbackForIE8();
1426 1173 },
1427 1174
1428 1175 getFieldId: function( field, fullID ) {
1429 1176 return getFieldId( field, fullID );
@@ -1606,12 +1353,12 @@
1606 1353 removeSubmitLoading: function( $object, enable, processesRunning ) {
1607 1354 removeSubmitLoading( $object, enable, processesRunning );
1608 1355 },
1609 1356
1610 - scrollToID: function( id ) {
1611 - var object = jQuery( document.getElementById( id ) );
1612 - frmFrontForm.scrollMsg( object, false );
1613 - },
1357 + scrollToID: function( id ) {
1358 + var object = jQuery( document.getElementById( id ) );
1359 + frmFrontForm.scrollMsg( object, false );
1360 + },
1614 1361
1615 1362 scrollMsg: function( id, object, animate ) {
1616 1363 var newPos, m, b, screenTop, screenBottom,
1617 1364 scrollObj = '';
@@ -1627,12 +1374,12 @@
1627 1374 }
1628 1375
1629 1376 jQuery( scrollObj ).trigger( 'focus' );
1630 1377 newPos = scrollObj.offset().top;
1631 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1378 + if ( ! newPos || frm_js.offset === '-1' ) {
1632 1379 return;
1633 1380 }
1634 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1381 + newPos = newPos - frm_js.offset;
1635 1382
1636 1383 m = jQuery( 'html' ).css( 'margin-top' );
1637 1384 b = jQuery( 'body' ).css( 'margin-top' );
1638 1385 if ( m || b ) {
@@ -1760,15 +1507,15 @@
1760 1507 function frmUpdateField( entryId, fieldId, value, message, num ) {
1761 1508 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1762 1509 jQuery.ajax({
1763 1510 type: 'POST',
1764 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1511 + url: frm_js.ajax_url,
1765 1512 data: {
1766 1513 action: 'frm_entries_update_field_ajax',
1767 1514 entry_id: entryId,
1768 1515 field_id: fieldId,
1769 1516 value: value,
1770 - nonce: frm_js.nonce // eslint-disable-line camelcase
1517 + nonce: frm_js.nonce
1771 1518 },
1772 1519 success: function() {
1773 1520 if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1774 1521 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
@@ -1783,13 +1530,13 @@
1783 1530 console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1784 1531 jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1785 1532 jQuery.ajax({
1786 1533 type: 'POST',
1787 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1534 + url: frm_js.ajax_url,
1788 1535 data: {
1789 1536 action: 'frm_entries_destroy',
1790 1537 entry: entryId,
1791 - nonce: frm_js.nonce // eslint-disable-line camelcase
1538 + nonce: frm_js.nonce
1792 1539 },
1793 1540 success: function( html ) {
1794 1541 if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1795 1542 jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
@@ -1810,14 +1557,14 @@
1810 1557 console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1811 1558 $link.append( '<span class="spinner" style="display:inline"></span>' );
1812 1559 jQuery.ajax({
1813 1560 type: 'POST',
1814 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1561 + url: frm_js.ajax_url,
1815 1562 data: {
1816 1563 action: 'frm_entries_send_email',
1817 1564 entry_id: entryId,
1818 1565 form_id: formId,
1819 - nonce: frm_js.nonce // eslint-disable-line camelcase
1566 + nonce: frm_js.nonce
1820 1567 },
1821 1568 success: function( msg ) {
1822 1569 $link.replaceWith( msg );
1823 1570 }