@4site/engrid-scripts 0.25.8 → 0.25.9
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 -0
- package/dist/engrid.js +21 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/engrid.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export declare abstract class ENGrid {
|
|
|
54
54
|
static removeHtml(target: string): void;
|
|
55
55
|
static slugify(text: string): string;
|
|
56
56
|
static watchForError(callback: Function): void;
|
|
57
|
+
private static getErrorCallbackKey;
|
|
57
58
|
static getPaymentType(): string;
|
|
58
59
|
static setPaymentType(paymentType: string): void;
|
|
59
60
|
static isInViewport(element: HTMLElement): boolean;
|
package/dist/engrid.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const errorCallbacks = new Map();
|
|
1
2
|
export class ENGrid {
|
|
2
3
|
constructor() {
|
|
3
4
|
if (!ENGrid.enForm) {
|
|
@@ -426,6 +427,7 @@ export class ENGrid {
|
|
|
426
427
|
else {
|
|
427
428
|
errorMessageElement.innerHTML = errorMessage;
|
|
428
429
|
}
|
|
430
|
+
errorCallbacks.forEach((callback) => callback());
|
|
429
431
|
}
|
|
430
432
|
}
|
|
431
433
|
static removeError(element) {
|
|
@@ -510,6 +512,24 @@ export class ENGrid {
|
|
|
510
512
|
// This function is used to run a callback function when an error is displayed on the page
|
|
511
513
|
static watchForError(callback) {
|
|
512
514
|
const errorElement = document.querySelector(".en__errorList");
|
|
515
|
+
const callbackType = ENGrid.getErrorCallbackKey(callback);
|
|
516
|
+
// Register callback so setError can trigger it too
|
|
517
|
+
if (!errorCallbacks.has(callbackType)) {
|
|
518
|
+
errorCallbacks.set(callbackType, callback);
|
|
519
|
+
}
|
|
520
|
+
if (errorElement && !errorElement.dataset[callbackType]) {
|
|
521
|
+
errorElement.dataset[callbackType] = "true";
|
|
522
|
+
const observer = new MutationObserver(function (mutations) {
|
|
523
|
+
mutations.forEach(function (mutation) {
|
|
524
|
+
if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
|
|
525
|
+
callback();
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
observer.observe(errorElement, { childList: true });
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
static getErrorCallbackKey(callback) {
|
|
513
533
|
const capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
514
534
|
// Avoid duplicate callbacks
|
|
515
535
|
let callbackType = callback.toString();
|
|
@@ -523,18 +543,7 @@ export class ENGrid {
|
|
|
523
543
|
callbackType = callbackType.replace(/[^a-zA-Z0-9]/g, "");
|
|
524
544
|
// Limit to 20 characters and add prefix
|
|
525
545
|
callbackType = callbackType.substring(0, 20);
|
|
526
|
-
|
|
527
|
-
if (errorElement && !errorElement.dataset[callbackType]) {
|
|
528
|
-
errorElement.dataset[callbackType] = "true";
|
|
529
|
-
const observer = new MutationObserver(function (mutations) {
|
|
530
|
-
mutations.forEach(function (mutation) {
|
|
531
|
-
if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
|
|
532
|
-
callback();
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
});
|
|
536
|
-
observer.observe(errorElement, { childList: true });
|
|
537
|
-
}
|
|
546
|
+
return "engrid" + capitalize(callbackType);
|
|
538
547
|
}
|
|
539
548
|
// Get the Payment Type
|
|
540
549
|
static getPaymentType() {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.25.
|
|
1
|
+
export declare const AppVersion = "0.25.9";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.25.
|
|
1
|
+
export const AppVersion = "0.25.9";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.9",
|
|
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": "18896dd2e4e4ed893ac2531f2fc01586fd5af904",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|