Notifications are closable

This commit is contained in:
Ludovic Stephan 2020-08-28 16:11:50 +02:00 committed by Martin Pépin
parent 1ac3e0f976
commit 8fa635773c
No known key found for this signature in database
GPG key ID: E7520278B1774448
2 changed files with 29 additions and 18 deletions

7
bds/static/bds/js/bds.js Normal file
View file

@ -0,0 +1,7 @@
$(function () {
// Close notifications when delete button is pressed
$(".notification .delete").on("click", function () {
$(this).parent().remove();
});
});

View file

@ -16,31 +16,35 @@
{# Javascript #} {# Javascript #}
<script src="{% static 'vendor/jquery/jquery-3.3.1.min.js' %}"></script> <script src="{% static 'vendor/jquery/jquery-3.3.1.min.js' %}"></script>
<script src="{% static "vendor/jquery/jquery.autocomplete-light.min.js" %}"></script> <script src="{% static "vendor/jquery/jquery.autocomplete-light.min.js" %}"></script>
<script src="{% static 'bds/js/bds.js' %}"></script>
{% block extra_head %}{% endblock extra_head %} {% block extra_head %}{% endblock extra_head %}
</head> </head>
<body> <body>
{% include "bds/nav.html" %} {% include "bds/nav.html" %}
{% block layout %}
<div class="columns">
<div class="column is-two-thirds is-offset-2">
<section class="section">
<section class="section"> {% if messages %}
<div class="columns"> {% for message in messages %}
<div class="column is-two-thirds is-offset-2"> <div class="notification is-{{ message.level_tag|bulma_message_tag }}">
{% if messages %} {% if 'safe' in message.tags %}
{% for message in messages %} {{ message|safe }}
<div class="notification is-{{ message.level_tag|bulma_message_tag }}"> {% else %}
{% if 'safe' in message.tags %} {{ message }}
{{ message|safe }} {% endif %}
{% else %} <button class="delete"></button>
{{ message }} </div>
{% endif %} {% endfor %}
</div> {% endif %}
{% endfor %}
{% endif %}
{% block content %} {% block content %}
{% endblock content %} {% endblock content %}
</div> </section>
</div> </div>
</section> </div>
{% endblock layout %}
</body> </body>
</html> </html>