| @@ -16,9 +16,8 @@ | ||
| 16 | 16 | * |
| 17 | 17 | * @since 5.4 |
| 18 | 18 | */ |
| 19 | 19 | function maybeAddPolyfills() { |
| 20 | - var i; | |
| 21 | 20 | if ( ! Element.prototype.matches ) { |
| 22 | 21 | // IE9 supports matches but as msMatchesSelector instead. |
| 23 | 22 | Element.prototype.matches = Element.prototype.msMatchesSelector; |
| 24 | 23 | } |
| @@ -41,9 +40,9 @@ | ||
| 41 | 40 | // NodeList.forEach(). |
| 42 | 41 | if ( window.NodeList && ! NodeList.prototype.forEach ) { |
| 43 | 42 | NodeList.prototype.forEach = function( callback, thisArg ) { |
| 44 | 43 | thisArg = thisArg || window; |
| 45 | - for ( i = 0; i < this.length; i++ ) { | |
| 44 | + for ( var i = 0; i < this.length; i++ ) { | |
| 46 | 45 | callback.call( thisArg, this[ i ], i, this ); |
| 47 | 46 | } |
| 48 | 47 | }; |
| 49 | 48 | } |
| @@ -48,34 +47,8 @@ | ||
| 48 | 47 | }; |
| 49 | 48 | } |
| 50 | 49 | } |
| 51 | 50 | |
| 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 ); | |
| 69 | - } else { | |
| 70 | - return; | |
| 71 | - } | |
| 72 | - | |
| 73 | - event.frmData = data; | |
| 74 | - | |
| 75 | - el.dispatchEvent( event ); | |
| 76 | - } | |
| 77 | - | |
| 78 | 51 | /* Get the ID of the field that changed*/ |
| 79 | 52 | function getFieldId( field, fullID ) { |
| 80 | 53 | var nameParts, fieldId, |
| 81 | 54 | isRepeating = false, |
| @@ -162,9 +135,9 @@ | ||
| 162 | 135 | * |
| 163 | 136 | * @since 2.03.02 |
| 164 | 137 | * |
| 165 | 138 | * @param {object} $form |
| 166 | - */ | |
| 139 | + */ | |
| 167 | 140 | function disableSubmitButton( $form ) { |
| 168 | 141 | $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).attr( 'disabled', 'disabled' ); |
| 169 | 142 | } |
| 170 | 143 | |
| @@ -173,9 +146,9 @@ | ||
| 173 | 146 | * |
| 174 | 147 | * @since 2.03.02 |
| 175 | 148 | * |
| 176 | 149 | * @param {object} $form |
| 177 | - */ | |
| 150 | + */ | |
| 178 | 151 | function enableSubmitButton( $form ) { |
| 179 | 152 | $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).prop( 'disabled', false ); |
| 180 | 153 | } |
| 181 | 154 | |
| @@ -222,10 +195,23 @@ | ||
| 222 | 195 | fields = jQuery( object ).find( 'input,select,textarea' ); |
| 223 | 196 | if ( fields.length ) { |
| 224 | 197 | for ( n = 0, nl = fields.length; n < nl; n++ ) { |
| 225 | 198 | field = fields[n]; |
| 226 | - if ( '' !== field.value ) { | |
| 227 | - validateFieldValue( field, errors ); | |
| 199 | + value = field.value; | |
| 200 | + if ( value !== '' ) { | |
| 201 | + if ( field.type === 'hidden' ) { | |
| 202 | + // don't validate | |
| 203 | + } else if ( field.type === 'number' ) { | |
| 204 | + errors = checkNumberField( field, errors ); | |
| 205 | + } else if ( field.type === 'email' ) { | |
| 206 | + errors = checkEmailField( field, errors ); | |
| 207 | + } else if ( field.type === 'password' ) { | |
| 208 | + errors = checkPasswordField( field, errors ); | |
| 209 | + } else if ( field.type === 'url' ) { | |
| 210 | + errors = checkUrlField( field, errors ); | |
| 211 | + } else if ( field.pattern !== null ) { | |
| 212 | + errors = checkPatternField( field, errors ); | |
| 213 | + } | |
| 228 | 214 | } |
| 229 | 215 | } |
| 230 | 216 | } |
| 231 | 217 | |
| @@ -272,9 +258,19 @@ | ||
| 272 | 258 | errors = checkRequiredField( field, errors ); |
| 273 | 259 | } |
| 274 | 260 | |
| 275 | 261 | if ( errors.length < 1 ) { |
| 276 | - validateFieldValue( field, errors ); | |
| 262 | + if ( field.type === 'email' ) { | |
| 263 | + errors = checkEmailField( field, errors ); | |
| 264 | + } else if ( field.type === 'password' ) { | |
| 265 | + errors = checkPasswordField( field, errors ); | |
| 266 | + } else if ( field.type === 'number' ) { | |
| 267 | + errors = checkNumberField( field, errors ); | |
| 268 | + } else if ( field.type === 'url' ) { | |
| 269 | + errors = checkUrlField( field, errors ); | |
| 270 | + } else if ( field.pattern !== null ) { | |
| 271 | + errors = checkPatternField( field, errors ); | |
| 272 | + } | |
| 277 | 273 | } |
| 278 | 274 | |
| 279 | 275 | removeFieldError( $fieldCont ); |
| 280 | 276 | if ( Object.keys( errors ).length > 0 ) { |
| @@ -283,29 +279,8 @@ | ||
| 283 | 279 | } |
| 284 | 280 | } |
| 285 | 281 | } |
| 286 | 282 | |
| 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 | 283 | function checkRequiredField( field, errors ) { |
| 309 | 284 | var checkGroup, tempVal, i, placeholder, |
| 310 | 285 | val = '', |
| 311 | 286 | fieldID = '', |
| @@ -421,8 +396,9 @@ | ||
| 421 | 396 | if ( ! ( fieldID in errors ) ) { |
| 422 | 397 | errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' ); |
| 423 | 398 | } |
| 424 | 399 | } |
| 400 | + return errors; | |
| 425 | 401 | } |
| 426 | 402 | |
| 427 | 403 | function checkEmailField( field, errors ) { |
| 428 | 404 | var fieldID = getFieldId( field, true ), |
| @@ -433,12 +409,14 @@ | ||
| 433 | 409 | errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' ); |
| 434 | 410 | } |
| 435 | 411 | |
| 436 | 412 | confirmField( field, errors ); |
| 413 | + return errors; | |
| 437 | 414 | } |
| 438 | 415 | |
| 439 | 416 | function checkPasswordField( field, errors ) { |
| 440 | 417 | confirmField( field, errors ); |
| 418 | + return errors; | |
| 441 | 419 | } |
| 442 | 420 | |
| 443 | 421 | function confirmField( field, errors ) { |
| 444 | 422 | var value, confirmValue, firstField, |
| @@ -472,8 +450,9 @@ | ||
| 472 | 450 | if ( ! ( fieldID in errors ) ) { |
| 473 | 451 | errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' ); |
| 474 | 452 | } |
| 475 | 453 | } |
| 454 | + return errors; | |
| 476 | 455 | } |
| 477 | 456 | |
| 478 | 457 | function checkPatternField( field, errors ) { |
| 479 | 458 | var fieldID, |
| @@ -488,8 +467,9 @@ | ||
| 488 | 467 | errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' ); |
| 489 | 468 | } |
| 490 | 469 | } |
| 491 | 470 | } |
| 471 | + return errors; | |
| 492 | 472 | } |
| 493 | 473 | |
| 494 | 474 | function hasInvisibleRecaptcha( object ) { |
| 495 | 475 | var recaptcha, recaptchaID, alreadyChecked; |
| @@ -576,9 +556,9 @@ | ||
| 576 | 556 | return validate; |
| 577 | 557 | } |
| 578 | 558 | |
| 579 | 559 | function getFormErrors( object, action ) { |
| 580 | - var fieldset, data, success, error, shouldTriggerEvent; | |
| 560 | + var fieldset, data, success, error; | |
| 581 | 561 | |
| 582 | 562 | if ( typeof action === 'undefined' ) { |
| 583 | 563 | jQuery( object ).find( 'input[name="frm_action"]' ).val(); |
| 584 | 564 | } |
| @@ -585,21 +565,14 @@ | ||
| 585 | 565 | |
| 586 | 566 | fieldset = jQuery( object ).find( '.frm_form_field' ); |
| 587 | 567 | fieldset.addClass( 'frm_doing_ajax' ); |
| 588 | 568 | |
| 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' ); | |
| 569 | + data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; | |
| 591 | 570 | |
| 592 | 571 | 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 | - | |
| 572 | + var formID, replaceContent, pageOrder, formReturned, contSubmit, delay, | |
| 573 | + $fieldCont, key, inCollapsedSection, frmTrigger, | |
| 574 | + defaultResponse = { 'content': '', 'errors': {}, 'pass': false }; | |
| 602 | 575 | if ( response === null ) { |
| 603 | 576 | response = defaultResponse; |
| 604 | 577 | } |
| 605 | 578 | |
| @@ -610,41 +583,17 @@ | ||
| 610 | 583 | response = defaultResponse; |
| 611 | 584 | } |
| 612 | 585 | |
| 613 | 586 | if ( typeof response.redirect !== 'undefined' ) { |
| 614 | - if ( shouldTriggerEvent ) { | |
| 615 | - triggerCustomEvent( object, 'frmSubmitEvent' ); | |
| 616 | - return; | |
| 617 | - } | |
| 618 | - | |
| 619 | 587 | 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 !== '' ) { | |
| 588 | + window.location = response.redirect; | |
| 589 | + } else if ( response.content !== '' ) { | |
| 635 | 590 | // the form or success message was returned |
| 636 | 591 | |
| 637 | - if ( shouldTriggerEvent ) { | |
| 638 | - triggerCustomEvent( object, 'frmSubmitEvent' ); | |
| 639 | - return; | |
| 640 | - } | |
| 641 | - | |
| 642 | 592 | removeSubmitLoading( jQuery( object ) ); |
| 643 | - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase | |
| 593 | + if ( frm_js.offset != -1 ) { | |
| 644 | 594 | frmFrontForm.scrollMsg( jQuery( object ), false ); |
| 645 | 595 | } |
| 646 | - | |
| 647 | 596 | formID = jQuery( object ).find( 'input[name="form_id"]' ).val(); |
| 648 | 597 | response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' ); |
| 649 | 598 | replaceContent = jQuery( object ).closest( '.frm_forms' ); |
| 650 | 599 | removeAddedScripts( replaceContent, formID ); |
| @@ -681,8 +630,9 @@ | ||
| 681 | 630 | delay |
| 682 | 631 | ); |
| 683 | 632 | } else if ( Object.keys( response.errors ).length ) { |
| 684 | 633 | // errors were returned |
| 634 | + | |
| 685 | 635 | removeSubmitLoading( jQuery( object ), 'enable' ); |
| 686 | 636 | |
| 687 | 637 | //show errors |
| 688 | 638 | contSubmit = true; |
| @@ -712,9 +662,9 @@ | ||
| 712 | 662 | } |
| 713 | 663 | } |
| 714 | 664 | } |
| 715 | 665 | |
| 716 | - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() { | |
| 666 | + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() { | |
| 717 | 667 | var $recaptcha = jQuery( this ), |
| 718 | 668 | recaptchaID = $recaptcha.data( 'rid' ); |
| 719 | 669 | |
| 720 | 670 | if ( typeof grecaptcha !== 'undefined' && grecaptcha ) { |
| @@ -723,11 +673,8 @@ | ||
| 723 | 673 | } else { |
| 724 | 674 | grecaptcha.reset(); |
| 725 | 675 | } |
| 726 | 676 | } |
| 727 | - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) { | |
| 728 | - hcaptcha.reset(); | |
| 729 | - } | |
| 730 | 677 | }); |
| 731 | 678 | |
| 732 | 679 | jQuery( document ).trigger( 'frmFormErrors', [ object, response ]); |
| 733 | 680 | |
| @@ -759,9 +706,9 @@ | ||
| 759 | 706 | |
| 760 | 707 | function postToAjaxUrl( form, data, success, error ) { |
| 761 | 708 | var ajaxUrl, action, ajaxParams; |
| 762 | 709 | |
| 763 | - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase | |
| 710 | + ajaxUrl = frm_js.ajax_url; | |
| 764 | 711 | action = form.getAttribute( 'action' ); |
| 765 | 712 | |
| 766 | 713 | if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) { |
| 767 | 714 | ajaxUrl = action.split( '?action=frm_forms_preview' )[0]; |
| @@ -862,9 +809,9 @@ | ||
| 862 | 809 | $fieldCont.append( |
| 863 | 810 | jsErrors[key] |
| 864 | 811 | ); |
| 865 | 812 | } else { |
| 866 | - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase | |
| 813 | + roleString = frm_js.include_alert_role ? 'role="alert"' : ''; | |
| 867 | 814 | $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' ); |
| 868 | 815 | } |
| 869 | 816 | |
| 870 | 817 | if ( typeof describedBy === 'undefined' ) { |
| @@ -1010,14 +957,14 @@ | ||
| 1010 | 957 | label.append( '<span class="frm-wait"></span>' ); |
| 1011 | 958 | |
| 1012 | 959 | jQuery.ajax({ |
| 1013 | 960 | type: 'POST', |
| 1014 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 961 | + url: frm_js.ajax_url, | |
| 1015 | 962 | data: { |
| 1016 | 963 | action: 'frm_entries_send_email', |
| 1017 | 964 | entry_id: entryId, |
| 1018 | 965 | form_id: formId, |
| 1019 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 966 | + nonce: frm_js.nonce | |
| 1020 | 967 | }, |
| 1021 | 968 | success: function( msg ) { |
| 1022 | 969 | var admin = document.getElementById( 'wpbody' ); |
| 1023 | 970 | if ( admin === null ) { |
| @@ -1055,9 +1002,32 @@ | ||
| 1055 | 1002 | /********************************************** |
| 1056 | 1003 | * Fallback functions |
| 1057 | 1004 | *********************************************/ |
| 1058 | 1005 | |
| 1059 | - function addTrimFallbackForIE() { | |
| 1006 | + function addIndexOfFallbackForIE8() { | |
| 1007 | + var len, from; | |
| 1008 | + | |
| 1009 | + if ( ! Array.prototype.indexOf ) { | |
| 1010 | + Array.prototype.indexOf = function( elt /*, from*/ ) { | |
| 1011 | + len = this.length >>> 0; | |
| 1012 | + | |
| 1013 | + from = Number( arguments[1]) || 0; | |
| 1014 | + from = ( from < 0 ) ? Math.ceil( from ) : Math.floor( from ); | |
| 1015 | + if ( from < 0 ) { | |
| 1016 | + from += len; | |
| 1017 | + } | |
| 1018 | + | |
| 1019 | + for ( ; from < len; from++ ) { | |
| 1020 | + if ( from in this && this[from] === elt ) { | |
| 1021 | + return from; | |
| 1022 | + } | |
| 1023 | + } | |
| 1024 | + return -1; | |
| 1025 | + }; | |
| 1026 | + } | |
| 1027 | + } | |
| 1028 | + | |
| 1029 | + function addTrimFallbackForIE8() { | |
| 1060 | 1030 | if ( typeof String.prototype.trim !== 'function' ) { |
| 1061 | 1031 | String.prototype.trim = function() { |
| 1062 | 1032 | return this.replace( /^\s+|\s+$/g, '' ); |
| 1063 | 1033 | }; |
| @@ -1063,9 +1033,9 @@ | ||
| 1063 | 1033 | }; |
| 1064 | 1034 | } |
| 1065 | 1035 | } |
| 1066 | 1036 | |
| 1067 | - function addFilterFallbackForIE() { | |
| 1037 | + function addFilterFallbackForIE8() { | |
| 1068 | 1038 | var t, len, res, thisp, i, val; |
| 1069 | 1039 | |
| 1070 | 1040 | if ( ! Array.prototype.filter ) { |
| 1071 | 1041 | |
| @@ -1096,8 +1066,26 @@ | ||
| 1096 | 1066 | }; |
| 1097 | 1067 | } |
| 1098 | 1068 | } |
| 1099 | 1069 | |
| 1070 | + function addKeysFallbackForIE8() { | |
| 1071 | + var keys, i; | |
| 1072 | + | |
| 1073 | + if ( ! Object.keys ) { | |
| 1074 | + Object.keys = function( obj ) { | |
| 1075 | + keys = []; | |
| 1076 | + | |
| 1077 | + for ( i in obj ) { | |
| 1078 | + if ( obj.hasOwnProperty( i ) ) { | |
| 1079 | + keys.push( i ); | |
| 1080 | + } | |
| 1081 | + } | |
| 1082 | + | |
| 1083 | + return keys; | |
| 1084 | + }; | |
| 1085 | + } | |
| 1086 | + } | |
| 1087 | + | |
| 1100 | 1088 | /** |
| 1101 | 1089 | * Check for -webkit-box-shadow css value for input:-webkit-autofill selector. |
| 1102 | 1090 | * If this is a match, the User is autofilling the input on a Webkit browser. |
| 1103 | 1091 | * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete. |
| @@ -1108,38 +1096,8 @@ | ||
| 1108 | 1096 | this.parentNode.removeChild( this ); |
| 1109 | 1097 | } |
| 1110 | 1098 | } |
| 1111 | 1099 | |
| 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 | 1100 | /** |
| 1143 | 1101 | * Focus on the first sub field when clicking to the primary label of combo field. |
| 1144 | 1102 | * |
| 1145 | 1103 | * @since 4.10.02 |
| @@ -1144,11 +1102,11 @@ | ||
| 1144 | 1102 | * |
| 1145 | 1103 | * @since 4.10.02 |
| 1146 | 1104 | */ |
| 1147 | 1105 | function changeFocusWhenClickComboFieldLabel() { |
| 1148 | - var label; | |
| 1106 | + let label; | |
| 1149 | 1107 | |
| 1150 | - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' ); | |
| 1108 | + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' ); | |
| 1151 | 1109 | comboInputsContainer.forEach( function( inputsContainer ) { |
| 1152 | 1110 | if ( ! inputsContainer.closest( '.frm_form_field' ) ) { |
| 1153 | 1111 | return; |
| 1154 | 1112 | } |
| @@ -1166,9 +1124,9 @@ | ||
| 1166 | 1124 | |
| 1167 | 1125 | function checkForErrorsAndMaybeSetFocus() { |
| 1168 | 1126 | var errors, element, timeoutCallback; |
| 1169 | 1127 | |
| 1170 | - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase | |
| 1128 | + if ( ! frm_js.focus_first_error ) { | |
| 1171 | 1129 | return; |
| 1172 | 1130 | } |
| 1173 | 1131 | |
| 1174 | 1132 | errors = document.querySelectorAll( '.frm_form_field .frm_error' ); |
| @@ -1236,9 +1194,9 @@ | ||
| 1236 | 1194 | var target; |
| 1237 | 1195 | |
| 1238 | 1196 | // loop parent nodes from the target to the delegation node. |
| 1239 | 1197 | for ( target = e.target; target && target != this; target = target.parentNode ) { |
| 1240 | - if ( target && target.matches && target.matches( selector ) ) { | |
| 1198 | + if ( target.matches( selector ) ) { | |
| 1241 | 1199 | handler.call( target, e ); |
| 1242 | 1200 | break; |
| 1243 | 1201 | } |
| 1244 | 1202 | } |
| @@ -1360,87 +1318,8 @@ | ||
| 1360 | 1318 | runOnLoad(); |
| 1361 | 1319 | }); |
| 1362 | 1320 | } |
| 1363 | 1321 | |
| 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 | 1322 | return { |
| 1444 | 1323 | init: function() { |
| 1445 | 1324 | maybeAddPolyfills(); |
| 1446 | 1325 | |
| @@ -1461,9 +1340,8 @@ | ||
| 1461 | 1340 | |
| 1462 | 1341 | 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 ); |
| 1463 | 1342 | |
| 1464 | 1343 | jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange ); |
| 1465 | - maybeMakeHoneypotFieldsUntabbable(); | |
| 1466 | 1344 | |
| 1467 | 1345 | jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick ); |
| 1468 | 1346 | jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv ); |
| 1469 | 1347 | |
| @@ -1471,18 +1349,15 @@ | ||
| 1471 | 1349 | |
| 1472 | 1350 | // Focus on the first sub field when clicking to the primary label of combo field. |
| 1473 | 1351 | changeFocusWhenClickComboFieldLabel(); |
| 1474 | 1352 | |
| 1475 | - // Add fallbacks for IE. | |
| 1476 | - addTrimFallbackForIE(); // Trim only works in IE10+. | |
| 1477 | - addFilterFallbackForIE(); // Filter is not supported in any version of IE. | |
| 1353 | + // Add fallbacks for the beloved IE8 | |
| 1354 | + addIndexOfFallbackForIE8(); | |
| 1355 | + addTrimFallbackForIE8(); | |
| 1356 | + addFilterFallbackForIE8(); | |
| 1357 | + addKeysFallbackForIE8(); | |
| 1478 | 1358 | |
| 1479 | 1359 | initFloatingLabels(); |
| 1480 | - maybeShowNewTabFallbackMessage(); | |
| 1481 | - | |
| 1482 | - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage ); | |
| 1483 | - setCustomValidityMessage(); | |
| 1484 | - jQuery( document ).on( 'frmFieldChanged', maybeClearCustomValidityMessage ); | |
| 1485 | 1360 | }, |
| 1486 | 1361 | |
| 1487 | 1362 | getFieldId: function( field, fullID ) { |
| 1488 | 1363 | return getFieldId( field, fullID ); |
| @@ -1665,12 +1540,12 @@ | ||
| 1665 | 1540 | removeSubmitLoading: function( $object, enable, processesRunning ) { |
| 1666 | 1541 | removeSubmitLoading( $object, enable, processesRunning ); |
| 1667 | 1542 | }, |
| 1668 | 1543 | |
| 1669 | - scrollToID: function( id ) { | |
| 1670 | - var object = jQuery( document.getElementById( id ) ); | |
| 1671 | - frmFrontForm.scrollMsg( object, false ); | |
| 1672 | - }, | |
| 1544 | + scrollToID: function( id ) { | |
| 1545 | + var object = jQuery( document.getElementById( id ) ); | |
| 1546 | + frmFrontForm.scrollMsg( object, false ); | |
| 1547 | + }, | |
| 1673 | 1548 | |
| 1674 | 1549 | scrollMsg: function( id, object, animate ) { |
| 1675 | 1550 | var newPos, m, b, screenTop, screenBottom, |
| 1676 | 1551 | scrollObj = ''; |
| @@ -1686,12 +1561,12 @@ | ||
| 1686 | 1561 | } |
| 1687 | 1562 | |
| 1688 | 1563 | jQuery( scrollObj ).trigger( 'focus' ); |
| 1689 | 1564 | newPos = scrollObj.offset().top; |
| 1690 | - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase | |
| 1565 | + if ( ! newPos || frm_js.offset === '-1' ) { | |
| 1691 | 1566 | return; |
| 1692 | 1567 | } |
| 1693 | - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase | |
| 1568 | + newPos = newPos - frm_js.offset; | |
| 1694 | 1569 | |
| 1695 | 1570 | m = jQuery( 'html' ).css( 'margin-top' ); |
| 1696 | 1571 | b = jQuery( 'body' ).css( 'margin-top' ); |
| 1697 | 1572 | if ( m || b ) { |
| @@ -1819,15 +1694,15 @@ | ||
| 1819 | 1694 | function frmUpdateField( entryId, fieldId, value, message, num ) { |
| 1820 | 1695 | jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' ); |
| 1821 | 1696 | jQuery.ajax({ |
| 1822 | 1697 | type: 'POST', |
| 1823 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1698 | + url: frm_js.ajax_url, | |
| 1824 | 1699 | data: { |
| 1825 | 1700 | action: 'frm_entries_update_field_ajax', |
| 1826 | 1701 | entry_id: entryId, |
| 1827 | 1702 | field_id: fieldId, |
| 1828 | 1703 | value: value, |
| 1829 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1704 | + nonce: frm_js.nonce | |
| 1830 | 1705 | }, |
| 1831 | 1706 | success: function() { |
| 1832 | 1707 | if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) { |
| 1833 | 1708 | jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' ); |
| @@ -1842,13 +1717,13 @@ | ||
| 1842 | 1717 | console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' ); |
| 1843 | 1718 | jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' ); |
| 1844 | 1719 | jQuery.ajax({ |
| 1845 | 1720 | type: 'POST', |
| 1846 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1721 | + url: frm_js.ajax_url, | |
| 1847 | 1722 | data: { |
| 1848 | 1723 | action: 'frm_entries_destroy', |
| 1849 | 1724 | entry: entryId, |
| 1850 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1725 | + nonce: frm_js.nonce | |
| 1851 | 1726 | }, |
| 1852 | 1727 | success: function( html ) { |
| 1853 | 1728 | if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) { |
| 1854 | 1729 | jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' ); |
| @@ -1869,14 +1744,14 @@ | ||
| 1869 | 1744 | console.warn( 'DEPRECATED: function frm_resend_email in v2.0' ); |
| 1870 | 1745 | $link.append( '<span class="spinner" style="display:inline"></span>' ); |
| 1871 | 1746 | jQuery.ajax({ |
| 1872 | 1747 | type: 'POST', |
| 1873 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1748 | + url: frm_js.ajax_url, | |
| 1874 | 1749 | data: { |
| 1875 | 1750 | action: 'frm_entries_send_email', |
| 1876 | 1751 | entry_id: entryId, |
| 1877 | 1752 | form_id: formId, |
| 1878 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1753 | + nonce: frm_js.nonce | |
| 1879 | 1754 | }, |
| 1880 | 1755 | success: function( msg ) { |
| 1881 | 1756 | $link.replaceWith( msg ); |
| 1882 | 1757 | } |