8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-24 12:23:11 +00:00

Add CTRL+K and CTRL+L shortcuts

This commit is contained in:
Maël Kervella 2018-05-09 15:03:15 +00:00
parent 05bc645a65
commit 60337ee203
2 changed files with 37 additions and 2 deletions

34
static/js/shortcuts.js Normal file
View file

@ -0,0 +1,34 @@
$(document).ready(function() {
ctrl = false;
alt = false;
});
$(document).keydown(function(event) {
// Update state keys
if (event.which == "17")
ctrl = true;
else if (event.which == "18")
alt = true;
// CTRL+K will focus on the search bar
else if (ctrl && event.which == "75") {
event.stopPropagation();
event.preventDefault();
$("#search-term")[0].focus();
}
// CTRL+L will trigger the login/logout
else if (ctrl && event.which == "76") {
event.stopPropagation();
event.preventDefault();
window.location.href = $("#toggle_login")[0].href;
}
});
$(document).keyup(function(event) {
// Update state keys
if (event.which == "17")
ctrl = false;
else if (event.which == "18")
alt = false;
});

View file

@ -50,6 +50,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<script src="/static/js/konami/konami.js"></script>
<script src="/static/js/sapphire.js"> var s=Sapphire(); Konami(s.activate); </script>
<script src="/static/js/bootstrap-tokenfield/bootstrap-tokenfield.js"></script>
<script src="/static/js/shortcuts.js"></script>
<link rel="stylesheet" href="{% static "/css/base.css" %}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ site_name }} : {% block title %}Accueil{% endblock %}</title>
@ -74,7 +75,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user-circle"></i> {{request.user.pseudo|slice:":15"}} <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url "users:mon-profil" %}"><i class="fa fa-user"></i> Mon profil</a></li>
<li><a href="{% url 'logout' %}"><i class="fa fa-sign-out-alt"></i> Se déconnecter</a></li>
<li><a id="toggle_login" href="{% url 'logout' %}"><i class="fa fa-sign-out-alt"></i> Se déconnecter</a></li>
</ul>
</li>
{% endif %}
@ -129,7 +130,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</li>
{% endif %}
<li>
<a href="{% url 'login' %}">
<a id="toggle_login" href="{% url 'login' %}">
<i class="fa fa-sign-in-alt"></i> Login
</a>
</li>