-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1216 from seanpdoyle/config-disable-submitter
Configure Submitter disabling
- Loading branch information
Showing
10 changed files
with
162 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const drive = { | ||
enabled: true, | ||
progressBarDelay: 500 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { cancelEvent } from "../../util" | ||
|
||
const submitter = { | ||
"aria-disabled": { | ||
beforeSubmit: submitter => { | ||
submitter.setAttribute("aria-disabled", "true") | ||
submitter.addEventListener("click", cancelEvent) | ||
}, | ||
|
||
afterSubmit: submitter => { | ||
submitter.removeAttribute("aria-disabled") | ||
submitter.removeEventListener("click", cancelEvent) | ||
} | ||
}, | ||
|
||
"disabled": { | ||
beforeSubmit: submitter => submitter.disabled = true, | ||
afterSubmit: submitter => submitter.disabled = false | ||
} | ||
} | ||
|
||
class Config { | ||
#submitter = null | ||
|
||
constructor(config) { | ||
Object.assign(this, config) | ||
} | ||
|
||
get submitter() { | ||
return this.#submitter | ||
} | ||
|
||
set submitter(value) { | ||
this.#submitter = submitter[value] || value | ||
} | ||
} | ||
|
||
export const forms = new Config({ | ||
mode: "on", | ||
submitter: "disabled" | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { drive } from "./drive" | ||
import { forms } from "./forms" | ||
|
||
export const config = { | ||
drive, | ||
forms | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters