PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.2.02.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.2.02.01
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | js/formidable.js +122 -438 6.45.2.02.01 View file →
@@ -10,70 +10,19 @@
10 10
11 11 var action = '';
12 12 var jsErrors = [];
13 13
14 - /**
15 - * Maybe add polyfills.
16 - *
17 - * @since 5.4
18 - */
19 - function maybeAddPolyfills() {
20 - var i;
21 - if ( ! Element.prototype.matches ) {
22 - // IE9 supports matches but as msMatchesSelector instead.
23 - Element.prototype.matches = Element.prototype.msMatchesSelector;
24 - }
14 + function maybeShowLabel() {
15 + /*jshint validthis:true */
16 + var $field = jQuery( this ),
17 + $label = $field.closest( '.frm_inside_container' ).find( '.frm_primary_label' ),
18 + val = $field.val();
25 19
26 - if ( ! Element.prototype.closest ) {
27 - Element.prototype.closest = function( s ) {
28 - var el = this;
29 -
30 - do {
31 - if ( el.matches( s ) ) {
32 - return el;
33 - }
34 - el = el.parentElement || el.parentNode;
35 - } while ( el !== null && el.nodeType === 1 );
36 -
37 - return null;
38 - };
39 - }
40 -
41 - // NodeList.forEach().
42 - if ( window.NodeList && ! NodeList.prototype.forEach ) {
43 - NodeList.prototype.forEach = function( callback, thisArg ) {
44 - thisArg = thisArg || window;
45 - for ( i = 0; i < this.length; i++ ) {
46 - callback.call( thisArg, this[ i ], i, this );
47 - }
48 - };
49 - }
50 - }
51 -
52 - /**
53 - * Triggers custom JS event.
54 - *
55 - * @since 5.5.3
56 - *
57 - * @param {HTMLElement} el The HTML element.
58 - * @param {String} eventName Event name.
59 - * @param {mixed} data The passed data.
60 - */
61 - function triggerCustomEvent( el, eventName, data ) {
62 - var event;
63 -
64 - if ( typeof window.CustomEvent === 'function' ) {
65 - event = new CustomEvent( eventName );
66 - } else if ( document.createEvent ) {
67 - event = document.createEvent( 'HTMLEvents' );
68 - event.initEvent( eventName, false, true );
20 + if ( val !== null && val.length > 0 ) {
21 + $label.addClass( 'frm_visible' );
69 22 } else {
70 - return;
23 + $label.removeClass( 'frm_visible' );
71 24 }
72 -
73 - event.frmData = data;
74 -
75 - el.dispatchEvent( event );
76 25 }
77 26
78 27 /* Get the ID of the field that changed*/
79 28 function getFieldId( field, fullID ) {
@@ -162,9 +111,9 @@
162 111 *
163 112 * @since 2.03.02
164 113 *
165 114 * @param {object} $form
166 - */
115 + */
167 116 function disableSubmitButton( $form ) {
168 117 $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).attr( 'disabled', 'disabled' );
169 118 }
170 119
@@ -173,9 +122,9 @@
173 122 *
174 123 * @since 2.03.02
175 124 *
176 125 * @param {object} $form
177 - */
126 + */
178 127 function enableSubmitButton( $form ) {
179 128 $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).prop( 'disabled', false );
180 129 }
181 130
@@ -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, newTab;
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,41 +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 -
621 - if ( ! response.openInNewTab ) {
622 - // We return here because we're redirecting there is no need to update content.
623 - window.location = response.redirect;
624 - return;
625 - }
626 -
627 - // We don't return here because we're opening in a new tab, the old tab will still update.
628 - newTab = window.open( response.redirect, '_blank' );
629 - if ( ! newTab && response.fallbackMsg && response.content ) {
630 - response.content = response.content.trim().replace( /(<\/div><\/div>)$/, ' ' + response.fallbackMsg + '</div></div>' );
631 - }
632 - }
633 -
634 - if ( response.content !== '' ) {
564 + window.location = response.redirect;
565 + } else if ( response.content !== '' ) {
635 566 // the form or success message was returned
636 567
637 - if ( shouldTriggerEvent ) {
638 - triggerCustomEvent( object, 'frmSubmitEvent' );
639 - return;
640 - }
641 -
642 568 removeSubmitLoading( jQuery( object ) );
643 - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase
569 + if ( frm_js.offset != -1 ) {
644 570 frmFrontForm.scrollMsg( jQuery( object ), false );
645 571 }
646 -
647 572 formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
648 573 response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
649 574 replaceContent = jQuery( object ).closest( '.frm_forms' );
650 575 removeAddedScripts( replaceContent, formID );
@@ -681,8 +606,9 @@
681 606 delay
682 607 );
683 608 } else if ( Object.keys( response.errors ).length ) {
684 609 // errors were returned
610 +
685 611 removeSubmitLoading( jQuery( object ), 'enable' );
686 612
687 613 //show errors
688 614 contSubmit = true;
@@ -712,9 +638,9 @@
712 638 }
713 639 }
714 640 }
715 641
716 - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() {
642 + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
717 643 var $recaptcha = jQuery( this ),
718 644 recaptchaID = $recaptcha.data( 'rid' );
719 645
720 646 if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
@@ -723,11 +649,8 @@
723 649 } else {
724 650 grecaptcha.reset();
725 651 }
726 652 }
727 - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) {
728 - hcaptcha.reset();
729 - }
730 653 });
731 654
732 655 jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
733 656
@@ -759,9 +682,9 @@
759 682
760 683 function postToAjaxUrl( form, data, success, error ) {
761 684 var ajaxUrl, action, ajaxParams;
762 685
763 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
686 + ajaxUrl = frm_js.ajax_url;
764 687 action = form.getAttribute( 'action' );
765 688
766 689 if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
767 690 ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
@@ -847,9 +770,9 @@
847 770 return kvp.join( '&' );
848 771 }
849 772
850 773 function addFieldError( $fieldCont, key, jsErrors ) {
851 - var input, id, describedBy, roleString;
774 + var input, id, describedBy;
852 775 if ( $fieldCont.length && $fieldCont.is( ':visible' ) ) {
853 776 $fieldCont.addClass( 'frm_blank_field' );
854 777 input = $fieldCont.find( 'input, select, textarea' );
855 778 id = 'frm_error_field_' + key;
@@ -862,25 +785,20 @@
862 785 $fieldCont.append(
863 786 jsErrors[key]
864 787 );
865 788 } else {
866 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
867 - $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
789 + $fieldCont.append( '<div class="frm_error" role="alert" id="' + id + '">' + jsErrors[key] + '</div>' );
868 790 }
869 791
870 792 if ( typeof describedBy === 'undefined' ) {
871 793 describedBy = id;
872 - } else if ( describedBy.indexOf( id ) === -1 && describedBy.indexOf( 'frm_error_field_' ) === -1 ) {
873 - if ( input.data( 'error-first' ) === 0 ) {
874 - describedBy = describedBy + ' ' + id;
875 - } else {
876 - describedBy = id + ' ' + describedBy;
877 - }
794 + } else if ( describedBy.indexOf( id ) === -1 ) {
795 + describedBy = describedBy + ' ' + id;
878 796 }
879 -
880 797 input.attr( 'aria-describedby', describedBy );
881 798 }
882 799 input.attr( 'aria-invalid', true );
800 + input.attr( 'aria-describedby', id );
883 801
884 802 jQuery( document ).trigger( 'frmAddFieldError', [ $fieldCont, key, jsErrors ]);
885 803 }
886 804 }
@@ -1010,14 +928,14 @@
1010 928 label.append( '<span class="frm-wait"></span>' );
1011 929
1012 930 jQuery.ajax({
1013 931 type: 'POST',
1014 - url: frm_js.ajax_url, // eslint-disable-line camelcase
932 + url: frm_js.ajax_url,
1015 933 data: {
1016 934 action: 'frm_entries_send_email',
1017 935 entry_id: entryId,
1018 936 form_id: formId,
1019 - nonce: frm_js.nonce // eslint-disable-line camelcase
937 + nonce: frm_js.nonce
1020 938 },
1021 939 success: function( msg ) {
1022 940 var admin = document.getElementById( 'wpbody' );
1023 941 if ( admin === null ) {
@@ -1055,9 +973,32 @@
1055 973 /**********************************************
1056 974 * Fallback functions
1057 975 *********************************************/
1058 976
1059 - 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() {
1060 1001 if ( typeof String.prototype.trim !== 'function' ) {
1061 1002 String.prototype.trim = function() {
1062 1003 return this.replace( /^\s+|\s+$/g, '' );
1063 1004 };
@@ -1063,9 +1004,9 @@
1063 1004 };
1064 1005 }
1065 1006 }
1066 1007
1067 - function addFilterFallbackForIE() {
1008 + function addFilterFallbackForIE8() {
1068 1009 var t, len, res, thisp, i, val;
1069 1010
1070 1011 if ( ! Array.prototype.filter ) {
1071 1012
@@ -1096,8 +1037,26 @@
1096 1037 };
1097 1038 }
1098 1039 }
1099 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 +
1100 1059 /**
1101 1060 * Check for -webkit-box-shadow css value for input:-webkit-autofill selector.
1102 1061 * If this is a match, the User is autofilling the input on a Webkit browser.
1103 1062 * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete.
@@ -1108,38 +1067,8 @@
1108 1067 this.parentNode.removeChild( this );
1109 1068 }
1110 1069 }
1111 1070
1112 - function maybeMakeHoneypotFieldsUntabbable() {
1113 - document.addEventListener( 'keydown', handleKeyUp );
1114 -
1115 - function handleKeyUp( event ) {
1116 - var code;
1117 -
1118 - if ( 'undefined' !== typeof event.key ) {
1119 - code = event.key;
1120 - } else if ( 'undefined' !== typeof event.keyCode && 9 === event.keyCode ) {
1121 - code = 'Tab';
1122 - }
1123 -
1124 - if ( 'Tab' === code ) {
1125 - makeHoneypotFieldsUntabbable();
1126 - document.removeEventListener( 'keydown', handleKeyUp );
1127 - }
1128 - }
1129 -
1130 - function makeHoneypotFieldsUntabbable() {
1131 - document.querySelectorAll( '.frm_verify' ).forEach(
1132 - function( wrapper ) {
1133 - var input = wrapper.querySelector( 'input[id^=frm_email]' );
1134 - if ( input ) {
1135 - input.setAttribute( 'tabindex', -1 );
1136 - }
1137 - }
1138 - );
1139 - }
1140 - }
1141 -
1142 1071 /**
1143 1072 * Focus on the first sub field when clicking to the primary label of combo field.
1144 1073 *
1145 1074 * @since 4.10.02
@@ -1144,11 +1073,11 @@
1144 1073 *
1145 1074 * @since 4.10.02
1146 1075 */
1147 1076 function changeFocusWhenClickComboFieldLabel() {
1148 - var label;
1077 + let label;
1149 1078
1150 - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1079 + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1151 1080 comboInputsContainer.forEach( function( inputsContainer ) {
1152 1081 if ( ! inputsContainer.closest( '.frm_form_field' ) ) {
1153 1082 return;
1154 1083 }
@@ -1166,12 +1095,8 @@
1166 1095
1167 1096 function checkForErrorsAndMaybeSetFocus() {
1168 1097 var errors, element, timeoutCallback;
1169 1098
1170 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1171 - return;
1172 - }
1173 -
1174 1099 errors = document.querySelectorAll( '.frm_form_field .frm_error' );
1175 1100 if ( ! errors.length ) {
1176 1101 return;
1177 1102 }
@@ -1205,246 +1130,10 @@
1205 1130 }
1206 1131 } while ( element.previousSibling );
1207 1132 }
1208 1133
1209 - /**
1210 - * Checks if is on IE browser.
1211 - *
1212 - * @since 5.4
1213 - *
1214 - * @return {Boolean}
1215 - */
1216 - function isIE() {
1217 - return navigator.userAgent.indexOf( 'MSIE' ) > -1 || navigator.userAgent.indexOf( 'Trident' ) > -1;
1218 - }
1219 -
1220 - /**
1221 - * Does the same as jQuery( document ).on( 'event', 'selector', handler ).
1222 - *
1223 - * @since 5.4
1224 - *
1225 - * @param {String} event Event name.
1226 - * @param {String} selector Selector.
1227 - * @param {Function} handler Handler.
1228 - * @param {Boolean|Object} options Options to be added to `addEventListener()` method. Default is `false`.
1229 - */
1230 - function documentOn( event, selector, handler, options ) {
1231 - if ( 'undefined' === typeof options ) {
1232 - options = false;
1233 - }
1234 -
1235 - document.addEventListener( event, function( e ) {
1236 - var target;
1237 -
1238 - // loop parent nodes from the target to the delegation node.
1239 - for ( target = e.target; target && target != this; target = target.parentNode ) {
1240 - if ( target && target.matches && target.matches( selector ) ) {
1241 - handler.call( target, e );
1242 - break;
1243 - }
1244 - }
1245 - }, options );
1246 - }
1247 -
1248 - function initFloatingLabels() {
1249 - var checkFloatLabel, checkDropdownLabel, checkPlaceholderIE, runOnLoad, selector, floatClass;
1250 -
1251 - selector = '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea';
1252 - floatClass = 'frm_label_float_top';
1253 -
1254 - checkFloatLabel = function( input ) {
1255 - var container, shouldFloatTop, firstOpt;
1256 -
1257 - container = input.closest( '.frm_inside_container' );
1258 - if ( ! container ) {
1259 - return;
1260 - }
1261 -
1262 - shouldFloatTop = input.value || document.activeElement === input;
1263 -
1264 - container.classList.toggle( floatClass, shouldFloatTop );
1265 -
1266 - if ( 'SELECT' === input.tagName ) {
1267 - firstOpt = input.querySelector( 'option:first-child' );
1268 -
1269 - if ( shouldFloatTop ) {
1270 - if ( firstOpt.hasAttribute( 'data-label' ) ) {
1271 - firstOpt.textContent = firstOpt.getAttribute( 'data-label' );
1272 - firstOpt.removeAttribute( 'data-label' );
1273 - }
1274 - } else {
1275 - if ( firstOpt.textContent ) {
1276 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1277 - firstOpt.textContent = '';
1278 - }
1279 - }
1280 - } else if ( isIE() ) {
1281 - checkPlaceholderIE( input );
1282 - }
1283 - };
1284 -
1285 - checkDropdownLabel = function() {
1286 - document.querySelectorAll( '.frm-show-form .frm_inside_container:not(.' + floatClass + ') select' ).forEach( function( input ) {
1287 - var firstOpt = input.querySelector( 'option:first-child' );
1288 -
1289 - if ( firstOpt.textContent ) {
1290 - firstOpt.setAttribute( 'data-label', firstOpt.textContent );
1291 - firstOpt.textContent = '';
1292 - }
1293 - });
1294 - };
1295 -
1296 - checkPlaceholderIE = function( input ) {
1297 - if ( input.value ) {
1298 - // Don't need to handle this case because placeholder isn't shown.
1299 - return;
1300 - }
1301 -
1302 - if ( document.activeElement === input ) {
1303 - if ( input.hasAttribute( 'data-placeholder' ) ) {
1304 - input.placeholder = input.getAttribute( 'data-placeholder' );
1305 - input.removeAttribute( 'data-placeholder' );
1306 - }
1307 - } else {
1308 - if ( input.placeholder ) {
1309 - input.setAttribute( 'data-placeholder', input.placeholder );
1310 - input.placeholder = '';
1311 - }
1312 - }
1313 - };
1314 -
1315 - [ 'focus', 'blur', 'change' ].forEach( function( eventName ) {
1316 - documentOn(
1317 - eventName,
1318 - selector,
1319 - function( event ) {
1320 - checkFloatLabel( event.target );
1321 - },
1322 - true
1323 - );
1324 - });
1325 -
1326 - jQuery( document ).on( 'change', selector, function( event ) {
1327 - checkFloatLabel( event.target );
1328 - });
1329 -
1330 - runOnLoad = function( firstLoad ) {
1331 - if ( firstLoad && document.activeElement && -1 !== [ 'INPUT', 'SELECT', 'TEXTAREA' ].indexOf( document.activeElement.tagName ) ) {
1332 - checkFloatLabel( document.activeElement );
1333 - } else if ( firstLoad ) {
1334 - document.querySelectorAll( '.frm_inside_container' ).forEach(
1335 - function( container ) {
1336 - var input = container.querySelector( 'input, select, textarea' );
1337 - if ( input && '' !== input.value ) {
1338 - checkFloatLabel( input );
1339 - }
1340 - }
1341 - );
1342 - }
1343 -
1344 - checkDropdownLabel();
1345 -
1346 - if ( isIE() ) {
1347 - document.querySelectorAll( selector ).forEach( function( input ) {
1348 - checkPlaceholderIE( input );
1349 - });
1350 - }
1351 - };
1352 -
1353 - runOnLoad( true );
1354 -
1355 - jQuery( document ).on( 'frmPageChanged', function( event ) {
1356 - runOnLoad();
1357 - });
1358 -
1359 - document.addEventListener( 'frm_after_start_over', function( event ) {
1360 - runOnLoad();
1361 - });
1362 - }
1363 -
1364 - function shouldUpdateValidityMessage( target ) {
1365 - if ( 'INPUT' !== target.nodeName ) {
1366 - return false;
1367 - }
1368 -
1369 - if ( ! target.dataset.invmsg ) {
1370 - return false;
1371 - }
1372 -
1373 - if ( 'text' !== target.getAttribute( 'type' ) ) {
1374 - return false;
1375 - }
1376 -
1377 - if ( target.classList.contains( 'frm_verify' ) ) {
1378 - return false;
1379 - }
1380 -
1381 - return true;
1382 - }
1383 -
1384 - function maybeClearCustomValidityMessage( event, field ) {
1385 - var key,
1386 - isInvalid = false;
1387 -
1388 - if ( ! shouldUpdateValidityMessage( field ) ) {
1389 - return;
1390 - }
1391 -
1392 - for ( key in field.validity ) {
1393 - if ( 'customError' === key ) {
1394 - continue;
1395 - }
1396 - if ( 'valid' !== key && field.validity[ key ] === true ) {
1397 - isInvalid = true;
1398 - break;
1399 - }
1400 - };
1401 -
1402 - if ( ! isInvalid ) {
1403 - field.setCustomValidity( '' );
1404 - }
1405 - }
1406 -
1407 - function maybeShowNewTabFallbackMessage() {
1408 - var messageEl;
1409 -
1410 - if ( ! window.frmShowNewTabFallback ) {
1411 - return;
1412 - }
1413 -
1414 - messageEl = document.querySelector( '#frm_form_' + frmShowNewTabFallback.formId + '_container .frm_message' );
1415 - if ( ! messageEl ) {
1416 - return;
1417 - }
1418 -
1419 - messageEl.insertAdjacentHTML( 'beforeend', ' ' + frmShowNewTabFallback.message );
1420 - }
1421 -
1422 - function setCustomValidityMessage() {
1423 - var forms, length, index;
1424 -
1425 - forms = document.getElementsByClassName( 'frm-show-form' );
1426 - length = forms.length;
1427 -
1428 - for ( index = 0; index < length; ++index ) {
1429 - forms[ index ].addEventListener(
1430 - 'invalid',
1431 - function( event ) {
1432 - var target = event.target;
1433 -
1434 - if ( shouldUpdateValidityMessage( target ) ) {
1435 - target.setCustomValidity( target.dataset.invmsg );
1436 - }
1437 - },
1438 - true
1439 - );
1440 - }
1441 - }
1442 -
1443 1134 return {
1444 1135 init: function() {
1445 - maybeAddPolyfills();
1446 -
1447 1136 jQuery( document ).off( 'submit.formidable', '.frm-show-form' );
1448 1137 jQuery( document ).on( 'submit.formidable', '.frm-show-form', frmFrontForm.submitForm );
1449 1138
1450 1139 jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() {
@@ -1459,11 +1148,11 @@
1459 1148
1460 1149 jQuery( document.getElementById( 'frm_resend_email' ) ).on( 'click', resendEmail );
1461 1150
1462 1151 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 );
1152 + 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 );
1463 1153
1464 1154 jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange );
1465 - maybeMakeHoneypotFieldsUntabbable();
1466 1155
1467 1156 jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick );
1468 1157 jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv );
1469 1158
@@ -1471,18 +1160,13 @@
1471 1160
1472 1161 // Focus on the first sub field when clicking to the primary label of combo field.
1473 1162 changeFocusWhenClickComboFieldLabel();
1474 1163
1475 - // Add fallbacks for IE.
1476 - addTrimFallbackForIE(); // Trim only works in IE10+.
1477 - addFilterFallbackForIE(); // Filter is not supported in any version of IE.
1478 -
1479 - initFloatingLabels();
1480 - maybeShowNewTabFallbackMessage();
1481 -
1482 - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage );
1483 - setCustomValidityMessage();
1484 - jQuery( document ).on( 'frmFieldChanged', maybeClearCustomValidityMessage );
1164 + // Add fallbacks for the beloved IE8
1165 + addIndexOfFallbackForIE8();
1166 + addTrimFallbackForIE8();
1167 + addFilterFallbackForIE8();
1168 + addKeysFallbackForIE8();
1485 1169 },
1486 1170
1487 1171 getFieldId: function( field, fullID ) {
1488 1172 return getFieldId( field, fullID );
@@ -1665,12 +1349,12 @@
1665 1349 removeSubmitLoading: function( $object, enable, processesRunning ) {
1666 1350 removeSubmitLoading( $object, enable, processesRunning );
1667 1351 },
1668 1352
1669 - scrollToID: function( id ) {
1670 - var object = jQuery( document.getElementById( id ) );
1671 - frmFrontForm.scrollMsg( object, false );
1672 - },
1353 + scrollToID: function( id ) {
1354 + var object = jQuery( document.getElementById( id ) );
1355 + frmFrontForm.scrollMsg( object, false );
1356 + },
1673 1357
1674 1358 scrollMsg: function( id, object, animate ) {
1675 1359 var newPos, m, b, screenTop, screenBottom,
1676 1360 scrollObj = '';
@@ -1686,12 +1370,12 @@
1686 1370 }
1687 1371
1688 1372 jQuery( scrollObj ).trigger( 'focus' );
1689 1373 newPos = scrollObj.offset().top;
1690 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1374 + if ( ! newPos || frm_js.offset === '-1' ) {
1691 1375 return;
1692 1376 }
1693 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1377 + newPos = newPos - frm_js.offset;
1694 1378
1695 1379 m = jQuery( 'html' ).css( 'margin-top' );
1696 1380 b = jQuery( 'body' ).css( 'margin-top' );
1697 1381 if ( m || b ) {
@@ -1819,15 +1503,15 @@
1819 1503 function frmUpdateField( entryId, fieldId, value, message, num ) {
1820 1504 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1821 1505 jQuery.ajax({
1822 1506 type: 'POST',
1823 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1507 + url: frm_js.ajax_url,
1824 1508 data: {
1825 1509 action: 'frm_entries_update_field_ajax',
1826 1510 entry_id: entryId,
1827 1511 field_id: fieldId,
1828 1512 value: value,
1829 - nonce: frm_js.nonce // eslint-disable-line camelcase
1513 + nonce: frm_js.nonce
1830 1514 },
1831 1515 success: function() {
1832 1516 if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1833 1517 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
@@ -1842,13 +1526,13 @@
1842 1526 console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1843 1527 jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1844 1528 jQuery.ajax({
1845 1529 type: 'POST',
1846 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1530 + url: frm_js.ajax_url,
1847 1531 data: {
1848 1532 action: 'frm_entries_destroy',
1849 1533 entry: entryId,
1850 - nonce: frm_js.nonce // eslint-disable-line camelcase
1534 + nonce: frm_js.nonce
1851 1535 },
1852 1536 success: function( html ) {
1853 1537 if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1854 1538 jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
@@ -1869,14 +1553,14 @@
1869 1553 console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1870 1554 $link.append( '<span class="spinner" style="display:inline"></span>' );
1871 1555 jQuery.ajax({
1872 1556 type: 'POST',
1873 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1557 + url: frm_js.ajax_url,
1874 1558 data: {
1875 1559 action: 'frm_entries_send_email',
1876 1560 entry_id: entryId,
1877 1561 form_id: formId,
1878 - nonce: frm_js.nonce // eslint-disable-line camelcase
1562 + nonce: frm_js.nonce
1879 1563 },
1880 1564 success: function( msg ) {
1881 1565 $link.replaceWith( msg );
1882 1566 }