@4site/engrid-scripts 0.25.5 → 0.25.7
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/a11y.d.ts +13 -0
- package/dist/a11y.js +111 -1
- package/dist/click-to-expand.js +48 -17
- package/dist/data-layer.d.ts +2 -0
- package/dist/data-layer.js +8 -0
- package/dist/interfaces/options.d.ts +1 -1
- package/dist/min-max-amount.js +1 -1
- package/dist/optin-ladder.d.ts +3 -0
- package/dist/optin-ladder.js +61 -6
- package/dist/remember-me.js +0 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/a11y.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
export declare class A11y {
|
|
2
|
+
private logger;
|
|
3
|
+
private observer;
|
|
2
4
|
constructor();
|
|
5
|
+
private addErrorAlertArea;
|
|
3
6
|
private addGroupRole;
|
|
4
7
|
private addRequired;
|
|
5
8
|
private addLabel;
|
|
6
9
|
private updateFrequencyLabel;
|
|
7
10
|
private setAutoGeneratedAltTags;
|
|
11
|
+
/**
|
|
12
|
+
* Observe #engrid for .en__field__error additions and removals, mirroring
|
|
13
|
+
* text into the per-field .en__field__error__alert live region and toggling
|
|
14
|
+
* aria-invalid / aria-describedby on the corresponding input. Runs for the
|
|
15
|
+
* lifetime of the page so async validators (NeverBounce, VGS, server
|
|
16
|
+
* re-renders) are caught without timing assumptions.
|
|
17
|
+
*/
|
|
18
|
+
private observeErrorMessages;
|
|
19
|
+
private moveErrorMessage;
|
|
20
|
+
private clearErrorMessage;
|
|
8
21
|
private manageErrorListAlertRole;
|
|
9
22
|
}
|
package/dist/a11y.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { EngridLogger } from "./logger";
|
|
1
2
|
// a11y means accessibility
|
|
2
3
|
// This Component is supposed to be used as a helper for Aria Attributes & Other Accessibility Features
|
|
3
4
|
export class A11y {
|
|
4
5
|
constructor() {
|
|
6
|
+
this.logger = new EngridLogger("A11y", "#FFFFFF", "#811212", "👁️🗨️");
|
|
7
|
+
this.observer = null;
|
|
8
|
+
this.addErrorAlertArea();
|
|
5
9
|
this.addRequired();
|
|
6
10
|
this.addLabel();
|
|
7
11
|
this.addGroupRole();
|
|
@@ -9,6 +13,21 @@ export class A11y {
|
|
|
9
13
|
const ecardImages = document.querySelectorAll('.en__ecarditems__list img');
|
|
10
14
|
this.setAutoGeneratedAltTags(ecardImages);
|
|
11
15
|
this.manageErrorListAlertRole();
|
|
16
|
+
this.observeErrorMessages();
|
|
17
|
+
}
|
|
18
|
+
addErrorAlertArea() {
|
|
19
|
+
const fieldElements = document.querySelectorAll('.en__field .en__field__element');
|
|
20
|
+
fieldElements.forEach((fieldElement) => {
|
|
21
|
+
var _a;
|
|
22
|
+
if ((_a = fieldElement.nextElementSibling) === null || _a === void 0 ? void 0 : _a.classList.contains('en__field__error__alert'))
|
|
23
|
+
return;
|
|
24
|
+
const errorAlert = document.createElement('div');
|
|
25
|
+
errorAlert.setAttribute('aria-live', 'polite');
|
|
26
|
+
errorAlert.setAttribute('aria-atomic', 'true');
|
|
27
|
+
errorAlert.classList.add('en__field__error__alert');
|
|
28
|
+
errorAlert.id = `en__field__error__alert--${Math.random().toString(36).slice(2, 7)}`;
|
|
29
|
+
fieldElement.insertAdjacentElement('afterend', errorAlert);
|
|
30
|
+
});
|
|
12
31
|
}
|
|
13
32
|
addGroupRole() {
|
|
14
33
|
// Add role="group" to all EN Radio fields
|
|
@@ -90,10 +109,101 @@ export class A11y {
|
|
|
90
109
|
img.alt = altText;
|
|
91
110
|
}
|
|
92
111
|
catch (error) {
|
|
93
|
-
|
|
112
|
+
this.logger.danger(`Error processing image: ${img.src}`, error);
|
|
94
113
|
}
|
|
95
114
|
});
|
|
96
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Observe #engrid for .en__field__error additions and removals, mirroring
|
|
118
|
+
* text into the per-field .en__field__error__alert live region and toggling
|
|
119
|
+
* aria-invalid / aria-describedby on the corresponding input. Runs for the
|
|
120
|
+
* lifetime of the page so async validators (NeverBounce, VGS, server
|
|
121
|
+
* re-renders) are caught without timing assumptions.
|
|
122
|
+
*/
|
|
123
|
+
observeErrorMessages() {
|
|
124
|
+
var _a;
|
|
125
|
+
const root = (_a = document.getElementById('engrid')) !== null && _a !== void 0 ? _a : document.body;
|
|
126
|
+
this.observer = new MutationObserver(records => {
|
|
127
|
+
for (const record of records) {
|
|
128
|
+
if (record.type !== 'childList')
|
|
129
|
+
continue;
|
|
130
|
+
record.addedNodes.forEach(node => {
|
|
131
|
+
if (node instanceof HTMLElement && node.classList.contains('en__field__error')) {
|
|
132
|
+
this.moveErrorMessage(node);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
record.removedNodes.forEach(node => {
|
|
136
|
+
var _a, _b;
|
|
137
|
+
if (!(node instanceof HTMLElement))
|
|
138
|
+
return;
|
|
139
|
+
if (!node.classList.contains('en__field__error'))
|
|
140
|
+
return;
|
|
141
|
+
// node.parentElement is null after removal; record.target is the
|
|
142
|
+
// former parent. Walk up to the enclosing .en__field to be defensive
|
|
143
|
+
// against deeper nesting.
|
|
144
|
+
const fieldWrapper = (_b = (_a = record.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, '.en__field');
|
|
145
|
+
const alert = fieldWrapper === null || fieldWrapper === void 0 ? void 0 : fieldWrapper.querySelector('.en__field__error__alert');
|
|
146
|
+
if (alert)
|
|
147
|
+
this.clearErrorMessage(alert);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
this.observer.observe(root, { childList: true, subtree: true });
|
|
152
|
+
// Initial sweep for errors rendered server-side or by scripts that ran
|
|
153
|
+
// before this observer was attached.
|
|
154
|
+
document.querySelectorAll('.en__field').forEach(field => {
|
|
155
|
+
const error = field.querySelector('.en__field__error');
|
|
156
|
+
const alert = field.querySelector('.en__field__error__alert');
|
|
157
|
+
if (error)
|
|
158
|
+
this.moveErrorMessage(error);
|
|
159
|
+
else if (alert)
|
|
160
|
+
this.clearErrorMessage(alert);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
moveErrorMessage(field) {
|
|
164
|
+
var _a;
|
|
165
|
+
if (field.closest('.en__field__error__alert'))
|
|
166
|
+
return;
|
|
167
|
+
const fieldWrapper = field.closest('.en__field');
|
|
168
|
+
if (!fieldWrapper)
|
|
169
|
+
return;
|
|
170
|
+
const alertContainer = fieldWrapper.querySelector('.en__field__error__alert');
|
|
171
|
+
if (!alertContainer)
|
|
172
|
+
return;
|
|
173
|
+
alertContainer.textContent = field.textContent;
|
|
174
|
+
field.classList.add('en__field__error--hidden-by-a11y');
|
|
175
|
+
const inputElement = fieldWrapper.querySelector('.en__field__element input, .en__field__element select, .en__field__element textarea');
|
|
176
|
+
if (!inputElement)
|
|
177
|
+
return;
|
|
178
|
+
inputElement.setAttribute('aria-invalid', 'true');
|
|
179
|
+
const describedBy = ((_a = inputElement.getAttribute('aria-describedby')) !== null && _a !== void 0 ? _a : '')
|
|
180
|
+
.split(/\s+/)
|
|
181
|
+
.filter(Boolean);
|
|
182
|
+
if (describedBy.indexOf(alertContainer.id) === -1) {
|
|
183
|
+
describedBy.push(alertContainer.id);
|
|
184
|
+
}
|
|
185
|
+
inputElement.setAttribute('aria-describedby', describedBy.join(' '));
|
|
186
|
+
}
|
|
187
|
+
clearErrorMessage(alert) {
|
|
188
|
+
var _a;
|
|
189
|
+
alert.textContent = '';
|
|
190
|
+
const fieldWrapper = alert.closest('.en__field');
|
|
191
|
+
if (!fieldWrapper)
|
|
192
|
+
return;
|
|
193
|
+
const inputElement = fieldWrapper.querySelector('.en__field__element input, .en__field__element select, .en__field__element textarea');
|
|
194
|
+
if (!inputElement)
|
|
195
|
+
return;
|
|
196
|
+
inputElement.removeAttribute('aria-invalid');
|
|
197
|
+
const remaining = ((_a = inputElement.getAttribute('aria-describedby')) !== null && _a !== void 0 ? _a : '')
|
|
198
|
+
.split(/\s+/)
|
|
199
|
+
.filter(id => id && id !== alert.id);
|
|
200
|
+
if (remaining.length) {
|
|
201
|
+
inputElement.setAttribute('aria-describedby', remaining.join(' '));
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
inputElement.removeAttribute('aria-describedby');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
97
207
|
manageErrorListAlertRole() {
|
|
98
208
|
const errorList = document.querySelector('ul.en__errorList');
|
|
99
209
|
if (!errorList)
|
package/dist/click-to-expand.js
CHANGED
|
@@ -6,29 +6,60 @@ export class ClickToExpand {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
this.clickToExpandWrapper = document.querySelectorAll("div.click-to-expand");
|
|
8
8
|
if (this.clickToExpandWrapper.length) {
|
|
9
|
-
this.clickToExpandWrapper.forEach((element) => {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
this.clickToExpandWrapper.forEach((element, index) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const textWrapperId = `click-to-expand-text-${index}`;
|
|
12
|
+
const ctaId = `click-to-expand-cta-${index}`;
|
|
13
|
+
// Extract screen reader tip from the live DOM
|
|
14
|
+
const screenReaderTip = element.querySelector(".click-to-expand-screenreader-tip");
|
|
15
|
+
let ariaLabel = "Show more";
|
|
16
|
+
if (screenReaderTip) {
|
|
17
|
+
const tipText = (_a = screenReaderTip.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
18
|
+
if (tipText) {
|
|
19
|
+
ariaLabel = `Show more: ${tipText}`;
|
|
20
20
|
}
|
|
21
|
+
screenReaderTip.remove();
|
|
22
|
+
}
|
|
23
|
+
// Capture all original child nodes before restructuring
|
|
24
|
+
const originalChildren = Array.from(element.childNodes);
|
|
25
|
+
element.innerHTML = "";
|
|
26
|
+
// Create the text wrapper
|
|
27
|
+
const textWrapper = document.createElement("div");
|
|
28
|
+
textWrapper.className = "click-to-expand-text-wrapper";
|
|
29
|
+
textWrapper.id = textWrapperId;
|
|
30
|
+
textWrapper.setAttribute("aria-hidden", "true");
|
|
31
|
+
textWrapper.setAttribute("aria-label", "Expanded content" + (ariaLabel ? `${ariaLabel.replace('Show more', '')}` : ""));
|
|
32
|
+
textWrapper.setAttribute("tabindex", "-1");
|
|
33
|
+
originalChildren.forEach((child) => {
|
|
34
|
+
textWrapper.appendChild(child);
|
|
21
35
|
});
|
|
36
|
+
const cta = document.createElement("div");
|
|
37
|
+
cta.className = "click-to-expand-cta";
|
|
38
|
+
cta.id = ctaId;
|
|
39
|
+
cta.setAttribute("role", "button");
|
|
40
|
+
cta.setAttribute("tabindex", "0");
|
|
41
|
+
cta.setAttribute("aria-expanded", "false");
|
|
42
|
+
cta.setAttribute("aria-controls", textWrapperId);
|
|
43
|
+
cta.setAttribute("aria-label", ariaLabel);
|
|
44
|
+
element.appendChild(textWrapper);
|
|
45
|
+
element.appendChild(cta);
|
|
46
|
+
const expand = () => {
|
|
47
|
+
if (ENGrid.debug) {
|
|
48
|
+
console.log("A click-to-expand div was expanded");
|
|
49
|
+
}
|
|
50
|
+
element.classList.add("expanded");
|
|
51
|
+
cta.setAttribute("aria-expanded", "true");
|
|
52
|
+
cta.setAttribute("aria-hidden", "true");
|
|
53
|
+
textWrapper.setAttribute("aria-hidden", "false");
|
|
54
|
+
textWrapper.focus(); // Move focus to revealed content for screen reader announcement
|
|
55
|
+
};
|
|
56
|
+
element.addEventListener("click", expand);
|
|
22
57
|
element.addEventListener("keydown", (event) => {
|
|
23
58
|
if (event.key === "Enter") {
|
|
24
|
-
|
|
25
|
-
console.log("A click-to-expand div had the 'Enter' key pressed on it");
|
|
26
|
-
element.classList.add("expanded");
|
|
59
|
+
expand();
|
|
27
60
|
}
|
|
28
61
|
else if (event.key === " ") {
|
|
29
|
-
|
|
30
|
-
console.log("A click-to-expand div had the 'Spacebar' key pressed on it");
|
|
31
|
-
element.classList.add("expanded");
|
|
62
|
+
expand();
|
|
32
63
|
event.preventDefault(); // Prevents the page from scrolling
|
|
33
64
|
event.stopPropagation(); // Prevent a console error generated by LastPass https://github.com/KillerCodeMonkey/ngx-quill/issues/351#issuecomment-476017960
|
|
34
65
|
}
|
package/dist/data-layer.d.ts
CHANGED
|
@@ -27,4 +27,6 @@ export declare class DataLayer {
|
|
|
27
27
|
private storeEndOfGiftProcessData;
|
|
28
28
|
private addEndOfGiftProcessEventsToDataLayer;
|
|
29
29
|
private getEndOfGiftProcessData;
|
|
30
|
+
pushVariable(variableName: string, variableValue?: any): void;
|
|
31
|
+
pushEvent(eventName: string, eventProperties?: object): void;
|
|
30
32
|
}
|
package/dist/data-layer.js
CHANGED
|
@@ -346,4 +346,12 @@ export class DataLayer {
|
|
|
346
346
|
let eventsData = window.sessionStorage.getItem(this.endOfGiftProcessStorageKey);
|
|
347
347
|
return !eventsData ? [] : JSON.parse(eventsData);
|
|
348
348
|
}
|
|
349
|
+
pushVariable(variableName, variableValue = "") {
|
|
350
|
+
this.dataLayer.push({
|
|
351
|
+
[variableName.toUpperCase()]: variableValue,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
pushEvent(eventName, eventProperties = {}) {
|
|
355
|
+
this.dataLayer.push(Object.assign({ event: eventName }, eventProperties));
|
|
356
|
+
}
|
|
349
357
|
}
|
|
@@ -16,7 +16,7 @@ export interface Options {
|
|
|
16
16
|
MinAmountMessage?: string;
|
|
17
17
|
MaxAmountMessage?: string;
|
|
18
18
|
UseAmountValidatorFromEN?: boolean;
|
|
19
|
-
|
|
19
|
+
DisableMinMaxLiveValidation?: boolean;
|
|
20
20
|
SkipToMainContentLink?: boolean;
|
|
21
21
|
SrcDefer?: boolean;
|
|
22
22
|
SuppressPurchaseEcard?: boolean;
|
package/dist/min-max-amount.js
CHANGED
|
@@ -10,7 +10,7 @@ export class MinMaxAmount {
|
|
|
10
10
|
this.maxAmount = (_b = ENGrid.getOption("MaxAmount")) !== null && _b !== void 0 ? _b : 100000;
|
|
11
11
|
this.minAmountMessage = ENGrid.getOption("MinAmountMessage");
|
|
12
12
|
this.maxAmountMessage = ENGrid.getOption("MaxAmountMessage");
|
|
13
|
-
this.disableLiveValidation = ENGrid.getOption("
|
|
13
|
+
this.disableLiveValidation = ENGrid.getOption("DisableMinMaxLiveValidation");
|
|
14
14
|
this.enAmountValidator = null;
|
|
15
15
|
this.logger = new EngridLogger("MinMaxAmount", "white", "purple", "🔢");
|
|
16
16
|
if (!this.shouldRun()) {
|
package/dist/optin-ladder.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export declare class OptInLadder {
|
|
2
2
|
private logger;
|
|
3
3
|
private _form;
|
|
4
|
+
private _dataLayer;
|
|
4
5
|
constructor();
|
|
5
6
|
private runAsParent;
|
|
6
7
|
private runAsChildRegular;
|
|
7
8
|
private runAsChildThankYou;
|
|
8
9
|
private inIframe;
|
|
10
|
+
private listenForParentInfo;
|
|
9
11
|
private saveStepToSessionStorage;
|
|
10
12
|
private saveOptInsToSessionStorage;
|
|
11
13
|
private isEmbeddedThankYouPage;
|
|
@@ -13,4 +15,5 @@ export declare class OptInLadder {
|
|
|
13
15
|
private getFirstPageUrl;
|
|
14
16
|
private hidePage;
|
|
15
17
|
private clearSessionStorage;
|
|
18
|
+
private isFollowupStep;
|
|
16
19
|
}
|
package/dist/optin-ladder.js
CHANGED
|
@@ -6,19 +6,23 @@
|
|
|
6
6
|
* If the page is embedded in an iframe and on a Thank You Page, and the child iFrame is also a Thank You Page, we will look for a sessionStorage that has the current ladder step and the total number of steps.
|
|
7
7
|
* If the current step is less than the total number of steps, we will redirect to the first page. If the current step is equal to the total number of steps, we will show the Thank You Page.
|
|
8
8
|
*/
|
|
9
|
-
import { EngridLogger, ENGrid, EnForm } from ".";
|
|
9
|
+
import { EngridLogger, ENGrid, EnForm, DataLayer } from ".";
|
|
10
10
|
export class OptInLadder {
|
|
11
11
|
constructor() {
|
|
12
12
|
this.logger = new EngridLogger("OptInLadder", "lightgreen", "darkgreen", "✔");
|
|
13
13
|
this._form = EnForm.getInstance();
|
|
14
|
+
this._dataLayer = DataLayer.getInstance();
|
|
14
15
|
if (!this.inIframe()) {
|
|
15
16
|
this.runAsParent();
|
|
16
17
|
}
|
|
17
|
-
else if (ENGrid.getPageNumber() === 1) {
|
|
18
|
-
this.runAsChildRegular();
|
|
19
|
-
}
|
|
20
18
|
else {
|
|
21
|
-
this.
|
|
19
|
+
this.listenForParentInfo();
|
|
20
|
+
if (ENGrid.getPageNumber() === 1) {
|
|
21
|
+
this.runAsChildRegular();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.runAsChildThankYou();
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
runAsParent() {
|
|
@@ -64,6 +68,17 @@ export class OptInLadder {
|
|
|
64
68
|
return;
|
|
65
69
|
}
|
|
66
70
|
placement.appendChild(iframe);
|
|
71
|
+
iframe.addEventListener("load", () => {
|
|
72
|
+
var _a;
|
|
73
|
+
if (iframe.contentWindow) {
|
|
74
|
+
iframe.contentWindow.postMessage({
|
|
75
|
+
type: "engrid-optin-ladder-parent-info",
|
|
76
|
+
pageID: ENGrid.getPageID(),
|
|
77
|
+
pageName: ((_a = window === null || window === void 0 ? void 0 : window.pageJson) === null || _a === void 0 ? void 0 : _a.pageName) || "",
|
|
78
|
+
pageType: ENGrid.getPageType(),
|
|
79
|
+
}, "*");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
67
82
|
}
|
|
68
83
|
else {
|
|
69
84
|
// Grab all the checkboxes with the name starting with "supporter.questions"
|
|
@@ -83,6 +98,7 @@ export class OptInLadder {
|
|
|
83
98
|
}
|
|
84
99
|
}
|
|
85
100
|
runAsChildRegular() {
|
|
101
|
+
var _a;
|
|
86
102
|
if (!this.isEmbeddedThankYouPage()) {
|
|
87
103
|
this.logger.log("Not Embedded on a Thank You Page");
|
|
88
104
|
return;
|
|
@@ -106,6 +122,8 @@ export class OptInLadder {
|
|
|
106
122
|
let totalSteps = optInHeaders.length;
|
|
107
123
|
let currentHeader = null;
|
|
108
124
|
let currentFormBlock = null;
|
|
125
|
+
let submissionCount = Number(sessionStorage.getItem("engrid.optin-ladder-submission-count")) ||
|
|
126
|
+
0;
|
|
109
127
|
for (let i = 0; i < optInHeaders.length; i++) {
|
|
110
128
|
const header = optInHeaders[i];
|
|
111
129
|
// Get the optin number from the .optin-ladder-XXXX class
|
|
@@ -168,8 +186,23 @@ export class OptInLadder {
|
|
|
168
186
|
});
|
|
169
187
|
// Save the current step to sessionStorage
|
|
170
188
|
this.saveStepToSessionStorage(currentStep, totalSteps);
|
|
189
|
+
if (!this.isFollowupStep()) {
|
|
190
|
+
this._dataLayer.pushVariable("ENGRID_OPTIN_LADDER_FIRST_STEP_ID", ((_a = currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.className.match(/optin-ladder-(\d+)/)) === null || _a === void 0 ? void 0 : _a[1]) || "");
|
|
191
|
+
this._dataLayer.pushVariable("ENGRID_OPTIN_LADDER_FIRST_STEP_NAME", (currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.innerText.trim()) || "");
|
|
192
|
+
}
|
|
171
193
|
// On form submit, save the checkbox values to sessionStorage
|
|
172
194
|
this._form.onSubmit.subscribe(() => {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
submissionCount++;
|
|
197
|
+
this._dataLayer.pushEvent("ENGRID_OPTIN_LADDER_SUBMIT", {
|
|
198
|
+
opt_in_label: (_a = currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.innerText.trim()) !== null && _a !== void 0 ? _a : "Unknown",
|
|
199
|
+
opt_in_id: ((_b = currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.className.match(/optin-ladder-(\d+)/)) === null || _b === void 0 ? void 0 : _b[1]) || "",
|
|
200
|
+
opt_in_step: currentStep,
|
|
201
|
+
opt_in_total_steps: totalSteps,
|
|
202
|
+
submission_count: submissionCount,
|
|
203
|
+
});
|
|
204
|
+
this._dataLayer.pushVariable("ENGRID_OPTIN_LADDER_SUBMISSION_COUNT", submissionCount);
|
|
205
|
+
sessionStorage.setItem("engrid.optin-ladder-submission-count", submissionCount.toString());
|
|
173
206
|
this.saveOptInsToSessionStorage("child");
|
|
174
207
|
// Save the current step to sessionStorage
|
|
175
208
|
currentStep++;
|
|
@@ -221,6 +254,16 @@ export class OptInLadder {
|
|
|
221
254
|
return true;
|
|
222
255
|
}
|
|
223
256
|
}
|
|
257
|
+
listenForParentInfo() {
|
|
258
|
+
window.addEventListener("message", (event) => {
|
|
259
|
+
var _a, _b, _c;
|
|
260
|
+
if (event.data && event.data.type === "engrid-optin-ladder-parent-info") {
|
|
261
|
+
this._dataLayer.pushVariable("ENGRID_OPTIN_LADDER_PARENT_ID", ((_a = event.data) === null || _a === void 0 ? void 0 : _a.pageID) || "");
|
|
262
|
+
this._dataLayer.pushVariable("ENGRID_OPTIN_LADDER_PARENT_NAME", ((_b = event.data) === null || _b === void 0 ? void 0 : _b.pageName) || "");
|
|
263
|
+
this._dataLayer.pushVariable("ENGRID_OPTIN_LADDER_PARENT_TYPE", ((_c = event.data) === null || _c === void 0 ? void 0 : _c.pageType) || "");
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
224
267
|
saveStepToSessionStorage(step, totalSteps) {
|
|
225
268
|
sessionStorage.setItem("engrid.optin-ladder", JSON.stringify({ step, totalSteps }));
|
|
226
269
|
this.logger.log(`Saved step ${step} of ${totalSteps} to sessionStorage`);
|
|
@@ -258,7 +301,12 @@ export class OptInLadder {
|
|
|
258
301
|
const url = new URL(window.location.href);
|
|
259
302
|
const path = url.pathname.split("/");
|
|
260
303
|
path[path.length - 1] = String(page);
|
|
261
|
-
|
|
304
|
+
url.pathname = path.join("/");
|
|
305
|
+
if (chain) {
|
|
306
|
+
url.searchParams.set("chain", "true");
|
|
307
|
+
}
|
|
308
|
+
url.searchParams.set("engrid_optin_ladder_followup", "true");
|
|
309
|
+
return url.toString();
|
|
262
310
|
}
|
|
263
311
|
getFirstPageUrl() {
|
|
264
312
|
return this.getPageUrl(1, true);
|
|
@@ -281,5 +329,12 @@ export class OptInLadder {
|
|
|
281
329
|
sessionStorage.removeItem("engrid.optin-ladder");
|
|
282
330
|
sessionStorage.removeItem("engrid.optin-ladder-stop");
|
|
283
331
|
sessionStorage.removeItem("engrid.optin-ladder-persist-stop");
|
|
332
|
+
sessionStorage.removeItem("engrid.optin-ladder-submission-count");
|
|
333
|
+
}
|
|
334
|
+
isFollowupStep() {
|
|
335
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
336
|
+
const fromUrl = searchParams.get("engrid_optin_ladder_followup") === "true";
|
|
337
|
+
const fromStorage = Number(sessionStorage.getItem("engrid.optin-ladder-submission-count")) > 0;
|
|
338
|
+
return fromUrl || fromStorage;
|
|
284
339
|
}
|
|
285
340
|
}
|
package/dist/remember-me.js
CHANGED
|
@@ -83,11 +83,9 @@ export class RememberMe {
|
|
|
83
83
|
let hasFieldData = Object.keys(this.fieldData).length > 0;
|
|
84
84
|
if (!hasFieldData) {
|
|
85
85
|
this.insertRememberMeOptin();
|
|
86
|
-
this.rememberMeOptIn = false;
|
|
87
86
|
}
|
|
88
87
|
else {
|
|
89
88
|
this.insertClearRememberMeLink();
|
|
90
|
-
this.rememberMeOptIn = true;
|
|
91
89
|
}
|
|
92
90
|
this.writeFields();
|
|
93
91
|
this._form.onSubmit.subscribe(() => {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.25.
|
|
1
|
+
export declare const AppVersion = "0.25.7";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.25.
|
|
1
|
+
export const AppVersion = "0.25.7";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.7",
|
|
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": "dedeb6ea7fe99ce49c00fdd46827c7fd6470d044",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|