@4site/engrid-scripts 0.19.12 → 0.19.14
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/dist/events/donation-amount.js +12 -0
- package/dist/upsell-checkbox.d.ts +2 -0
- package/dist/upsell-checkbox.js +27 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/welcome-back.d.ts +1 -0
- package/dist/welcome-back.js +4 -0
- package/package.json +2 -2
|
@@ -89,6 +89,12 @@ export class DonationAmount {
|
|
|
89
89
|
if (found.length) {
|
|
90
90
|
const amountField = found[0];
|
|
91
91
|
amountField.checked = true;
|
|
92
|
+
// Change Event
|
|
93
|
+
const event = new Event("change", {
|
|
94
|
+
bubbles: true,
|
|
95
|
+
cancelable: true,
|
|
96
|
+
});
|
|
97
|
+
amountField.dispatchEvent(event);
|
|
92
98
|
// Clear OTHER text field
|
|
93
99
|
this.clearOther();
|
|
94
100
|
}
|
|
@@ -100,6 +106,12 @@ export class DonationAmount {
|
|
|
100
106
|
enFieldOtherAmountRadio.checked = true;
|
|
101
107
|
}
|
|
102
108
|
otherField.value = parseFloat(amount.toString()).toFixed(2);
|
|
109
|
+
// Change Event
|
|
110
|
+
const event = new Event("change", {
|
|
111
|
+
bubbles: true,
|
|
112
|
+
cancelable: true,
|
|
113
|
+
});
|
|
114
|
+
otherField.dispatchEvent(event);
|
|
103
115
|
const otherWrapper = otherField.parentNode;
|
|
104
116
|
otherWrapper.classList.remove("en__field__item--hidden");
|
|
105
117
|
}
|
|
@@ -11,9 +11,11 @@ export declare class UpsellCheckbox {
|
|
|
11
11
|
private checkboxContainer;
|
|
12
12
|
private oldAmount;
|
|
13
13
|
private oldFrequency;
|
|
14
|
+
private resetCheckbox;
|
|
14
15
|
private logger;
|
|
15
16
|
constructor();
|
|
16
17
|
private updateLiveData;
|
|
18
|
+
private resetUpsellCheckbox;
|
|
17
19
|
private renderCheckbox;
|
|
18
20
|
private shouldRun;
|
|
19
21
|
private showCheckbox;
|
package/dist/upsell-checkbox.js
CHANGED
|
@@ -16,6 +16,7 @@ export class UpsellCheckbox {
|
|
|
16
16
|
this.checkboxContainer = null;
|
|
17
17
|
this.oldAmount = 0;
|
|
18
18
|
this.oldFrequency = "one-time";
|
|
19
|
+
this.resetCheckbox = false;
|
|
19
20
|
this.logger = new EngridLogger("UpsellCheckbox", "black", "LemonChiffon", "✅");
|
|
20
21
|
let options = "EngridUpsell" in window ? window.EngridUpsell : {};
|
|
21
22
|
this.options = Object.assign(Object.assign({}, UpsellOptionsDefaults), options);
|
|
@@ -23,8 +24,8 @@ export class UpsellCheckbox {
|
|
|
23
24
|
this.logger.log("Skipped");
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
|
-
//
|
|
27
|
-
if (
|
|
27
|
+
// To avoid using both UpsellLightbox and UpsellCheckbox at the same time, set window.EngridUpsell.skipUpsell to true if there's an upsellCheckbox
|
|
28
|
+
if ("upsellCheckbox" in options && options.upsellCheckbox !== false) {
|
|
28
29
|
window.EngridUpsell.skipUpsell = true; // Skip the upsell lightbox
|
|
29
30
|
}
|
|
30
31
|
this.checkboxOptions = Object.assign(Object.assign({}, this.checkboxOptionsDefaults), this.options.upsellCheckbox);
|
|
@@ -36,13 +37,32 @@ export class UpsellCheckbox {
|
|
|
36
37
|
this.renderCheckbox();
|
|
37
38
|
this.updateLiveData();
|
|
38
39
|
this._frequency.onFrequencyChange.subscribe(() => this.updateLiveData());
|
|
40
|
+
this._frequency.onFrequencyChange.subscribe(() => this.resetUpsellCheckbox());
|
|
39
41
|
this._amount.onAmountChange.subscribe(() => this.updateLiveData());
|
|
42
|
+
this._amount.onAmountChange.subscribe(() => this.resetUpsellCheckbox());
|
|
40
43
|
this._fees.onFeeChange.subscribe(() => this.updateLiveData());
|
|
41
44
|
}
|
|
42
45
|
updateLiveData() {
|
|
43
46
|
this.liveAmounts();
|
|
44
47
|
this.liveFrequency();
|
|
45
48
|
}
|
|
49
|
+
resetUpsellCheckbox() {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
// Only reset the upsell checkbox if it has been checked
|
|
52
|
+
if (!this.resetCheckbox)
|
|
53
|
+
return;
|
|
54
|
+
this.logger.log("Reset");
|
|
55
|
+
// Uncheck the upsell checkbox
|
|
56
|
+
const checkbox = (_a = this.checkboxContainer) === null || _a === void 0 ? void 0 : _a.querySelector("#upsellCheckbox");
|
|
57
|
+
if (checkbox) {
|
|
58
|
+
checkbox.checked = false;
|
|
59
|
+
}
|
|
60
|
+
// Hide the upsell checkbox
|
|
61
|
+
(_b = this.checkboxContainer) === null || _b === void 0 ? void 0 : _b.classList.add("recurring-frequency-y-hide");
|
|
62
|
+
this.oldAmount = 0;
|
|
63
|
+
this.oldFrequency = "one-time";
|
|
64
|
+
this.resetCheckbox = false;
|
|
65
|
+
}
|
|
46
66
|
renderCheckbox() {
|
|
47
67
|
if (this.checkboxOptions === false)
|
|
48
68
|
return;
|
|
@@ -168,8 +188,13 @@ export class UpsellCheckbox {
|
|
|
168
188
|
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_ORIGINAL_AMOUNT", originalAmount);
|
|
169
189
|
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY", "MONTHLY");
|
|
170
190
|
this.renderConversionField("upsellSuccess", "onetime", originalAmount, "monthly", upsoldAmount, "monthly", upsoldAmount);
|
|
191
|
+
// Set the resetCheckbox flag to true so it will reset if the user changes the amount or frequency
|
|
192
|
+
window.setTimeout(() => {
|
|
193
|
+
this.resetCheckbox = true;
|
|
194
|
+
}, 500);
|
|
171
195
|
}
|
|
172
196
|
else {
|
|
197
|
+
this.resetCheckbox = false;
|
|
173
198
|
this.logger.success("Not Upsold");
|
|
174
199
|
this._amount.setAmount(this.oldAmount);
|
|
175
200
|
this._frequency.setFrequency(this.oldFrequency);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.19.
|
|
1
|
+
export declare const AppVersion = "0.19.14";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.19.
|
|
1
|
+
export const AppVersion = "0.19.14";
|
package/dist/welcome-back.d.ts
CHANGED
package/dist/welcome-back.js
CHANGED
|
@@ -15,6 +15,7 @@ export class WelcomeBack {
|
|
|
15
15
|
this.supporterDetails = {};
|
|
16
16
|
this.options = (_a = ENGrid.getOption("WelcomeBack")) !== null && _a !== void 0 ? _a : false;
|
|
17
17
|
this.rememberMeEvents = RememberMeEvents.getInstance();
|
|
18
|
+
this.hasRun = false;
|
|
18
19
|
if (!this.shouldRun())
|
|
19
20
|
return;
|
|
20
21
|
if (ENGrid.getOption("RememberMe")) {
|
|
@@ -30,6 +31,9 @@ export class WelcomeBack {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
run() {
|
|
34
|
+
if (this.hasRun)
|
|
35
|
+
return;
|
|
36
|
+
this.hasRun = true;
|
|
33
37
|
this.supporterDetails = {
|
|
34
38
|
firstName: ENGrid.getFieldValue("supporter.firstName"),
|
|
35
39
|
lastName: ENGrid.getFieldValue("supporter.lastName"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.14",
|
|
4
4
|
"description": "Scripts for the ENGRID Project",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"strongly-typed-events": "^2.0.9"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/4site-interactive-studios/engrid#readme",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "15f7f50a88b04c675f65c35e03cc663ba7110d4e",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|