I am currently working on implementing a notification system that will appear for a few seconds and then vanish. However, I want to give users the option to hover over it with their mouse to prevent it from disappearing. It would also be nice to have the notification disappear on click, although that is not mandatory. I am unsure of how to make the hover functionality in HTML interact with embedded Ruby to halt the timeout. It may require a restructuring of the code to achieve this. Below are snippets of relevant CSS, HTML, and ERB code (not executable):
setTimeout(function() {
$('#alert_box').fadeOut('fast');
}, 3000);
.alert_wrap {
padding: 0px 50px;
margin-top: 3px;
height: 5%;
background-color: rgba(255, 0, 0, .3);
border: 3px solid red;
grid-row-start: 2;
justify-self: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<% unless notice == nil %>
<div id="alert_box" class="alert_wrap">
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
</div>
<% end %>