@4site/engrid-scripts 0.21.6 → 0.21.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/post-donation-embed.js +18 -10
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// This component only works on Thank You pages and the current page IS NOT embedded as an iframe.
|
|
2
2
|
// It searches for a post-donation tag (engrid-post-donation)
|
|
3
|
-
// and if it exists, it will replace it with an iframe of the current donation page, replacing the
|
|
4
|
-
// "/donate/2" with "/donate/1"
|
|
5
|
-
//
|
|
6
|
-
// 1.
|
|
7
|
-
// 2.
|
|
3
|
+
// and if it exists, it will replace it with an iframe of the chained `src` attribute (or the current donation page, replacing the
|
|
4
|
+
// "/donate/2" with "/donate/1").
|
|
5
|
+
// The engrid-post-donation tag has 3 attributes:
|
|
6
|
+
// 1. src: the URL of the iframe to load (optional)
|
|
7
|
+
// 2. params: the URL parameters to pass to the iframe
|
|
8
|
+
// 3. amounts: comma separated list of amounts to pass to the iframe
|
|
8
9
|
import { ENGrid, EngridLogger } from ".";
|
|
9
10
|
export class PostDonationEmbed {
|
|
10
11
|
constructor() {
|
|
@@ -13,10 +14,17 @@ export class PostDonationEmbed {
|
|
|
13
14
|
return;
|
|
14
15
|
this.logger.log("Post Donation Tag found");
|
|
15
16
|
const postDonationTag = document.querySelector("engrid-post-donation");
|
|
16
|
-
// Get
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
// Get `src` attribute from the <engrid-post-donation> tag if it exists
|
|
18
|
+
// If not, use the current page URL as the base URL
|
|
19
|
+
let iFrameSRC;
|
|
20
|
+
if (!postDonationTag.getAttribute("src")) {
|
|
21
|
+
iFrameSRC = new URL(window.location.href);
|
|
22
|
+
// Modify the path: replace "/donate/2" with "/donate/1"
|
|
23
|
+
iFrameSRC.pathname = iFrameSRC.pathname.replace("/donate/2", "/donate/1");
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
iFrameSRC = new URL(postDonationTag.getAttribute("src") || "");
|
|
27
|
+
}
|
|
20
28
|
// Extract parameters from the <engrid-post-donation> tag
|
|
21
29
|
let params = postDonationTag.getAttribute("params") || "";
|
|
22
30
|
let amounts = postDonationTag.getAttribute("amounts");
|
|
@@ -27,7 +35,7 @@ export class PostDonationEmbed {
|
|
|
27
35
|
.replace(/%5B/g, "[")
|
|
28
36
|
.replace(/%5D/g, "]");
|
|
29
37
|
// Construct new URL with "chain" parameter
|
|
30
|
-
let newUrl = `${
|
|
38
|
+
let newUrl = `${iFrameSRC.origin}${iFrameSRC.pathname}?chain&${paramString}`;
|
|
31
39
|
if (amounts) {
|
|
32
40
|
newUrl += `&engrid-amounts=${amounts}`;
|
|
33
41
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.21.
|
|
1
|
+
export declare const AppVersion = "0.21.7";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.21.
|
|
1
|
+
export const AppVersion = "0.21.7";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.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": "7bceb7455c1b61341c473c824f72a81039110421",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|