@4site/engrid-scripts 0.28.1 → 0.28.2
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/remember-me.d.ts +0 -23
- package/dist/remember-me.js +7 -117
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/remember-me.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { EnForm, RememberMeEvents } from "./events";
|
|
|
2
2
|
export declare class RememberMe {
|
|
3
3
|
_form: EnForm;
|
|
4
4
|
_events: RememberMeEvents;
|
|
5
|
-
private _frequency;
|
|
6
5
|
private remoteUrl;
|
|
7
6
|
private cookieName;
|
|
8
7
|
private fieldNames;
|
|
@@ -15,7 +14,6 @@ export declare class RememberMe {
|
|
|
15
14
|
private fieldDonationAmountRadioName;
|
|
16
15
|
private fieldDonationAmountOtherName;
|
|
17
16
|
private fieldDonationRecurrPayRadioName;
|
|
18
|
-
private fieldDonationRecurrFreqRadioName;
|
|
19
17
|
private fieldDonationAmountOtherCheckboxID;
|
|
20
18
|
private fieldOptInSelectorTarget;
|
|
21
19
|
private fieldOptInSelectorTargetLocation;
|
|
@@ -31,7 +29,6 @@ export declare class RememberMe {
|
|
|
31
29
|
fieldDonationAmountRadioName?: string;
|
|
32
30
|
fieldDonationAmountOtherName?: string;
|
|
33
31
|
fieldDonationRecurrPayRadioName?: string;
|
|
34
|
-
fieldDonationRecurrFreqRadioName?: string;
|
|
35
32
|
fieldDonationAmountOtherCheckboxID?: string;
|
|
36
33
|
fieldOptInSelectorTarget?: string;
|
|
37
34
|
fieldOptInSelectorTargetLocation?: string;
|
|
@@ -104,25 +101,5 @@ export declare class RememberMe {
|
|
|
104
101
|
* @param overwrite - A boolean indicating whether to overwrite the existing value of the fields. Defaults to false.
|
|
105
102
|
*/
|
|
106
103
|
private writeFields;
|
|
107
|
-
/**
|
|
108
|
-
* SwapAmounts replaces the donationAmt radio DOM nodes ~1 second after page
|
|
109
|
-
* load (triggered by DonationFrequency.load() setTimeout). When that happens
|
|
110
|
-
* the selection the RememberMe just wrote gets wiped out.
|
|
111
|
-
*
|
|
112
|
-
* This method subscribes to the first onFrequencyChange event and, after a
|
|
113
|
-
* short delay to let SwapAmounts finish its DOM update, re-applies only the
|
|
114
|
-
* donation amount. It unsubscribes immediately so it only fires once.
|
|
115
|
-
*
|
|
116
|
-
* To avoid overwriting a manual donor interaction, the handler checks
|
|
117
|
-
* whether the current amount selection is empty/wiped (as SwapAmounts does)
|
|
118
|
-
* OR still matches what writeFields originally set. If the donor already
|
|
119
|
-
* picked a different amount, we skip re-application.
|
|
120
|
-
*/
|
|
121
|
-
private reapplyDonationAmtAfterSwap;
|
|
122
|
-
/**
|
|
123
|
-
* Returns the currently selected donation amount value, or null if nothing
|
|
124
|
-
* is selected. Checks both predefined radio buttons and the "Other" text input.
|
|
125
|
-
*/
|
|
126
|
-
private getCurrentSelectedAmount;
|
|
127
104
|
private isJson;
|
|
128
105
|
}
|
package/dist/remember-me.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import * as cookie from "./cookie";
|
|
11
|
-
import { EnForm, RememberMeEvents
|
|
11
|
+
import { EnForm, RememberMeEvents } from "./events";
|
|
12
12
|
import { ENGrid } from "./engrid";
|
|
13
13
|
const tippy = require("tippy.js").default;
|
|
14
14
|
// localStorage key used to cache the per-device AES-GCM encryption key.
|
|
@@ -18,7 +18,6 @@ export class RememberMe {
|
|
|
18
18
|
constructor(options) {
|
|
19
19
|
this._form = EnForm.getInstance();
|
|
20
20
|
this._events = RememberMeEvents.getInstance();
|
|
21
|
-
this._frequency = DonationFrequency.getInstance();
|
|
22
21
|
this.iframe = null;
|
|
23
22
|
this.encryptData = options.encryptData ? options.encryptData : false;
|
|
24
23
|
this.hide = options.hide ? options.hide : false;
|
|
@@ -41,10 +40,6 @@ export class RememberMe {
|
|
|
41
40
|
options.fieldDonationRecurrPayRadioName
|
|
42
41
|
? options.fieldDonationRecurrPayRadioName
|
|
43
42
|
: "transaction.recurrpay";
|
|
44
|
-
this.fieldDonationRecurrFreqRadioName =
|
|
45
|
-
options.fieldDonationRecurrFreqRadioName
|
|
46
|
-
? options.fieldDonationRecurrFreqRadioName
|
|
47
|
-
: "transaction.recurrfreq";
|
|
48
43
|
this.fieldDonationAmountOtherCheckboxID =
|
|
49
44
|
options.fieldDonationAmountOtherCheckboxID
|
|
50
45
|
? options.fieldDonationAmountOtherCheckboxID
|
|
@@ -106,7 +101,6 @@ export class RememberMe {
|
|
|
106
101
|
}
|
|
107
102
|
else {
|
|
108
103
|
this.insertClearRememberMeLink();
|
|
109
|
-
this.reapplyDonationAmtAfterSwap();
|
|
110
104
|
}
|
|
111
105
|
}
|
|
112
106
|
});
|
|
@@ -126,9 +120,6 @@ export class RememberMe {
|
|
|
126
120
|
this.insertClearRememberMeLink();
|
|
127
121
|
}
|
|
128
122
|
this.writeFields();
|
|
129
|
-
if (hasFieldData) {
|
|
130
|
-
this.reapplyDonationAmtAfterSwap();
|
|
131
|
-
}
|
|
132
123
|
this._form.onSubmit.subscribe(() => {
|
|
133
124
|
if (this.rememberMeOptIn) {
|
|
134
125
|
this.readFields();
|
|
@@ -147,9 +138,6 @@ export class RememberMe {
|
|
|
147
138
|
this.insertClearRememberMeLink();
|
|
148
139
|
}
|
|
149
140
|
this.writeFields();
|
|
150
|
-
if (hasFieldData) {
|
|
151
|
-
this.reapplyDonationAmtAfterSwap();
|
|
152
|
-
}
|
|
153
141
|
this._form.onSubmit.subscribe(() => {
|
|
154
142
|
if (this.rememberMeOptIn) {
|
|
155
143
|
this.readFields();
|
|
@@ -483,17 +471,6 @@ export class RememberMe {
|
|
|
483
471
|
if (type === "radio" || type === "checkbox") {
|
|
484
472
|
field = document.querySelector(fieldSelector + ":checked");
|
|
485
473
|
}
|
|
486
|
-
// When the donation amount radio is set to "Other", save the actual
|
|
487
|
-
// custom value from the .other text input instead of "Other".
|
|
488
|
-
if (this.fieldNames[i] === this.fieldDonationAmountRadioName &&
|
|
489
|
-
field &&
|
|
490
|
-
field.value.toLowerCase() === "other") {
|
|
491
|
-
const otherField = document.querySelector("input[name='" + this.fieldDonationAmountOtherName + "']");
|
|
492
|
-
if (otherField && otherField.value) {
|
|
493
|
-
this.fieldData[this.fieldNames[i]] = encodeURIComponent(otherField.value);
|
|
494
|
-
continue;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
474
|
this.fieldData[this.fieldNames[i]] = encodeURIComponent(field.value);
|
|
498
475
|
}
|
|
499
476
|
else if (field.tagName === "SELECT") {
|
|
@@ -577,36 +554,17 @@ export class RememberMe {
|
|
|
577
554
|
field.click();
|
|
578
555
|
}
|
|
579
556
|
}
|
|
580
|
-
else if (this.fieldNames[i] === this.fieldDonationRecurrFreqRadioName) {
|
|
581
|
-
// recurrfreq is a radio group — find the specific radio with the saved value and click it
|
|
582
|
-
const savedValue = this.fieldData[this.fieldNames[i]];
|
|
583
|
-
if (savedValue) {
|
|
584
|
-
const freqRadio = document.querySelector(fieldSelector + "[value='" + CSS.escape(savedValue) + "']");
|
|
585
|
-
if (freqRadio) {
|
|
586
|
-
freqRadio.click();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
557
|
else if (this.fieldDonationAmountRadioName === this.fieldNames[i]) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
558
|
+
field = document.querySelector(fieldSelector +
|
|
559
|
+
"[value='" +
|
|
560
|
+
this.fieldData[this.fieldNames[i]] +
|
|
561
|
+
"']");
|
|
594
562
|
if (field) {
|
|
595
|
-
// Saved value matches a predefined radio option — just click it
|
|
596
563
|
field.click();
|
|
597
564
|
}
|
|
598
565
|
else {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
// then fill in the numeric value.
|
|
602
|
-
const otherRadio = document.querySelector(fieldSelector + "[value='Other'], " +
|
|
603
|
-
fieldSelector + "[value='other'], " +
|
|
604
|
-
fieldSelector + "[value='OTHER']");
|
|
605
|
-
if (otherRadio) {
|
|
606
|
-
otherRadio.click();
|
|
607
|
-
}
|
|
608
|
-
const otherField = document.querySelector("input[name='" + this.fieldDonationAmountOtherName + "']");
|
|
609
|
-
this.setFieldValue(otherField, savedAmt, true);
|
|
566
|
+
field = document.querySelector("input[name='" + this.fieldDonationAmountOtherName + "']");
|
|
567
|
+
this.setFieldValue(field, this.fieldData[this.fieldNames[i]], true);
|
|
610
568
|
}
|
|
611
569
|
}
|
|
612
570
|
else {
|
|
@@ -619,74 +577,6 @@ export class RememberMe {
|
|
|
619
577
|
}
|
|
620
578
|
}
|
|
621
579
|
}
|
|
622
|
-
/**
|
|
623
|
-
* SwapAmounts replaces the donationAmt radio DOM nodes ~1 second after page
|
|
624
|
-
* load (triggered by DonationFrequency.load() setTimeout). When that happens
|
|
625
|
-
* the selection the RememberMe just wrote gets wiped out.
|
|
626
|
-
*
|
|
627
|
-
* This method subscribes to the first onFrequencyChange event and, after a
|
|
628
|
-
* short delay to let SwapAmounts finish its DOM update, re-applies only the
|
|
629
|
-
* donation amount. It unsubscribes immediately so it only fires once.
|
|
630
|
-
*
|
|
631
|
-
* To avoid overwriting a manual donor interaction, the handler checks
|
|
632
|
-
* whether the current amount selection is empty/wiped (as SwapAmounts does)
|
|
633
|
-
* OR still matches what writeFields originally set. If the donor already
|
|
634
|
-
* picked a different amount, we skip re-application.
|
|
635
|
-
*/
|
|
636
|
-
reapplyDonationAmtAfterSwap() {
|
|
637
|
-
const savedAmt = this.fieldData[this.fieldDonationAmountRadioName];
|
|
638
|
-
if (!savedAmt)
|
|
639
|
-
return;
|
|
640
|
-
// Capture the amount that writeFields just set so we can detect manual changes
|
|
641
|
-
const amountAtRegistration = this.getCurrentSelectedAmount();
|
|
642
|
-
const handler = () => {
|
|
643
|
-
// SwapAmounts calls _amount.load() after swapList — give it a tick to settle
|
|
644
|
-
window.setTimeout(() => {
|
|
645
|
-
const currentAmt = this.getCurrentSelectedAmount();
|
|
646
|
-
// Only re-apply if the selection is now empty (DOM was swapped out)
|
|
647
|
-
// or still matches what we originally wrote. If the donor manually
|
|
648
|
-
// selected a different amount, respect their choice.
|
|
649
|
-
const selectionWiped = currentAmt === null || currentAmt === "";
|
|
650
|
-
const selectionUnchanged = currentAmt === amountAtRegistration;
|
|
651
|
-
if (!selectionWiped && !selectionUnchanged) {
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
const fieldSelector = "[name='" + this.fieldDonationAmountRadioName + "']";
|
|
655
|
-
const escapedAmt = CSS.escape(savedAmt);
|
|
656
|
-
let radio = document.querySelector(fieldSelector + "[value='" + escapedAmt + "']");
|
|
657
|
-
if (radio) {
|
|
658
|
-
radio.click();
|
|
659
|
-
}
|
|
660
|
-
else {
|
|
661
|
-
// Custom amount: click "Other" radio then fill the text input
|
|
662
|
-
const otherRadio = document.querySelector(fieldSelector + "[value='Other'], " +
|
|
663
|
-
fieldSelector + "[value='other'], " +
|
|
664
|
-
fieldSelector + "[value='OTHER']");
|
|
665
|
-
if (otherRadio)
|
|
666
|
-
otherRadio.click();
|
|
667
|
-
const otherField = document.querySelector("input[name='" + this.fieldDonationAmountOtherName + "']");
|
|
668
|
-
this.setFieldValue(otherField, savedAmt, true);
|
|
669
|
-
}
|
|
670
|
-
}, 200);
|
|
671
|
-
};
|
|
672
|
-
// Subscribe once: fires on the first frequency change then auto-unsubscribes
|
|
673
|
-
this._frequency.onFrequencyChange.one(handler);
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Returns the currently selected donation amount value, or null if nothing
|
|
677
|
-
* is selected. Checks both predefined radio buttons and the "Other" text input.
|
|
678
|
-
*/
|
|
679
|
-
getCurrentSelectedAmount() {
|
|
680
|
-
const fieldSelector = "[name='" + this.fieldDonationAmountRadioName + "']";
|
|
681
|
-
const checkedRadio = document.querySelector(fieldSelector + ":checked");
|
|
682
|
-
if (!checkedRadio)
|
|
683
|
-
return null;
|
|
684
|
-
if (checkedRadio.value.toLowerCase() === "other") {
|
|
685
|
-
const otherField = document.querySelector("input[name='" + this.fieldDonationAmountOtherName + "']");
|
|
686
|
-
return otherField ? otherField.value : null;
|
|
687
|
-
}
|
|
688
|
-
return checkedRadio.value;
|
|
689
|
-
}
|
|
690
580
|
isJson(str) {
|
|
691
581
|
try {
|
|
692
582
|
JSON.parse(str);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.28.
|
|
1
|
+
export declare const AppVersion = "0.28.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.28.
|
|
1
|
+
export const AppVersion = "0.28.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.2",
|
|
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": "16aba8b38f4a978d1f965272f2df6bf6b98dd9f8",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20",
|
|
31
31
|
"typescript": "^4.9.5"
|