From 59f7bdb54e8215355c06bd78036a4f1b18bfe1a2 Mon Sep 17 00:00:00 2001 From: zmagod Date: Fri, 11 Nov 2016 12:30:48 +0100 Subject: [PATCH] hide flash after 5 sec [fixes SCI-660] --- app/assets/javascripts/application.js.erb | 34 ++++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index a4319f77e..9f890efd0 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -191,12 +191,32 @@ function notificationAlertClose(){ .removeClass("alert-shown"); }); } +(function(){ -$(document).ready(function(){ - $('.tree-link a').each( function(){ - truncateLongString( $(this), <%= Constants::NAME_TRUNCATION_LENGTH %>); + function tree_link_truncation() { + $('.tree-link a').each( function(){ + truncateLongString( $(this), <%= Constants::NAME_TRUNCATION_LENGTH %>); + }); + $(".tree-link span").each( function(){ + truncateLongString( $(this), <%= Constants::NAME_TRUNCATION_LENGTH %>); + }); + } + + function hide_flash_msg() { + var flash = $('.alert'); + if (flash.length > 0) { + window.setTimeout(function () { + flash.fadeTo(500, 0).slideUp(500, function () { + $(this).remove(); + $('#content-wrapper') + .css('marginTop', '50px'); + }); + }, 5000); + } + } + + $( document ).ready(function() { + tree_link_truncation(); + hide_flash_msg(); }); - $(".tree-link span").each( function(){ - truncateLongString( $(this), <%= Constants::NAME_TRUNCATION_LENGTH %>); - }); -}); +})();