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

@ -24,11 +24,25 @@
var showFlashes = function() {
$('.flash').each(function() {
if ($(this).html() !== '') {
$(this).slideDown().delay(DURATION).slideUp(function() {
$(this).html('');
var container = $(this);
var message = container.children().first();
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();
});
});
};