Skip to content

Commit

Permalink
Merge pull request #990 from ae-utbm/jquery
Browse files Browse the repository at this point in the history
Remove some jquery
  • Loading branch information
klmp200 authored Jan 9, 2025
2 parents cca486f + 2db3290 commit 843ce2e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 36 deletions.
15 changes: 7 additions & 8 deletions core/templates/core/base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 0 additions & 9 deletions core/templates/core/file.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,4 @@
{% endblock %}
{% endif %}

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

{% endblock %}
41 changes: 22 additions & 19 deletions core/templates/core/user_detail.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}");
}
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);
// 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;
})
}
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 () {
$("#drop_gifts").accordion({
heightStyle: "content",
Expand Down

0 comments on commit 843ce2e

Please sign in to comment.