8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Merge branch 'moamoak/js_shortcuts' into 'master'

Add CTRL+K and CTRL+L shortcuts

See merge request federez/re2o!156
This commit is contained in:
chirac 2018-05-10 12:14:20 +02:00
commit add24d5c7d
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/konami/konami.js"></script>
<script src="/static/js/sapphire.js"> var s=Sapphire(); Konami(s.activate); </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/bootstrap-tokenfield/bootstrap-tokenfield.js"></script>
<script src="/static/js/shortcuts.js"></script>
<link rel="stylesheet" href="{% static "/css/base.css" %}"> <link rel="stylesheet" href="{% static "/css/base.css" %}">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ site_name }} : {% block title %}Accueil{% endblock %}</title> <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> <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"> <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 "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> </ul>
</li> </li>
{% endif %} {% endif %}
@ -129,7 +130,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</li> </li>
{% endif %} {% endif %}
<li> <li>
<a href="{% url 'login' %}"> <a id="toggle_login" href="{% url 'login' %}">
<i class="fa fa-sign-in-alt"></i> Login <i class="fa fa-sign-in-alt"></i> Login
</a> </a>
</li> </li>