@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,147 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
backgroundImage?: string | string[];
|
|
3
|
+
MediaAttribution?: boolean;
|
|
4
|
+
applePay?: boolean;
|
|
5
|
+
CapitalizeFields?: boolean;
|
|
6
|
+
ClickToExpand?: boolean;
|
|
7
|
+
CurrencySymbol?: string;
|
|
8
|
+
CurrencyCode?: string;
|
|
9
|
+
AddCurrencySymbol?: boolean;
|
|
10
|
+
CurrencySeparator?: string;
|
|
11
|
+
ThousandsSeparator?: string;
|
|
12
|
+
DecimalSeparator?: string;
|
|
13
|
+
DecimalPlaces?: number;
|
|
14
|
+
MinAmount?: number;
|
|
15
|
+
MaxAmount?: number;
|
|
16
|
+
MinAmountMessage?: string;
|
|
17
|
+
MaxAmountMessage?: string;
|
|
18
|
+
SkipToMainContentLink?: boolean;
|
|
19
|
+
SrcDefer?: boolean;
|
|
20
|
+
NeverBounceAPI?: string | null;
|
|
21
|
+
NeverBounceDateField?: string | null;
|
|
22
|
+
NeverBounceDateFormat?: string;
|
|
23
|
+
NeverBounceStatusField?: string | null;
|
|
24
|
+
FreshAddress?: false | {
|
|
25
|
+
dateField?: string;
|
|
26
|
+
dateFieldFormat?: string;
|
|
27
|
+
statusField?: string;
|
|
28
|
+
messageField?: string;
|
|
29
|
+
};
|
|
30
|
+
ProgressBar?: boolean | null;
|
|
31
|
+
AutoYear?: boolean;
|
|
32
|
+
TranslateFields?: boolean;
|
|
33
|
+
Debug?: boolean;
|
|
34
|
+
RegionLongFormat?: string;
|
|
35
|
+
RememberMe?: boolean | {
|
|
36
|
+
remoteUrl?: string;
|
|
37
|
+
cookieName?: string;
|
|
38
|
+
cookieExpirationDays?: number;
|
|
39
|
+
fieldNames?: string[];
|
|
40
|
+
fieldDonationAmountRadioName?: string;
|
|
41
|
+
fieldDonationAmountOtherName?: string;
|
|
42
|
+
fieldDonationRecurrPayRadioName?: string;
|
|
43
|
+
fieldDonationAmountOtherCheckboxID?: string;
|
|
44
|
+
fieldOptInSelectorTarget?: string;
|
|
45
|
+
fieldOptInSelectorTargetLocation?: string;
|
|
46
|
+
fieldClearSelectorTarget?: string;
|
|
47
|
+
fieldClearSelectorTargetLocation?: string;
|
|
48
|
+
checked?: boolean;
|
|
49
|
+
};
|
|
50
|
+
TidyContact?: false | {
|
|
51
|
+
cid?: string;
|
|
52
|
+
record_field?: string;
|
|
53
|
+
date_field?: string;
|
|
54
|
+
status_field?: string;
|
|
55
|
+
countries?: string[];
|
|
56
|
+
country_fallback?: string;
|
|
57
|
+
us_zip_divider?: string;
|
|
58
|
+
address_enable?: boolean;
|
|
59
|
+
address_fields?: {
|
|
60
|
+
address1: string;
|
|
61
|
+
address2: string;
|
|
62
|
+
address3: string;
|
|
63
|
+
city: string;
|
|
64
|
+
region: string;
|
|
65
|
+
postalCode: string;
|
|
66
|
+
country: string;
|
|
67
|
+
phone: string;
|
|
68
|
+
};
|
|
69
|
+
phone_enable?: boolean;
|
|
70
|
+
phone_flags?: boolean;
|
|
71
|
+
phone_country_from_ip?: boolean;
|
|
72
|
+
phone_preferred_countries?: string[];
|
|
73
|
+
phone_record_field?: string;
|
|
74
|
+
phone_date_field?: string;
|
|
75
|
+
phone_status_field?: string;
|
|
76
|
+
};
|
|
77
|
+
MobileCTA?: false | {
|
|
78
|
+
label?: string;
|
|
79
|
+
pages?: string[];
|
|
80
|
+
};
|
|
81
|
+
PageLayouts?: string[];
|
|
82
|
+
CountryDisable?: string[];
|
|
83
|
+
Plaid?: boolean;
|
|
84
|
+
Placeholders?: false | {
|
|
85
|
+
[key: string]: string;
|
|
86
|
+
};
|
|
87
|
+
ENValidators?: boolean;
|
|
88
|
+
CustomCurrency?: false | {
|
|
89
|
+
label?: string;
|
|
90
|
+
default: {
|
|
91
|
+
[key: string]: string;
|
|
92
|
+
};
|
|
93
|
+
countries?: {
|
|
94
|
+
[key: string]: {
|
|
95
|
+
[key: string]: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
VGS?: false | {
|
|
100
|
+
"transaction.ccnumber"?: {
|
|
101
|
+
showCardIcon?: boolean;
|
|
102
|
+
css?: {
|
|
103
|
+
[key: string]: string | object;
|
|
104
|
+
};
|
|
105
|
+
icons?: {
|
|
106
|
+
[key: string]: string;
|
|
107
|
+
};
|
|
108
|
+
ariaLabel?: string;
|
|
109
|
+
placeholder?: string;
|
|
110
|
+
};
|
|
111
|
+
"transaction.ccvv"?: {
|
|
112
|
+
showCardIcon?: boolean;
|
|
113
|
+
css?: {
|
|
114
|
+
[key: string]: string | object;
|
|
115
|
+
};
|
|
116
|
+
ariaLabel?: string;
|
|
117
|
+
placeholder?: string;
|
|
118
|
+
hideValue?: boolean;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
PostalCodeValidator?: boolean;
|
|
122
|
+
CountryRedirect?: false | {
|
|
123
|
+
[key: string]: string;
|
|
124
|
+
};
|
|
125
|
+
WelcomeBack?: false | {
|
|
126
|
+
welcomeBackMessage: {
|
|
127
|
+
display: boolean;
|
|
128
|
+
title: string;
|
|
129
|
+
editText: string;
|
|
130
|
+
anchor: string;
|
|
131
|
+
placement: "beforebegin" | "afterbegin" | "beforeend" | "afterend";
|
|
132
|
+
};
|
|
133
|
+
personalDetailsSummary: {
|
|
134
|
+
display: boolean;
|
|
135
|
+
title: string;
|
|
136
|
+
editText: string;
|
|
137
|
+
anchor: string;
|
|
138
|
+
placement: "beforebegin" | "afterbegin" | "beforeend" | "afterend";
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
onLoad?: () => void;
|
|
142
|
+
onResize?: () => void;
|
|
143
|
+
onSubmit?: () => void;
|
|
144
|
+
onError?: () => void;
|
|
145
|
+
onValidate?: () => void;
|
|
146
|
+
}
|
|
147
|
+
export declare const OptionsDefaults: Options;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const OptionsDefaults = {
|
|
2
|
+
backgroundImage: "",
|
|
3
|
+
MediaAttribution: true,
|
|
4
|
+
applePay: false,
|
|
5
|
+
CapitalizeFields: false,
|
|
6
|
+
ClickToExpand: true,
|
|
7
|
+
CurrencySymbol: "$",
|
|
8
|
+
CurrencyCode: "USD",
|
|
9
|
+
AddCurrencySymbol: true,
|
|
10
|
+
ThousandsSeparator: "",
|
|
11
|
+
DecimalSeparator: ".",
|
|
12
|
+
DecimalPlaces: 2,
|
|
13
|
+
MinAmount: 1,
|
|
14
|
+
MaxAmount: 100000,
|
|
15
|
+
MinAmountMessage: "Amount must be at least $1",
|
|
16
|
+
MaxAmountMessage: "Amount must be less than $100,000",
|
|
17
|
+
SkipToMainContentLink: true,
|
|
18
|
+
SrcDefer: true,
|
|
19
|
+
NeverBounceAPI: null,
|
|
20
|
+
NeverBounceDateField: null,
|
|
21
|
+
NeverBounceStatusField: null,
|
|
22
|
+
NeverBounceDateFormat: "MM/DD/YYYY",
|
|
23
|
+
FreshAddress: false,
|
|
24
|
+
ProgressBar: false,
|
|
25
|
+
AutoYear: false,
|
|
26
|
+
TranslateFields: true,
|
|
27
|
+
Debug: false,
|
|
28
|
+
RememberMe: false,
|
|
29
|
+
TidyContact: false,
|
|
30
|
+
RegionLongFormat: "",
|
|
31
|
+
CountryDisable: [],
|
|
32
|
+
Plaid: false,
|
|
33
|
+
Placeholders: false,
|
|
34
|
+
ENValidators: false,
|
|
35
|
+
MobileCTA: false,
|
|
36
|
+
CustomCurrency: false,
|
|
37
|
+
VGS: false,
|
|
38
|
+
PostalCodeValidator: false,
|
|
39
|
+
CountryRedirect: false,
|
|
40
|
+
WelcomeBack: false,
|
|
41
|
+
PageLayouts: [
|
|
42
|
+
"leftleft1col",
|
|
43
|
+
"centerleft1col",
|
|
44
|
+
"centercenter1col",
|
|
45
|
+
"centercenter2col",
|
|
46
|
+
"centerright1col",
|
|
47
|
+
"rightright1col",
|
|
48
|
+
"none",
|
|
49
|
+
],
|
|
50
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const ptbrTranslation = [
|
|
2
|
+
{ field: "supporter.firstName", translation: "Nome" },
|
|
3
|
+
{ field: "supporter.lastName", translation: "Sobrenome" },
|
|
4
|
+
{ field: "supporter.phoneNumber", translation: "Celular" },
|
|
5
|
+
{ field: "supporter.address1", translation: "Endereço" },
|
|
6
|
+
{ field: "supporter.address2", translation: "Complemento" },
|
|
7
|
+
{ field: "supporter.postcode", translation: "CEP" },
|
|
8
|
+
{ field: "supporter.city", translation: "Cidade" },
|
|
9
|
+
{ field: "supporter.region", translation: "Estado" },
|
|
10
|
+
{ field: "supporter.country", translation: "PaÃs" },
|
|
11
|
+
];
|
|
12
|
+
const deTranslation = [
|
|
13
|
+
{ field: "supporter.address1", translation: "Straße, Hausnummer" },
|
|
14
|
+
{ field: "supporter.postcode", translation: "Postleitzahl" },
|
|
15
|
+
{ field: "supporter.city", translation: "Ort" },
|
|
16
|
+
{ field: "supporter.region", translation: "Bundesland" },
|
|
17
|
+
{ field: "supporter.country", translation: "Land" },
|
|
18
|
+
];
|
|
19
|
+
const frTranslation = [
|
|
20
|
+
{ field: "supporter.address1", translation: "Adresse" },
|
|
21
|
+
{ field: "supporter.postcode", translation: "Code Postal" },
|
|
22
|
+
{ field: "supporter.city", translation: "Ville" },
|
|
23
|
+
{ field: "supporter.region", translation: "Région" },
|
|
24
|
+
{ field: "supporter.country", translation: "Country" },
|
|
25
|
+
];
|
|
26
|
+
const nlTranslation = [
|
|
27
|
+
{ field: "supporter.address1", translation: "Adres" },
|
|
28
|
+
{ field: "supporter.postcode", translation: "Postcode" },
|
|
29
|
+
{ field: "supporter.city", translation: "Woonplaats" },
|
|
30
|
+
{ field: "supporter.region", translation: "Provincie" },
|
|
31
|
+
{ field: "supporter.country", translation: "Country" },
|
|
32
|
+
];
|
|
33
|
+
export const TranslateOptionsDefaults = {
|
|
34
|
+
BR: ptbrTranslation,
|
|
35
|
+
BRA: ptbrTranslation,
|
|
36
|
+
DE: deTranslation,
|
|
37
|
+
DEU: deTranslation,
|
|
38
|
+
FR: frTranslation,
|
|
39
|
+
FRA: frTranslation,
|
|
40
|
+
NL: nlTranslation,
|
|
41
|
+
NLD: nlTranslation,
|
|
42
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface UpsellOptions {
|
|
2
|
+
image: string;
|
|
3
|
+
imagePosition: string;
|
|
4
|
+
title: string;
|
|
5
|
+
paragraph: string;
|
|
6
|
+
yesLabel: string;
|
|
7
|
+
noLabel: string;
|
|
8
|
+
otherAmount: boolean;
|
|
9
|
+
otherLabel: string;
|
|
10
|
+
upsellOriginalGiftAmountFieldName: string;
|
|
11
|
+
amountRange: Array<{
|
|
12
|
+
max: number;
|
|
13
|
+
suggestion: number | string;
|
|
14
|
+
}>;
|
|
15
|
+
minAmount: number;
|
|
16
|
+
canClose: boolean;
|
|
17
|
+
submitOnClose: boolean;
|
|
18
|
+
oneTime: boolean;
|
|
19
|
+
annual: boolean;
|
|
20
|
+
disablePaymentMethods: Array<string>;
|
|
21
|
+
skipUpsell: boolean;
|
|
22
|
+
conversionField: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const UpsellOptionsDefaults: UpsellOptions;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const UpsellOptionsDefaults = {
|
|
2
|
+
image: "https://picsum.photos/480/650",
|
|
3
|
+
imagePosition: "left",
|
|
4
|
+
title: "Will you change your gift to just {new-amount} a month to boost your impact?",
|
|
5
|
+
paragraph: "Make a monthly pledge today to support us with consistent, reliable resources during emergency moments.",
|
|
6
|
+
yesLabel: "Yes! Process My <br> {new-amount} monthly gift",
|
|
7
|
+
noLabel: "No, thanks. Continue with my <br> {old-amount} one-time gift",
|
|
8
|
+
otherAmount: true,
|
|
9
|
+
otherLabel: "Or enter a different monthly amount:",
|
|
10
|
+
upsellOriginalGiftAmountFieldName: "",
|
|
11
|
+
amountRange: [
|
|
12
|
+
{ max: 10, suggestion: 5 },
|
|
13
|
+
{ max: 15, suggestion: 7 },
|
|
14
|
+
{ max: 20, suggestion: 8 },
|
|
15
|
+
{ max: 25, suggestion: 9 },
|
|
16
|
+
{ max: 30, suggestion: 10 },
|
|
17
|
+
{ max: 35, suggestion: 11 },
|
|
18
|
+
{ max: 40, suggestion: 12 },
|
|
19
|
+
{ max: 50, suggestion: 14 },
|
|
20
|
+
{ max: 100, suggestion: 15 },
|
|
21
|
+
{ max: 200, suggestion: 19 },
|
|
22
|
+
{ max: 300, suggestion: 29 },
|
|
23
|
+
{ max: 500, suggestion: "Math.ceil((amount / 12)/5)*5" },
|
|
24
|
+
],
|
|
25
|
+
minAmount: 0,
|
|
26
|
+
canClose: true,
|
|
27
|
+
submitOnClose: false,
|
|
28
|
+
oneTime: true,
|
|
29
|
+
annual: false,
|
|
30
|
+
disablePaymentMethods: [],
|
|
31
|
+
skipUpsell: false,
|
|
32
|
+
conversionField: "",
|
|
33
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DonationAmount } from ".";
|
|
2
|
+
export declare class LiveCurrency {
|
|
3
|
+
private logger;
|
|
4
|
+
private elementsFound;
|
|
5
|
+
private isUpdating;
|
|
6
|
+
_amount: DonationAmount;
|
|
7
|
+
private _frequency;
|
|
8
|
+
private _fees;
|
|
9
|
+
constructor();
|
|
10
|
+
searchElements(): void;
|
|
11
|
+
shouldRun(): boolean;
|
|
12
|
+
addMutationObserver(): void;
|
|
13
|
+
addEventListeners(): void;
|
|
14
|
+
updateCurrency(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// This script enables live currency symbol and code to the page.
|
|
2
|
+
import { DonationAmount, DonationFrequency, ENGrid, EngridLogger, ProcessingFees, } from ".";
|
|
3
|
+
export class LiveCurrency {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.logger = new EngridLogger("LiveCurrency", "#1901b1", "#feb47a", "💲");
|
|
6
|
+
this.elementsFound = false;
|
|
7
|
+
this.isUpdating = false;
|
|
8
|
+
this._amount = DonationAmount.getInstance();
|
|
9
|
+
this._frequency = DonationFrequency.getInstance();
|
|
10
|
+
this._fees = ProcessingFees.getInstance();
|
|
11
|
+
this.searchElements();
|
|
12
|
+
if (!this.shouldRun())
|
|
13
|
+
return;
|
|
14
|
+
ENGrid.setBodyData("live-currency", "active");
|
|
15
|
+
this.updateCurrency();
|
|
16
|
+
this.addEventListeners();
|
|
17
|
+
// Make labels visible on page load
|
|
18
|
+
document
|
|
19
|
+
.querySelectorAll(".en__field--donationAmt .en__field__element--radio .en__field__item")
|
|
20
|
+
.forEach((node) => {
|
|
21
|
+
node.setAttribute("data-engrid-currency-symbol-updated", "true");
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
searchElements() {
|
|
25
|
+
const enElements = document.querySelectorAll(`
|
|
26
|
+
.en__component--copyblock,
|
|
27
|
+
.en__component--codeblock,
|
|
28
|
+
.en__field label,
|
|
29
|
+
.en__submit
|
|
30
|
+
`);
|
|
31
|
+
if (enElements.length > 0) {
|
|
32
|
+
this.elementsFound = true;
|
|
33
|
+
const currency = ENGrid.getCurrencySymbol();
|
|
34
|
+
const currencyCode = ENGrid.getCurrencyCode();
|
|
35
|
+
const currencyElement = `<span class="engrid-currency-symbol">${currency}</span>`;
|
|
36
|
+
const currencyCodeElement = `<span class="engrid-currency-code">${currencyCode}</span>`;
|
|
37
|
+
enElements.forEach((item) => {
|
|
38
|
+
// If item starts with <script, skip it
|
|
39
|
+
if (item instanceof HTMLElement &&
|
|
40
|
+
item.innerHTML.startsWith("<script")) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (item instanceof HTMLElement &&
|
|
44
|
+
(item.innerHTML.includes("[$]") || item.innerHTML.includes("[$$$]"))) {
|
|
45
|
+
this.logger.log("Old Value:", item.innerHTML);
|
|
46
|
+
const currencyRegex = /\[\$\]/g;
|
|
47
|
+
const currencyCodeRegex = /\[\$\$\$\]/g;
|
|
48
|
+
item.innerHTML = item.innerHTML.replace(currencyCodeRegex, currencyCodeElement);
|
|
49
|
+
item.innerHTML = item.innerHTML.replace(currencyRegex, currencyElement);
|
|
50
|
+
this.logger.log("New Value:", item.innerHTML);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
shouldRun() {
|
|
56
|
+
return this.elementsFound;
|
|
57
|
+
}
|
|
58
|
+
addMutationObserver() {
|
|
59
|
+
const targetNode = document.querySelector(".en__field--donationAmt .en__field__element--radio");
|
|
60
|
+
if (!targetNode)
|
|
61
|
+
return;
|
|
62
|
+
const observer = new MutationObserver((mutations) => {
|
|
63
|
+
mutations.forEach((mutation) => {
|
|
64
|
+
if (mutation.type === "childList") {
|
|
65
|
+
// Update the currency only once, after the mutation is complete
|
|
66
|
+
if (this.isUpdating)
|
|
67
|
+
return;
|
|
68
|
+
this.isUpdating = true;
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
this.searchElements();
|
|
71
|
+
this.updateCurrency();
|
|
72
|
+
targetNode.querySelectorAll(".en__field__item").forEach((node) => {
|
|
73
|
+
node.setAttribute("data-engrid-currency-symbol-updated", "true");
|
|
74
|
+
});
|
|
75
|
+
this.isUpdating = false;
|
|
76
|
+
}, 20);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
const config = { childList: true };
|
|
81
|
+
observer.observe(targetNode, config);
|
|
82
|
+
}
|
|
83
|
+
addEventListeners() {
|
|
84
|
+
this._fees.onFeeChange.subscribe(() => {
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
this.updateCurrency();
|
|
87
|
+
}, 10);
|
|
88
|
+
});
|
|
89
|
+
this._amount.onAmountChange.subscribe(() => {
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
this.updateCurrency();
|
|
92
|
+
}, 10);
|
|
93
|
+
});
|
|
94
|
+
this._frequency.onFrequencyChange.subscribe(() => {
|
|
95
|
+
if (this.isUpdating)
|
|
96
|
+
return;
|
|
97
|
+
this.isUpdating = true;
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
this.searchElements();
|
|
100
|
+
this.updateCurrency();
|
|
101
|
+
document
|
|
102
|
+
.querySelectorAll(".en__field--donationAmt .en__field__element--radio .en__field__item")
|
|
103
|
+
.forEach((node) => {
|
|
104
|
+
node.setAttribute("data-engrid-currency-symbol-updated", "true");
|
|
105
|
+
});
|
|
106
|
+
this.isUpdating = false;
|
|
107
|
+
}, 10);
|
|
108
|
+
});
|
|
109
|
+
const currencyField = ENGrid.getField("transaction.paycurrency");
|
|
110
|
+
if (currencyField) {
|
|
111
|
+
currencyField.addEventListener("change", () => {
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
this.updateCurrency();
|
|
114
|
+
this._amount.load();
|
|
115
|
+
const otherAmountDiv = document.querySelector(".en__field--donationAmt .en__field__item--other");
|
|
116
|
+
if (otherAmountDiv) {
|
|
117
|
+
otherAmountDiv.setAttribute("data-currency-symbol", ENGrid.getCurrencySymbol());
|
|
118
|
+
}
|
|
119
|
+
ENGrid.setBodyData("currency-code", ENGrid.getCurrencyCode());
|
|
120
|
+
}, 10);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
this.addMutationObserver();
|
|
124
|
+
}
|
|
125
|
+
updateCurrency() {
|
|
126
|
+
const currencySymbolElements = document.querySelectorAll(".engrid-currency-symbol");
|
|
127
|
+
const currencyCodeElements = document.querySelectorAll(".engrid-currency-code");
|
|
128
|
+
if (currencySymbolElements.length > 0) {
|
|
129
|
+
currencySymbolElements.forEach((item) => {
|
|
130
|
+
item.innerHTML = ENGrid.getCurrencySymbol();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (currencyCodeElements.length > 0) {
|
|
134
|
+
currencyCodeElements.forEach((item) => {
|
|
135
|
+
item.innerHTML = ENGrid.getCurrencyCode();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
this.logger.log(`Currency updated for ${currencySymbolElements.length + currencyCodeElements.length} elements`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DonationAmount } from ".";
|
|
2
|
+
export declare class LiveFrequency {
|
|
3
|
+
private logger;
|
|
4
|
+
private elementsFound;
|
|
5
|
+
_amount: DonationAmount;
|
|
6
|
+
private _frequency;
|
|
7
|
+
constructor();
|
|
8
|
+
searchElements(): void;
|
|
9
|
+
shouldRun(): boolean;
|
|
10
|
+
addEventListeners(): void;
|
|
11
|
+
updateFrequency(): void;
|
|
12
|
+
replaceMergeTags(tag: string, element: HTMLElement): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// This script creates merge tags: [[frequency]], [[Frequency]], or [[FREQUENCY]]
|
|
2
|
+
// that gets replaced with the donation frequency
|
|
3
|
+
// and can be used on any Code Block, Text Block, or Form Block
|
|
4
|
+
import { DonationAmount, DonationFrequency, EngridLogger } from ".";
|
|
5
|
+
export class LiveFrequency {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.logger = new EngridLogger("LiveFrequency", "#00ff00", "#000000", "🧾");
|
|
8
|
+
this.elementsFound = false;
|
|
9
|
+
this._amount = DonationAmount.getInstance();
|
|
10
|
+
this._frequency = DonationFrequency.getInstance();
|
|
11
|
+
this.searchElements();
|
|
12
|
+
if (!this.shouldRun())
|
|
13
|
+
return;
|
|
14
|
+
this.updateFrequency();
|
|
15
|
+
this.addEventListeners();
|
|
16
|
+
}
|
|
17
|
+
searchElements() {
|
|
18
|
+
const enElements = document.querySelectorAll(`
|
|
19
|
+
.en__component--copyblock,
|
|
20
|
+
.en__component--codeblock,
|
|
21
|
+
.en__field label,
|
|
22
|
+
.en__submit
|
|
23
|
+
`);
|
|
24
|
+
if (enElements.length > 0) {
|
|
25
|
+
const pattern = /\[\[(frequency)\]\]/gi;
|
|
26
|
+
let totalFound = 0;
|
|
27
|
+
enElements.forEach((item) => {
|
|
28
|
+
const match = item.innerHTML.match(pattern);
|
|
29
|
+
if (item instanceof HTMLElement && match) {
|
|
30
|
+
this.elementsFound = true;
|
|
31
|
+
match.forEach((matchedSubstring) => {
|
|
32
|
+
totalFound++;
|
|
33
|
+
this.replaceMergeTags(matchedSubstring, item);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (totalFound > 0) {
|
|
38
|
+
this.logger.log(`Found ${totalFound} merge tag${totalFound > 1 ? "s" : ""} in the page.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
shouldRun() {
|
|
43
|
+
if (!this.elementsFound) {
|
|
44
|
+
this.logger.log("No merge tags found. Skipping.");
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
addEventListeners() {
|
|
50
|
+
this._amount.onAmountChange.subscribe(() => {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
this.updateFrequency();
|
|
53
|
+
}, 10);
|
|
54
|
+
});
|
|
55
|
+
this._frequency.onFrequencyChange.subscribe(() => {
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
this.searchElements();
|
|
58
|
+
this.updateFrequency();
|
|
59
|
+
}, 10);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
updateFrequency() {
|
|
63
|
+
const frequency = this._frequency.frequency === "onetime"
|
|
64
|
+
? "one-time"
|
|
65
|
+
: this._frequency.frequency;
|
|
66
|
+
const elemenst = document.querySelectorAll(".engrid-frequency");
|
|
67
|
+
elemenst.forEach((item) => {
|
|
68
|
+
if (item.classList.contains("engrid-frequency--lowercase")) {
|
|
69
|
+
item.innerHTML = frequency.toLowerCase();
|
|
70
|
+
}
|
|
71
|
+
else if (item.classList.contains("engrid-frequency--capitalized")) {
|
|
72
|
+
item.innerHTML = frequency.charAt(0).toUpperCase() + frequency.slice(1);
|
|
73
|
+
}
|
|
74
|
+
else if (item.classList.contains("engrid-frequency--uppercase")) {
|
|
75
|
+
item.innerHTML = frequency.toUpperCase();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
item.innerHTML = frequency;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
replaceMergeTags(tag, element) {
|
|
83
|
+
const frequency = this._frequency.frequency === "onetime"
|
|
84
|
+
? "one-time"
|
|
85
|
+
: this._frequency.frequency;
|
|
86
|
+
const frequencyElement = document.createElement("span");
|
|
87
|
+
frequencyElement.classList.add("engrid-frequency");
|
|
88
|
+
frequencyElement.innerHTML = frequency;
|
|
89
|
+
switch (tag) {
|
|
90
|
+
case "[[frequency]]":
|
|
91
|
+
frequencyElement.classList.add("engrid-frequency--lowercase");
|
|
92
|
+
frequencyElement.innerHTML = frequencyElement.innerHTML.toLowerCase();
|
|
93
|
+
element.innerHTML = element.innerHTML.replace(tag, frequencyElement.outerHTML);
|
|
94
|
+
break;
|
|
95
|
+
case "[[Frequency]]":
|
|
96
|
+
frequencyElement.classList.add("engrid-frequency--capitalized");
|
|
97
|
+
frequencyElement.innerHTML =
|
|
98
|
+
frequencyElement.innerHTML.charAt(0).toUpperCase() +
|
|
99
|
+
frequencyElement.innerHTML.slice(1);
|
|
100
|
+
element.innerHTML = element.innerHTML.replace(tag, frequencyElement.outerHTML);
|
|
101
|
+
break;
|
|
102
|
+
case "[[FREQUENCY]]":
|
|
103
|
+
frequencyElement.classList.add("engrid-frequency--uppercase");
|
|
104
|
+
frequencyElement.innerHTML = frequencyElement.innerHTML.toUpperCase();
|
|
105
|
+
element.innerHTML = element.innerHTML.replace(tag, frequencyElement.outerHTML);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DonationAmount, ProcessingFees } from "./events";
|
|
2
|
+
import { Options } from ".";
|
|
3
|
+
export declare class LiveVariables {
|
|
4
|
+
_amount: DonationAmount;
|
|
5
|
+
_fees: ProcessingFees;
|
|
6
|
+
private _frequency;
|
|
7
|
+
private _form;
|
|
8
|
+
private multiplier;
|
|
9
|
+
private submitLabel;
|
|
10
|
+
private options;
|
|
11
|
+
constructor(options: Options);
|
|
12
|
+
private getAmountTxt;
|
|
13
|
+
private getUpsellAmountTxt;
|
|
14
|
+
private getUpsellAmountRaw;
|
|
15
|
+
changeSubmitButton(): void;
|
|
16
|
+
changeLiveAmount(): void;
|
|
17
|
+
changeLiveUpsellAmount(): void;
|
|
18
|
+
changeLiveFrequency(): void;
|
|
19
|
+
changeRecurrency(): void;
|
|
20
|
+
private upsold;
|
|
21
|
+
}
|