1
Fork 0

Only setup event handlers once document is ready

This commit is contained in:
Jake Howard 2022-01-14 19:05:36 +00:00
parent 81642bc854
commit 9ad27215ab
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -58,30 +58,30 @@ $(document).ready(function() {
endAudio: '/audio/ding.mp3', endAudio: '/audio/ding.mp3',
preloadAudio: false, preloadAudio: false,
}); });
});
$('#scroll-top').on('click', function() { $('#scroll-top').on('click', function() {
scrollTo(0); scrollTo(0);
resetHash();
});
$('a[href^="#"]').on('click', function(event) {
if (this.dataset.noPreventDefault === undefined) {
event.preventDefault();
resetHash(); resetHash();
} });
const target = $($(this).attr('href'));
if (target.length) {
scrollTo(target.offset().top);
}
});
$('.content img').on('click', function(event) { $('a[href^="#"]').on('click', function(event) {
event.preventDefault(); if (this.dataset.noPreventDefault === undefined) {
const lightbox = $('#lightbox-modal'); event.preventDefault();
lightbox.find('img').remove(); resetHash();
$(this) }
.clone() const target = $($(this).attr('href'));
.appendTo(lightbox.find('.modal-content')); if (target.length) {
lightbox.modal(); scrollTo(target.offset().top);
}
});
$('.content img').on('click', function(event) {
event.preventDefault();
const lightbox = $('#lightbox-modal');
lightbox.find('img').remove();
$(this)
.clone()
.appendTo(lightbox.find('.modal-content'));
lightbox.modal();
});
}); });