@4site/engrid-scripts 0.27.3 → 0.27.5
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/engrid.d.ts +1 -1
- package/dist/engrid.js +9 -1
- package/dist/frequency-upsell-modal.d.ts +1 -1
- package/dist/frequency-upsell-modal.js +3 -2
- package/dist/frequency-upsell.d.ts +5 -0
- package/dist/frequency-upsell.js +15 -1
- package/dist/interfaces/frequency-upsell-options.d.ts +2 -0
- package/dist/interfaces/frequency-upsell-options.js +2 -0
- package/dist/interfaces/options.d.ts +1 -0
- package/dist/modal.d.ts +9 -0
- package/dist/modal.js +25 -6
- package/dist/remember-me.d.ts +2 -0
- package/dist/remember-me.js +6 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/engrid.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare abstract class ENGrid {
|
|
|
26
26
|
*/
|
|
27
27
|
static getPageIdFromUrl(url: string): number;
|
|
28
28
|
static getClientID(): any;
|
|
29
|
-
static getDataCenter(): "us" | "ca";
|
|
29
|
+
static getDataCenter(): "us2" | "us" | "ca";
|
|
30
30
|
static getPageType(): "DONATION" | "ECARD" | "SURVEY" | "EMAILTOTARGET" | "ADVOCACY" | "SUBSCRIBEFORM" | "EVENT" | "SUPPORTERHUB" | "UNSUBSCRIBE" | "TWEETPAGE" | "UNKNOWN";
|
|
31
31
|
static setBodyData(dataName: string, value: string | boolean): void;
|
|
32
32
|
static getBodyData(dataName: string): string | null;
|
package/dist/engrid.js
CHANGED
|
@@ -205,7 +205,15 @@ export class ENGrid {
|
|
|
205
205
|
}
|
|
206
206
|
//returns 'us or 'ca' based on the client ID
|
|
207
207
|
static getDataCenter() {
|
|
208
|
-
|
|
208
|
+
if (ENGrid.getClientID() > 20000) {
|
|
209
|
+
return "us2";
|
|
210
|
+
}
|
|
211
|
+
else if (ENGrid.getClientID() > 10000) {
|
|
212
|
+
return "us";
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
return "ca";
|
|
216
|
+
}
|
|
209
217
|
}
|
|
210
218
|
// Return the current page type
|
|
211
219
|
static getPageType() {
|
|
@@ -3,7 +3,7 @@ export declare class FrequencyUpsellModal extends Modal {
|
|
|
3
3
|
private readonly upsellOptions;
|
|
4
4
|
private _amountWithFees;
|
|
5
5
|
private _upsellAmountWithFees;
|
|
6
|
-
constructor(upsellOptions: FrequencyUpsellOptions);
|
|
6
|
+
constructor(upsellOptions: FrequencyUpsellOptions, onDismiss?: () => void);
|
|
7
7
|
set amountWithFees(value: number);
|
|
8
8
|
set upsellAmountWithFees(value: number);
|
|
9
9
|
updateModalContent(): void;
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ENGrid, Modal } from ".";
|
|
7
7
|
export class FrequencyUpsellModal extends Modal {
|
|
8
|
-
constructor(upsellOptions) {
|
|
8
|
+
constructor(upsellOptions, onDismiss) {
|
|
9
9
|
super({
|
|
10
10
|
onClickOutside: "bounce",
|
|
11
11
|
customClass: `engrid--frequency-upsell-modal ${upsellOptions.customClass}`,
|
|
12
|
-
showCloseX:
|
|
12
|
+
showCloseX: upsellOptions.showCloseX,
|
|
13
|
+
onDismiss,
|
|
13
14
|
});
|
|
14
15
|
this._amountWithFees = 0;
|
|
15
16
|
this._upsellAmountWithFees = 0;
|
|
@@ -31,6 +31,11 @@ export declare class FrequencyUpsell {
|
|
|
31
31
|
*/
|
|
32
32
|
getUpsellAmount(withFee: boolean): number;
|
|
33
33
|
private addEventListeners;
|
|
34
|
+
/**
|
|
35
|
+
* Handle the modal being dismissed via the X button, Esc key, or click-outside.
|
|
36
|
+
* This always counts as a decline (onDecline fires either way).
|
|
37
|
+
*/
|
|
38
|
+
private handleModalDismiss;
|
|
34
39
|
/**
|
|
35
40
|
* Create the frequency field for the upsell, if it does not exist on the page already
|
|
36
41
|
* This is required by DonationFrequency to set the frequency
|
package/dist/frequency-upsell.js
CHANGED
|
@@ -23,7 +23,7 @@ export class FrequencyUpsell {
|
|
|
23
23
|
}
|
|
24
24
|
this.options = this.selectOptions(window.EngridFrequencyUpsell);
|
|
25
25
|
this.logger.log("FrequencyUpsell initialized", this.options);
|
|
26
|
-
this.upsellModal = new FrequencyUpsellModal(this.options);
|
|
26
|
+
this.upsellModal = new FrequencyUpsellModal(this.options, () => this.handleModalDismiss());
|
|
27
27
|
this.createFrequencyField();
|
|
28
28
|
this.addEventListeners();
|
|
29
29
|
}
|
|
@@ -144,6 +144,20 @@ export class FrequencyUpsell {
|
|
|
144
144
|
return true;
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Handle the modal being dismissed via the X button, Esc key, or click-outside.
|
|
149
|
+
* This always counts as a decline (onDecline fires either way).
|
|
150
|
+
*/
|
|
151
|
+
handleModalDismiss() {
|
|
152
|
+
this.logger.log("Frequency upsell modal dismissed (declined)");
|
|
153
|
+
this.options.onDecline();
|
|
154
|
+
if (this.options.submitOnClose) {
|
|
155
|
+
this._form.submitForm();
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this._form.dispatchError();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
147
161
|
/**
|
|
148
162
|
* Create the frequency field for the upsell, if it does not exist on the page already
|
|
149
163
|
* This is required by DonationFrequency to set the frequency
|
package/dist/modal.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ interface ModalOptions {
|
|
|
4
4
|
closeButtonLabel?: string;
|
|
5
5
|
customClass?: string;
|
|
6
6
|
showCloseX?: boolean;
|
|
7
|
+
closeOnEsc?: boolean;
|
|
8
|
+
onDismiss?: () => void;
|
|
7
9
|
}
|
|
8
10
|
export declare abstract class Modal {
|
|
9
11
|
modalContent: NodeListOf<Element> | HTMLElement | String;
|
|
@@ -13,7 +15,14 @@ export declare abstract class Modal {
|
|
|
13
15
|
protected constructor(options: ModalOptions);
|
|
14
16
|
private createModal;
|
|
15
17
|
private addEventListeners;
|
|
18
|
+
/**
|
|
19
|
+
* Generic entry point for dismissing the modal.
|
|
20
|
+
* Fires the onDismiss callback before closing, so consumers can react to the modal being
|
|
21
|
+
* dismissed rather than closed via their own explicit button logic.
|
|
22
|
+
*/
|
|
23
|
+
private dismiss;
|
|
16
24
|
private focusTrapHandler;
|
|
25
|
+
private escKeyHandler;
|
|
17
26
|
open(): void;
|
|
18
27
|
close(): void;
|
|
19
28
|
getModalContent(): NodeListOf<Element> | HTMLElement | String;
|
package/dist/modal.js
CHANGED
|
@@ -8,6 +8,8 @@ export class Modal {
|
|
|
8
8
|
closeButtonLabel: "Okay!",
|
|
9
9
|
customClass: "",
|
|
10
10
|
showCloseX: true,
|
|
11
|
+
closeOnEsc: true,
|
|
12
|
+
onDismiss: () => { },
|
|
11
13
|
};
|
|
12
14
|
this.focusTrapHandler = (e) => {
|
|
13
15
|
const modalElement = this.modal;
|
|
@@ -33,6 +35,11 @@ export class Modal {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
};
|
|
38
|
+
this.escKeyHandler = (e) => {
|
|
39
|
+
if (e.key === "Escape" && this.options.closeOnEsc) {
|
|
40
|
+
this.dismiss();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
36
43
|
this.options = Object.assign(Object.assign({}, this.defaultOptions), options);
|
|
37
44
|
this.modalContent = this.getModalContent();
|
|
38
45
|
this.createModal();
|
|
@@ -83,7 +90,7 @@ export class Modal {
|
|
|
83
90
|
button.classList.add("engrid-modal__button");
|
|
84
91
|
button.textContent = this.options.closeButtonLabel;
|
|
85
92
|
button.addEventListener("click", () => {
|
|
86
|
-
this.
|
|
93
|
+
this.dismiss();
|
|
87
94
|
});
|
|
88
95
|
modalBody === null || modalBody === void 0 ? void 0 : modalBody.appendChild(button);
|
|
89
96
|
}
|
|
@@ -93,13 +100,13 @@ export class Modal {
|
|
|
93
100
|
var _a, _b, _c, _d, _e;
|
|
94
101
|
// Close event on top X
|
|
95
102
|
(_b = (_a = this.modal) === null || _a === void 0 ? void 0 : _a.querySelector(".engrid-modal__close")) === null || _b === void 0 ? void 0 : _b.addEventListener("click", () => {
|
|
96
|
-
this.
|
|
103
|
+
this.dismiss();
|
|
97
104
|
});
|
|
98
105
|
// Bounce scale when clicking outside of modal
|
|
99
106
|
(_d = (_c = this.modal) === null || _c === void 0 ? void 0 : _c.querySelector(".engrid-modal__overlay")) === null || _d === void 0 ? void 0 : _d.addEventListener("click", (event) => {
|
|
100
107
|
if (event.target === event.currentTarget) {
|
|
101
108
|
if (this.options.onClickOutside === "close") {
|
|
102
|
-
this.
|
|
109
|
+
this.dismiss();
|
|
103
110
|
}
|
|
104
111
|
else if (this.options.onClickOutside === "bounce") {
|
|
105
112
|
const modal = document.querySelector(".engrid-modal");
|
|
@@ -115,25 +122,37 @@ export class Modal {
|
|
|
115
122
|
const closeEls = (_e = this.modal) === null || _e === void 0 ? void 0 : _e.querySelectorAll(".modal__close");
|
|
116
123
|
closeEls === null || closeEls === void 0 ? void 0 : closeEls.forEach((el) => {
|
|
117
124
|
el.addEventListener("click", () => {
|
|
118
|
-
this.
|
|
125
|
+
this.dismiss();
|
|
119
126
|
});
|
|
120
127
|
});
|
|
121
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Generic entry point for dismissing the modal.
|
|
131
|
+
* Fires the onDismiss callback before closing, so consumers can react to the modal being
|
|
132
|
+
* dismissed rather than closed via their own explicit button logic.
|
|
133
|
+
*/
|
|
134
|
+
dismiss() {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
(_b = (_a = this.options).onDismiss) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
137
|
+
this.close();
|
|
138
|
+
}
|
|
122
139
|
open() {
|
|
123
|
-
var _a, _b, _c, _d;
|
|
140
|
+
var _a, _b, _c, _d, _e;
|
|
124
141
|
ENGrid.setBodyData("has-lightbox", "true");
|
|
125
142
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.classList.remove("modal--hidden");
|
|
126
143
|
(_b = this.modal) === null || _b === void 0 ? void 0 : _b.removeAttribute("aria-hidden");
|
|
127
144
|
const container = (_c = this.modal) === null || _c === void 0 ? void 0 : _c.querySelector(".engrid-modal__container");
|
|
128
145
|
container === null || container === void 0 ? void 0 : container.focus({ preventScroll: true });
|
|
129
146
|
(_d = this.modal) === null || _d === void 0 ? void 0 : _d.addEventListener("keydown", this.focusTrapHandler);
|
|
147
|
+
(_e = this.modal) === null || _e === void 0 ? void 0 : _e.addEventListener("keydown", this.escKeyHandler);
|
|
130
148
|
}
|
|
131
149
|
close() {
|
|
132
|
-
var _a, _b, _c;
|
|
150
|
+
var _a, _b, _c, _d;
|
|
133
151
|
ENGrid.setBodyData("has-lightbox", false);
|
|
134
152
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.classList.add("modal--hidden");
|
|
135
153
|
(_b = this.modal) === null || _b === void 0 ? void 0 : _b.setAttribute("aria-hidden", "true");
|
|
136
154
|
(_c = this.modal) === null || _c === void 0 ? void 0 : _c.removeEventListener("keydown", this.focusTrapHandler);
|
|
155
|
+
(_d = this.modal) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.escKeyHandler);
|
|
137
156
|
}
|
|
138
157
|
getModalContent() {
|
|
139
158
|
return "<h1>Default Modal Content</h1>";
|
package/dist/remember-me.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class RememberMe {
|
|
|
22
22
|
private fieldClearSelectorTarget;
|
|
23
23
|
private fieldClearSelectorTargetLocation;
|
|
24
24
|
private fieldClearLabel;
|
|
25
|
+
private rememberMeLabel;
|
|
25
26
|
constructor(options: {
|
|
26
27
|
remoteUrl?: string;
|
|
27
28
|
cookieName?: string;
|
|
@@ -37,6 +38,7 @@ export declare class RememberMe {
|
|
|
37
38
|
fieldClearSelectorTarget?: string;
|
|
38
39
|
fieldClearSelectorTargetLocation?: string;
|
|
39
40
|
fieldClearLabel?: string;
|
|
41
|
+
rememberMeLabel?: string;
|
|
40
42
|
checked?: boolean;
|
|
41
43
|
encryptData?: boolean;
|
|
42
44
|
hide?: boolean;
|
package/dist/remember-me.js
CHANGED
|
@@ -65,6 +65,9 @@ export class RememberMe {
|
|
|
65
65
|
this.fieldClearLabel = options.fieldClearLabel
|
|
66
66
|
? options.fieldClearLabel
|
|
67
67
|
: "(clear autofill)";
|
|
68
|
+
this.rememberMeLabel = options.rememberMeLabel
|
|
69
|
+
? options.rememberMeLabel
|
|
70
|
+
: "Remember Me";
|
|
68
71
|
this.fieldData = {};
|
|
69
72
|
if (this.useRemote()) {
|
|
70
73
|
this.createIframe(() => {
|
|
@@ -228,11 +231,11 @@ export class RememberMe {
|
|
|
228
231
|
insertRememberMeOptin() {
|
|
229
232
|
let rememberMeOptInField = document.getElementById("remember-me-opt-in");
|
|
230
233
|
if (!rememberMeOptInField) {
|
|
231
|
-
const rememberMeLabel =
|
|
234
|
+
const rememberMeLabel = this.rememberMeLabel;
|
|
232
235
|
const rememberMeInfo = `
|
|
233
|
-
Check
|
|
236
|
+
Check “${rememberMeLabel}” to complete forms on this device faster.
|
|
234
237
|
While your financial information won’t be stored, you should only check this box from a personal device.
|
|
235
|
-
Click
|
|
238
|
+
Click “${this.fieldClearLabel}” to remove the information from your device at any time.
|
|
236
239
|
`;
|
|
237
240
|
const rememberMeOptInFieldChecked = this.rememberMeOptIn ? "checked" : "";
|
|
238
241
|
const rememberMeOptInField = document.createElement("div");
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.27.
|
|
1
|
+
export declare const AppVersion = "0.27.5";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.27.
|
|
1
|
+
export const AppVersion = "0.27.5";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.5",
|
|
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": "d21f3b47609308bd75a8309d7c0e71d1519717e4",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|