Skip to content

Commit

Permalink
disable xverify when a page is loaded with a prefilled email address
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelT372 committed Dec 11, 2024
1 parent 0346166 commit f67220a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dist/engrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*
* ENGRID PAGE TEMPLATE ASSETS
*
* Date: Thursday, October 31, 2024 @ 11:21:36 ET
* By: bryancasler
* Date: Wednesday, December 11, 2024 @ 11:03:39 ET
* By: michael
* ENGrid styles: v0.19.9
* ENGrid scripts: v0.19.9
*
Expand Down
11 changes: 9 additions & 2 deletions dist/engrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*
* ENGRID PAGE TEMPLATE ASSETS
*
* Date: Thursday, October 31, 2024 @ 11:21:36 ET
* By: bryancasler
* Date: Wednesday, December 11, 2024 @ 11:03:39 ET
* By: michael
* ENGrid styles: v0.19.9
* ENGrid scripts: v0.19.9
*
Expand Down Expand Up @@ -21651,6 +21651,8 @@ class XVerify {

_defineProperty(this, "logger", new EngridLogger("XVerify", "blueviolet", "aliceblue", "🔍"));

_defineProperty(this, "submissionFailed", !!(engrid_ENGrid.checkNested(window.EngagingNetworks, "require", "_defined", "enjs", "checkSubmissionFailed") && window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()));

this.emailField = document.querySelector("#en__field_supporter_emailAddress");
this.options = options;
this.xvStatus = this.options.statusField ? document.querySelector(`[name="${this.options.statusField}"]`) : null;
Expand Down Expand Up @@ -21689,6 +21691,11 @@ class XVerify {
return;
}

if (this.emailField.value !== "" && !this.submissionFailed) {
this.logger.log("X-Verify is Disabled for Autofilled Email Address");
return;
}

this.form.onValidate.subscribe(() => {
if (this.form.validate) {
this.logger.log("onValidate");
Expand Down
4 changes: 2 additions & 2 deletions dist/engrid.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/engrid.min.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/scripts/xverify/xverify.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { EnForm, ENGrid, EngridLogger } from "@4site/engrid-scripts";
// import { EnForm, ENGrid } from "../../../../engrid/packages/scripts"; // Uses ENGrid via Visual Studio Workspace

declare global {
interface Window {
EngagingNetworks: any;
}
}

export class XVerify {
public form: EnForm = EnForm.getInstance();
public emailField: HTMLInputElement;
Expand All @@ -23,6 +29,15 @@ export class XVerify {
"aliceblue",
"🔍"
);
private submissionFailed: boolean = !!(
ENGrid.checkNested(
window.EngagingNetworks,
"require",
"_defined",
"enjs",
"checkSubmissionFailed"
) && window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()
);
constructor(options: {
statusField?: string;
dateField?: string;
Expand Down Expand Up @@ -71,6 +86,10 @@ export class XVerify {
this.logger.log("E-mail Field Not Found", this.emailField);
return;
}
if (this.emailField.value !== "" && !this.submissionFailed) {
this.logger.log("X-Verify is Disabled for Autofilled Email Address");
return;
}
this.form.onValidate.subscribe(() => {
if (this.form.validate) {
this.logger.log("onValidate");
Expand Down

0 comments on commit f67220a

Please sign in to comment.