tuxwebror/app/assets/javascripts/application.js
2018-12-21 19:06:39 +01:00

58 lines
1.8 KiB
JavaScript

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require jquery
//= require_tree .
$(document).on('turbolinks:load', () => {
//////////////////////////////////////////////////////////////
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('#scrollTop').show();
} else {
$('#scrollTop').hide();
}
});
//////////////////////////////////////////////////////////////
$('#scrollTop').click(function () {
$('html, body').animate({scrollTop: 0}, 200);
return false;
});
$('.modal-button').click(function () {
$('html').addClass('is-clipped');
$(`#${this.dataset.target}`).addClass('is-active')
});
$('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button').click(function () {
$('html').removeClass('is-clipped');
$('.modal').removeClass('is-active')
});
$('html').keydown(function (e) {
if (e.keyCode === 27) {
$('html').removeClass('is-clipped');
$('.modal').removeClass('is-active')
}
});
//////////////////////////////////////////////////////////////
console.log('%c[Application.js]', 'font-weight: bold; color: #17a2b8', 'loaded!')
});