Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify and improve the client-side logic for form submissions #2391

Merged
merged 4 commits into from
Jul 2, 2024

Conversation

Changaco
Copy link
Member

See the description of the last commit.

@Changaco Changaco force-pushed the js-submit branch 2 times, most recently from 64abb62 to 71d06cd Compare July 1, 2024 12:25
Changaco added 2 commits July 2, 2024 11:50
- drop the `js-submit` class and merge the two separate `submit` event handlers into one
  - it's now easy to run custom functions both before and after a form submission
    - however, the after functions may not be called if the server responds to the form submission with an error
  - the unified function's source code is commented
  - the unified function sends debugging messages to the console
  - form inputs are no longer disabled during submission, because it was complicating the JavaScript code
    - CSS is used instead to gray out the entire form and disable mouse events, but keyboard events aren't be disabled
  - the submission feedback overlay is back, for forms making slow requests before submitting
- replace most uses of `jQuery.ajax()` with `fetch()`, simplifying the `Liberapay.error()` function and removing the need for the `Liberapay.getCookie()` function
  - all forms are now required to include an anti-CSRF token, whereas previously the forms that required JavaScript didn't need to contain the token as it would be taken from the cookies anyway
  - since we no longer need the `csrf_token` cookie to be accessible from JavaScript, mark it as `httponly`
@Changaco Changaco merged commit 81993cc into master Jul 2, 2024
2 checks passed
@Changaco Changaco deleted the js-submit branch July 2, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant