PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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
formidable / js / admin / settings.js

settings.js in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.24, at js/admin/settings.js

51 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function() {
2 function addEventListeners() {
3 document.addEventListener( 'change', handleChangeEvent );
4 document.addEventListener( 'keydown', handleKeyDownEvent );
5 }
6
7 function handleChangeEvent( e ) {
8 if ( 'INPUT' === e.target.nodeName && 'checkbox' === e.target.type && e.target.parentNode.classList.contains( 'frm_toggle_block' ) ) {
9 handleToggleChangeEvent( e );
10 }
11
12 if ( 'frm_currency' === e.target.id ) {
13 syncCurrencyOptions( e.target );
14 }
15 }
16
17 function handleKeyDownEvent( e ) {
18 switch ( e.key ) { // eslint-disable-line sonarjs/no-small-switch
19 case ' ':
20 handleSpaceDownEvent( e );
21 break;
22 }
23 }
24
25 function handleToggleChangeEvent( e ) {
26 e.target.nextElementSibling.setAttribute( 'aria-checked', e.target.checked ? 'true' : 'false' );
27 }
28
29 /**
30 * Updates the currency formatting options based on the selected currency.
31 *
32 * @param {HTMLSelectElement} currencySelect The currency select element.
33 */
34 function syncCurrencyOptions( currencySelect ) {
35 const currency = frmSettings.currencies[ currencySelect.value ];
36
37 document.getElementById( 'frm_thousand_separator' ).value = currency.thousand_separator;
38 document.getElementById( 'frm_decimal_separator' ).value = currency.decimal_separator;
39 document.getElementById( 'frm_decimals' ).value = currency.decimals;
40 }
41
42 function handleSpaceDownEvent( e ) {
43 if ( e.target.classList.contains( 'frm_toggle' ) ) {
44 e.preventDefault(); // Prevent automatic browser scroll when space is pressed.
45 e.target.click();
46 }
47 }
48
49 addEventListeners();
50 }() );
51