PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.4
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 -166 6.5.15.5.4 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.
@@ -490,45 +489,8 @@
490 489 }
491 490 }
492 491 }
493 492
494 - /**
495 - * Set color for select placeholders.
496 - *
497 - * @since 6.5.1
498 - */
499 - function setSelectPlaceholderColor() {
500 - var selects = document.querySelectorAll( '.form-field select' ),
501 - styleElement = document.querySelector( '.with_frm_style' ),
502 - textColorDisabled = styleElement ? getComputedStyle( styleElement ).getPropertyValue( '--text-color-disabled' ).trim() : '',
503 - changeSelectColor;
504 -
505 - // Exit if there are no select elements or the textColorDisabled property is missing
506 - if ( ! selects.length || ! textColorDisabled ) {
507 - return;
508 - }
509 -
510 - // Function to change the color of a select element
511 - changeSelectColor = function( select ) {
512 - if ( hasClass( select.options[select.selectedIndex], 'frm-select-placeholder' ) ) {
513 - select.style.setProperty( 'color', textColorDisabled, 'important' );
514 - } else {
515 - select.style.color = '';
516 - }
517 - };
518 -
519 - // Use a loop to iterate through each select element
520 - Array.prototype.forEach.call( selects, function( select ) {
521 - // Apply the color change to each select element
522 - changeSelectColor( select );
523 -
524 - // Add an event listener for future changes
525 - select.addEventListener( 'change', function() {
526 - changeSelectColor( select );
527 - });
528 - });
529 - }
530 -
531 493 function hasInvisibleRecaptcha( object ) {
532 494 var recaptcha, recaptchaID, alreadyChecked;
533 495
534 496 if ( isGoingToPrevPage( object ) ) {
@@ -622,14 +584,14 @@
622 584
623 585 fieldset = jQuery( object ).find( '.frm_form_field' );
624 586 fieldset.addClass( 'frm_doing_ajax' );
625 587
626 - 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;
627 589 shouldTriggerEvent = object.classList.contains( 'frm_trigger_event_on_submit' );
628 590
629 591 success = function( response ) {
630 592 var defaultResponse, formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
631 - $fieldCont, key, inCollapsedSection, frmTrigger, newTab;
593 + $fieldCont, key, inCollapsedSection, frmTrigger;
632 594
633 595 defaultResponse = {
634 596 content: '',
635 597 errors: {},
@@ -653,23 +615,10 @@
653 615 return;
654 616 }
655 617
656 618 jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
657 -
658 - if ( ! response.openInNewTab ) {
659 - // We return here because we're redirecting there is no need to update content.
660 - window.location = response.redirect;
661 - return;
662 - }
663 -
664 - // We don't return here because we're opening in a new tab, the old tab will still update.
665 - newTab = window.open( response.redirect, '_blank' );
666 - if ( ! newTab && response.fallbackMsg && response.content ) {
667 - response.content = response.content.trim().replace( /(<\/div><\/div>)$/, ' ' + response.fallbackMsg + '</div></div>' );
668 - }
669 - }
670 -
671 - if ( response.content !== '' ) {
619 + window.location = response.redirect;
620 + } else if ( response.content !== '' ) {
672 621 // the form or success message was returned
673 622
674 623 if ( shouldTriggerEvent ) {
675 624 triggerCustomEvent( object, 'frmSubmitEvent' );
@@ -676,9 +625,9 @@
676 625 return;
677 626 }
678 627
679 628 removeSubmitLoading( jQuery( object ) );
680 - if ( frm_js.offset != -1 ) { // eslint-disable-line camelcase
629 + if ( frm_js.offset != -1 ) {
681 630 frmFrontForm.scrollMsg( jQuery( object ), false );
682 631 }
683 632
684 633 formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
@@ -796,9 +745,9 @@
796 745
797 746 function postToAjaxUrl( form, data, success, error ) {
798 747 var ajaxUrl, action, ajaxParams;
799 748
800 - ajaxUrl = frm_js.ajax_url; // eslint-disable-line camelcase
749 + ajaxUrl = frm_js.ajax_url;
801 750 action = form.getAttribute( 'action' );
802 751
803 752 if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
804 753 ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
@@ -899,9 +848,9 @@
899 848 $fieldCont.append(
900 849 jsErrors[key]
901 850 );
902 851 } else {
903 - roleString = frm_js.include_alert_role ? 'role="alert"' : ''; // eslint-disable-line camelcase
852 + roleString = frm_js.include_alert_role ? 'role="alert"' : '';
904 853 $fieldCont.append( '<div class="frm_error" ' + roleString + ' id="' + id + '">' + jsErrors[key] + '</div>' );
905 854 }
906 855
907 856 if ( typeof describedBy === 'undefined' ) {
@@ -1047,14 +996,14 @@
1047 996 label.append( '<span class="frm-wait"></span>' );
1048 997
1049 998 jQuery.ajax({
1050 999 type: 'POST',
1051 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1000 + url: frm_js.ajax_url,
1052 1001 data: {
1053 1002 action: 'frm_entries_send_email',
1054 1003 entry_id: entryId,
1055 1004 form_id: formId,
1056 - nonce: frm_js.nonce // eslint-disable-line camelcase
1005 + nonce: frm_js.nonce
1057 1006 },
1058 1007 success: function( msg ) {
1059 1008 var admin = document.getElementById( 'wpbody' );
1060 1009 if ( admin === null ) {
@@ -1165,10 +1114,11 @@
1165 1114 }
1166 1115
1167 1116 function makeHoneypotFieldsUntabbable() {
1168 1117 document.querySelectorAll( '.frm_verify' ).forEach(
1169 - function( input ) {
1170 - if ( input.id && 0 === input.id.indexOf( 'frm_email_' ) ) {
1118 + function( wrapper ) {
1119 + var input = wrapper.querySelector( 'input[id^=frm_email]' );
1120 + if ( input ) {
1171 1121 input.setAttribute( 'tabindex', -1 );
1172 1122 }
1173 1123 }
1174 1124 );
@@ -1202,9 +1152,9 @@
1202 1152
1203 1153 function checkForErrorsAndMaybeSetFocus() {
1204 1154 var errors, element, timeoutCallback;
1205 1155
1206 - if ( ! frm_js.focus_first_error ) { // eslint-disable-line camelcase
1156 + if ( ! frm_js.focus_first_error ) {
1207 1157 return;
1208 1158 }
1209 1159
1210 1160 errors = document.querySelectorAll( '.frm_form_field .frm_error' );
@@ -1272,9 +1222,9 @@
1272 1222 var target;
1273 1223
1274 1224 // loop parent nodes from the target to the delegation node.
1275 1225 for ( target = e.target; target && target != this; target = target.parentNode ) {
1276 - if ( target && target.matches && target.matches( selector ) ) {
1226 + if ( target.matches( selector ) ) {
1277 1227 handler.call( target, e );
1278 1228 break;
1279 1229 }
1280 1230 }
@@ -1396,87 +1346,8 @@
1396 1346 runOnLoad();
1397 1347 });
1398 1348 }
1399 1349
1400 - function shouldUpdateValidityMessage( target ) {
1401 - if ( 'INPUT' !== target.nodeName ) {
1402 - return false;
1403 - }
1404 -
1405 - if ( ! target.dataset.invmsg ) {
1406 - return false;
1407 - }
1408 -
1409 - if ( 'text' !== target.getAttribute( 'type' ) ) {
1410 - return false;
1411 - }
1412 -
1413 - if ( target.classList.contains( 'frm_verify' ) ) {
1414 - return false;
1415 - }
1416 -
1417 - return true;
1418 - }
1419 -
1420 - function maybeClearCustomValidityMessage( event, field ) {
1421 - var key,
1422 - isInvalid = false;
1423 -
1424 - if ( ! shouldUpdateValidityMessage( field ) ) {
1425 - return;
1426 - }
1427 -
1428 - for ( key in field.validity ) {
1429 - if ( 'customError' === key ) {
1430 - continue;
1431 - }
1432 - if ( 'valid' !== key && field.validity[ key ] === true ) {
1433 - isInvalid = true;
1434 - break;
1435 - }
1436 - };
1437 -
1438 - if ( ! isInvalid ) {
1439 - field.setCustomValidity( '' );
1440 - }
1441 - }
1442 -
1443 - function maybeShowNewTabFallbackMessage() {
1444 - var messageEl;
1445 -
1446 - if ( ! window.frmShowNewTabFallback ) {
1447 - return;
1448 - }
1449 -
1450 - messageEl = document.querySelector( '#frm_form_' + frmShowNewTabFallback.formId + '_container .frm_message' );
1451 - if ( ! messageEl ) {
1452 - return;
1453 - }
1454 -
1455 - messageEl.insertAdjacentHTML( 'beforeend', ' ' + frmShowNewTabFallback.message );
1456 - }
1457 -
1458 - function setCustomValidityMessage() {
1459 - var forms, length, index;
1460 -
1461 - forms = document.getElementsByClassName( 'frm-show-form' );
1462 - length = forms.length;
1463 -
1464 - for ( index = 0; index < length; ++index ) {
1465 - forms[ index ].addEventListener(
1466 - 'invalid',
1467 - function( event ) {
1468 - var target = event.target;
1469 -
1470 - if ( shouldUpdateValidityMessage( target ) ) {
1471 - target.setCustomValidity( target.dataset.invmsg );
1472 - }
1473 - },
1474 - true
1475 - );
1476 - }
1477 - }
1478 -
1479 1350 return {
1480 1351 init: function() {
1481 1352 maybeAddPolyfills();
1482 1353
@@ -1512,18 +1383,8 @@
1512 1383 addTrimFallbackForIE(); // Trim only works in IE10+.
1513 1384 addFilterFallbackForIE(); // Filter is not supported in any version of IE.
1514 1385
1515 1386 initFloatingLabels();
1516 - maybeShowNewTabFallbackMessage();
1517 -
1518 - jQuery( document ).on( 'frmAfterAddRow', setCustomValidityMessage );
1519 - setCustomValidityMessage();
1520 - jQuery( document ).on( 'frmFieldChanged', maybeClearCustomValidityMessage );
1521 -
1522 - setSelectPlaceholderColor();
1523 -
1524 - // Elementor popup show event. Fix Elementor Popup && FF Captcha field conflicts
1525 - jQuery( document ).on( 'elementor/popup/show', frmRecaptcha );
1526 1387 },
1527 1388
1528 1389 getFieldId: function( field, fullID ) {
1529 1390 return getFieldId( field, fullID );
@@ -1727,12 +1588,12 @@
1727 1588 }
1728 1589
1729 1590 jQuery( scrollObj ).trigger( 'focus' );
1730 1591 newPos = scrollObj.offset().top;
1731 - if ( ! newPos || frm_js.offset === '-1' ) { // eslint-disable-line camelcase
1592 + if ( ! newPos || frm_js.offset === '-1' ) {
1732 1593 return;
1733 1594 }
1734 - newPos = newPos - frm_js.offset; // eslint-disable-line camelcase
1595 + newPos = newPos - frm_js.offset;
1735 1596
1736 1597 m = jQuery( 'html' ).css( 'margin-top' );
1737 1598 b = jQuery( 'body' ).css( 'margin-top' );
1738 1599 if ( m || b ) {
@@ -1835,11 +1696,9 @@
1835 1696 },
1836 1697
1837 1698 visible: function( classes ) {
1838 1699 jQuery( classes ).css( 'visibility', 'visible' );
1839 - },
1840 -
1841 - triggerCustomEvent: triggerCustomEvent
1700 + }
1842 1701 };
1843 1702 }
1844 1703 frmFrontForm = frmFrontFormJS();
1845 1704
@@ -1862,15 +1721,15 @@
1862 1721 function frmUpdateField( entryId, fieldId, value, message, num ) {
1863 1722 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).html( '<span class="frm-loading-img"></span>' );
1864 1723 jQuery.ajax({
1865 1724 type: 'POST',
1866 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1725 + url: frm_js.ajax_url,
1867 1726 data: {
1868 1727 action: 'frm_entries_update_field_ajax',
1869 1728 entry_id: entryId,
1870 1729 field_id: fieldId,
1871 1730 value: value,
1872 - nonce: frm_js.nonce // eslint-disable-line camelcase
1731 + nonce: frm_js.nonce
1873 1732 },
1874 1733 success: function() {
1875 1734 if ( message.replace( /^\s+|\s+$/g, '' ) === '' ) {
1876 1735 jQuery( document.getElementById( 'frm_update_field_' + entryId + '_' + fieldId + '_' + num ) ).fadeOut( 'slow' );
@@ -1885,13 +1744,13 @@
1885 1744 console.warn( 'DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry' );
1886 1745 jQuery( document.getElementById( 'frm_delete_' + entryId ) ).replaceWith( '<span class="frm-loading-img" id="frm_delete_' + entryId + '"></span>' );
1887 1746 jQuery.ajax({
1888 1747 type: 'POST',
1889 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1748 + url: frm_js.ajax_url,
1890 1749 data: {
1891 1750 action: 'frm_entries_destroy',
1892 1751 entry: entryId,
1893 - nonce: frm_js.nonce // eslint-disable-line camelcase
1752 + nonce: frm_js.nonce
1894 1753 },
1895 1754 success: function( html ) {
1896 1755 if ( html.replace( /^\s+|\s+$/g, '' ) === 'success' ) {
1897 1756 jQuery( document.getElementById( prefix + entryId ) ).fadeOut( 'slow' );
@@ -1912,14 +1771,14 @@
1912 1771 console.warn( 'DEPRECATED: function frm_resend_email in v2.0' );
1913 1772 $link.append( '<span class="spinner" style="display:inline"></span>' );
1914 1773 jQuery.ajax({
1915 1774 type: 'POST',
1916 - url: frm_js.ajax_url, // eslint-disable-line camelcase
1775 + url: frm_js.ajax_url,
1917 1776 data: {
1918 1777 action: 'frm_entries_send_email',
1919 1778 entry_id: entryId,
1920 1779 form_id: formId,
1921 - nonce: frm_js.nonce // eslint-disable-line camelcase
1780 + nonce: frm_js.nonce
1922 1781 },
1923 1782 success: function( msg ) {
1924 1783 $link.replaceWith( msg );
1925 1784 }