Skip to content

Commit

Permalink
REMOVED: Make Sure we don't have selected hidden payment method when …
Browse files Browse the repository at this point in the history
…changing frequency or currency
  • Loading branch information
fernanDOTdo committed Jul 16, 2024
1 parent 900f22f commit 50d50f8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 81 deletions.
2 changes: 1 addition & 1 deletion dist/engrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* ENGRID PAGE TEMPLATE ASSETS
*
* Date: Tuesday, July 9, 2024 @ 22:43:41 ET
* Date: Tuesday, July 16, 2024 @ 11:05:51 ET
* By: fernando
* ENGrid styles: v0.18.18
* ENGrid scripts: v0.18.18
Expand Down
36 changes: 1 addition & 35 deletions dist/engrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* ENGRID PAGE TEMPLATE ASSETS
*
* Date: Tuesday, July 9, 2024 @ 22:43:41 ET
* Date: Tuesday, July 16, 2024 @ 11:05:51 ET
* By: fernando
* ENGrid styles: v0.18.18
* ENGrid scripts: v0.18.18
Expand Down Expand Up @@ -22289,40 +22289,6 @@ const customScript = function (App, EnForm) {

if (enFieldMobilePhone) {
enFieldMobilePhone.placeholder = "000-000-0000 (optional)";
} // Make Sure we don't have selected hidden payment method when changing frequency or currency


const isVisibile = el => !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);

const frequencyRadio = document.querySelectorAll("[name='transaction.recurrfreq']");
const currencySelect = document.querySelector("[name='transaction.paycurrency']");
const paymentMethodRadioWrapper = document.querySelectorAll(".give-by-select .en__field__item");

if (frequencyRadio && currencySelect && paymentMethodRadioWrapper) {
[...frequencyRadio, currencySelect].forEach(el => {
el.addEventListener("change", () => {
App.log("CHANGING");
window.setTimeout(() => {
// Get selected payment method
const selectedPaymentMethod = document.querySelector("[name='transaction.giveBySelect']:checked");

if (selectedPaymentMethod) {
const selectedPaymentContainer = selectedPaymentMethod.closest(".en__field__item"); // Check if selected payment method is hidden

if (!isVisibile(selectedPaymentContainer)) {
// If hidden, click on the first visible payment method
[...paymentMethodRadioWrapper].every(element => {
if (isVisibile(element)) {
App.log(`Clicking on ${element.querySelector("label").innerText}`);
element.querySelector("label").click();
return false;
}
});
}
}
}, 500);
});
});
}

const attriubtion = document.querySelector(".media-with-attribution figattribution");
Expand Down
2 changes: 1 addition & 1 deletion dist/engrid.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/engrid.min.js

Large diffs are not rendered by default.

42 changes: 0 additions & 42 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,48 +38,6 @@ export const customScript = function (App, EnForm) {
enFieldMobilePhone.placeholder = "000-000-0000 (optional)";
}

// Make Sure we don't have selected hidden payment method when changing frequency or currency
const isVisibile = (el) =>
!!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
const frequencyRadio = document.querySelectorAll(
"[name='transaction.recurrfreq']"
);
const currencySelect = document.querySelector(
"[name='transaction.paycurrency']"
);
const paymentMethodRadioWrapper = document.querySelectorAll(
".give-by-select .en__field__item"
);
if (frequencyRadio && currencySelect && paymentMethodRadioWrapper) {
[...frequencyRadio, currencySelect].forEach((el) => {
el.addEventListener("change", () => {
App.log("CHANGING");
window.setTimeout(() => {
// Get selected payment method
const selectedPaymentMethod = document.querySelector(
"[name='transaction.giveBySelect']:checked"
);
if (selectedPaymentMethod) {
const selectedPaymentContainer =
selectedPaymentMethod.closest(".en__field__item");
// Check if selected payment method is hidden
if (!isVisibile(selectedPaymentContainer)) {
// If hidden, click on the first visible payment method
[...paymentMethodRadioWrapper].every((element) => {
if (isVisibile(element)) {
App.log(
`Clicking on ${element.querySelector("label").innerText}`
);
element.querySelector("label").click();
return false;
}
});
}
}
}, 500);
});
});
}
const attriubtion = document.querySelector(
".media-with-attribution figattribution"
);
Expand Down

0 comments on commit 50d50f8

Please sign in to comment.