PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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/admin/settings.js +1 -87 6.316.13 View file →
@@ -1,15 +1,9 @@
1 1 ( function() {
2 - 'use strict';
3 2
4 - const globalVars = {
5 - sendTestEmailModal: null
6 - };
7 -
8 3 function addEventListeners() {
9 4 document.addEventListener( 'change', handleChangeEvent );
10 5 document.addEventListener( 'keydown', handleKeyDownEvent );
11 - document.addEventListener( 'click', handleClickEvent );
12 6 }
13 7
14 8 function handleChangeEvent( e ) {
15 9 if ( 'INPUT' === e.target.nodeName && 'checkbox' === e.target.type && e.target.parentNode.classList.contains( 'frm_toggle_block' ) ) {
@@ -14,16 +8,12 @@
14 8 function handleChangeEvent( e ) {
15 9 if ( 'INPUT' === e.target.nodeName && 'checkbox' === e.target.type && e.target.parentNode.classList.contains( 'frm_toggle_block' ) ) {
16 10 handleToggleChangeEvent( e );
17 11 }
18 -
19 - if ( 'frm_currency' === e.target.id ) {
20 - syncCurrencyOptions( e.target );
21 - }
22 12 }
23 13
24 14 function handleKeyDownEvent( e ) {
25 - switch ( e.key ) { // eslint-disable-line sonarjs/no-small-switch
15 + switch ( e.key ) {
26 16 case ' ':
27 17 handleSpaceDownEvent( e );
28 18 break;
29 19 }
@@ -30,84 +20,8 @@
30 20 }
31 21
32 22 function handleToggleChangeEvent( e ) {
33 23 e.target.nextElementSibling.setAttribute( 'aria-checked', e.target.checked ? 'true' : 'false' );
34 - }
35 -
36 - function handleClickEvent( e ) {
37 - if ( 'BUTTON' === e.target.nodeName && 'choose' === e.target.dataset.action && e.target.closest( '.frm-email-style' ) ) {
38 - handleClickChooseEmailStyle( e );
39 - return;
40 - }
41 -
42 - if ( 'frm-send-test-email' === e.target.id ) {
43 - showSendTestEmailModal();
44 - return;
45 - }
46 -
47 - if ( 'frm-send-test-email-btn' === e.target.id ) {
48 - handleClickSendTestEmailBtn();
49 - }
50 - }
51 -
52 - function handleClickChooseEmailStyle( e ) {
53 - const styleEls = document.querySelectorAll( '.frm-email-style' );
54 - styleEls.forEach( el => {
55 - el.classList.remove( 'frm-email-style--selected' );
56 - } );
57 -
58 - const styleEl = e.target.closest( '.frm-email-style' );
59 - styleEl.classList.add( 'frm-email-style--selected' );
60 -
61 - const { styleKey } = styleEl.dataset;
62 - document.getElementById( 'frm-email-style-value' ).value = styleKey;
63 - }
64 -
65 - function showSendTestEmailModal() {
66 - if ( ! globalVars.sendTestEmailModal ) {
67 - globalVars.sendTestEmailModal = frmAdminBuild.initModal( '#frm-send-test-email-modal', '400px' );
68 - }
69 -
70 - globalVars.sendTestEmailModal.dialog( 'open' );
71 - }
72 -
73 - function handleClickSendTestEmailBtn() {
74 - const emailInput = document.getElementById( 'frm-test-email-address' );
75 - const resultEl = document.getElementById( 'frm-send-test-email-result' );
76 -
77 - const showResult = ( msg, success ) => {
78 - resultEl.textContent = msg;
79 - resultEl.classList.add( success ? 'frm_updated_message' : 'frm_error_style' );
80 - };
81 -
82 - resultEl.textContent = '';
83 - resultEl.classList.remove( 'frm_error_style', 'frm_updated_message' );
84 -
85 - if ( ! emailInput.value ) {
86 - showResult( 'Empty email address' );
87 - return;
88 - }
89 -
90 - const data = new FormData();
91 - data.append( 'emails_str', emailInput.value );
92 - frmDom.ajax.doJsonPost( 'send_test_email', data ).then( response => {
93 - showResult( response, true );
94 - } ).catch( error => {
95 - showResult( error );
96 - } );
97 - }
98 -
99 - /**
100 - * Updates the currency formatting options based on the selected currency.
101 - *
102 - * @param {HTMLSelectElement} currencySelect The currency select element.
103 - */
104 - function syncCurrencyOptions( currencySelect ) {
105 - const currency = frmSettings.currencies[ currencySelect.value ];
106 -
107 - document.getElementById( 'frm_thousand_separator' ).value = currency.thousand_separator;
108 - document.getElementById( 'frm_decimal_separator' ).value = currency.decimal_separator;
109 - document.getElementById( 'frm_decimals' ).value = currency.decimals;
110 24 }
111 25
112 26 function handleSpaceDownEvent( e ) {
113 27 if ( e.target.classList.contains( 'frm_toggle' ) ) {