From 2db3290bed341736e40923ee0ee80c6ff00defb2 Mon Sep 17 00:00:00 2001 From: Sli Date: Sun, 5 Jan 2025 20:17:30 +0100 Subject: [PATCH] Remove some jquery --- core/templates/core/base.jinja | 15 +++++----- core/templates/core/file.jinja | 9 ------ core/templates/core/user_detail.jinja | 41 ++++++++++++++------------- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 17b9befa..ef184fbf 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -125,15 +125,14 @@ navbar.style.setProperty("display", current === "none" ? "block" : "none"); } - $(document).keydown(function (e) { - if ($(e.target).is('input')) { return } - if ($(e.target).is('textarea')) { return } - if ($(e.target).is('select')) { return } - if (e.keyCode === 83) { - $("#search").focus(); - return false; + document.addEventListener("keydown", (e) => { + // Looking at the `s` key when not typing in a form + if (e.keyCode !== 83 || ["INPUT", "TEXTAREA", "SELECT"].includes(e.target.nodeName)) { + return; } - }); + document.getElementById("search").focus(); + e.preventDefault(); // Don't type the character in the focused search input + }) {% endblock %} diff --git a/core/templates/core/file.jinja b/core/templates/core/file.jinja index 95c29bdc..09b86936 100644 --- a/core/templates/core/file.jinja +++ b/core/templates/core/file.jinja @@ -57,13 +57,4 @@ {% endblock %} {% endif %} - {% block script %} - {{ super() }} - {% if popup %} - - {% endif %} - {% endblock %} - {% endblock %} diff --git a/core/templates/core/user_detail.jinja b/core/templates/core/user_detail.jinja index 58836b6f..cb93b1cd 100644 --- a/core/templates/core/user_detail.jinja +++ b/core/templates/core/user_detail.jinja @@ -244,27 +244,30 @@ {% block script %} {{ super() }}