PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.3
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | js/formidable.js +25 -125 6.4.15.5.3 View file →
@@ -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 }
@@ -51,9 +50,9 @@
51 50
52 51 /**
53 52 * Triggers custom JS event.
54 53 *
55 - * @since 5.5.3
54 + * @since 5.x
56 55 *
57 56 * @param {HTMLElement} el The HTML element.
58 57 * @param {String} eventName Event name.
59 58 * @param {mixed} data The passed data.
@@ -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();
@@ -681,8 +667,9 @@
681 667 delay
682 668 );
683 669 } else if ( Object.keys( response.errors ).length ) {
684 670 // errors were returned
671 +
685 672 removeSubmitLoading( jQuery( object ), 'enable' );
686 673
687 674 //show errors
688 675 contSubmit = true;
@@ -712,9 +699,9 @@
712 699 }
713 700 }
714 701 }
715 702
716 - jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha, .h-captcha' ).each( function() {
703 + jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
717 704 var $recaptcha = jQuery( this ),
718 705 recaptchaID = $recaptcha.data( 'rid' );
719 706
720 707 if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
@@ -723,11 +710,8 @@
723 710 } else {
724 711 grecaptcha.reset();
725 712 }
726 713 }
727 - if ( typeof hcaptcha !== 'undefined' && hcaptcha ) {
728 - hcaptcha.reset();
729 - }
730 714 });
731 715
732 716 jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
733 717
@@ -759,9 +743,9 @@
759 743
760 744 function postToAjaxUrl( form, data, success, error ) {
761 745 var ajaxUrl, action, ajaxParams;
762 746
763 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
747 + ajaxUrl = frm_js.ajax_url;
764 748 action = form.getAttribute( 'action' );
765 749
766 750 if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
767 751 ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
@@ -862,9 +846,9 @@
862 846 $fieldCont.append(
863 847 jsErrors[key]
864 848 );
865 849 } else {
866 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
850 + roleString = frm_js.include_alert_role ? 'role="alert"' : '';
867 851 $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
868 852 }
869 853
870 854 if ( typeof describedBy === 'undefined' ) {
@@ -1010,14 +994,14 @@
1010 994 label.append( '<span class="frm-wait"></span>' );
1011 995
1012 996 jQuery.ajax({
1013 997 type: 'POST',
1014 - url: frm_js.ajax_url, // eslint-disable-line camelcase
998 + url: frm_js.ajax_url,
1015 999 data: {
1016 1000 action: 'frm_entries_send_email',
1017 1001 entry_id: entryId,
1018 1002 form_id: formId,
1019 - nonce: frm_js.nonce // eslint-disable-line camelcase
1003 + nonce: frm_js.nonce
1020 1004 },
1021 1005 success: function( msg ) {
1022 1006 var admin = document.getElementById( 'wpbody' );
1023 1007 if ( admin === null ) {
@@ -1144,11 +1128,11 @@
1144 1128 *
1145 1129 * @since 4.10.02
1146 1130 */
1147 1131 function changeFocusWhenClickComboFieldLabel() {
1148 - var label;
1132 + let label;
1149 1133
1150 - var comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1134 + const comboInputsContainer = document.querySelectorAll( '.frm_combo_inputs_container' );
1151 1135 comboInputsContainer.forEach( function( inputsContainer ) {
1152 1136 if ( ! inputsContainer.closest( '.frm_form_field' ) ) {
1153 1137 return;
1154 1138 }
@@ -1166,9 +1150,9 @@
1166 1150
1167 1151 function checkForErrorsAndMaybeSetFocus() {
1168 1152 var errors, element, timeoutCallback;
1169 1153
1170 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1154 + if ( ! frm_js.focus_first_error ) {
1171 1155 return;
1172 1156 }
1173 1157
1174 1158 errors = document.querySelectorAll( '.frm_form_field .frm_error' );
@@ -1236,9 +1220,9 @@
1236 1220 var target;
1237 1221
1238 1222 // loop parent nodes from the target to the delegation node.
1239 1223 for ( target = e.target; target && target != this; target = target.parentNode ) {
1240 - if ( target && target.matches && target.matches( selector ) ) {
1224 + if ( target.matches( selector ) ) {
1241 1225 handler.call( target, e );
1242 1226 break;
1243 1227 }
1244 1228 }
@@ -1360,87 +1344,8 @@
1360 1344 runOnLoad();
1361 1345 });
1362 1346 }
1363 1347
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 1348 return {
1444 1349 init: function() {
1445 1350 maybeAddPolyfills();
1446 1351
@@ -1476,13 +1381,8 @@
1476 1381 addTrimFallbackForIE(); // Trim only works in IE10+.
1477 1382 addFilterFallbackForIE(); // Filter is not supported in any version of IE.
1478 1383
1479 1384 initFloatingLabels();
1480 - maybeShowNewTabFallbackMessage();
1481 -
1482 - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage );
1483 - setCustomValidityMessage();
1484 - jQuery( document ).on( 'frmFieldChanged', maybeClearCustomValidityMessage );
1485 1385 },
1486 1386
1487 1387 getFieldId: function( field, fullID ) {
1488 1388 return getFieldId( field, fullID );
@@ -1686,12 +1586,12 @@
1686 1586 }
1687 1587
1688 1588 jQuery( scrollObj ).trigger( 'focus' );
1689 1589 newPos = scrollObj.offset().top;
1690 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1590 + if ( ! newPos || frm_js.offset === '-1' ) {
1691 1591 return;
1692 1592 }
1693 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1593 + newPos = newPos - frm_js.offset;
1694 1594
1695 1595 m = jQuery( 'html' ).css( 'margin-top' );
1696 1596 b = jQuery( 'body' ).css( 'margin-top' );
1697 1597 if ( m || b ) {
@@ -1819,15 +1719,15 @@
1819 1719 function frmUpdateField( entryId, fieldId, value, message, num ) {
1820 1720 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1821 1721 jQuery.ajax({
1822 1722 type: 'POST',
1823 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1723 + url: frm_js.ajax_url,
1824 1724 data: {
1825 1725 action: 'frm_entries_update_field_ajax',
1826 1726 entry_id: entryId,
1827 1727 field_id: fieldId,
1828 1728 value: value,
1829 - nonce: frm_js.nonce // eslint-disable-line camelcase
1729 + nonce: frm_js.nonce
1830 1730 },
1831 1731 success: function() {
1832 1732 if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1833 1733 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
@@ -1842,13 +1742,13 @@
1842 1742 console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1843 1743 jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1844 1744 jQuery.ajax({
1845 1745 type: 'POST',
1846 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1746 + url: frm_js.ajax_url,
1847 1747 data: {
1848 1748 action: 'frm_entries_destroy',
1849 1749 entry: entryId,
1850 - nonce: frm_js.nonce // eslint-disable-line camelcase
1750 + nonce: frm_js.nonce
1851 1751 },
1852 1752 success: function( html ) {
1853 1753 if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1854 1754 jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
@@ -1869,14 +1769,14 @@
1869 1769 console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1870 1770 $link.append( '<span class="spinner" style="display:inline"></span>' );
1871 1771 jQuery.ajax({
1872 1772 type: 'POST',
1873 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1773 + url: frm_js.ajax_url,
1874 1774 data: {
1875 1775 action: 'frm_entries_send_email',
1876 1776 entry_id: entryId,
1877 1777 form_id: formId,
1878 - nonce: frm_js.nonce // eslint-disable-line camelcase
1778 + nonce: frm_js.nonce
1879 1779 },
1880 1780 success: function( msg ) {
1881 1781 $link.replaceWith( msg );
1882 1782 }