Added dismissable notifications

- Bootstrap alert
- Can close manually
- Also set to disappear after configurable time
This commit is contained in:
Oliver 2018-04-29 23:29:38 +10:00
parent 006aa69dbb
commit b6665ec2a7
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,8 @@
function showAlert(target, message, timeout=5000) {
$(target).find(".alert-msg").html(message);
$(target).show();
$(target).delay(timeout).slideUp(200, function() {
$(this).alert(close);
});
}

View File

@ -39,6 +39,7 @@ InvenTree
{% endblock %}
</div>
{% include 'notification.html' %}
</div>
<!-- Scripts -->
@ -48,6 +49,7 @@ InvenTree
<script type='text/javascript' src="{% static 'script/bootstrap-treeview.js' %}"></script>
<script type='text/javascript' src="{% static 'script/trees.js' %}"></script>
<script type='text/javascript' src="{% static 'script/sidenav.js' %}"></script>
<script type='text/javascript' src="{% static 'script/notification.js' %}"></script>
{% block js_load %}
{% endblock %}

View File

@ -0,0 +1,16 @@
<div class="alert alert-success alert-dismissable" id="alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Success alert</div>
</div>
<div class='alert alert-info alert-dismissable' id='alert-info'>
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Info alert</div>
</div>
<div class='alert alert-warning alert-dismissable' id='alert-warning'>
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Warning alert</div>
</div>
<div class='alert alert-danger alert-dismissable' id='alert-danger'>
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Danger alert</div>
</div>