| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | * @since 5.5.3 |
| 16 | 16 | * |
| 17 | 17 | * @param {HTMLElement} el The HTML element. |
| 18 | 18 | * @param {string} eventName Event name. |
| 19 | - * @param {*} data The passed data. | |
| 19 | + * @param {mixed} data The passed data. | |
| 20 | 20 | */ |
| 21 | 21 | function triggerCustomEvent( el, eventName, data ) { |
| 22 | 22 | if ( typeof window.CustomEvent !== 'function' ) { |
| 23 | 23 | return; |
| @@ -73,24 +73,25 @@ | ||
| 73 | 73 | return 0; |
| 74 | 74 | } |
| 75 | 75 | nameParts = nameParts.filter( function( n ) { |
| 76 | 76 | return n !== ''; |
| 77 | - } ); | |
| 77 | + }); | |
| 78 | 78 | |
| 79 | - fieldId = nameParts[ 0 ]; | |
| 79 | + fieldId = nameParts[0]; | |
| 80 | 80 | |
| 81 | 81 | if ( nameParts.length === 1 ) { |
| 82 | 82 | return fieldId; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ( nameParts[ 1 ] === '[form' || nameParts[ 1 ] === '[row_ids' ) { | |
| 85 | + if ( nameParts[1] === '[form' || nameParts[1] === '[row_ids' ) { | |
| 86 | 86 | return 0; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Check if 'this' is in a repeating section |
| 90 | 90 | if ( document.querySelector( 'input[name="item_meta[' + fieldId + '][form]"]' ) ) { |
| 91 | + | |
| 91 | 92 | // this is a repeatable section with name: item_meta[repeating-section-id][row-id][field-id] |
| 92 | - fieldId = nameParts[ 2 ].replace( '[', '' ); | |
| 93 | + fieldId = nameParts[2].replace( '[', '' ); | |
| 93 | 94 | isRepeating = true; |
| 94 | 95 | } |
| 95 | 96 | |
| 96 | 97 | // Check if 'this' is an other text field and get field ID for it |
| @@ -96,21 +97,21 @@ | ||
| 96 | 97 | // Check if 'this' is an other text field and get field ID for it |
| 97 | 98 | if ( 'other' === fieldId ) { |
| 98 | 99 | if ( isRepeating ) { |
| 99 | 100 | // name for other fields: item_meta[370][0][other][414] |
| 100 | - fieldId = nameParts[ 3 ].replace( '[', '' ); | |
| 101 | + fieldId = nameParts[3].replace( '[', '' ); | |
| 101 | 102 | } else { |
| 102 | 103 | // Other field name: item_meta[other][370] |
| 103 | - fieldId = nameParts[ 1 ].replace( '[', '' ); | |
| 104 | + fieldId = nameParts[1].replace( '[', '' ); | |
| 104 | 105 | } |
| 105 | 106 | } |
| 106 | 107 | |
| 107 | 108 | if ( fullID === true ) { |
| 108 | 109 | // For use in the container div id |
| 109 | - if ( fieldId === nameParts[ 0 ] ) { | |
| 110 | - fieldId = fieldId + '-' + nameParts[ 1 ].replace( '[', '' ); | |
| 110 | + if ( fieldId === nameParts[0]) { | |
| 111 | + fieldId = fieldId + '-' + nameParts[1].replace( '[', '' ); | |
| 111 | 112 | } else { |
| 112 | - fieldId = fieldId + '-' + nameParts[ 0 ] + '-' + nameParts[ 1 ].replace( '[', '' ); | |
| 113 | + fieldId = fieldId + '-' + nameParts[0] + '-' + nameParts[1].replace( '[', '' ); | |
| 113 | 114 | } |
| 114 | 115 | } |
| 115 | 116 | |
| 116 | 117 | return fieldId; |
| @@ -159,12 +160,12 @@ | ||
| 159 | 160 | function enableSaveDraft( $form ) { |
| 160 | 161 | if ( ! $form.length ) { |
| 161 | 162 | return; |
| 162 | 163 | } |
| 163 | - $form[ 0 ].querySelectorAll( '.frm_save_draft' ).forEach( saveDraftButton => { | |
| 164 | - saveDraftButton.disabled = false; | |
| 164 | + $form[0].querySelectorAll( '.frm_save_draft' ).forEach( saveDraftButton => { | |
| 165 | + saveDraftButton.disabled = false; | |
| 165 | 166 | saveDraftButton.style.pointerEvents = ''; |
| 166 | - } ); | |
| 167 | + }); | |
| 167 | 168 | } |
| 168 | 169 | |
| 169 | 170 | /** |
| 170 | 171 | * Validate form with JS. |
| @@ -242,9 +243,9 @@ | ||
| 242 | 243 | return; |
| 243 | 244 | } |
| 244 | 245 | |
| 245 | 246 | fieldID = getFieldId( field, true ); |
| 246 | - if ( 'undefined' === typeof errors[ fieldID ] ) { | |
| 247 | + if ( 'undefined' === typeof errors[ fieldID ]) { | |
| 247 | 248 | errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' ); |
| 248 | 249 | } |
| 249 | 250 | |
| 250 | 251 | if ( 'function' === typeof field.reportValidity ) { |
| @@ -268,9 +269,9 @@ | ||
| 268 | 269 | * @param {HTMLElement} field |
| 269 | 270 | */ |
| 270 | 271 | function maybeValidateChange( field ) { |
| 271 | 272 | if ( field.type === 'url' ) { |
| 272 | - maybeAddHttpsToUrl( field ); | |
| 273 | + maybeAddHttpToUrl( field ); | |
| 273 | 274 | } |
| 274 | 275 | const form = field.closest( 'form' ); |
| 275 | 276 | if ( form && hasClass( form, 'frm_js_validate' ) ) { |
| 276 | 277 | validateField( field ); |
| @@ -279,13 +280,13 @@ | ||
| 279 | 280 | |
| 280 | 281 | /** |
| 281 | 282 | * @param {HTMLElement} field |
| 282 | 283 | */ |
| 283 | - function maybeAddHttpsToUrl( field ) { | |
| 284 | + function maybeAddHttpToUrl( field ) { | |
| 284 | 285 | const url = field.value; |
| 285 | 286 | const matches = url.match( /^(https?|ftps?|mailto|news|feed|telnet):/ ); |
| 286 | 287 | if ( field.value !== '' && matches === null ) { |
| 287 | - field.value = 'https://' + url; | |
| 288 | + field.value = 'http://' + url; | |
| 288 | 289 | } |
| 289 | 290 | } |
| 290 | 291 | |
| 291 | 292 | /** |
| @@ -297,9 +298,9 @@ | ||
| 297 | 298 | */ |
| 298 | 299 | function validateField( field ) { |
| 299 | 300 | let errors, key; |
| 300 | 301 | |
| 301 | - errors = []; | |
| 302 | + errors = []; | |
| 302 | 303 | const fieldContainer = field.closest( '.frm_form_field' ); |
| 303 | 304 | |
| 304 | 305 | if ( ! fieldContainer ) { |
| 305 | 306 | // Hidden fields do not have a field container and do not require JS validation. |
| @@ -353,9 +354,9 @@ | ||
| 353 | 354 | triggerCustomEvent( document, 'frm_validate_field_value', { |
| 354 | 355 | field: field, |
| 355 | 356 | errors: errors, |
| 356 | 357 | onSubmit: onSubmit |
| 357 | - } ); | |
| 358 | + }); | |
| 358 | 359 | } |
| 359 | 360 | |
| 360 | 361 | /** |
| 361 | 362 | * @param {HTMLElement} field |
| @@ -406,10 +407,10 @@ | ||
| 406 | 407 | } else if ( typeof val !== 'string' ) { |
| 407 | 408 | tempVal = val; |
| 408 | 409 | val = ''; |
| 409 | 410 | for ( i = 0; i < tempVal.length; i++ ) { |
| 410 | - if ( tempVal[ i ] !== '' ) { | |
| 411 | - val = tempVal[ i ]; | |
| 411 | + if ( tempVal[i] !== '' ) { | |
| 412 | + val = tempVal[i]; | |
| 412 | 413 | } |
| 413 | 414 | } |
| 414 | 415 | } |
| 415 | 416 | |
| @@ -493,9 +494,9 @@ | ||
| 493 | 494 | fileFields.each( function() { |
| 494 | 495 | if ( val === '' ) { |
| 495 | 496 | val = this.value; |
| 496 | 497 | } |
| 497 | - } ); | |
| 498 | + }); | |
| 498 | 499 | return val; |
| 499 | 500 | } |
| 500 | 501 | |
| 501 | 502 | /** |
| @@ -665,9 +666,9 @@ | ||
| 665 | 666 | } |
| 666 | 667 | |
| 667 | 668 | // Function to change the color of a select element |
| 668 | 669 | changeSelectColor = function( select ) { |
| 669 | - if ( select.options[ select.selectedIndex ] && hasClass( select.options[ select.selectedIndex ], 'frm-select-placeholder' ) ) { | |
| 670 | + if ( select.options[select.selectedIndex] && hasClass( select.options[select.selectedIndex], 'frm-select-placeholder' ) ) { | |
| 670 | 671 | select.style.setProperty( 'color', textColorDisabled, 'important' ); |
| 671 | 672 | } else { |
| 672 | 673 | select.style.color = ''; |
| 673 | 674 | } |
| @@ -680,10 +681,10 @@ | ||
| 680 | 681 | |
| 681 | 682 | // Add an event listener for future changes |
| 682 | 683 | select.addEventListener( 'change', function() { |
| 683 | 684 | changeSelectColor( select ); |
| 684 | - } ); | |
| 685 | - } ); | |
| 685 | + }); | |
| 686 | + }); | |
| 686 | 687 | } |
| 687 | 688 | |
| 688 | 689 | /** |
| 689 | 690 | * @param {HTMLElement|jQuery} object |
| @@ -736,9 +737,9 @@ | ||
| 736 | 737 | } |
| 737 | 738 | |
| 738 | 739 | if ( response.length === 0 ) { |
| 739 | 740 | const fieldContainer = $recaptcha.closest( '.frm_form_field' ); |
| 740 | - const fieldID = fieldContainer.attr( 'id' ).replace( 'frm_field_', '' ).replace( '_container', '' ); | |
| 741 | + const fieldID = fieldContainer.attr( 'id' ).replace( 'frm_field_', '' ).replace( '_container', '' ); | |
| 741 | 742 | errors[ fieldID ] = ''; |
| 742 | 743 | } |
| 743 | 744 | |
| 744 | 745 | return errors; |
| @@ -772,15 +773,15 @@ | ||
| 772 | 773 | if ( null === errorHtml ) { |
| 773 | 774 | return msg; |
| 774 | 775 | } |
| 775 | 776 | |
| 776 | - errorHtml = errorHtml.replace( /\+/g, '%20' ); | |
| 777 | - msg = decodeURIComponent( errorHtml ).replace( '[error]', msg ); | |
| 778 | - const fieldId = getFieldId( field, false ); | |
| 779 | - const split = fieldId.split( '-' ); | |
| 777 | + errorHtml = errorHtml.replace( /\+/g, '%20' ); | |
| 778 | + msg = decodeURIComponent( errorHtml ).replace( '[error]', msg ); | |
| 779 | + const fieldId = getFieldId( field, false ); | |
| 780 | + const split = fieldId.split( '-' ); | |
| 780 | 781 | const fieldIdParts = field.id.split( '_' ); |
| 781 | 782 | fieldIdParts.shift(); // Drop the "field" value from the front. |
| 782 | - split[ 0 ] = fieldIdParts.join( '_' ); | |
| 783 | + split[0] = fieldIdParts.join( '_' ); | |
| 783 | 784 | const errorKey = split.join( '-' ); |
| 784 | 785 | return msg.replace( '[key]', errorKey ); |
| 785 | 786 | } |
| 786 | 787 | |
| @@ -817,13 +818,13 @@ | ||
| 817 | 818 | |
| 818 | 819 | fieldset = jQuery( object ).find( '.frm_form_field' ); |
| 819 | 820 | fieldset.addClass( 'frm_doing_ajax' ); |
| 820 | 821 | |
| 821 | - data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; // eslint-disable-line camelcase | |
| 822 | + data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; // eslint-disable-line camelcase | |
| 822 | 823 | shouldTriggerEvent = object.classList.contains( 'frm_trigger_event_on_submit' ); |
| 823 | 824 | |
| 824 | 825 | const doRedirect = response => { |
| 825 | - jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ] ); | |
| 826 | + jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]); | |
| 826 | 827 | |
| 827 | 828 | if ( ! response.openInNewTab ) { |
| 828 | 829 | // We return here because we're redirecting there is no need to update content. |
| 829 | 830 | window.location = response.redirect; |
| @@ -877,9 +878,9 @@ | ||
| 877 | 878 | if ( 'string' === typeof response.content && response.content !== '' ) { |
| 878 | 879 | // the form or success message was returned |
| 879 | 880 | |
| 880 | 881 | if ( shouldTriggerEvent ) { |
| 881 | - triggerCustomEvent( object, 'frmSubmitEvent', { content: response.content } ); | |
| 882 | + triggerCustomEvent( object, 'frmSubmitEvent', { content: response.content }); | |
| 882 | 883 | return; |
| 883 | 884 | } |
| 884 | 885 | |
| 885 | 886 | removeSubmitLoading( jQuery( object ) ); |
| @@ -958,9 +959,9 @@ | ||
| 958 | 959 | } |
| 959 | 960 | } |
| 960 | 961 | |
| 961 | 962 | jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() { |
| 962 | - const $recaptcha = jQuery( this ), | |
| 963 | + const $recaptcha = jQuery( this ), | |
| 963 | 964 | recaptchaID = $recaptcha.data( 'rid' ); |
| 964 | 965 | |
| 965 | 966 | if ( typeof grecaptcha !== 'undefined' && grecaptcha ) { |
| 966 | 967 | if ( recaptchaID ) { |
| @@ -971,9 +972,9 @@ | ||
| 971 | 972 | } |
| 972 | 973 | if ( typeof hcaptcha !== 'undefined' && hcaptcha ) { |
| 973 | 974 | hcaptcha.reset(); |
| 974 | 975 | } |
| 975 | - } ); | |
| 976 | + }); | |
| 976 | 977 | |
| 977 | 978 | if ( window.turnstile ) { |
| 978 | 979 | object.querySelectorAll( '.cf-turnstile' ).forEach( |
| 979 | 980 | turnstileField => turnstileField.dataset.rid && turnstile.reset( turnstileField.dataset.rid ) |
| @@ -979,9 +980,9 @@ | ||
| 979 | 980 | turnstileField => turnstileField.dataset.rid && turnstile.reset( turnstileField.dataset.rid ) |
| 980 | 981 | ); |
| 981 | 982 | } |
| 982 | 983 | |
| 983 | - jQuery( document ).trigger( 'frmFormErrors', [ object, response ] ); | |
| 984 | + jQuery( document ).trigger( 'frmFormErrors', [ object, response ]); | |
| 984 | 985 | |
| 985 | 986 | fieldset.removeClass( 'frm_doing_ajax' ); |
| 986 | 987 | scrollToFirstField( object ); |
| 987 | 988 | |
| @@ -1014,9 +1015,9 @@ | ||
| 1014 | 1015 | ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase |
| 1015 | 1016 | action = form.getAttribute( 'action' ); |
| 1016 | 1017 | |
| 1017 | 1018 | if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) { |
| 1018 | - ajaxUrl = action.split( '?action=frm_forms_preview' )[ 0 ]; | |
| 1019 | + ajaxUrl = action.split( '?action=frm_forms_preview' )[0]; | |
| 1019 | 1020 | } |
| 1020 | 1021 | |
| 1021 | 1022 | ajaxParams = { |
| 1022 | 1023 | type: 'POST', |
| @@ -1034,11 +1035,11 @@ | ||
| 1034 | 1035 | |
| 1035 | 1036 | function afterFormSubmitted( object, response ) { |
| 1036 | 1037 | const formCompleted = jQuery( response.content ).find( '.frm_message' ); |
| 1037 | 1038 | if ( formCompleted.length ) { |
| 1038 | - jQuery( document ).trigger( 'frmFormComplete', [ object, response ] ); | |
| 1039 | + jQuery( document ).trigger( 'frmFormComplete', [ object, response ]); | |
| 1039 | 1040 | } else { |
| 1040 | - jQuery( document ).trigger( 'frmPageChanged', [ object, response ] ); | |
| 1041 | + jQuery( document ).trigger( 'frmPageChanged', [ object, response ]); | |
| 1041 | 1042 | } |
| 1042 | 1043 | } |
| 1043 | 1044 | |
| 1044 | 1045 | /** |
| @@ -1052,9 +1053,9 @@ | ||
| 1052 | 1053 | */ |
| 1053 | 1054 | function afterFormSubmittedBeforeReplace( object, response ) { |
| 1054 | 1055 | const formCompleted = jQuery( response.content ).find( '.frm_message' ); |
| 1055 | 1056 | if ( formCompleted.length ) { |
| 1056 | - triggerCustomEvent( document, 'frmFormCompleteBeforeReplace', { object, response } ); | |
| 1057 | + triggerCustomEvent( document, 'frmFormCompleteBeforeReplace', { object, response }); | |
| 1057 | 1058 | } |
| 1058 | 1059 | } |
| 1059 | 1060 | |
| 1060 | 1061 | function removeAddedScripts( formContainer, formID ) { |
| @@ -1083,9 +1084,9 @@ | ||
| 1083 | 1084 | function addUrlParam( response ) { |
| 1084 | 1085 | let url; |
| 1085 | 1086 | if ( history.pushState && typeof response.page !== 'undefined' ) { |
| 1086 | 1087 | url = addQueryVar( 'frm_page', response.page ); |
| 1087 | - window.history.pushState( { html: response.html }, '', '?' + url ); | |
| 1088 | + window.history.pushState({ 'html': response.html }, '', '?' + url ); | |
| 1088 | 1089 | } |
| 1089 | 1090 | } |
| 1090 | 1091 | |
| 1091 | 1092 | function addQueryVar( key, value ) { |
| @@ -1097,13 +1098,13 @@ | ||
| 1097 | 1098 | kvp = document.location.search.substr( 1 ).split( '&' ); |
| 1098 | 1099 | |
| 1099 | 1100 | i = kvp.length; |
| 1100 | 1101 | while ( i-- ) { |
| 1101 | - x = kvp[ i ].split( '=' ); | |
| 1102 | + x = kvp[i].split( '=' ); | |
| 1102 | 1103 | |
| 1103 | - if ( x[ 0 ] == key ) { | |
| 1104 | - x[ 1 ] = value; | |
| 1105 | - kvp[ i ] = x.join( '=' ); | |
| 1104 | + if ( x[0] == key ) { | |
| 1105 | + x[1] = value; | |
| 1106 | + kvp[i] = x.join( '=' ); | |
| 1106 | 1107 | break; |
| 1107 | 1108 | } |
| 1108 | 1109 | } |
| 1109 | 1110 | |
| @@ -1125,15 +1126,15 @@ | ||
| 1125 | 1126 | |
| 1126 | 1127 | if ( typeof frmThemeOverride_frmPlaceError === 'function' ) { // eslint-disable-line camelcase |
| 1127 | 1128 | frmThemeOverride_frmPlaceError( key, jsErrors ); |
| 1128 | 1129 | } else { |
| 1129 | - if ( -1 !== jsErrors[ key ].indexOf( '<div' ) ) { | |
| 1130 | + if ( -1 !== jsErrors[key].indexOf( '<div' ) ) { | |
| 1130 | 1131 | $fieldCont.append( |
| 1131 | - jsErrors[ key ] | |
| 1132 | + jsErrors[key] | |
| 1132 | 1133 | ); |
| 1133 | 1134 | } else { |
| 1134 | 1135 | roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase |
| 1135 | - $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[ key ] + '</div>' ); | |
| 1136 | + $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' ); | |
| 1136 | 1137 | } |
| 1137 | 1138 | |
| 1138 | 1139 | if ( typeof describedBy === 'undefined' ) { |
| 1139 | 1140 | describedBy = id; |
| @@ -1146,16 +1147,11 @@ | ||
| 1146 | 1147 | } |
| 1147 | 1148 | |
| 1148 | 1149 | input.attr( 'aria-describedby', describedBy ); |
| 1149 | 1150 | } |
| 1151 | + input.attr( 'aria-invalid', true ); | |
| 1150 | 1152 | |
| 1151 | - if ( [ 'radio', 'checkbox' ].includes( input.attr( 'type' ) ) ) { | |
| 1152 | - input.closest( '[role="radiogroup"], [role="group"]' ).attr( 'aria-invalid', true ); | |
| 1153 | - } else { | |
| 1154 | - input.attr( 'aria-invalid', true ); | |
| 1155 | - } | |
| 1156 | - | |
| 1157 | - jQuery( document ).trigger( 'frmAddFieldError', [ $fieldCont, key, jsErrors ] ); | |
| 1153 | + jQuery( document ).trigger( 'frmAddFieldError', [ $fieldCont, key, jsErrors ]); | |
| 1158 | 1154 | } |
| 1159 | 1155 | } |
| 1160 | 1156 | |
| 1161 | 1157 | /** |
| @@ -1181,11 +1177,11 @@ | ||
| 1181 | 1177 | * @return {void} |
| 1182 | 1178 | */ |
| 1183 | 1179 | function removeFieldError( $fieldCont ) { |
| 1184 | 1180 | const errorMessage = $fieldCont.find( '.frm_error' ); |
| 1185 | - const errorId = errorMessage.attr( 'id' ); | |
| 1186 | - const input = $fieldCont.find( 'input, select, textarea' ); | |
| 1187 | - let describedBy = input.attr( 'aria-describedby' ); | |
| 1181 | + const errorId = errorMessage.attr( 'id' ); | |
| 1182 | + const input = $fieldCont.find( 'input, select, textarea' ); | |
| 1183 | + let describedBy = input.attr( 'aria-describedby' ); | |
| 1188 | 1184 | |
| 1189 | 1185 | const fieldContainer = $fieldCont.get( 0 ); |
| 1190 | 1186 | if ( fieldContainer && fieldContainer.classList ) { |
| 1191 | 1187 | fieldContainer.classList.remove( 'frm_blank_field', 'has-error' ); |
| @@ -1190,15 +1186,10 @@ | ||
| 1190 | 1186 | if ( fieldContainer && fieldContainer.classList ) { |
| 1191 | 1187 | fieldContainer.classList.remove( 'frm_blank_field', 'has-error' ); |
| 1192 | 1188 | } |
| 1193 | 1189 | |
| 1194 | - if ( 'true' === input.attr( 'aria-invalid' ) ) { | |
| 1195 | - input.attr( 'aria-invalid', false ); | |
| 1196 | - } else if ( [ 'radio', 'checkbox' ].includes( input.attr( 'type' ) ) ) { | |
| 1197 | - input.closest( '[role="radiogroup"], [role="group"]' ).attr( 'aria-invalid', false ); | |
| 1198 | - } | |
| 1199 | - | |
| 1200 | 1190 | errorMessage.remove(); |
| 1191 | + input.attr( 'aria-invalid', false ); | |
| 1201 | 1192 | input.removeAttr( 'aria-describedby' ); |
| 1202 | 1193 | |
| 1203 | 1194 | if ( typeof describedBy !== 'undefined' ) { |
| 1204 | 1195 | describedBy = describedBy.replace( errorId, '' ); |
| @@ -1324,10 +1315,10 @@ | ||
| 1324 | 1315 | } |
| 1325 | 1316 | |
| 1326 | 1317 | label.addEventListener( 'click', function() { |
| 1327 | 1318 | inputsContainer.querySelector( '.frm_form_field:first-child input, .frm_form_field:first-child select, .frm_form_field:first-child textarea' ).focus(); |
| 1328 | - } ); | |
| 1329 | - } ); | |
| 1319 | + }); | |
| 1320 | + }); | |
| 1330 | 1321 | } |
| 1331 | 1322 | |
| 1332 | 1323 | /** |
| 1333 | 1324 | * Sets focus on a the first subfield of a combo field that has an error. |
| @@ -1363,9 +1354,9 @@ | ||
| 1363 | 1354 | if ( ! errors.length ) { |
| 1364 | 1355 | return; |
| 1365 | 1356 | } |
| 1366 | 1357 | |
| 1367 | - element = errors[ 0 ]; | |
| 1358 | + element = errors[0]; | |
| 1368 | 1359 | do { |
| 1369 | 1360 | element = element.previousSibling; |
| 1370 | 1361 | if ( -1 !== [ 'input', 'select', 'textarea' ].indexOf( element.nodeName.toLowerCase() ) ) { |
| 1371 | 1362 | focusInput( element ); |
| @@ -1415,9 +1406,9 @@ | ||
| 1415 | 1406 | function focusInput( input ) { |
| 1416 | 1407 | if ( input.offsetParent !== null ) { |
| 1417 | 1408 | input.focus(); |
| 1418 | 1409 | } else { |
| 1419 | - triggerCustomEvent( document, 'frmMaybeDelayFocus', { input } ); | |
| 1410 | + triggerCustomEvent( document, 'frmMaybeDelayFocus', { input }); | |
| 1420 | 1411 | } |
| 1421 | 1412 | } |
| 1422 | 1413 | |
| 1423 | 1414 | /** |
| @@ -1450,9 +1441,9 @@ | ||
| 1450 | 1441 | |
| 1451 | 1442 | function initFloatingLabels() { |
| 1452 | 1443 | let checkFloatLabel, checkDropdownLabel, runOnLoad, selector, floatClass; |
| 1453 | 1444 | |
| 1454 | - selector = '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea'; | |
| 1445 | + selector = '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea'; | |
| 1455 | 1446 | floatClass = 'frm_label_float_top'; |
| 1456 | 1447 | |
| 1457 | 1448 | checkFloatLabel = function( input ) { |
| 1458 | 1449 | let container, shouldFloatTop, firstOpt; |
| @@ -1488,9 +1479,9 @@ | ||
| 1488 | 1479 | if ( firstOpt.textContent ) { |
| 1489 | 1480 | firstOpt.setAttribute( 'data-label', firstOpt.textContent ); |
| 1490 | 1481 | firstOpt.textContent = ''; |
| 1491 | 1482 | } |
| 1492 | - } ); | |
| 1483 | + }); | |
| 1493 | 1484 | }; |
| 1494 | 1485 | |
| 1495 | 1486 | [ 'focus', 'blur', 'change' ].forEach( function( eventName ) { |
| 1496 | 1487 | documentOn( |
| @@ -1500,13 +1491,13 @@ | ||
| 1500 | 1491 | checkFloatLabel( event.target ); |
| 1501 | 1492 | }, |
| 1502 | 1493 | true |
| 1503 | 1494 | ); |
| 1504 | - } ); | |
| 1495 | + }); | |
| 1505 | 1496 | |
| 1506 | 1497 | jQuery( document ).on( 'change', selector, function( event ) { |
| 1507 | 1498 | checkFloatLabel( event.target ); |
| 1508 | - } ); | |
| 1499 | + }); | |
| 1509 | 1500 | |
| 1510 | 1501 | runOnLoad = function( firstLoad ) { |
| 1511 | 1502 | if ( firstLoad && document.activeElement && -1 !== [ 'INPUT', 'SELECT', 'TEXTAREA' ].indexOf( document.activeElement.tagName ) ) { |
| 1512 | 1503 | checkFloatLabel( document.activeElement ); |
| @@ -1527,13 +1518,13 @@ | ||
| 1527 | 1518 | runOnLoad( true ); |
| 1528 | 1519 | |
| 1529 | 1520 | jQuery( document ).on( 'frmPageChanged', function( event ) { |
| 1530 | 1521 | runOnLoad(); |
| 1531 | - } ); | |
| 1522 | + }); | |
| 1532 | 1523 | |
| 1533 | 1524 | document.addEventListener( 'frm_after_start_over', function( event ) { |
| 1534 | 1525 | runOnLoad(); |
| 1535 | - } ); | |
| 1526 | + }); | |
| 1536 | 1527 | } |
| 1537 | 1528 | |
| 1538 | 1529 | function shouldUpdateValidityMessage( target ) { |
| 1539 | 1530 | if ( 'INPUT' !== target.nodeName ) { |
| @@ -1570,9 +1561,9 @@ | ||
| 1570 | 1561 | if ( 'valid' !== key && field.validity[ key ] === true ) { |
| 1571 | 1562 | isInvalid = true; |
| 1572 | 1563 | break; |
| 1573 | 1564 | } |
| 1574 | - } | |
| 1565 | + }; | |
| 1575 | 1566 | |
| 1576 | 1567 | if ( ! isInvalid ) { |
| 1577 | 1568 | field.setCustomValidity( '' ); |
| 1578 | 1569 | } |
| @@ -1595,9 +1586,9 @@ | ||
| 1595 | 1586 | |
| 1596 | 1587 | function setCustomValidityMessage() { |
| 1597 | 1588 | let forms, length, index; |
| 1598 | 1589 | |
| 1599 | - forms = document.getElementsByClassName( 'frm-show-form' ); | |
| 1590 | + forms = document.getElementsByClassName( 'frm-show-form' ); | |
| 1600 | 1591 | length = forms.length; |
| 1601 | 1592 | |
| 1602 | 1593 | for ( index = 0; index < length; ++index ) { |
| 1603 | 1594 | forms[ index ].addEventListener( |
| @@ -1623,9 +1614,9 @@ | ||
| 1623 | 1614 | } |
| 1624 | 1615 | ); |
| 1625 | 1616 | removeSubmitLoading(); |
| 1626 | 1617 | } |
| 1627 | - } ); | |
| 1618 | + }); | |
| 1628 | 1619 | } |
| 1629 | 1620 | |
| 1630 | 1621 | /** |
| 1631 | 1622 | * Destroys the formidable generated global hcaptcha object since it wouldn't otherwise render. |
| @@ -1667,11 +1658,11 @@ | ||
| 1667 | 1658 | } |
| 1668 | 1659 | |
| 1669 | 1660 | /* eslint-disable compat/compat */ |
| 1670 | 1661 | const startTime = performance.now(); |
| 1671 | - const step = currentTime => { | |
| 1662 | + const step = ( currentTime ) => { | |
| 1672 | 1663 | const progress = Math.min( ( currentTime - startTime ) / duration, 1 ); |
| 1673 | - document.documentElement.scrollTop = start + ( ( end - start ) * progress ); | |
| 1664 | + document.documentElement.scrollTop = start + ( end - start ) * progress; | |
| 1674 | 1665 | if ( progress < 1 ) { |
| 1675 | 1666 | requestAnimationFrame( step ); |
| 1676 | 1667 | } |
| 1677 | 1668 | }; |
| @@ -1687,9 +1678,9 @@ | ||
| 1687 | 1678 | jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() { |
| 1688 | 1679 | if ( jQuery( this ).val() === '' ) { |
| 1689 | 1680 | jQuery( this ).trigger( 'blur' ); |
| 1690 | 1681 | } |
| 1691 | - } ); | |
| 1682 | + }); | |
| 1692 | 1683 | |
| 1693 | 1684 | 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 ); |
| 1694 | 1685 | |
| 1695 | 1686 | jQuery( document ).on( 'change', '.frm_verify[id^=field_]', onHoneypotFieldChange ); |
| @@ -1734,9 +1725,9 @@ | ||
| 1734 | 1725 | if ( rendered ) { |
| 1735 | 1726 | return; |
| 1736 | 1727 | } |
| 1737 | 1728 | |
| 1738 | - const size = captcha.getAttribute( 'data-size' ); | |
| 1729 | + const size = captcha.getAttribute( 'data-size' ); | |
| 1739 | 1730 | const params = { |
| 1740 | 1731 | sitekey: captcha.getAttribute( 'data-sitekey' ), |
| 1741 | 1732 | size: size, |
| 1742 | 1733 | theme: captcha.getAttribute( 'data-theme' ) |
| @@ -1754,22 +1745,22 @@ | ||
| 1754 | 1745 | frmFrontForm.afterRecaptcha( token, formID ); |
| 1755 | 1746 | }; |
| 1756 | 1747 | } |
| 1757 | 1748 | |
| 1758 | - const activeCaptcha = getSelectedCaptcha( captchaSelector ); | |
| 1749 | + const activeCaptcha = getSelectedCaptcha( captchaSelector ); | |
| 1759 | 1750 | const captchaContainer = typeof turnstile !== 'undefined' && turnstile === activeCaptcha ? '#' + captcha.id : captcha.id; |
| 1760 | - const captchaID = activeCaptcha.render( captchaContainer, params ); | |
| 1751 | + const captchaID = activeCaptcha.render( captchaContainer, params ); | |
| 1761 | 1752 | |
| 1762 | 1753 | captcha.setAttribute( 'data-rid', captchaID ); |
| 1763 | 1754 | }, |
| 1764 | 1755 | |
| 1765 | 1756 | afterSingleRecaptcha: function() { |
| 1766 | - const object = jQuery( '.frm-show-form .g-recaptcha' ).closest( 'form' )[ 0 ]; | |
| 1757 | + const object = jQuery( '.frm-show-form .g-recaptcha' ).closest( 'form' )[0]; | |
| 1767 | 1758 | frmFrontForm.submitFormNow( object ); |
| 1768 | 1759 | }, |
| 1769 | 1760 | |
| 1770 | 1761 | afterRecaptcha: function( _, formID ) { |
| 1771 | - const object = jQuery( '#frm_form_' + formID + '_container form' )[ 0 ]; | |
| 1762 | + const object = jQuery( '#frm_form_' + formID + '_container form' )[0]; | |
| 1772 | 1763 | frmFrontForm.submitFormNow( object ); |
| 1773 | 1764 | }, |
| 1774 | 1765 | |
| 1775 | 1766 | submitForm: function( e ) { |
| @@ -1811,11 +1802,12 @@ | ||
| 1811 | 1802 | if ( invisibleRecaptcha.length ) { |
| 1812 | 1803 | showLoadingIndicator( jQuery( object ) ); |
| 1813 | 1804 | executeInvisibleRecaptcha( invisibleRecaptcha ); |
| 1814 | 1805 | } else { |
| 1806 | + | |
| 1815 | 1807 | showSubmitLoading( jQuery( object ) ); |
| 1816 | 1808 | |
| 1817 | - frmFrontForm.submitFormNow( object ); | |
| 1809 | + frmFrontForm.submitFormNow( object, classList ); | |
| 1818 | 1810 | } |
| 1819 | 1811 | }, |
| 1820 | 1812 | |
| 1821 | 1813 | submitFormNow: function( object ) { |
| @@ -1832,10 +1824,10 @@ | ||
| 1832 | 1824 | } |
| 1833 | 1825 | |
| 1834 | 1826 | // Add a unique ID, used for duplicate checks. |
| 1835 | 1827 | const uniqueIDInput = document.createElement( 'input' ); |
| 1836 | - uniqueIDInput.type = 'hidden'; | |
| 1837 | - uniqueIDInput.name = 'unique_id'; | |
| 1828 | + uniqueIDInput.type = 'hidden'; | |
| 1829 | + uniqueIDInput.name = 'unique_id'; | |
| 1838 | 1830 | uniqueIDInput.value = getUniqueKey(); |
| 1839 | 1831 | object.appendChild( uniqueIDInput ); |
| 1840 | 1832 | |
| 1841 | 1833 | if ( classList.indexOf( 'frm_ajax_submit' ) > -1 ) { |
| @@ -1840,9 +1832,9 @@ | ||
| 1840 | 1832 | |
| 1841 | 1833 | if ( classList.indexOf( 'frm_ajax_submit' ) > -1 ) { |
| 1842 | 1834 | hasFileFields = jQuery( object ).find( 'input[type="file"]' ).filter( function() { |
| 1843 | 1835 | return !! this.value; |
| 1844 | - } ).length; | |
| 1836 | + }).length; | |
| 1845 | 1837 | if ( hasFileFields < 1 ) { |
| 1846 | 1838 | const action = jQuery( object ).find( 'input[name="frm_action"]' ).val(); |
| 1847 | 1839 | frmFrontForm.checkFormErrors( object, action ); |
| 1848 | 1840 | } else { |
| @@ -1886,9 +1878,9 @@ | ||
| 1886 | 1878 | jsErrors = validateForm( object ); |
| 1887 | 1879 | if ( typeof frmThemeOverride_jsErrors === 'function' ) { // eslint-disable-line camelcase |
| 1888 | 1880 | const action = jQuery( object ).find( 'input[name="frm_action"]' ).val(); |
| 1889 | 1881 | customErrors = frmThemeOverride_jsErrors( action, object ); |
| 1890 | - if ( Object.keys( customErrors ).length ) { | |
| 1882 | + if ( Object.keys( customErrors ).length ) { | |
| 1891 | 1883 | for ( key in customErrors ) { |
| 1892 | 1884 | jsErrors[ key ] = customErrors[ key ]; |
| 1893 | 1885 | } |
| 1894 | 1886 | } |
| @@ -1896,9 +1888,9 @@ | ||
| 1896 | 1888 | |
| 1897 | 1889 | triggerCustomEvent( document, 'frm_get_ajax_form_errors', { |
| 1898 | 1890 | formEl: object, |
| 1899 | 1891 | errors: jsErrors |
| 1900 | - } ); | |
| 1892 | + }); | |
| 1901 | 1893 | |
| 1902 | 1894 | return jsErrors; |
| 1903 | 1895 | }, |
| 1904 | 1896 | |
| @@ -1989,9 +1981,9 @@ | ||
| 1989 | 1981 | if ( e.frmTriggered && e.frmTriggered == fieldId ) { |
| 1990 | 1982 | return; |
| 1991 | 1983 | } |
| 1992 | 1984 | |
| 1993 | - jQuery( document ).trigger( 'frmFieldChanged', [ this, fieldId, e ] ); | |
| 1985 | + jQuery( document ).trigger( 'frmFieldChanged', [ this, fieldId, e ]); | |
| 1994 | 1986 | |
| 1995 | 1987 | if ( e.selfTriggered !== true ) { |
| 1996 | 1988 | maybeValidateChange( this ); |
| 1997 | 1989 | } |
| @@ -2037,9 +2029,9 @@ | ||
| 2037 | 2029 | window.frmFrontForm = frmFrontFormJS(); |
| 2038 | 2030 | |
| 2039 | 2031 | jQuery( document ).ready( function() { |
| 2040 | 2032 | frmFrontForm.init(); |
| 2041 | -} ); | |
| 2033 | +}); | |
| 2042 | 2034 | |
| 2043 | 2035 | function frmRecaptcha() { |
| 2044 | 2036 | frmCaptcha( '.frm-g-recaptcha' ); |
| 2045 | 2037 | } |
| @@ -2050,13 +2042,13 @@ | ||
| 2050 | 2042 | |
| 2051 | 2043 | function frmCaptcha( captchaSelector ) { |
| 2052 | 2044 | let c; |
| 2053 | 2045 | const captchas = document.querySelectorAll( captchaSelector ); |
| 2054 | - const cl = captchas.length; | |
| 2046 | + const cl = captchas.length; | |
| 2055 | 2047 | for ( c = 0; c < cl; c++ ) { |
| 2056 | - const closestForm = captchas[ c ].closest( 'form' ); | |
| 2048 | + const closestForm = captchas[c].closest( 'form' ); | |
| 2057 | 2049 | const formIsVisible = closestForm && closestForm.offsetParent !== null; |
| 2058 | - const captcha = captchas[ c ]; | |
| 2050 | + const captcha = captchas[c]; | |
| 2059 | 2051 | if ( ! formIsVisible ) { |
| 2060 | 2052 | // If the form is not visible, try again later in 400ms. |
| 2061 | 2053 | // This fixes issues where the form fades visible on page load. |
| 2062 | 2054 | // Or whne the form is inside of a modal. |