Remove some jquery

This commit is contained in:
Antoine Bartuccio 2025-01-05 20:17:30 +01:00
parent 429df81ec9
commit 2db3290bed
3 changed files with 29 additions and 36 deletions

View File

@ -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
})
</script>
{% endblock %}
</body>

View File

@ -57,13 +57,4 @@
{% endblock %}
{% endif %}
{% block script %}
{{ super() }}
{% if popup %}
<script>
parent.$(".choose_file_widget").css("height", "75%");
</script>
{% endif %}
{% endblock %}
{% endblock %}

View File

@ -244,27 +244,30 @@
{% block script %}
{{ super() }}
<script>
$(function () {
var keys = [];
var pattern = "71,85,89,71,85,89";
$(document).keydown(function (e) {
keys.push(e.keyCode);
if (keys.toString() == pattern) {
keys = [];
$("#big_picture img").attr("src", "{{ static('core/img/yug.jpg') }}");
// Image selection
for (const img of document.querySelectorAll("#small_pictures img")){
img.addEventListener("click", (e) => {
const displayed = document.querySelector("#big_picture img");
displayed.src = e.target.src;
displayed.alt = e.target.alt;
displayed.title = e.target.title;
})
}
if (keys.length == 6) {
let keys = [];
const pattern = "71,85,89,71,85,89";
document.addEventListener("keydown", (e) => {
keys.push(e.keyCode);
if (keys.toString() === pattern) {
keys = [];
document.querySelector("#big_picture img").src = "{{ static('core/img/yug.jpg') }}";
}
if (keys.length === 6) {
keys.shift();
}
});
});
$(function () {
$("#small_pictures img").click(function () {
$("#big_picture img").attr("src", $(this)[0].src);
$("#big_picture img").attr("alt", $(this)[0].alt);
$("#big_picture img").attr("title", $(this)[0].title);
})
});
$(function () {
$("#drop_gifts").accordion({
heightStyle: "content",