app/views/shared/_scripts.html.erb
<script>
// Scroll to top button
$(function () {
$(window).scroll(function () {
if ($(window).scrollTop() > 20) {
btn.addClass("show");
} else {
btn.removeClass("show");
}
});
let btn = $("#buttonToTop");
btn.on("click", function (e) {
e.preventDefault();
$("html, body").animate({
scrollTop: 0
},
"900"
);
});
})
// --- GDPR POP UP
$(function () {
if ($.cookie('cookies_enable')) {
$("#message").css("display:", "none");
} else {
$('#message').delay(1000).slideDown(500);
}
});
// To hide the message but show it again on page reload
function hideMessage() {
$('#message').delay().slideUp(500);
}
// To hide the message and set the cookie so when the page is reloaded the message does not appear
function hideForever() {
$('#message').delay().slideUp(500);
$.cookie('cookies_enable', 'foo', {
expires: 180
});
}
// Optional function to show message manually on the demo page
function showMessage() {
$('#message').delay().slideDown(500);
}
// Delete cookie
function deleteCookie() {
$.removeCookie('cookies_enable');
}
// --- /. GDPR POP UP
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>