Skip to content

Commit beb8057

Browse files
committed
Rewrite the save shortcut JS without jQuery
1 parent 75f8836 commit beb8057

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ repos:
1414
- id: mixed-line-ending
1515
- id: trailing-whitespace
1616
- repo: https://github.com/adamchainz/django-upgrade
17-
rev: 1.24.0
17+
rev: 1.25.0
1818
hooks:
1919
- id: django-upgrade
2020
args: [--target-version, "3.2"]
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: "v0.11.5"
22+
rev: "v0.12.0"
2323
hooks:
2424
- id: ruff
2525
args: [--unsafe-fixes]
@@ -30,7 +30,7 @@ repos:
3030
- id: biome-check
3131
args: [--unsafe]
3232
- repo: https://github.com/tox-dev/pyproject-fmt
33-
rev: v2.5.1
33+
rev: v2.6.0
3434
hooks:
3535
- id: pyproject-fmt
3636
- repo: https://github.com/abravalheri/validate-pyproject

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Next version
1111
- Prepared for the new object-based ``Script`` by moving from django-js-asset's
1212
``JS`` to a script without attributes, and moved the configuration into an
1313
inline JSON blob.
14+
- Rewrote ``content_editor/save_shortcut.js`` without jQuery.
1415

1516

1617
7.2 (2025-01-27)
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
/* global django */
2-
django.jQuery(($) => {
3-
$(document).keydown(function handleKeys(event) {
4-
if (event.which === 83 && (event.metaKey || event.ctrlKey)) {
5-
$("form input[name=_continue]").click()
6-
return false
7-
}
8-
})
1+
window.addEventListener("keydown", (e) => {
2+
let el
3+
if (
4+
e.key === "s" &&
5+
(e.metaKey || e.ctrlKey) &&
6+
(el = document.querySelector("form input[name=_continue]"))
7+
) {
8+
e.preventDefault()
9+
el.click()
10+
}
911
})

0 commit comments

Comments
 (0)