Fix #1411 Cannot cloe alert

This commit is contained in:
Nicolas Le Goff
2013-08-08 12:03:26 +02:00
parent 72aaa24ce5
commit 9ecfc82b9f
4 changed files with 44 additions and 30 deletions

View File

@@ -46,5 +46,14 @@
</div>
</div>
</div>
{% block scripts %}{% endblock %}
{% block scripts %}
<script type="text/javascript">
// close alerts
$(document).on("click", ".alert .alert-block-close a", function(e){
e.preventDefault();
$(this).closest('.alert').alert('close');
return false;
});
</script>
{% endblock %}
{% endblock %}

View File

@@ -138,28 +138,33 @@
</div>
{% endmacro %}
{% macro alert(type, message) %}
<div class="alert alert-{{ type }}">
{% set sign = "icon-exclamation-sign" %}
{% if type == "error" %}
{% set sign = "icon-warning-sign" %}
{% elseif type == "success" %}
{% set sign = "icon-ok-sign" %}
{% elseif type == "info" %}
{% set sign = "icon-info-sign" %}
{% endif %}
<table>
<tr>
<td class="alert-block-logo"><i class="icon-2x icon-white {{ sign }}"></i></td>
<td class="alert-block-content">{{ message }}</td>
<td class="alert-block-close"><a href="#"><b>&times;</b></a></td>
</tr>
</table>
</div>
{% endmacro %}
{% macro flashes() %}
{% import _self as login %}
{% for type in app.getAvailableFlashTypes %}
{% for message in app.getFlash(type) %}
<div class="alert alert-{{ type }}">
{% set sign = "icon-exclamation-sign" %}
{% if type == "error" %}
{% set sign = "icon-warning-sign" %}
{% elseif type == "success" %}
{% set sign = "icon-ok-sign" %}
{% elseif type == "info" %}
{% set sign = "icon-info-sign" %}
{% endif %}
<table>
<tr>
<td class="alert-block-logo"><i class="icon-2x icon-white {{ sign }}"></i></td>
<td class="alert-block-content">{{ message }}</td>
<td class="alert-block-close"><a href="#"><b>&times;</b></a></td>
</tr>
</table>
</div>
{{ login.alert(type, message) }}
{% endfor %}
{% endfor %}
{% endmacro %}

View File

@@ -257,8 +257,8 @@ ul {
border-left: 1px solid darken(@warningBackground, 20%);
}
.alert .close {
position: static;
.alert-block-close a {
color: @white;
}
.alert table {

View File

@@ -269,20 +269,20 @@
// Form states and alerts
// -------------------------
@warningText: #c09853;
@warningBackground: #fcf8e3;
@warningText: @white;
@warningBackground: @grayDark;
@warningBorder: darken(spin(@warningBackground, -10), 3%);
@errorText: #b94a48;
@errorBackground: #f2dede;
@errorText: @white;
@errorBackground: #c9322b;
@errorBorder: darken(spin(@errorBackground, -10), 3%);
@successText: #468847;
@successBackground: #dff0d8;
@successText: @white;
@successBackground: #1f914f;
@successBorder: darken(spin(@successBackground, -10), 5%);
@infoText: #3a87ad;
@infoBackground: #d9edf7;
@infoText: @white;
@infoBackground: #4889af;
@infoBorder: darken(spin(@infoBackground, -10), 7%);