File: D:/HostingSpaces/netwerkbrabant/netwerkbrabant.nl/resources/assets/js/site/paymentMethodsHandler.js
/* ==========================================================================
Payment methods Handler
Currently only for one form in a page
========================================================================== */
const PaymentMethodsHandler = {
paymentMethodsElement: null,
init: function () {
PaymentMethodsHandler.paymentMethodsElement = document.querySelector('.payment-methods');
if (isset(PaymentMethodsHandler.paymentMethodsElement)) {
const radioButtons = PaymentMethodsHandler.paymentMethodsElement.querySelectorAll('.js-payment-methods-radio')
const nRadioButtons = radioButtons.length;
for (let i = 0; i < nRadioButtons; i++) {
const radioButton = radioButtons[i];
radioButton.addEventListener('change', function () {
// Get and remove the current selected state
const currentSelected = PaymentMethodsHandler.paymentMethodsElement.querySelector('.is-selected');
if (isset(currentSelected)) currentSelected.classList.remove('is-selected');
this.parentElement.classList.add('is-selected');
});
}
}
},
};
PaymentMethodsHandler.init();