@4site/engrid-scripts 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.js +226 -0
- package/LICENSE +24 -0
- package/dist/a11y.d.ts +6 -0
- package/dist/a11y.js +46 -0
- package/dist/add-name-to-message.d.ts +5 -0
- package/dist/add-name-to-message.js +49 -0
- package/dist/advocacy.d.ts +7 -0
- package/dist/advocacy.js +34 -0
- package/dist/amount-label.d.ts +6 -0
- package/dist/amount-label.js +29 -0
- package/dist/app.d.ts +19 -0
- package/dist/app.js +340 -0
- package/dist/apple-pay.d.ts +13 -0
- package/dist/apple-pay.js +169 -0
- package/dist/auto-country-select.d.ts +10 -0
- package/dist/auto-country-select.js +63 -0
- package/dist/auto-year.d.ts +7 -0
- package/dist/auto-year.js +35 -0
- package/dist/autocomplete.d.ts +5 -0
- package/dist/autocomplete.js +38 -0
- package/dist/autosubmit.d.ts +5 -0
- package/dist/autosubmit.js +14 -0
- package/dist/branding-html.d.ts +14 -0
- package/dist/branding-html.js +70 -0
- package/dist/capitalize-fields.d.ts +7 -0
- package/dist/capitalize-fields.js +22 -0
- package/dist/click-to-expand.d.ts +4 -0
- package/dist/click-to-expand.js +39 -0
- package/dist/cookie.d.ts +53 -0
- package/dist/cookie.js +76 -0
- package/dist/country-disable.d.ts +4 -0
- package/dist/country-disable.js +22 -0
- package/dist/country-redirect.d.ts +7 -0
- package/dist/country-redirect.js +61 -0
- package/dist/custom-currency.d.ts +9 -0
- package/dist/custom-currency.js +112 -0
- package/dist/data-attributes.d.ts +5 -0
- package/dist/data-attributes.js +122 -0
- package/dist/data-hide.d.ts +15 -0
- package/dist/data-hide.js +66 -0
- package/dist/data-layer.d.ts +23 -0
- package/dist/data-layer.js +312 -0
- package/dist/data-replace.d.ts +26 -0
- package/dist/data-replace.js +76 -0
- package/dist/debug-hidden-fields.d.ts +4 -0
- package/dist/debug-hidden-fields.js +42 -0
- package/dist/debug-panel.d.ts +27 -0
- package/dist/debug-panel.js +508 -0
- package/dist/deprecated.d.ts +5 -0
- package/dist/deprecated.js +40 -0
- package/dist/digital-wallets.d.ts +8 -0
- package/dist/digital-wallets.js +143 -0
- package/dist/ecard-to-target.d.ts +11 -0
- package/dist/ecard-to-target.js +73 -0
- package/dist/ecard.d.ts +8 -0
- package/dist/ecard.js +61 -0
- package/dist/embedded-ecard.d.ts +18 -0
- package/dist/embedded-ecard.js +267 -0
- package/dist/en-validators.d.ts +10 -0
- package/dist/en-validators.js +89 -0
- package/dist/engrid.d.ts +49 -0
- package/dist/engrid.js +547 -0
- package/dist/event-tickets.d.ts +3 -0
- package/dist/event-tickets.js +24 -0
- package/dist/events/country.d.ts +12 -0
- package/dist/events/country.js +42 -0
- package/dist/events/donation-amount.d.ts +16 -0
- package/dist/events/donation-amount.js +119 -0
- package/dist/events/donation-frequency.d.ts +17 -0
- package/dist/events/donation-frequency.js +115 -0
- package/dist/events/en-form.d.ts +20 -0
- package/dist/events/en-form.js +52 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/index.js +6 -0
- package/dist/events/processing-fees.d.ts +20 -0
- package/dist/events/processing-fees.js +92 -0
- package/dist/events/remember-me-events.d.ts +18 -0
- package/dist/events/remember-me-events.js +36 -0
- package/dist/exit-intent-lightbox.d.ts +14 -0
- package/dist/exit-intent-lightbox.js +145 -0
- package/dist/expand-region-name.d.ts +7 -0
- package/dist/expand-region-name.js +44 -0
- package/dist/fast-form-fill.d.ts +8 -0
- package/dist/fast-form-fill.js +75 -0
- package/dist/freshaddress.d.ts +18 -0
- package/dist/freshaddress.js +204 -0
- package/dist/give-by-select.d.ts +9 -0
- package/dist/give-by-select.js +82 -0
- package/dist/iframe.d.ts +16 -0
- package/dist/iframe.js +217 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +84 -0
- package/dist/input-has-value-and-focus.d.ts +9 -0
- package/dist/input-has-value-and-focus.js +50 -0
- package/dist/input-placeholders.d.ts +7 -0
- package/dist/input-placeholders.js +82 -0
- package/dist/interfaces/ecard-to-target-options.d.ts +9 -0
- package/dist/interfaces/ecard-to-target-options.js +8 -0
- package/dist/interfaces/embedded-ecard-options.d.ts +8 -0
- package/dist/interfaces/embedded-ecard-options.js +7 -0
- package/dist/interfaces/exit-intent-options.d.ts +13 -0
- package/dist/interfaces/exit-intent-options.js +13 -0
- package/dist/interfaces/options.d.ts +147 -0
- package/dist/interfaces/options.js +50 -0
- package/dist/interfaces/translate-options.d.ts +7 -0
- package/dist/interfaces/translate-options.js +42 -0
- package/dist/interfaces/upsell-options.d.ts +24 -0
- package/dist/interfaces/upsell-options.js +33 -0
- package/dist/live-currency.d.ts +15 -0
- package/dist/live-currency.js +140 -0
- package/dist/live-frequency.d.ts +13 -0
- package/dist/live-frequency.js +109 -0
- package/dist/live-variables.d.ts +21 -0
- package/dist/live-variables.js +147 -0
- package/dist/loader.d.ts +10 -0
- package/dist/loader.js +175 -0
- package/dist/logger.d.ts +16 -0
- package/dist/logger.js +84 -0
- package/dist/media-attribution.d.ts +4 -0
- package/dist/media-attribution.js +66 -0
- package/dist/menu.d.ts +0 -0
- package/dist/menu.js +1 -0
- package/dist/min-max-amount.d.ts +13 -0
- package/dist/min-max-amount.js +71 -0
- package/dist/mobile-cta.d.ts +9 -0
- package/dist/mobile-cta.js +71 -0
- package/dist/modal.d.ts +19 -0
- package/dist/modal.js +129 -0
- package/dist/neverbounce.d.ts +23 -0
- package/dist/neverbounce.js +244 -0
- package/dist/other-amount.d.ts +6 -0
- package/dist/other-amount.js +70 -0
- package/dist/page-background.d.ts +7 -0
- package/dist/page-background.js +55 -0
- package/dist/plaid.d.ts +6 -0
- package/dist/plaid.js +49 -0
- package/dist/postal-code-validator.d.ts +20 -0
- package/dist/postal-code-validator.js +118 -0
- package/dist/premium-gift.d.ts +10 -0
- package/dist/premium-gift.js +115 -0
- package/dist/progress-bar.d.ts +3 -0
- package/dist/progress-bar.js +40 -0
- package/dist/remember-me.d.ts +61 -0
- package/dist/remember-me.js +358 -0
- package/dist/required-if-visible.d.ts +8 -0
- package/dist/required-if-visible.js +60 -0
- package/dist/set-attr.d.ts +4 -0
- package/dist/set-attr.js +31 -0
- package/dist/set-recurr-freq.d.ts +7 -0
- package/dist/set-recurr-freq.js +70 -0
- package/dist/show-hide-radio-checkboxes.d.ts +13 -0
- package/dist/show-hide-radio-checkboxes.js +161 -0
- package/dist/show-if-amount.d.ts +15 -0
- package/dist/show-if-amount.js +117 -0
- package/dist/show-if-present.d.ts +7 -0
- package/dist/show-if-present.js +79 -0
- package/dist/skip-link.d.ts +4 -0
- package/dist/skip-link.js +36 -0
- package/dist/src-defer.d.ts +6 -0
- package/dist/src-defer.js +70 -0
- package/dist/supporter-hub.d.ts +9 -0
- package/dist/supporter-hub.js +75 -0
- package/dist/swap-amounts.d.ts +45 -0
- package/dist/swap-amounts.js +81 -0
- package/dist/thank-you-page-conditional-content.d.ts +8 -0
- package/dist/thank-you-page-conditional-content.js +46 -0
- package/dist/ticker.d.ts +11 -0
- package/dist/ticker.js +66 -0
- package/dist/tidycontact.d.ts +46 -0
- package/dist/tidycontact.js +1202 -0
- package/dist/translate-fields.d.ts +12 -0
- package/dist/translate-fields.js +548 -0
- package/dist/universal-opt-in.d.ts +7 -0
- package/dist/universal-opt-in.js +91 -0
- package/dist/upsell-lightbox.d.ts +31 -0
- package/dist/upsell-lightbox.js +363 -0
- package/dist/url-params-to-body-attrs.d.ts +5 -0
- package/dist/url-params-to-body-attrs.js +14 -0
- package/dist/url-to-form.d.ts +7 -0
- package/dist/url-to-form.js +32 -0
- package/dist/us-only-form.d.ts +4 -0
- package/dist/us-only-form.js +30 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/vgs.d.ts +16 -0
- package/dist/vgs.js +250 -0
- package/dist/welcome-back.d.ts +10 -0
- package/dist/welcome-back.js +112 -0
- package/package.json +32 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class EventTickets {
|
|
2
|
+
constructor() {
|
|
3
|
+
// --------------------------------------------
|
|
4
|
+
// Format ticket amounts as currency.
|
|
5
|
+
const ticketCostElements = document.getElementsByClassName("en__ticket__field--cost");
|
|
6
|
+
const ticketCurrencyElements = document.getElementsByClassName("en__ticket__currency");
|
|
7
|
+
for (const ticketCurrencyElement of ticketCurrencyElements) {
|
|
8
|
+
ticketCurrencyElement.classList.add("en__ticket__currency__hidden");
|
|
9
|
+
}
|
|
10
|
+
for (const ticketCostElement of ticketCostElements) {
|
|
11
|
+
const ticketAmountElement = ticketCostElement.getElementsByClassName("en__ticket__price")[0];
|
|
12
|
+
const ticketCurrencyElement = ticketCostElement.getElementsByClassName("en__ticket__currency")[0];
|
|
13
|
+
const formatterOptions = {
|
|
14
|
+
style: "currency",
|
|
15
|
+
currency: ticketCurrencyElement.innerText,
|
|
16
|
+
};
|
|
17
|
+
let ticketAmountAsCurrency = Intl.NumberFormat(undefined, formatterOptions).format(Number(ticketAmountElement.innerText));
|
|
18
|
+
if (ticketAmountAsCurrency.slice(-3) === ".00") {
|
|
19
|
+
ticketAmountAsCurrency = ticketAmountAsCurrency.slice(0, -3);
|
|
20
|
+
}
|
|
21
|
+
ticketAmountElement.innerText = ticketAmountAsCurrency;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class Country {
|
|
2
|
+
private _onCountryChange;
|
|
3
|
+
private _country;
|
|
4
|
+
private _field;
|
|
5
|
+
private static instance;
|
|
6
|
+
constructor();
|
|
7
|
+
static getInstance(): Country;
|
|
8
|
+
get countryField(): HTMLElement | null;
|
|
9
|
+
get onCountryChange(): import("strongly-typed-events").ISimpleEvent<string>;
|
|
10
|
+
get country(): string;
|
|
11
|
+
set country(value: string);
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SimpleEventDispatcher } from "strongly-typed-events";
|
|
2
|
+
import { ENGrid } from "../engrid";
|
|
3
|
+
export class Country {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._onCountryChange = new SimpleEventDispatcher();
|
|
6
|
+
this._country = "";
|
|
7
|
+
this._field = null;
|
|
8
|
+
// Run only if it is a Page with a Country field
|
|
9
|
+
this._field = document.getElementById("en__field_supporter_country");
|
|
10
|
+
if (!this._field) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
document.addEventListener("change", (e) => {
|
|
14
|
+
const element = e.target;
|
|
15
|
+
if (element && element.name == "supporter.country") {
|
|
16
|
+
this.country = element.value;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
// Set the country to the current value on the field
|
|
20
|
+
this.country = ENGrid.getFieldValue("supporter.country");
|
|
21
|
+
}
|
|
22
|
+
static getInstance() {
|
|
23
|
+
if (!Country.instance) {
|
|
24
|
+
Country.instance = new Country();
|
|
25
|
+
}
|
|
26
|
+
return Country.instance;
|
|
27
|
+
}
|
|
28
|
+
get countryField() {
|
|
29
|
+
return this._field;
|
|
30
|
+
}
|
|
31
|
+
get onCountryChange() {
|
|
32
|
+
return this._onCountryChange.asEvent();
|
|
33
|
+
}
|
|
34
|
+
get country() {
|
|
35
|
+
return this._country;
|
|
36
|
+
}
|
|
37
|
+
// Every time we set a country, trigger the onCountryChange event
|
|
38
|
+
set country(value) {
|
|
39
|
+
this._country = value;
|
|
40
|
+
this._onCountryChange.dispatch(this._country);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class DonationAmount {
|
|
2
|
+
private _onAmountChange;
|
|
3
|
+
private _amount;
|
|
4
|
+
private _radios;
|
|
5
|
+
private _other;
|
|
6
|
+
private _dispatch;
|
|
7
|
+
private static instance;
|
|
8
|
+
private constructor();
|
|
9
|
+
static getInstance(radios?: string, other?: string): DonationAmount;
|
|
10
|
+
get amount(): number;
|
|
11
|
+
set amount(value: number);
|
|
12
|
+
get onAmountChange(): import("strongly-typed-events").ISimpleEvent<number>;
|
|
13
|
+
load(): void;
|
|
14
|
+
setAmount(amount: number, dispatch?: boolean): void;
|
|
15
|
+
clearOther(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { SimpleEventDispatcher } from "strongly-typed-events";
|
|
2
|
+
import { ENGrid } from "..";
|
|
3
|
+
export class DonationAmount {
|
|
4
|
+
constructor(radios = "transaction.donationAmt", other = "transaction.donationAmt.other") {
|
|
5
|
+
this._onAmountChange = new SimpleEventDispatcher();
|
|
6
|
+
this._amount = 0;
|
|
7
|
+
this._radios = "";
|
|
8
|
+
this._other = "";
|
|
9
|
+
this._dispatch = true;
|
|
10
|
+
this._other = other;
|
|
11
|
+
this._radios = radios;
|
|
12
|
+
// Watch Radios Inputs for Changes
|
|
13
|
+
document.addEventListener("change", (e) => {
|
|
14
|
+
const element = e.target;
|
|
15
|
+
if (element) {
|
|
16
|
+
if (element.name == radios) {
|
|
17
|
+
this.amount = parseFloat(element.value);
|
|
18
|
+
}
|
|
19
|
+
else if (element.name == other) {
|
|
20
|
+
const cleanedAmount = ENGrid.cleanAmount(element.value);
|
|
21
|
+
element.value =
|
|
22
|
+
cleanedAmount % 1 != 0
|
|
23
|
+
? cleanedAmount.toFixed(2)
|
|
24
|
+
: cleanedAmount.toString();
|
|
25
|
+
this.amount = cleanedAmount;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
// Watch Other Amount Field
|
|
30
|
+
const otherField = document.querySelector(`[name='${this._other}']`);
|
|
31
|
+
if (otherField) {
|
|
32
|
+
otherField.addEventListener("keyup", (e) => {
|
|
33
|
+
this.amount = ENGrid.cleanAmount(otherField.value);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
static getInstance(radios = "transaction.donationAmt", other = "transaction.donationAmt.other") {
|
|
38
|
+
if (!DonationAmount.instance) {
|
|
39
|
+
DonationAmount.instance = new DonationAmount(radios, other);
|
|
40
|
+
}
|
|
41
|
+
return DonationAmount.instance;
|
|
42
|
+
}
|
|
43
|
+
get amount() {
|
|
44
|
+
return this._amount;
|
|
45
|
+
}
|
|
46
|
+
// Every time we set an amount, trigger the onAmountChange event
|
|
47
|
+
set amount(value) {
|
|
48
|
+
this._amount = value || 0;
|
|
49
|
+
if (this._dispatch)
|
|
50
|
+
this._onAmountChange.dispatch(this._amount);
|
|
51
|
+
}
|
|
52
|
+
get onAmountChange() {
|
|
53
|
+
return this._onAmountChange.asEvent();
|
|
54
|
+
}
|
|
55
|
+
// Set amount var with currently selected amount
|
|
56
|
+
load() {
|
|
57
|
+
const currentAmountField = document.querySelector('input[name="' + this._radios + '"]:checked');
|
|
58
|
+
if (currentAmountField) {
|
|
59
|
+
let currentAmountValue = parseFloat(currentAmountField.value || "");
|
|
60
|
+
if (currentAmountValue > 0) {
|
|
61
|
+
this.amount = parseFloat(currentAmountField.value);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const otherField = document.querySelector('input[name="' + this._other + '"]');
|
|
65
|
+
currentAmountValue = ENGrid.cleanAmount(otherField.value);
|
|
66
|
+
this.amount = currentAmountValue;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (ENGrid.checkNested(window.EngagingNetworks, "require", "_defined", "enjs", "getDonationTotal") &&
|
|
70
|
+
ENGrid.checkNested(window.EngagingNetworks, "require", "_defined", "enjs", "getDonationFee")) {
|
|
71
|
+
const total = window.EngagingNetworks.require._defined.enjs.getDonationTotal() -
|
|
72
|
+
window.EngagingNetworks.require._defined.enjs.getDonationFee();
|
|
73
|
+
if (total) {
|
|
74
|
+
this.amount = total;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Force a new amount
|
|
79
|
+
setAmount(amount, dispatch = true) {
|
|
80
|
+
// Run only if it is a Donation Page with a Donation Amount field
|
|
81
|
+
if (!document.getElementsByName(this._radios).length) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Set dispatch to be checked by the SET method
|
|
85
|
+
this._dispatch = dispatch;
|
|
86
|
+
// Search for the current amount on radio boxes
|
|
87
|
+
let found = Array.from(document.querySelectorAll('input[name="' + this._radios + '"]')).filter((el) => el instanceof HTMLInputElement && parseInt(el.value) == amount);
|
|
88
|
+
// We found the amount on the radio boxes, so check it
|
|
89
|
+
if (found.length) {
|
|
90
|
+
const amountField = found[0];
|
|
91
|
+
amountField.checked = true;
|
|
92
|
+
// Clear OTHER text field
|
|
93
|
+
this.clearOther();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const otherField = document.querySelector('input[name="' + this._other + '"]');
|
|
97
|
+
if (otherField) {
|
|
98
|
+
const enFieldOtherAmountRadio = document.querySelector(`.en__field--donationAmt.en__field--withOther .en__field__item:nth-last-child(2) input[name="${this._radios}"]`);
|
|
99
|
+
if (enFieldOtherAmountRadio) {
|
|
100
|
+
enFieldOtherAmountRadio.checked = true;
|
|
101
|
+
}
|
|
102
|
+
otherField.value = parseFloat(amount.toString()).toFixed(2);
|
|
103
|
+
const otherWrapper = otherField.parentNode;
|
|
104
|
+
otherWrapper.classList.remove("en__field__item--hidden");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Set the new amount and trigger all live variables
|
|
108
|
+
this.amount = amount;
|
|
109
|
+
// Revert dispatch to default value (true)
|
|
110
|
+
this._dispatch = true;
|
|
111
|
+
}
|
|
112
|
+
// Clear Other Field
|
|
113
|
+
clearOther() {
|
|
114
|
+
const otherField = document.querySelector('input[name="' + this._other + '"]');
|
|
115
|
+
otherField.value = "";
|
|
116
|
+
const otherWrapper = otherField.parentNode;
|
|
117
|
+
otherWrapper.classList.add("en__field__item--hidden");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class DonationFrequency {
|
|
2
|
+
private _onFrequencyChange;
|
|
3
|
+
private _frequency;
|
|
4
|
+
private _recurring;
|
|
5
|
+
private _dispatch;
|
|
6
|
+
private static instance;
|
|
7
|
+
private constructor();
|
|
8
|
+
static getInstance(): DonationFrequency;
|
|
9
|
+
get frequency(): string;
|
|
10
|
+
set frequency(value: string);
|
|
11
|
+
get recurring(): string;
|
|
12
|
+
set recurring(value: string);
|
|
13
|
+
get onFrequencyChange(): import("strongly-typed-events").ISimpleEvent<string>;
|
|
14
|
+
load(): void;
|
|
15
|
+
setRecurrency(recurr: string, dispatch?: boolean): void;
|
|
16
|
+
setFrequency(freq: string, dispatch?: boolean): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { SimpleEventDispatcher } from "strongly-typed-events";
|
|
2
|
+
import { ENGrid } from "../engrid";
|
|
3
|
+
export class DonationFrequency {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._onFrequencyChange = new SimpleEventDispatcher();
|
|
6
|
+
this._frequency = "onetime";
|
|
7
|
+
this._recurring = "n";
|
|
8
|
+
this._dispatch = true;
|
|
9
|
+
// Watch the Radios for Changes
|
|
10
|
+
document.addEventListener("change", (e) => {
|
|
11
|
+
const element = e.target;
|
|
12
|
+
if (element && element.name == "transaction.recurrpay") {
|
|
13
|
+
this.recurring = element.value;
|
|
14
|
+
// When this element is a radio, that means you're between onetime and monthly only
|
|
15
|
+
if (element.type == "radio") {
|
|
16
|
+
this.frequency =
|
|
17
|
+
element.value.toLowerCase() == "n" ? "onetime" : "monthly";
|
|
18
|
+
// This field is hidden when transaction.recurrpay is radio
|
|
19
|
+
ENGrid.setFieldValue("transaction.recurrfreq", this.frequency.toUpperCase());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (element && element.name == "transaction.recurrfreq") {
|
|
23
|
+
this.frequency = element.value;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//Thank you page handling for utility classes
|
|
27
|
+
if (ENGrid.getGiftProcess()) {
|
|
28
|
+
ENGrid.setBodyData("transaction-recurring-frequency", sessionStorage.getItem("engrid-transaction-recurring-frequency") ||
|
|
29
|
+
"onetime");
|
|
30
|
+
ENGrid.setBodyData("transaction-recurring", window.pageJson.recurring ? "y" : "n");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
static getInstance() {
|
|
34
|
+
if (!DonationFrequency.instance) {
|
|
35
|
+
DonationFrequency.instance = new DonationFrequency();
|
|
36
|
+
}
|
|
37
|
+
return DonationFrequency.instance;
|
|
38
|
+
}
|
|
39
|
+
get frequency() {
|
|
40
|
+
return this._frequency;
|
|
41
|
+
}
|
|
42
|
+
// Every time we set a frequency, trigger the onFrequencyChange event
|
|
43
|
+
set frequency(value) {
|
|
44
|
+
this._frequency = value.toLowerCase() || "onetime";
|
|
45
|
+
if (this._dispatch)
|
|
46
|
+
this._onFrequencyChange.dispatch(this._frequency);
|
|
47
|
+
ENGrid.setBodyData("transaction-recurring-frequency", this._frequency);
|
|
48
|
+
sessionStorage.setItem("engrid-transaction-recurring-frequency", this._frequency);
|
|
49
|
+
}
|
|
50
|
+
get recurring() {
|
|
51
|
+
return this._recurring;
|
|
52
|
+
}
|
|
53
|
+
set recurring(value) {
|
|
54
|
+
this._recurring = value.toLowerCase() || "n";
|
|
55
|
+
ENGrid.setBodyData("transaction-recurring", this._recurring);
|
|
56
|
+
}
|
|
57
|
+
get onFrequencyChange() {
|
|
58
|
+
return this._onFrequencyChange.asEvent();
|
|
59
|
+
}
|
|
60
|
+
// Set amount var with currently selected amount
|
|
61
|
+
load() {
|
|
62
|
+
var _a;
|
|
63
|
+
this.frequency =
|
|
64
|
+
ENGrid.getFieldValue("transaction.recurrfreq") ||
|
|
65
|
+
sessionStorage.getItem("engrid-transaction-recurring-frequency") ||
|
|
66
|
+
"onetime";
|
|
67
|
+
const recurrField = ENGrid.getField("transaction.recurrpay");
|
|
68
|
+
if (recurrField) {
|
|
69
|
+
this.recurring = ENGrid.getFieldValue("transaction.recurrpay");
|
|
70
|
+
}
|
|
71
|
+
else if (ENGrid.checkNested(window.EngagingNetworks, "require", "_defined", "enjs", "getSupporterData")) {
|
|
72
|
+
this.recurring =
|
|
73
|
+
((_a = window.EngagingNetworks.require._defined.enjs
|
|
74
|
+
.getSupporterData("recurrpay")) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "n";
|
|
75
|
+
}
|
|
76
|
+
// ENGrid.enParseDependencies();
|
|
77
|
+
}
|
|
78
|
+
// Force a new recurrency
|
|
79
|
+
setRecurrency(recurr, dispatch = true) {
|
|
80
|
+
// Run only if it is a Donation Page with a Recurrency
|
|
81
|
+
if (!document.getElementsByName("transaction.recurrpay").length) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Set dispatch to be checked by the SET method
|
|
85
|
+
this._dispatch = dispatch;
|
|
86
|
+
ENGrid.setFieldValue("transaction.recurrpay", recurr.toUpperCase());
|
|
87
|
+
// Revert dispatch to default value (true)
|
|
88
|
+
this._dispatch = true;
|
|
89
|
+
}
|
|
90
|
+
// Force a new frequency
|
|
91
|
+
setFrequency(freq, dispatch = true) {
|
|
92
|
+
// Run only if it is a Donation Page with a Frequency
|
|
93
|
+
if (!document.getElementsByName("transaction.recurrfreq").length) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Set dispatch to be checked by the SET method
|
|
97
|
+
this._dispatch = dispatch;
|
|
98
|
+
// Search for the current amount on radio boxes
|
|
99
|
+
let found = Array.from(document.querySelectorAll('input[name="transaction.recurrfreq"]')).filter((el) => el instanceof HTMLInputElement && el.value == freq.toUpperCase());
|
|
100
|
+
// We found the amount on the radio boxes, so check it
|
|
101
|
+
if (found.length) {
|
|
102
|
+
const freqField = found[0];
|
|
103
|
+
freqField.checked = true;
|
|
104
|
+
this.frequency = freq.toLowerCase();
|
|
105
|
+
if (this.frequency === "onetime") {
|
|
106
|
+
this.setRecurrency("N", dispatch);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.setRecurrency("Y", dispatch);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Revert dispatch to default value (true)
|
|
113
|
+
this._dispatch = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class EnForm {
|
|
2
|
+
private logger;
|
|
3
|
+
private _onSubmit;
|
|
4
|
+
private _onValidate;
|
|
5
|
+
private _onError;
|
|
6
|
+
submit: boolean;
|
|
7
|
+
submitPromise: boolean | Promise<any>;
|
|
8
|
+
validate: boolean;
|
|
9
|
+
validatePromise: boolean | Promise<any>;
|
|
10
|
+
private static instance;
|
|
11
|
+
private constructor();
|
|
12
|
+
static getInstance(): EnForm;
|
|
13
|
+
dispatchSubmit(): void;
|
|
14
|
+
dispatchValidate(): void;
|
|
15
|
+
dispatchError(): void;
|
|
16
|
+
submitForm(): void;
|
|
17
|
+
get onSubmit(): import("strongly-typed-events").ISignal;
|
|
18
|
+
get onError(): import("strongly-typed-events").ISignal;
|
|
19
|
+
get onValidate(): import("strongly-typed-events").ISignal;
|
|
20
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SignalDispatcher } from "strongly-typed-events";
|
|
2
|
+
import { EngridLogger } from "..";
|
|
3
|
+
export class EnForm {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.logger = new EngridLogger("EnForm");
|
|
6
|
+
this._onSubmit = new SignalDispatcher();
|
|
7
|
+
this._onValidate = new SignalDispatcher();
|
|
8
|
+
this._onError = new SignalDispatcher();
|
|
9
|
+
this.submit = true;
|
|
10
|
+
this.submitPromise = false;
|
|
11
|
+
this.validate = true;
|
|
12
|
+
this.validatePromise = false;
|
|
13
|
+
}
|
|
14
|
+
static getInstance() {
|
|
15
|
+
if (!EnForm.instance) {
|
|
16
|
+
EnForm.instance = new EnForm();
|
|
17
|
+
}
|
|
18
|
+
return EnForm.instance;
|
|
19
|
+
}
|
|
20
|
+
dispatchSubmit() {
|
|
21
|
+
this._onSubmit.dispatch();
|
|
22
|
+
this.logger.log("dispatchSubmit");
|
|
23
|
+
}
|
|
24
|
+
dispatchValidate() {
|
|
25
|
+
this._onValidate.dispatch();
|
|
26
|
+
this.logger.log("dispatchValidate");
|
|
27
|
+
}
|
|
28
|
+
dispatchError() {
|
|
29
|
+
this._onError.dispatch();
|
|
30
|
+
this.logger.log("dispatchError");
|
|
31
|
+
}
|
|
32
|
+
submitForm() {
|
|
33
|
+
const enForm = document.querySelector("form .en__submit button");
|
|
34
|
+
if (enForm) {
|
|
35
|
+
// Add submitting class to modal
|
|
36
|
+
const enModal = document.getElementById("enModal");
|
|
37
|
+
if (enModal)
|
|
38
|
+
enModal.classList.add("is-submitting");
|
|
39
|
+
enForm.click();
|
|
40
|
+
this.logger.log("submitForm");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
get onSubmit() {
|
|
44
|
+
return this._onSubmit.asEvent();
|
|
45
|
+
}
|
|
46
|
+
get onError() {
|
|
47
|
+
return this._onError.asEvent();
|
|
48
|
+
}
|
|
49
|
+
get onValidate() {
|
|
50
|
+
return this._onValidate.asEvent();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EnForm } from "./en-form";
|
|
2
|
+
import { DonationAmount } from "./donation-amount";
|
|
3
|
+
export declare class ProcessingFees {
|
|
4
|
+
private _onFeeChange;
|
|
5
|
+
_amount: DonationAmount;
|
|
6
|
+
_form: EnForm;
|
|
7
|
+
private _fee;
|
|
8
|
+
private _field;
|
|
9
|
+
private _subscribe?;
|
|
10
|
+
private static instance;
|
|
11
|
+
constructor();
|
|
12
|
+
static getInstance(): ProcessingFees;
|
|
13
|
+
get onFeeChange(): import("strongly-typed-events").ISimpleEvent<number>;
|
|
14
|
+
get fee(): number;
|
|
15
|
+
set fee(value: number);
|
|
16
|
+
calculateFees(amount?: number): any;
|
|
17
|
+
private addFees;
|
|
18
|
+
private removeFees;
|
|
19
|
+
private isENfeeCover;
|
|
20
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { SimpleEventDispatcher } from "strongly-typed-events";
|
|
2
|
+
import { EnForm } from "./en-form";
|
|
3
|
+
import { DonationAmount } from "./donation-amount";
|
|
4
|
+
export class ProcessingFees {
|
|
5
|
+
constructor() {
|
|
6
|
+
this._onFeeChange = new SimpleEventDispatcher();
|
|
7
|
+
this._amount = DonationAmount.getInstance();
|
|
8
|
+
this._form = EnForm.getInstance();
|
|
9
|
+
this._fee = 0;
|
|
10
|
+
this._field = null;
|
|
11
|
+
// console.log('%c Processing Fees Constructor', 'font-size: 30px; background-color: #000; color: #FF0');
|
|
12
|
+
// Run only if it is a Donation Page with a Donation Amount field
|
|
13
|
+
if (!document.getElementsByName("transaction.donationAmt").length) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this._field = this.isENfeeCover()
|
|
17
|
+
? document.querySelector("#en__field_transaction_feeCover")
|
|
18
|
+
: document.querySelector('input[name="supporter.processing_fees"]');
|
|
19
|
+
// Watch the Radios for Changes
|
|
20
|
+
if (this._field instanceof HTMLInputElement) {
|
|
21
|
+
// console.log('%c Processing Fees Start', 'font-size: 30px; background-color: #000; color: #FF0');
|
|
22
|
+
this._field.addEventListener("change", (e) => {
|
|
23
|
+
if (this._field instanceof HTMLInputElement &&
|
|
24
|
+
this._field.checked &&
|
|
25
|
+
!this._subscribe) {
|
|
26
|
+
this._subscribe = this._form.onSubmit.subscribe(() => this.addFees());
|
|
27
|
+
}
|
|
28
|
+
this._onFeeChange.dispatch(this.fee);
|
|
29
|
+
// // console.log('%c Processing Fees Script Applied', 'font-size: 30px; background-color: #000; color: #FF0');
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// this._amount = amount;
|
|
33
|
+
}
|
|
34
|
+
static getInstance() {
|
|
35
|
+
if (!ProcessingFees.instance) {
|
|
36
|
+
ProcessingFees.instance = new ProcessingFees();
|
|
37
|
+
}
|
|
38
|
+
return ProcessingFees.instance;
|
|
39
|
+
}
|
|
40
|
+
get onFeeChange() {
|
|
41
|
+
return this._onFeeChange.asEvent();
|
|
42
|
+
}
|
|
43
|
+
get fee() {
|
|
44
|
+
return this.calculateFees();
|
|
45
|
+
}
|
|
46
|
+
// Every time we set a frequency, trigger the onFrequencyChange event
|
|
47
|
+
set fee(value) {
|
|
48
|
+
this._fee = value;
|
|
49
|
+
this._onFeeChange.dispatch(this._fee);
|
|
50
|
+
}
|
|
51
|
+
calculateFees(amount = 0) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (this._field instanceof HTMLInputElement && this._field.checked) {
|
|
54
|
+
if (this.isENfeeCover()) {
|
|
55
|
+
return amount > 0
|
|
56
|
+
? window.EngagingNetworks.require._defined.enjs.feeCover.fee(amount)
|
|
57
|
+
: window.EngagingNetworks.require._defined.enjs.getDonationFee();
|
|
58
|
+
}
|
|
59
|
+
const fees = Object.assign({
|
|
60
|
+
processingfeepercentadded: "0",
|
|
61
|
+
processingfeefixedamountadded: "0",
|
|
62
|
+
}, (_a = this._field) === null || _a === void 0 ? void 0 : _a.dataset);
|
|
63
|
+
const amountToFee = amount > 0 ? amount : this._amount.amount;
|
|
64
|
+
const processing_fee = (parseFloat(fees.processingfeepercentadded) / 100) * amountToFee +
|
|
65
|
+
parseFloat(fees.processingfeefixedamountadded);
|
|
66
|
+
return Math.round(processing_fee * 100) / 100;
|
|
67
|
+
}
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
// Add Fees to Amount
|
|
71
|
+
addFees() {
|
|
72
|
+
if (this._form.submit && !this.isENfeeCover()) {
|
|
73
|
+
this._amount.setAmount(this._amount.amount + this.fee, false);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Remove Fees From Amount
|
|
77
|
+
removeFees() {
|
|
78
|
+
if (!this.isENfeeCover())
|
|
79
|
+
this._amount.setAmount(this._amount.amount - this.fee);
|
|
80
|
+
}
|
|
81
|
+
// Check if this is a Processing Fee from EN
|
|
82
|
+
isENfeeCover() {
|
|
83
|
+
if ("feeCover" in window.EngagingNetworks) {
|
|
84
|
+
for (const key in window.EngagingNetworks.feeCover) {
|
|
85
|
+
if (window.EngagingNetworks.feeCover.hasOwnProperty(key)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This class is responsible for managing events related to the "Remember Me" functionality.
|
|
3
|
+
* It uses the Singleton design pattern to ensure only one instance of this class exists.
|
|
4
|
+
* It provides methods for dispatching load and clear events, and getters for accessing these events.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RememberMeEvents {
|
|
7
|
+
private logger;
|
|
8
|
+
private _onLoad;
|
|
9
|
+
private _onClear;
|
|
10
|
+
hasData: boolean;
|
|
11
|
+
private static instance;
|
|
12
|
+
private constructor();
|
|
13
|
+
static getInstance(): RememberMeEvents;
|
|
14
|
+
dispatchLoad(hasData: boolean): void;
|
|
15
|
+
dispatchClear(): void;
|
|
16
|
+
get onLoad(): import("strongly-typed-events").ISimpleEvent<boolean>;
|
|
17
|
+
get onClear(): import("strongly-typed-events").ISignal;
|
|
18
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This class is responsible for managing events related to the "Remember Me" functionality.
|
|
3
|
+
* It uses the Singleton design pattern to ensure only one instance of this class exists.
|
|
4
|
+
* It provides methods for dispatching load and clear events, and getters for accessing these events.
|
|
5
|
+
*/
|
|
6
|
+
import { SignalDispatcher, SimpleEventDispatcher } from "strongly-typed-events";
|
|
7
|
+
import { EngridLogger } from "..";
|
|
8
|
+
export class RememberMeEvents {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.logger = new EngridLogger("RememberMeEvents");
|
|
11
|
+
this._onLoad = new SimpleEventDispatcher();
|
|
12
|
+
this._onClear = new SignalDispatcher();
|
|
13
|
+
this.hasData = false;
|
|
14
|
+
}
|
|
15
|
+
static getInstance() {
|
|
16
|
+
if (!RememberMeEvents.instance) {
|
|
17
|
+
RememberMeEvents.instance = new RememberMeEvents();
|
|
18
|
+
}
|
|
19
|
+
return RememberMeEvents.instance;
|
|
20
|
+
}
|
|
21
|
+
dispatchLoad(hasData) {
|
|
22
|
+
this.hasData = hasData;
|
|
23
|
+
this._onLoad.dispatch(hasData);
|
|
24
|
+
this.logger.log(`dispatchLoad: ${hasData}`);
|
|
25
|
+
}
|
|
26
|
+
dispatchClear() {
|
|
27
|
+
this._onClear.dispatch();
|
|
28
|
+
this.logger.log("dispatchClear");
|
|
29
|
+
}
|
|
30
|
+
get onLoad() {
|
|
31
|
+
return this._onLoad.asEvent();
|
|
32
|
+
}
|
|
33
|
+
get onClear() {
|
|
34
|
+
return this._onClear.asEvent();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class ExitIntentLightbox {
|
|
2
|
+
private options;
|
|
3
|
+
private opened;
|
|
4
|
+
private dataLayer;
|
|
5
|
+
private logger;
|
|
6
|
+
constructor();
|
|
7
|
+
private watchForTriggers;
|
|
8
|
+
private triggerDelay;
|
|
9
|
+
private triggerTimeout;
|
|
10
|
+
private watchMouse;
|
|
11
|
+
private watchDocumentVisibility;
|
|
12
|
+
private open;
|
|
13
|
+
private close;
|
|
14
|
+
}
|