| @@ -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 | } |
| @@ -585,14 +584,14 @@ | ||
| 585 | 584 | |
| 586 | 585 | fieldset = jQuery( object ).find( '.frm_form_field' ); |
| 587 | 586 | fieldset.addClass( 'frm_doing_ajax' ); |
| 588 | 587 | |
| 589 | - data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; // eslint-disable-line camelcase | |
| 588 | + data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce; | |
| 590 | 589 | shouldTriggerEvent = object.classList.contains( 'frm_trigger_event_on_submit' ); |
| 591 | 590 | |
| 592 | 591 | success = function( response ) { |
| 593 | 592 | var defaultResponse, formID, replaceContent, pageOrder, formReturned, contSubmit, delay, |
| 594 | - $fieldCont, key, inCollapsedSection, frmTrigger, newTab; | |
| 593 | + $fieldCont, key, inCollapsedSection, frmTrigger; | |
| 595 | 594 | |
| 596 | 595 | defaultResponse = { |
| 597 | 596 | content: '', |
| 598 | 597 | errors: {}, |
| @@ -616,23 +615,10 @@ | ||
| 616 | 615 | return; |
| 617 | 616 | } |
| 618 | 617 | |
| 619 | 618 | 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 !== '' ) { | |
| 619 | + window.location = response.redirect; | |
| 620 | + } else if ( response.content !== '' ) { | |
| 635 | 621 | // the form or success message was returned |
| 636 | 622 | |
| 637 | 623 | if ( shouldTriggerEvent ) { |
| 638 | 624 | triggerCustomEvent( object, 'frmSubmitEvent' ); |
| @@ -639,9 +625,9 @@ | ||
| 639 | 625 | return; |
| 640 | 626 | } |
| 641 | 627 | |
| 642 | 628 | removeSubmitLoading( jQuery( object ) ); |
| 643 | - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase | |
| 629 | + if ( frm_js.offset != -1 ) { | |
| 644 | 630 | frmFrontForm.scrollMsg( jQuery( object ), false ); |
| 645 | 631 | } |
| 646 | 632 | |
| 647 | 633 | formID = jQuery( object ).find( 'input[name="form_id"]' ).val(); |
| @@ -759,9 +745,9 @@ | ||
| 759 | 745 | |
| 760 | 746 | function postToAjaxUrl( form, data, success, error ) { |
| 761 | 747 | var ajaxUrl, action, ajaxParams; |
| 762 | 748 | |
| 763 | - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase | |
| 749 | + ajaxUrl = frm_js.ajax_url; | |
| 764 | 750 | action = form.getAttribute( 'action' ); |
| 765 | 751 | |
| 766 | 752 | if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) { |
| 767 | 753 | ajaxUrl = action.split( '?action=frm_forms_preview' )[0]; |
| @@ -862,9 +848,9 @@ | ||
| 862 | 848 | $fieldCont.append( |
| 863 | 849 | jsErrors[key] |
| 864 | 850 | ); |
| 865 | 851 | } else { |
| 866 | - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase | |
| 852 | + roleString = frm_js.include_alert_role ? 'role="alert"' : ''; | |
| 867 | 853 | $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' ); |
| 868 | 854 | } |
| 869 | 855 | |
| 870 | 856 | if ( typeof describedBy === 'undefined' ) { |
| @@ -1010,14 +996,14 @@ | ||
| 1010 | 996 | label.append( '<span class="frm-wait"></span>' ); |
| 1011 | 997 | |
| 1012 | 998 | jQuery.ajax({ |
| 1013 | 999 | type: 'POST', |
| 1014 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1000 | + url: frm_js.ajax_url, | |
| 1015 | 1001 | data: { |
| 1016 | 1002 | action: 'frm_entries_send_email', |
| 1017 | 1003 | entry_id: entryId, |
| 1018 | 1004 | form_id: formId, |
| 1019 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1005 | + nonce: frm_js.nonce | |
| 1020 | 1006 | }, |
| 1021 | 1007 | success: function( msg ) { |
| 1022 | 1008 | var admin = document.getElementById( 'wpbody' ); |
| 1023 | 1009 | if ( admin === null ) { |
| @@ -1166,9 +1152,9 @@ | ||
| 1166 | 1152 | |
| 1167 | 1153 | function checkForErrorsAndMaybeSetFocus() { |
| 1168 | 1154 | var errors, element, timeoutCallback; |
| 1169 | 1155 | |
| 1170 | - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase | |
| 1156 | + if ( ! frm_js.focus_first_error ) { | |
| 1171 | 1157 | return; |
| 1172 | 1158 | } |
| 1173 | 1159 | |
| 1174 | 1160 | errors = document.querySelectorAll( '.frm_form_field .frm_error' ); |
| @@ -1360,87 +1346,8 @@ | ||
| 1360 | 1346 | runOnLoad(); |
| 1361 | 1347 | }); |
| 1362 | 1348 | } |
| 1363 | 1349 | |
| 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 | 1350 | return { |
| 1444 | 1351 | init: function() { |
| 1445 | 1352 | maybeAddPolyfills(); |
| 1446 | 1353 | |
| @@ -1476,13 +1383,8 @@ | ||
| 1476 | 1383 | addTrimFallbackForIE(); // Trim only works in IE10+. |
| 1477 | 1384 | addFilterFallbackForIE(); // Filter is not supported in any version of IE. |
| 1478 | 1385 | |
| 1479 | 1386 | initFloatingLabels(); |
| 1480 | - maybeShowNewTabFallbackMessage(); | |
| 1481 | - | |
| 1482 | - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage ); | |
| 1483 | - setCustomValidityMessage(); | |
| 1484 | - jQuery( document ).on( 'frmFieldChanged', maybeClearCustomValidityMessage ); | |
| 1485 | 1387 | }, |
| 1486 | 1388 | |
| 1487 | 1389 | getFieldId: function( field, fullID ) { |
| 1488 | 1390 | return getFieldId( field, fullID ); |
| @@ -1686,12 +1588,12 @@ | ||
| 1686 | 1588 | } |
| 1687 | 1589 | |
| 1688 | 1590 | jQuery( scrollObj ).trigger( 'focus' ); |
| 1689 | 1591 | newPos = scrollObj.offset().top; |
| 1690 | - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase | |
| 1592 | + if ( ! newPos || frm_js.offset === '-1' ) { | |
| 1691 | 1593 | return; |
| 1692 | 1594 | } |
| 1693 | - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase | |
| 1595 | + newPos = newPos - frm_js.offset; | |
| 1694 | 1596 | |
| 1695 | 1597 | m = jQuery( 'html' ).css( 'margin-top' ); |
| 1696 | 1598 | b = jQuery( 'body' ).css( 'margin-top' ); |
| 1697 | 1599 | if ( m || b ) { |
| @@ -1794,11 +1696,9 @@ | ||
| 1794 | 1696 | }, |
| 1795 | 1697 | |
| 1796 | 1698 | visible: function( classes ) { |
| 1797 | 1699 | jQuery( classes ).css( 'visibility', 'visible' ); |
| 1798 | - }, | |
| 1799 | - | |
| 1800 | - triggerCustomEvent: triggerCustomEvent | |
| 1700 | + } | |
| 1801 | 1701 | }; |
| 1802 | 1702 | } |
| 1803 | 1703 | frmFrontForm = frmFrontFormJS(); |
| 1804 | 1704 | |
| @@ -1821,15 +1721,15 @@ | ||
| 1821 | 1721 | function frmUpdateField( entryId, fieldId, value, message, num ) { |
| 1822 | 1722 | jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' ); |
| 1823 | 1723 | jQuery.ajax({ |
| 1824 | 1724 | type: 'POST', |
| 1825 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1725 | + url: frm_js.ajax_url, | |
| 1826 | 1726 | data: { |
| 1827 | 1727 | action: 'frm_entries_update_field_ajax', |
| 1828 | 1728 | entry_id: entryId, |
| 1829 | 1729 | field_id: fieldId, |
| 1830 | 1730 | value: value, |
| 1831 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1731 | + nonce: frm_js.nonce | |
| 1832 | 1732 | }, |
| 1833 | 1733 | success: function() { |
| 1834 | 1734 | if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) { |
| 1835 | 1735 | jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' ); |
| @@ -1844,13 +1744,13 @@ | ||
| 1844 | 1744 | console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' ); |
| 1845 | 1745 | jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' ); |
| 1846 | 1746 | jQuery.ajax({ |
| 1847 | 1747 | type: 'POST', |
| 1848 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1748 | + url: frm_js.ajax_url, | |
| 1849 | 1749 | data: { |
| 1850 | 1750 | action: 'frm_entries_destroy', |
| 1851 | 1751 | entry: entryId, |
| 1852 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1752 | + nonce: frm_js.nonce | |
| 1853 | 1753 | }, |
| 1854 | 1754 | success: function( html ) { |
| 1855 | 1755 | if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) { |
| 1856 | 1756 | jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' ); |
| @@ -1871,14 +1771,14 @@ | ||
| 1871 | 1771 | console.warn( 'DEPRECATED: function frm_resend_email in v2.0' ); |
| 1872 | 1772 | $link.append( '<span class="spinner" style="display:inline"></span>' ); |
| 1873 | 1773 | jQuery.ajax({ |
| 1874 | 1774 | type: 'POST', |
| 1875 | - url: frm_js.ajax_url, // eslint-disable-line camelcase | |
| 1775 | + url: frm_js.ajax_url, | |
| 1876 | 1776 | data: { |
| 1877 | 1777 | action: 'frm_entries_send_email', |
| 1878 | 1778 | entry_id: entryId, |
| 1879 | 1779 | form_id: formId, |
| 1880 | - nonce: frm_js.nonce // eslint-disable-line camelcase | |
| 1780 | + nonce: frm_js.nonce | |
| 1881 | 1781 | }, |
| 1882 | 1782 | success: function( msg ) { |
| 1883 | 1783 | $link.replaceWith( msg ); |
| 1884 | 1784 | } |