| @@ -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; | |
| 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,28 +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 | 588 | window.location = response.redirect; |
| 621 | 589 | } else if ( response.content !== '' ) { |
| 622 | 590 | // the form or success message was returned |
| 623 | 591 | |
| 624 | - if ( shouldTriggerEvent ) { | |
| 625 | - triggerCustomEvent( object, 'frmSubmitEvent' ); | |
| 626 | - return; | |
| 627 | - } | |
| 628 | - | |
| 629 | 592 | removeSubmitLoading( jQuery( object ) ); |
| 630 | - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase | |
| 593 | + if ( frm_js.offset != -1 ) { | |
| 631 | 594 | frmFrontForm.scrollMsg( jQuery( object ), false ); |
| 632 | 595 | } |
| 633 | - | |
| 634 | 596 | formID = jQuery( object ).find( 'input[name="form_id"]' ).val(); |
| 635 | 597 | response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' ); |
| 636 | 598 | replaceContent = jQuery( object ).closest( '.frm_forms' ); |
| 637 | 599 | removeAddedScripts( replaceContent, formID ); |
| @@ -668,8 +630,9 @@ | ||
| 668 | 630 | delay |
| 669 | 631 | ); |
| 670 | 632 | } else if ( Object.keys( response.errors ).length ) { |
| 671 | 633 | // errors were returned |
| 634 | + | |
| 672 | 635 | removeSubmitLoading( jQuery( object ), 'enable' ); |
| 673 | 636 | |
| 674 | 637 | //show errors |
| 675 | 638 | contSubmit = true; |
| @@ -699,9 +662,9 @@ | ||
| 699 | 662 | } |
| 700 | 663 | } |
| 701 | 664 | } |
| 702 | 665 | |
| 703 | - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() { | |
| 666 | + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() { | |
| 704 | 667 | var $recaptcha = jQuery( this ), |
| 705 | 668 | recaptchaID = $recaptcha.data( 'rid' ); |
| 706 | 669 | |
| 707 | 670 | if ( typeof grecaptcha !== 'undefined' && grecaptcha ) { |
| @@ -710,11 +673,8 @@ | ||
| 710 | 673 | } else { |
| 711 | 674 | grecaptcha.reset(); |
| 712 | 675 | } |
| 713 | 676 | } |
| 714 | - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) { | |
| 715 | - hcaptcha.reset(); | |
| 716 | - } | |
| 717 | 677 | }); |
| 718 | 678 | |
| 719 | 679 | jQuery( document ).trigger( 'frmFormErrors', [ object, response ]); |
| 720 | 680 | |
| @@ -746,9 +706,9 @@ | ||
| 746 | 706 | |
| 747 | 707 | function postToAjaxUrl( form, data, success, error ) { |
| 748 | 708 | var ajaxUrl, action, ajaxParams; |
| 749 | 709 | |
| 750 | - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase | |
| 710 | + ajaxUrl = frm_js.ajax_url; | |
| 751 | 711 | action = form.getAttribute( 'action' ); |
| 752 | 712 | |
| 753 | 713 | if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) { |
| 754 | 714 | ajaxUrl = action.split( '?action=frm_forms_preview' )[0]; |
| @@ -849,9 +809,9 @@ | ||
| 849 | 809 | $fieldCont.append( |
| 850 | 810 | jsErrors[key] |
| 851 | 811 | ); |
| 852 | 812 | } else { |
| 853 | - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase | |
| 813 | + roleString = frm_js.include_alert_role ? 'role="alert"' : ''; | |
| 854 | 814 | $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' ); |
| 855 | 815 | } |
| 856 | 816 | |
| 857 | 817 | if ( typeof describedBy === 'undefined' ) { |
| @@ -997,14 +957,14 @@ | ||
| 997 | 957 | label.append( '<span class="frm-wait"></span>' ); |
| 998 | 958 | |
| 999 | 959 | jQuery.ajax({ |
| 1000 | 960 | type: 'POST', |
| 1001 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 961 | + url: frm_js.ajax_url, | |
| 1002 | 962 | data: { |
| 1003 | 963 | action: 'frm_entries_send_email', |
| 1004 | 964 | entry_id: entryId, |
| 1005 | 965 | form_id: formId, |
| 1006 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 966 | + nonce: frm_js.nonce | |
| 1007 | 967 | }, |
| 1008 | 968 | success: function( msg ) { |
| 1009 | 969 | var admin = document.getElementById( 'wpbody' ); |
| 1010 | 970 | if ( admin === null ) { |
| @@ -1042,9 +1002,32 @@ | ||
| 1042 | 1002 | /********************************************** |
| 1043 | 1003 | * Fallback functions |
| 1044 | 1004 | *********************************************/ |
| 1045 | 1005 | |
| 1046 | - 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() { | |
| 1047 | 1030 | if ( typeof String.prototype.trim !== 'function' ) { |
| 1048 | 1031 | String.prototype.trim = function() { |
| 1049 | 1032 | return this.replace( /^\s+|\s+$/g, '' ); |
| 1050 | 1033 | }; |
| @@ -1050,9 +1033,9 @@ | ||
| 1050 | 1033 | }; |
| 1051 | 1034 | } |
| 1052 | 1035 | } |
| 1053 | 1036 | |
| 1054 | - function addFilterFallbackForIE() { | |
| 1037 | + function addFilterFallbackForIE8() { | |
| 1055 | 1038 | var t, len, res, thisp, i, val; |
| 1056 | 1039 | |
| 1057 | 1040 | if ( ! Array.prototype.filter ) { |
| 1058 | 1041 | |
| @@ -1083,8 +1066,26 @@ | ||
| 1083 | 1066 | }; |
| 1084 | 1067 | } |
| 1085 | 1068 | } |
| 1086 | 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 | + | |
| 1087 | 1088 | /** |
| 1088 | 1089 | * Check for -webkit-box-shadow css value for input:-webkit-autofill selector. |
| 1089 | 1090 | * If this is a match, the User is autofilling the input on a Webkit browser. |
| 1090 | 1091 | * We want to delete the Honeypot field, otherwise it will get triggered as spam on autocomplete. |
| @@ -1095,38 +1096,8 @@ | ||
| 1095 | 1096 | this.parentNode.removeChild( this ); |
| 1096 | 1097 | } |
| 1097 | 1098 | } |
| 1098 | 1099 | |
| 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 | 1100 | /** |
| 1130 | 1101 | * Focus on the first sub field when clicking to the primary label of combo field. |
| 1131 | 1102 | * |
| 1132 | 1103 | * @since 4.10.02 |
| @@ -1131,11 +1102,11 @@ | ||
| 1131 | 1102 | * |
| 1132 | 1103 | * @since 4.10.02 |
| 1133 | 1104 | */ |
| 1134 | 1105 | function changeFocusWhenClickComboFieldLabel() { |
| 1135 | - var label; | |
| 1106 | + let label; | |
| 1136 | 1107 | |
| 1137 | - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' ); | |
| 1108 | + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' ); | |
| 1138 | 1109 | comboInputsContainer.forEach( function( inputsContainer ) { |
| 1139 | 1110 | if ( ! inputsContainer.closest( '.frm_form_field' ) ) { |
| 1140 | 1111 | return; |
| 1141 | 1112 | } |
| @@ -1153,9 +1124,9 @@ | ||
| 1153 | 1124 | |
| 1154 | 1125 | function checkForErrorsAndMaybeSetFocus() { |
| 1155 | 1126 | var errors, element, timeoutCallback; |
| 1156 | 1127 | |
| 1157 | - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase | |
| 1128 | + if ( ! frm_js.focus_first_error ) { | |
| 1158 | 1129 | return; |
| 1159 | 1130 | } |
| 1160 | 1131 | |
| 1161 | 1132 | errors = document.querySelectorAll( '.frm_form_field .frm_error' ); |
| @@ -1223,9 +1194,9 @@ | ||
| 1223 | 1194 | var target; |
| 1224 | 1195 | |
| 1225 | 1196 | // loop parent nodes from the target to the delegation node. |
| 1226 | 1197 | for ( target = e.target; target && target != this; target = target.parentNode ) { |
| 1227 | - if ( target && target.matches && target.matches( selector ) ) { | |
| 1198 | + if ( target.matches( selector ) ) { | |
| 1228 | 1199 | handler.call( target, e ); |
| 1229 | 1200 | break; |
| 1230 | 1201 | } |
| 1231 | 1202 | } |
| @@ -1347,43 +1318,8 @@ | ||
| 1347 | 1318 | runOnLoad(); |
| 1348 | 1319 | }); |
| 1349 | 1320 | } |
| 1350 | 1321 | |
| 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 | 1322 | return { |
| 1387 | 1323 | init: function() { |
| 1388 | 1324 | maybeAddPolyfills(); |
| 1389 | 1325 | |
| @@ -1404,9 +1340,8 @@ | ||
| 1404 | 1340 | |
| 1405 | 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 ); |
| 1406 | 1342 | |
| 1407 | 1343 | jQuery( document ).on( 'change', '[id^=frm_email_]', onHoneypotFieldChange ); |
| 1408 | - maybeMakeHoneypotFieldsUntabbable(); | |
| 1409 | 1344 | |
| 1410 | 1345 | jQuery( document ).on( 'click', 'a[data-frmconfirm]', confirmClick ); |
| 1411 | 1346 | jQuery( 'a[data-frmtoggle]' ).on( 'click', toggleDiv ); |
| 1412 | 1347 | |
| @@ -1414,16 +1349,15 @@ | ||
| 1414 | 1349 | |
| 1415 | 1350 | // Focus on the first sub field when clicking to the primary label of combo field. |
| 1416 | 1351 | changeFocusWhenClickComboFieldLabel(); |
| 1417 | 1352 | |
| 1418 | - // Add fallbacks for IE. | |
| 1419 | - addTrimFallbackForIE(); // Trim only works in IE10+. | |
| 1420 | - 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(); | |
| 1421 | 1358 | |
| 1422 | 1359 | initFloatingLabels(); |
| 1423 | - | |
| 1424 | - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage ); | |
| 1425 | - setCustomValidityMessage(); | |
| 1426 | 1360 | }, |
| 1427 | 1361 | |
| 1428 | 1362 | getFieldId: function( field, fullID ) { |
| 1429 | 1363 | return getFieldId( field, fullID ); |
| @@ -1606,12 +1540,12 @@ | ||
| 1606 | 1540 | removeSubmitLoading: function( $object, enable, processesRunning ) { |
| 1607 | 1541 | removeSubmitLoading( $object, enable, processesRunning ); |
| 1608 | 1542 | }, |
| 1609 | 1543 | |
| 1610 | - scrollToID: function( id ) { | |
| 1611 | - var object = jQuery( document.getElementById( id ) ); | |
| 1612 | - frmFrontForm.scrollMsg( object, false ); | |
| 1613 | - }, | |
| 1544 | + scrollToID: function( id ) { | |
| 1545 | + var object = jQuery( document.getElementById( id ) ); | |
| 1546 | + frmFrontForm.scrollMsg( object, false ); | |
| 1547 | + }, | |
| 1614 | 1548 | |
| 1615 | 1549 | scrollMsg: function( id, object, animate ) { |
| 1616 | 1550 | var newPos, m, b, screenTop, screenBottom, |
| 1617 | 1551 | scrollObj = ''; |
| @@ -1627,12 +1561,12 @@ | ||
| 1627 | 1561 | } |
| 1628 | 1562 | |
| 1629 | 1563 | jQuery( scrollObj ).trigger( 'focus' ); |
| 1630 | 1564 | newPos = scrollObj.offset().top; |
| 1631 | - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase | |
| 1565 | + if ( ! newPos || frm_js.offset === '-1' ) { | |
| 1632 | 1566 | return; |
| 1633 | 1567 | } |
| 1634 | - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase | |
| 1568 | + newPos = newPos - frm_js.offset; | |
| 1635 | 1569 | |
| 1636 | 1570 | m = jQuery( 'html' ).css( 'margin-top' ); |
| 1637 | 1571 | b = jQuery( 'body' ).css( 'margin-top' ); |
| 1638 | 1572 | if ( m || b ) { |
| @@ -1760,15 +1694,15 @@ | ||
| 1760 | 1694 | function frmUpdateField( entryId, fieldId, value, message, num ) { |
| 1761 | 1695 | jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' ); |
| 1762 | 1696 | jQuery.ajax({ |
| 1763 | 1697 | type: 'POST', |
| 1764 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1698 | + url: frm_js.ajax_url, | |
| 1765 | 1699 | data: { |
| 1766 | 1700 | action: 'frm_entries_update_field_ajax', |
| 1767 | 1701 | entry_id: entryId, |
| 1768 | 1702 | field_id: fieldId, |
| 1769 | 1703 | value: value, |
| 1770 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1704 | + nonce: frm_js.nonce | |
| 1771 | 1705 | }, |
| 1772 | 1706 | success: function() { |
| 1773 | 1707 | if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) { |
| 1774 | 1708 | jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' ); |
| @@ -1783,13 +1717,13 @@ | ||
| 1783 | 1717 | console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' ); |
| 1784 | 1718 | jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' ); |
| 1785 | 1719 | jQuery.ajax({ |
| 1786 | 1720 | type: 'POST', |
| 1787 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1721 | + url: frm_js.ajax_url, | |
| 1788 | 1722 | data: { |
| 1789 | 1723 | action: 'frm_entries_destroy', |
| 1790 | 1724 | entry: entryId, |
| 1791 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1725 | + nonce: frm_js.nonce | |
| 1792 | 1726 | }, |
| 1793 | 1727 | success: function( html ) { |
| 1794 | 1728 | if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) { |
| 1795 | 1729 | jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' ); |
| @@ -1810,14 +1744,14 @@ | ||
| 1810 | 1744 | console.warn( 'DEPRECATED: function frm_resend_email in v2.0' ); |
| 1811 | 1745 | $link.append( '<span class="spinner" style="display:inline"></span>' ); |
| 1812 | 1746 | jQuery.ajax({ |
| 1813 | 1747 | type: 'POST', |
| 1814 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1748 | + url: frm_js.ajax_url, | |
| 1815 | 1749 | data: { |
| 1816 | 1750 | action: 'frm_entries_send_email', |
| 1817 | 1751 | entry_id: entryId, |
| 1818 | 1752 | form_id: formId, |
| 1819 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1753 | + nonce: frm_js.nonce | |
| 1820 | 1754 | }, |
| 1821 | 1755 | success: function( msg ) { |
| 1822 | 1756 | $link.replaceWith( msg ); |
| 1823 | 1757 | } |