@4site/engrid-scripts 0.20.4 → 0.20.6
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/interfaces/options.d.ts +8 -3
- package/dist/interfaces/options.js +1 -0
- package/dist/mobile-cta.js +15 -11
- package/dist/optin-ladder.js +55 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -75,9 +75,9 @@ export interface Options {
|
|
|
75
75
|
phone_status_field?: string;
|
|
76
76
|
};
|
|
77
77
|
MobileCTA?: false | {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
78
|
+
pageType: string;
|
|
79
|
+
label: string;
|
|
80
|
+
}[];
|
|
81
81
|
PageLayouts?: string[];
|
|
82
82
|
CountryDisable?: string[];
|
|
83
83
|
Plaid?: boolean;
|
|
@@ -138,6 +138,11 @@ export interface Options {
|
|
|
138
138
|
placement: "beforebegin" | "afterbegin" | "beforeend" | "afterend";
|
|
139
139
|
};
|
|
140
140
|
};
|
|
141
|
+
OptInLadder?: false | {
|
|
142
|
+
iframeUrl: string;
|
|
143
|
+
placementQuerySelector?: string | null;
|
|
144
|
+
excludePageIDs?: string[];
|
|
145
|
+
};
|
|
141
146
|
onLoad?: () => void;
|
|
142
147
|
onResize?: () => void;
|
|
143
148
|
onSubmit?: () => void;
|
package/dist/mobile-cta.js
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
import { ENGrid } from ".";
|
|
3
3
|
export class MobileCTA {
|
|
4
4
|
constructor() {
|
|
5
|
-
var _a
|
|
5
|
+
var _a;
|
|
6
6
|
// Initialize options with the MobileCTA value or false
|
|
7
7
|
this.options = (_a = ENGrid.getOption("MobileCTA")) !== null && _a !== void 0 ? _a : false;
|
|
8
8
|
this.buttonLabel = "";
|
|
9
9
|
// Return early if the options object is falsy or the current page type is not in the options.pages array
|
|
10
|
-
if (!this.options ||
|
|
11
|
-
!((_b = this.options.pages) === null || _b === void 0 ? void 0 : _b.includes(ENGrid.getPageType())) ||
|
|
12
|
-
ENGrid.getPageNumber() !== 1)
|
|
10
|
+
if (!this.options || ENGrid.getPageNumber() !== 1) {
|
|
13
11
|
return;
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
}
|
|
13
|
+
const labelForPageType = this.options.find((option) => option.pageType === ENGrid.getPageType());
|
|
14
|
+
if (!labelForPageType)
|
|
15
|
+
return;
|
|
16
|
+
// Set the button label to the window.mobileCTAButtonLabel value or the label for the current page type
|
|
17
|
+
this.buttonLabel = window.mobileCTAButtonLabel || labelForPageType.label;
|
|
16
18
|
this.renderButton();
|
|
17
19
|
this.addEventListeners();
|
|
18
20
|
}
|
|
@@ -25,11 +27,12 @@ export class MobileCTA {
|
|
|
25
27
|
const buttonContainer = document.createElement("div");
|
|
26
28
|
const button = document.createElement("button");
|
|
27
29
|
// Add necessary classes and set the initial display style for the button container
|
|
28
|
-
buttonContainer.classList.add("engrid-mobile-cta-container");
|
|
29
|
-
buttonContainer.style.display = "none";
|
|
30
|
+
buttonContainer.classList.add("engrid-mobile-cta-container", "hide-cta");
|
|
30
31
|
button.classList.add("primary");
|
|
31
32
|
// Set the button's innerHTML and add a click event listener
|
|
32
|
-
button.innerHTML =
|
|
33
|
+
button.innerHTML =
|
|
34
|
+
this.buttonLabel +
|
|
35
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>';
|
|
33
36
|
button.addEventListener("click", () => {
|
|
34
37
|
formBlock.scrollIntoView({ behavior: "smooth" });
|
|
35
38
|
});
|
|
@@ -51,6 +54,7 @@ export class MobileCTA {
|
|
|
51
54
|
this.showButton();
|
|
52
55
|
}
|
|
53
56
|
};
|
|
57
|
+
toggleButton();
|
|
54
58
|
// Add event listeners for load, resize, and scroll events to toggle the button visibility
|
|
55
59
|
window.addEventListener("load", toggleButton);
|
|
56
60
|
window.addEventListener("resize", toggleButton);
|
|
@@ -60,12 +64,12 @@ export class MobileCTA {
|
|
|
60
64
|
hideButton() {
|
|
61
65
|
const buttonContainer = document.querySelector(".engrid-mobile-cta-container");
|
|
62
66
|
if (buttonContainer)
|
|
63
|
-
buttonContainer.
|
|
67
|
+
buttonContainer.classList.add("hide-cta");
|
|
64
68
|
}
|
|
65
69
|
// Show the button by setting the container's display style to "block"
|
|
66
70
|
showButton() {
|
|
67
71
|
const buttonContainer = document.querySelector(".engrid-mobile-cta-container");
|
|
68
72
|
if (buttonContainer)
|
|
69
|
-
buttonContainer.
|
|
73
|
+
buttonContainer.classList.remove("hide-cta");
|
|
70
74
|
}
|
|
71
75
|
}
|
package/dist/optin-ladder.js
CHANGED
|
@@ -19,20 +19,62 @@ export class OptInLadder {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
runAsParent() {
|
|
22
|
-
// Grab all the checkboxes with the name starting with "supporter.questions"
|
|
23
|
-
const checkboxes = document.querySelectorAll('input[name^="supporter.questions"]');
|
|
24
|
-
if (checkboxes.length === 0) {
|
|
25
|
-
this.logger.log("No checkboxes found");
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
this._form.onSubmit.subscribe(() => {
|
|
29
|
-
// Save the checkbox values to sessionStorage
|
|
30
|
-
this.saveOptInsToSessionStorage("parent");
|
|
31
|
-
});
|
|
32
22
|
this.logger.log("Running as Parent");
|
|
33
|
-
if (ENGrid.getPageNumber() ===
|
|
34
|
-
//
|
|
35
|
-
|
|
23
|
+
if (ENGrid.getPageNumber() === ENGrid.getPageCount()) {
|
|
24
|
+
// We are on the Thank You Page as a Parent
|
|
25
|
+
// Check autoinject iFrame
|
|
26
|
+
const optInLadderOptions = ENGrid.getOption("OptInLadder");
|
|
27
|
+
if (!optInLadderOptions || !optInLadderOptions.iframeUrl) {
|
|
28
|
+
this.logger.log("Options not found");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Create an iFrame
|
|
32
|
+
const iframe = document.createElement("iframe");
|
|
33
|
+
iframe.src = optInLadderOptions.iframeUrl;
|
|
34
|
+
iframe.style.width = "100%";
|
|
35
|
+
iframe.style.height = "0";
|
|
36
|
+
iframe.scrolling = "no";
|
|
37
|
+
iframe.frameBorder = "0";
|
|
38
|
+
iframe.allowFullscreen = true;
|
|
39
|
+
iframe.allow = "payment";
|
|
40
|
+
iframe.classList.add("opt-in-ladder-iframe");
|
|
41
|
+
iframe.classList.add("engrid-iframe");
|
|
42
|
+
// If the page already has an iFrame with the same class, we don't need to add another one
|
|
43
|
+
const existingIframe = document.querySelector(".opt-in-ladder-iframe");
|
|
44
|
+
if (existingIframe) {
|
|
45
|
+
this.logger.log("iFrame already exists");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Check if the current page is part of the excludePageIDs
|
|
49
|
+
if (optInLadderOptions.excludePageIDs &&
|
|
50
|
+
optInLadderOptions.excludePageIDs.includes(ENGrid.getPageID())) {
|
|
51
|
+
this.logger.log("Current page is excluded");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Append the iFrame to the proper placement
|
|
55
|
+
const placementQuerySelector = optInLadderOptions.placementQuerySelector || ".body-top";
|
|
56
|
+
const placement = document.querySelector(placementQuerySelector);
|
|
57
|
+
if (!placement) {
|
|
58
|
+
this.logger.error("Placement not found");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
placement.appendChild(iframe);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Grab all the checkboxes with the name starting with "supporter.questions"
|
|
65
|
+
const checkboxes = document.querySelectorAll('input[name^="supporter.questions"]');
|
|
66
|
+
if (checkboxes.length === 0) {
|
|
67
|
+
this.logger.log("No checkboxes found");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this._form.onSubmit.subscribe(() => {
|
|
71
|
+
// Save the checkbox values to sessionStorage
|
|
72
|
+
this.saveOptInsToSessionStorage("parent");
|
|
73
|
+
});
|
|
74
|
+
if (ENGrid.getPageNumber() === 1) {
|
|
75
|
+
// Delete items from sessionStorage
|
|
76
|
+
this.clearSessionStorage();
|
|
77
|
+
}
|
|
36
78
|
}
|
|
37
79
|
}
|
|
38
80
|
runAsChildRegular() {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.20.
|
|
1
|
+
export declare const AppVersion = "0.20.6";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.20.
|
|
1
|
+
export const AppVersion = "0.20.6";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.6",
|
|
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": "b07efd7689177105b2f3136bf8dce785d8d580eb",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|