@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
package/dist/iframe.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { ENGrid, EngridLogger } from ".";
|
|
2
|
+
import { EnForm } from "./events";
|
|
3
|
+
export class iFrame {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._form = EnForm.getInstance();
|
|
6
|
+
this.logger = new EngridLogger("iFrame", "brown", "gray", "📡");
|
|
7
|
+
if (this.inIframe()) {
|
|
8
|
+
// Add the data-engrid-embedded attribute when inside an iFrame if it wasn't already added by a script in the Page Template
|
|
9
|
+
ENGrid.setBodyData("embedded", "");
|
|
10
|
+
// Fire the resize event
|
|
11
|
+
this.logger.log("iFrame Event - Begin Resizing");
|
|
12
|
+
window.addEventListener("load", (event) => {
|
|
13
|
+
// Scroll to top of iFrame
|
|
14
|
+
this.logger.log("iFrame Event - window.onload");
|
|
15
|
+
this.sendIframeHeight();
|
|
16
|
+
window.parent.postMessage({
|
|
17
|
+
scroll: this.shouldScroll(),
|
|
18
|
+
}, "*");
|
|
19
|
+
// On click fire the resize event
|
|
20
|
+
document.addEventListener("click", (e) => {
|
|
21
|
+
this.logger.log("iFrame Event - click");
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
this.sendIframeHeight();
|
|
24
|
+
}, 100);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
window.setTimeout(() => {
|
|
28
|
+
this.sendIframeHeight();
|
|
29
|
+
}, 300);
|
|
30
|
+
window.addEventListener("resize", this.debounceWithImmediate(() => {
|
|
31
|
+
this.logger.log("iFrame Event - window resized");
|
|
32
|
+
this.sendIframeHeight();
|
|
33
|
+
}));
|
|
34
|
+
// Listen for the form submit event
|
|
35
|
+
this._form.onSubmit.subscribe((e) => {
|
|
36
|
+
this.logger.log("iFrame Event - onSubmit");
|
|
37
|
+
this.sendIframeFormStatus("submit");
|
|
38
|
+
});
|
|
39
|
+
// If the iFrame is Chained, check if the form has data
|
|
40
|
+
if (this.isChained() && ENGrid.getPaymentType()) {
|
|
41
|
+
this.logger.log("iFrame Event - Chained iFrame");
|
|
42
|
+
this.sendIframeFormStatus("chained");
|
|
43
|
+
this.hideFormComponents();
|
|
44
|
+
this.addChainedBanner();
|
|
45
|
+
}
|
|
46
|
+
// Remove the skip link markup when inside an iFrame
|
|
47
|
+
const skipLink = document.querySelector(".skip-link");
|
|
48
|
+
if (skipLink) {
|
|
49
|
+
skipLink.remove();
|
|
50
|
+
}
|
|
51
|
+
this._form.onError.subscribe(() => {
|
|
52
|
+
// Get the first .en__field--validationFailed element
|
|
53
|
+
const firstError = document.querySelector(".en__field--validationFailed");
|
|
54
|
+
// Send scrollTo message
|
|
55
|
+
// Parent pages listens for this message and scrolls to the correct position
|
|
56
|
+
const scrollTo = firstError
|
|
57
|
+
? firstError.getBoundingClientRect().top
|
|
58
|
+
: 0;
|
|
59
|
+
this.logger.log(`iFrame Event 'scrollTo' - Position of top of first error ${scrollTo} px`); // check the message is being sent correctly
|
|
60
|
+
window.parent.postMessage({ scrollTo }, "*");
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// When not in iframe, default behaviour, smooth scroll to first error
|
|
65
|
+
this._form.onError.subscribe(() => {
|
|
66
|
+
// Smooth Scroll to the first .en__field--validationFailed element
|
|
67
|
+
const firstError = document.querySelector(".en__field--validationFailed");
|
|
68
|
+
if (firstError) {
|
|
69
|
+
firstError.scrollIntoView({ behavior: "smooth" });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
// Parent Page Logic (when an ENgrid form is embedded in an ENgrid page)
|
|
73
|
+
window.addEventListener("message", (event) => {
|
|
74
|
+
const iframe = this.getIFrameByEvent(event);
|
|
75
|
+
if (iframe) {
|
|
76
|
+
if (event.data.hasOwnProperty("frameHeight")) {
|
|
77
|
+
iframe.style.height = event.data.frameHeight + "px";
|
|
78
|
+
}
|
|
79
|
+
// Old scroll event logic "scroll", scrolls to correct iframe?
|
|
80
|
+
else if (event.data.hasOwnProperty("scroll") &&
|
|
81
|
+
event.data.scroll > 0) {
|
|
82
|
+
const elDistanceToTop = window.pageYOffset + iframe.getBoundingClientRect().top;
|
|
83
|
+
let scrollTo = elDistanceToTop + event.data.scroll;
|
|
84
|
+
window.scrollTo({
|
|
85
|
+
top: scrollTo,
|
|
86
|
+
left: 0,
|
|
87
|
+
behavior: "smooth",
|
|
88
|
+
});
|
|
89
|
+
this.logger.log("iFrame Event - Scrolling Window to " + scrollTo);
|
|
90
|
+
}
|
|
91
|
+
// New scroll event logic "scrollTo", scrolls to the first error
|
|
92
|
+
else if (event.data.hasOwnProperty("scrollTo")) {
|
|
93
|
+
const scrollToPosition = event.data.scrollTo +
|
|
94
|
+
window.scrollY +
|
|
95
|
+
iframe.getBoundingClientRect().top;
|
|
96
|
+
window.scrollTo({
|
|
97
|
+
top: scrollToPosition,
|
|
98
|
+
left: 0,
|
|
99
|
+
behavior: "smooth",
|
|
100
|
+
});
|
|
101
|
+
this.logger.log("iFrame Event - Scrolling Window to " + scrollToPosition);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
sendIframeHeight() {
|
|
108
|
+
let height = document.body.offsetHeight;
|
|
109
|
+
this.logger.log("iFrame Event - Sending iFrame height of: " + height + "px"); // check the message is being sent correctly
|
|
110
|
+
window.parent.postMessage({
|
|
111
|
+
frameHeight: height,
|
|
112
|
+
pageNumber: ENGrid.getPageNumber(),
|
|
113
|
+
pageCount: ENGrid.getPageCount(),
|
|
114
|
+
giftProcess: ENGrid.getGiftProcess(),
|
|
115
|
+
}, "*");
|
|
116
|
+
}
|
|
117
|
+
sendIframeFormStatus(status) {
|
|
118
|
+
window.parent.postMessage({
|
|
119
|
+
status: status,
|
|
120
|
+
pageNumber: ENGrid.getPageNumber(),
|
|
121
|
+
pageCount: ENGrid.getPageCount(),
|
|
122
|
+
giftProcess: ENGrid.getGiftProcess(),
|
|
123
|
+
}, "*");
|
|
124
|
+
}
|
|
125
|
+
getIFrameByEvent(event) {
|
|
126
|
+
return [].slice
|
|
127
|
+
.call(document.getElementsByTagName("iframe"))
|
|
128
|
+
.filter((iframe) => {
|
|
129
|
+
return iframe.contentWindow === event.source;
|
|
130
|
+
})[0];
|
|
131
|
+
}
|
|
132
|
+
shouldScroll() {
|
|
133
|
+
// If you find a error, scroll
|
|
134
|
+
if (document.querySelector(".en__errorHeader")) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
// If it's a chained iFrame, don't scroll
|
|
138
|
+
if (this.isChained()) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
// Try to match the iframe referrer URL by testing valid EN Page URLs
|
|
142
|
+
let referrer = document.referrer;
|
|
143
|
+
let enURLPattern = new RegExp(/^(.*)\/(page)\/(\d+.*)/);
|
|
144
|
+
// Scroll if the Regex matches, don't scroll otherwise
|
|
145
|
+
return enURLPattern.test(referrer);
|
|
146
|
+
}
|
|
147
|
+
inIframe() {
|
|
148
|
+
try {
|
|
149
|
+
return window.self !== window.top;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
isChained() {
|
|
156
|
+
return !!ENGrid.getUrlParameter("chain");
|
|
157
|
+
}
|
|
158
|
+
hideFormComponents() {
|
|
159
|
+
this.logger.log("iFrame Event - Hiding Form Components");
|
|
160
|
+
const en__component = document.querySelectorAll(".body-main > div");
|
|
161
|
+
en__component.forEach((component, index) => {
|
|
162
|
+
if (component.classList.contains("hide") === false &&
|
|
163
|
+
component.classList.contains("hide-iframe") === false &&
|
|
164
|
+
component.classList.contains("radio-to-buttons_donationAmt") ===
|
|
165
|
+
false &&
|
|
166
|
+
index < en__component.length - 1) {
|
|
167
|
+
component.classList.add("hide-iframe");
|
|
168
|
+
component.classList.add("hide-chained");
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
this.sendIframeHeight();
|
|
172
|
+
}
|
|
173
|
+
showFormComponents() {
|
|
174
|
+
this.logger.log("iFrame Event - Showing Form Components");
|
|
175
|
+
const en__component = document.querySelectorAll(".body-main > div.hide-chained");
|
|
176
|
+
en__component.forEach((component) => {
|
|
177
|
+
component.classList.remove("hide-iframe");
|
|
178
|
+
component.classList.remove("hide-chained");
|
|
179
|
+
});
|
|
180
|
+
this.sendIframeHeight();
|
|
181
|
+
}
|
|
182
|
+
addChainedBanner() {
|
|
183
|
+
var _a, _b;
|
|
184
|
+
this.logger.log("iFrame Event - Adding Chained Banner");
|
|
185
|
+
const banner = document.createElement("div");
|
|
186
|
+
const lastComponent = document.querySelector(".body-main > div:last-of-type");
|
|
187
|
+
banner.classList.add("en__component");
|
|
188
|
+
banner.classList.add("en__component--banner");
|
|
189
|
+
banner.classList.add("en__component--banner--chained");
|
|
190
|
+
banner.innerHTML = `<div class="en__component__content"><div class="en__component__content__inner"><div class="en__component__content__text"><p>
|
|
191
|
+
Giving as <strong>${ENGrid.getFieldValue("supporter.firstName")} ${ENGrid.getFieldValue("supporter.lastName")}</strong>
|
|
192
|
+
with <strong>${ENGrid.getFieldValue("transaction.paymenttype").toUpperCase()}</strong>
|
|
193
|
+
(<a href="#" class="en__component__content__link">change</a>)</p></div></div></div>`;
|
|
194
|
+
(_a = lastComponent === null || lastComponent === void 0 ? void 0 : lastComponent.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(banner, lastComponent);
|
|
195
|
+
(_b = banner
|
|
196
|
+
.querySelector(".en__component__content__link")) === null || _b === void 0 ? void 0 : _b.addEventListener("click", (e) => {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
this.showFormComponents();
|
|
199
|
+
banner.remove();
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
debounceWithImmediate(func, timeout = 1000) {
|
|
203
|
+
let timer;
|
|
204
|
+
let firstEvent = true;
|
|
205
|
+
return (...args) => {
|
|
206
|
+
clearTimeout(timer);
|
|
207
|
+
if (firstEvent) {
|
|
208
|
+
func.apply(this, args);
|
|
209
|
+
firstEvent = false;
|
|
210
|
+
}
|
|
211
|
+
timer = setTimeout(() => {
|
|
212
|
+
func.apply(this, args);
|
|
213
|
+
firstEvent = true;
|
|
214
|
+
}, timeout);
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export * from "./deprecated";
|
|
2
|
+
export { Options, OptionsDefaults } from "./interfaces/options";
|
|
3
|
+
export { UpsellOptions, UpsellOptionsDefaults, } from "./interfaces/upsell-options";
|
|
4
|
+
export { TranslateOptions, TranslateOptionsDefaults, } from "./interfaces/translate-options";
|
|
5
|
+
export { ExitIntentOptions, ExitIntentOptionsDefaults, } from "./interfaces/exit-intent-options";
|
|
6
|
+
export * from "./loader";
|
|
7
|
+
export * from "./app";
|
|
8
|
+
export * from "./amount-label";
|
|
9
|
+
export * from "./engrid";
|
|
10
|
+
export * from "./apple-pay";
|
|
11
|
+
export * from "./a11y";
|
|
12
|
+
export * from "./capitalize-fields";
|
|
13
|
+
export * from "./auto-year";
|
|
14
|
+
export * from "./autocomplete";
|
|
15
|
+
export * from "./ecard";
|
|
16
|
+
export * from "./click-to-expand";
|
|
17
|
+
export * from "./advocacy";
|
|
18
|
+
export * from "./data-attributes";
|
|
19
|
+
export * from "./iframe";
|
|
20
|
+
export * from "./input-has-value-and-focus";
|
|
21
|
+
export * from "./input-placeholders";
|
|
22
|
+
export * from "./media-attribution";
|
|
23
|
+
export * from "./live-variables";
|
|
24
|
+
export * from "./upsell-lightbox";
|
|
25
|
+
export * from "./show-hide-radio-checkboxes";
|
|
26
|
+
export * from "./translate-fields";
|
|
27
|
+
export * from "./auto-country-select";
|
|
28
|
+
export * from "./skip-link";
|
|
29
|
+
export * from "./src-defer";
|
|
30
|
+
export * from "./set-recurr-freq";
|
|
31
|
+
export * from "./page-background";
|
|
32
|
+
export * from "./neverbounce";
|
|
33
|
+
export * from "./freshaddress";
|
|
34
|
+
export * from "./progress-bar";
|
|
35
|
+
export * from "./remember-me";
|
|
36
|
+
export * from "./show-if-amount";
|
|
37
|
+
export * from "./other-amount";
|
|
38
|
+
export * from "./logger";
|
|
39
|
+
export * from "./min-max-amount";
|
|
40
|
+
export * from "./ticker";
|
|
41
|
+
export * from "./data-layer";
|
|
42
|
+
export * from "./data-replace";
|
|
43
|
+
export * from "./data-hide";
|
|
44
|
+
export * from "./add-name-to-message";
|
|
45
|
+
export * from "./expand-region-name";
|
|
46
|
+
export * from "./url-to-form";
|
|
47
|
+
export * from "./required-if-visible";
|
|
48
|
+
export * from "./tidycontact";
|
|
49
|
+
export * from "./live-currency";
|
|
50
|
+
export * from "./custom-currency";
|
|
51
|
+
export * from "./autosubmit";
|
|
52
|
+
export * from "./event-tickets";
|
|
53
|
+
export * from "./swap-amounts";
|
|
54
|
+
export * from "./debug-panel";
|
|
55
|
+
export * from "./debug-hidden-fields";
|
|
56
|
+
export * from "./branding-html";
|
|
57
|
+
export * from "./country-disable";
|
|
58
|
+
export * from "./premium-gift";
|
|
59
|
+
export * from "./digital-wallets";
|
|
60
|
+
export * from "./mobile-cta";
|
|
61
|
+
export * from "./live-frequency";
|
|
62
|
+
export * from "./universal-opt-in";
|
|
63
|
+
export * from "./plaid";
|
|
64
|
+
export * from "./give-by-select";
|
|
65
|
+
export * from "./url-params-to-body-attrs";
|
|
66
|
+
export * from "./exit-intent-lightbox";
|
|
67
|
+
export * from "./supporter-hub";
|
|
68
|
+
export * from "./fast-form-fill";
|
|
69
|
+
export * from "./set-attr";
|
|
70
|
+
export * from "./show-if-present";
|
|
71
|
+
export * from "./en-validators";
|
|
72
|
+
export * from "./modal";
|
|
73
|
+
export * from "./postal-code-validator";
|
|
74
|
+
export * from "./vgs";
|
|
75
|
+
export * from "./country-redirect";
|
|
76
|
+
export * from "./welcome-back";
|
|
77
|
+
export * from "./ecard-to-target";
|
|
78
|
+
export * from "./embedded-ecard";
|
|
79
|
+
export * from "./us-only-form";
|
|
80
|
+
export * from "./thank-you-page-conditional-content";
|
|
81
|
+
export * from "./events";
|
|
82
|
+
export * from "./version";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export * from "./deprecated"; // Runs first so it can change the DOM markup before any markup dependent code fires
|
|
2
|
+
export { OptionsDefaults } from "./interfaces/options";
|
|
3
|
+
export { UpsellOptionsDefaults, } from "./interfaces/upsell-options";
|
|
4
|
+
export { TranslateOptionsDefaults, } from "./interfaces/translate-options";
|
|
5
|
+
export { ExitIntentOptionsDefaults, } from "./interfaces/exit-intent-options";
|
|
6
|
+
export * from "./loader";
|
|
7
|
+
export * from "./app";
|
|
8
|
+
export * from "./amount-label";
|
|
9
|
+
export * from "./engrid";
|
|
10
|
+
export * from "./apple-pay";
|
|
11
|
+
export * from "./a11y";
|
|
12
|
+
export * from "./capitalize-fields";
|
|
13
|
+
export * from "./auto-year";
|
|
14
|
+
export * from "./autocomplete";
|
|
15
|
+
export * from "./ecard";
|
|
16
|
+
export * from "./click-to-expand";
|
|
17
|
+
export * from "./advocacy";
|
|
18
|
+
export * from "./data-attributes";
|
|
19
|
+
export * from "./iframe";
|
|
20
|
+
export * from "./input-has-value-and-focus";
|
|
21
|
+
export * from "./input-placeholders";
|
|
22
|
+
export * from "./media-attribution";
|
|
23
|
+
export * from "./live-variables";
|
|
24
|
+
export * from "./upsell-lightbox";
|
|
25
|
+
export * from "./show-hide-radio-checkboxes";
|
|
26
|
+
export * from "./translate-fields";
|
|
27
|
+
export * from "./auto-country-select";
|
|
28
|
+
export * from "./skip-link";
|
|
29
|
+
export * from "./src-defer";
|
|
30
|
+
export * from "./set-recurr-freq";
|
|
31
|
+
export * from "./page-background";
|
|
32
|
+
export * from "./neverbounce";
|
|
33
|
+
export * from "./freshaddress";
|
|
34
|
+
export * from "./progress-bar";
|
|
35
|
+
export * from "./remember-me";
|
|
36
|
+
export * from "./show-if-amount";
|
|
37
|
+
export * from "./other-amount";
|
|
38
|
+
export * from "./logger";
|
|
39
|
+
export * from "./min-max-amount";
|
|
40
|
+
export * from "./ticker";
|
|
41
|
+
export * from "./data-layer";
|
|
42
|
+
export * from "./data-replace";
|
|
43
|
+
export * from "./data-hide";
|
|
44
|
+
export * from "./add-name-to-message";
|
|
45
|
+
export * from "./expand-region-name";
|
|
46
|
+
export * from "./url-to-form";
|
|
47
|
+
export * from "./required-if-visible";
|
|
48
|
+
export * from "./tidycontact";
|
|
49
|
+
export * from "./live-currency";
|
|
50
|
+
export * from "./custom-currency";
|
|
51
|
+
export * from "./autosubmit";
|
|
52
|
+
export * from "./event-tickets";
|
|
53
|
+
export * from "./swap-amounts";
|
|
54
|
+
export * from "./debug-panel";
|
|
55
|
+
export * from "./debug-hidden-fields";
|
|
56
|
+
export * from "./branding-html";
|
|
57
|
+
export * from "./country-disable";
|
|
58
|
+
export * from "./premium-gift";
|
|
59
|
+
export * from "./digital-wallets";
|
|
60
|
+
export * from "./mobile-cta";
|
|
61
|
+
export * from "./live-frequency";
|
|
62
|
+
export * from "./universal-opt-in";
|
|
63
|
+
export * from "./plaid";
|
|
64
|
+
export * from "./give-by-select";
|
|
65
|
+
export * from "./url-params-to-body-attrs";
|
|
66
|
+
export * from "./exit-intent-lightbox";
|
|
67
|
+
export * from "./supporter-hub";
|
|
68
|
+
export * from "./fast-form-fill";
|
|
69
|
+
export * from "./set-attr";
|
|
70
|
+
export * from "./show-if-present";
|
|
71
|
+
export * from "./en-validators";
|
|
72
|
+
export * from "./modal";
|
|
73
|
+
export * from "./postal-code-validator";
|
|
74
|
+
export * from "./vgs";
|
|
75
|
+
export * from "./country-redirect";
|
|
76
|
+
export * from "./welcome-back";
|
|
77
|
+
export * from "./ecard-to-target";
|
|
78
|
+
export * from "./embedded-ecard";
|
|
79
|
+
export * from "./us-only-form";
|
|
80
|
+
export * from "./thank-you-page-conditional-content";
|
|
81
|
+
// Events
|
|
82
|
+
export * from "./events";
|
|
83
|
+
// Version
|
|
84
|
+
export * from "./version";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Component that adds has-value and has-focus classes to form inputs
|
|
2
|
+
import { EngridLogger } from ".";
|
|
3
|
+
export class InputHasValueAndFocus {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.logger = new EngridLogger("InputHasValueAndFocus", "yellow", "#333", "🌈");
|
|
6
|
+
this.formInputs = document.querySelectorAll(".en__field--text, .en__field--email:not(.en__field--checkbox), .en__field--telephone, .en__field--number, .en__field--textarea, .en__field--select, .en__field--checkbox");
|
|
7
|
+
if (this.shouldRun()) {
|
|
8
|
+
this.run();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
shouldRun() {
|
|
12
|
+
return this.formInputs.length > 0;
|
|
13
|
+
}
|
|
14
|
+
run() {
|
|
15
|
+
this.formInputs.forEach((el) => {
|
|
16
|
+
const input = el.querySelector("input, textarea, select");
|
|
17
|
+
if (input && input.value) {
|
|
18
|
+
el.classList.add("has-value");
|
|
19
|
+
}
|
|
20
|
+
this.bindEvents(el);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
bindEvents(el) {
|
|
24
|
+
const input = el.querySelector("input, textarea, select");
|
|
25
|
+
if (!input) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
input.addEventListener("focus", () => {
|
|
29
|
+
this.log("Focus added", input);
|
|
30
|
+
el.classList.add("has-focus");
|
|
31
|
+
});
|
|
32
|
+
input.addEventListener("blur", () => {
|
|
33
|
+
this.log("Focus removed", input);
|
|
34
|
+
el.classList.remove("has-focus");
|
|
35
|
+
});
|
|
36
|
+
input.addEventListener("input", () => {
|
|
37
|
+
if (input.value) {
|
|
38
|
+
this.log("Value added", input);
|
|
39
|
+
el.classList.add("has-value");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.log("Value removed", input);
|
|
43
|
+
el.classList.remove("has-value");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
log(message, input) {
|
|
48
|
+
this.logger.log(`${message} on ${input.name}: ${input.value}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Component that adds input placeholders
|
|
2
|
+
// You can override the default placeholders by adding a Placeholders option to the EngridOptions on the client theme.
|
|
3
|
+
// You can also add an EngridPageOptions override to the page, if you want to override the placeholders on a specific page. Example:
|
|
4
|
+
// <script type="text/javascript">
|
|
5
|
+
// EngridPageOptions = {
|
|
6
|
+
// Placeholders: {
|
|
7
|
+
// "input#en__field_supporter_firstName": "Nome",
|
|
8
|
+
// "input#en__field_supporter_lastName": "Sobrenome"
|
|
9
|
+
// }
|
|
10
|
+
// };
|
|
11
|
+
// </script>
|
|
12
|
+
import { ENGrid } from ".";
|
|
13
|
+
export class InputPlaceholders {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.defaultPlaceholders = {
|
|
16
|
+
"input#en__field_supporter_firstName": "First Name",
|
|
17
|
+
"input#en__field_supporter_lastName": "Last Name",
|
|
18
|
+
"input#en__field_supporter_emailAddress": "Email Address",
|
|
19
|
+
"input#en__field_supporter_phoneNumber": "Phone Number (Optional)",
|
|
20
|
+
".en__mandatory input#en__field_supporter_phoneNumber": "Phone Number",
|
|
21
|
+
"input#en__field_supporter_phoneNumber2": "000-000-0000 (Optional)",
|
|
22
|
+
".en__mandatory input#en__field_supporter_phoneNumber2": "000-000-0000",
|
|
23
|
+
"input#en__field_supporter_country": "Country",
|
|
24
|
+
"input#en__field_supporter_address1": "Street Address",
|
|
25
|
+
"input#en__field_supporter_address2": "Apt., Ste., Bldg.",
|
|
26
|
+
"input#en__field_supporter_city": "City",
|
|
27
|
+
"input#en__field_supporter_region": "Region",
|
|
28
|
+
"input#en__field_supporter_postcode": "ZIP Code",
|
|
29
|
+
".en__field--donationAmt.en__field--withOther .en__field__input--other": "Other",
|
|
30
|
+
"input#en__field_transaction_ccexpire": "MM / YY",
|
|
31
|
+
"input#en__field_supporter_bankAccountNumber": "Bank Account Number",
|
|
32
|
+
"input#en__field_supporter_bankRoutingNumber": "Bank Routing Number",
|
|
33
|
+
"input#en__field_transaction_honname": "Honoree Name",
|
|
34
|
+
"input#en__field_transaction_infname": "Recipient Name",
|
|
35
|
+
"input#en__field_transaction_infemail": "Recipient Email Address",
|
|
36
|
+
"input#en__field_transaction_infcountry": "Country",
|
|
37
|
+
"input#en__field_transaction_infadd1": "Recipient Street Address",
|
|
38
|
+
"input#en__field_transaction_infadd2": "Recipient Apt., Ste., Bldg.",
|
|
39
|
+
"input#en__field_transaction_infcity": "Recipient City",
|
|
40
|
+
"input#en__field_transaction_infpostcd": "Recipient Postal Code",
|
|
41
|
+
"input#en__field_transaction_gftrsn": "Reason for your gift",
|
|
42
|
+
"input#en__field_transaction_shipfname": "Shipping First Name",
|
|
43
|
+
"input#en__field_transaction_shiplname": "Shipping Last Name",
|
|
44
|
+
"input#en__field_transaction_shipemail": "Shipping Email Address",
|
|
45
|
+
"input#en__field_transaction_shipcountry": "Shipping Country",
|
|
46
|
+
"input#en__field_transaction_shipadd1": "Shipping Street Address",
|
|
47
|
+
"input#en__field_transaction_shipadd2": "Shipping Apt., Ste., Bldg.",
|
|
48
|
+
"input#en__field_transaction_shipcity": "Shipping City",
|
|
49
|
+
"input#en__field_transaction_shipregion": "Shipping Region",
|
|
50
|
+
"input#en__field_transaction_shippostcode": "Shipping Postal Code",
|
|
51
|
+
"input#en__field_supporter_billingCountry": "Billing Country",
|
|
52
|
+
"input#en__field_supporter_billingAddress1": "Billing Street Address",
|
|
53
|
+
"input#en__field_supporter_billingAddress2": "Billing Apt., Ste., Bldg.",
|
|
54
|
+
"input#en__field_supporter_billingCity": "Billing City",
|
|
55
|
+
"input#en__field_supporter_billingRegion": "Billing Region",
|
|
56
|
+
"input#en__field_supporter_billingPostcode": "Billing Postal Code",
|
|
57
|
+
};
|
|
58
|
+
if (this.shouldRun()) {
|
|
59
|
+
// If there's a Placeholders option, merge it with the default placeholders
|
|
60
|
+
const placeholders = ENGrid.getOption("Placeholders");
|
|
61
|
+
if (placeholders) {
|
|
62
|
+
this.defaultPlaceholders = Object.assign(Object.assign({}, this.defaultPlaceholders), placeholders);
|
|
63
|
+
}
|
|
64
|
+
this.run();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
shouldRun() {
|
|
68
|
+
return ENGrid.hasBodyData("add-input-placeholders");
|
|
69
|
+
}
|
|
70
|
+
run() {
|
|
71
|
+
Object.keys(this.defaultPlaceholders).forEach((selector) => {
|
|
72
|
+
if (selector in this.defaultPlaceholders)
|
|
73
|
+
this.addPlaceholder(selector, this.defaultPlaceholders[selector]);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
addPlaceholder(selector, placeholder) {
|
|
77
|
+
const fieldEl = document.querySelector(selector);
|
|
78
|
+
if (fieldEl) {
|
|
79
|
+
fieldEl.placeholder = placeholder;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface EcardToTargetOptions {
|
|
2
|
+
targetName: string;
|
|
3
|
+
targetEmail: string;
|
|
4
|
+
hideSendDate: boolean;
|
|
5
|
+
hideTarget: boolean;
|
|
6
|
+
hideMessage: boolean;
|
|
7
|
+
addSupporterNameToMessage: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const EcardToTargetOptionsDefaults: EcardToTargetOptions;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ExitIntentOptions {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
title: string;
|
|
4
|
+
text: string;
|
|
5
|
+
buttonText: string;
|
|
6
|
+
buttonLink: string;
|
|
7
|
+
cookieName: string;
|
|
8
|
+
cookieDuration: number;
|
|
9
|
+
triggers: {
|
|
10
|
+
[key: string]: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare const ExitIntentOptionsDefaults: ExitIntentOptions;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const ExitIntentOptionsDefaults = {
|
|
2
|
+
enabled: false,
|
|
3
|
+
title: "We are sad that you are leaving",
|
|
4
|
+
text: "Would you mind telling us why you are leaving this page?",
|
|
5
|
+
buttonText: "Send us your comments",
|
|
6
|
+
buttonLink: "https://www.4sitestudios.com/",
|
|
7
|
+
cookieName: "engrid-exit-intent-lightbox",
|
|
8
|
+
cookieDuration: 30,
|
|
9
|
+
triggers: {
|
|
10
|
+
visibilityState: true,
|
|
11
|
+
mousePosition: true,
|
|
12
|
+
},
|
|
13
|
+
};
|