Implement better flash behavior

This commit is contained in:
Maximilian Grundke
2017-06-23 12:19:27 +02:00
parent ff9fb8d491
commit e739749828
3 changed files with 28 additions and 15 deletions

View File

@ -1,3 +1,5 @@
#flash.fixed_error_messages.clickthrough data-message-failure=t('shared.message_failure') #flash.fixed_error_messages data-message-failure=t('shared.message_failure')
- %w[alert danger info notice success warning].each do |severity| - %w[alert danger info notice success warning].each do |severity|
p.alert.flash class="alert-#{{'alert' => 'warning', 'notice' => 'success'}.fetch(severity, severity)}" id="flash-#{severity}" = flash[severity] div.alert.flash class="alert-#{{'alert' => 'warning', 'notice' => 'success'}.fetch(severity, severity)}" id="flash-#{severity}"
p = flash[severity]
span.fa.fa-times

View File

@ -24,11 +24,25 @@
var showFlashes = function() { var showFlashes = function() {
$('.flash').each(function() { $('.flash').each(function() {
if ($(this).html() !== '') { var container = $(this);
$(this).slideDown().delay(DURATION).slideUp(function() { var message = container.children().first();
$(this).html(''); var button = container.children().last();
var hide = function() {
container.slideUp(function () {
message.html('');
}); });
};
if (message.html() !== '') {
container.slideDown();
container.animation = setTimeout(hide, DURATION);
} }
button.on('click', function () {
clearTimeout(container.animation);
hide();
});
}); });
}; };

View File

@ -1,5 +1,12 @@
.flash { .flash {
display: none; display: none;
span.fa-times {
position: relative;
top: -1.2em;
float: right;
cursor: pointer;
}
} }
.fixed_error_messages { .fixed_error_messages {
@ -13,14 +20,4 @@
padding-top: 0; padding-top: 0;
} }
.clickthrough {
pointer-events: none;
/* fixes for IE */
/*
background:white;
opacity:0;
filter:Alpha(opacity=0);
*/
}