Compare commits

...

3 commits

Author SHA1 Message Date
j
1e408d9b25 avoid errors in dead code 2025-03-27 08:59:36 +00:00
j
672bad887c don't fail if gif is missing 2025-03-27 08:59:20 +00:00
j
f61d1e0d45 add keyboard navigation 2025-03-27 08:59:04 +00:00
3 changed files with 15 additions and 18 deletions

View file

@ -79,6 +79,18 @@ function loadGallery(images, idx) {
const thumbnailsContainer = gallery.querySelector(".thumbnails"); const thumbnailsContainer = gallery.querySelector(".thumbnails");
const download = gallery.querySelector(".download"); const download = gallery.querySelector(".download");
gallery.addEventListener("keydown", event => {
if (event.keyCode == 39) {
event.preventDefault()
event.stopPropagation()
nextBtn.onclick(event)
} else if (event.keyCode == 37) {
event.preventDefault()
event.stopPropagation()
prevBtn.onclick(event)
}
})
function updateGallery(index) { function updateGallery(index) {
mainImage.src = images[index].src.replace('_display', '_thumbnail'); mainImage.src = images[index].src.replace('_display', '_thumbnail');
setTimeout(() => { setTimeout(() => {

View file

@ -34,30 +34,15 @@ document.querySelectorAll('.select-image').forEach(function(a) {
}; };
}); });
/*
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
var slide = parseInt(document.location.hash.slice(1))
if (slide) {
slider.goToSlide(slide - 1)
slider.resize()
slider.redrawSlider()
setTimeout(function() {
slider.resize()
slider.redrawSlider()
}, 2000)
}
}
*/
$(document).keydown(function(e){ $(document).keydown(function(e){
if (e.keyCode == 39) // Right arrow if (e.keyCode == 39) // Right arrow
{ {
slider && slider.goToNextSlide(); slider && slider.goToNextSlide && slider.goToNextSlide();
return false; return false;
} }
else if (e.keyCode == 37) // left arrow else if (e.keyCode == 37) // left arrow
{ {
slider && slider.goToPrevSlide(); slider && slider.goToPrevSlide && slider.goToPrevSlide();
return false; return false;
} }
}); });

View file

@ -200,7 +200,7 @@ class Content(models.Model):
if self.photo and self.photo.image.url.endswith('.gif'): if self.photo and self.photo.image.url.endswith('.gif'):
video_path = self.photo.image.path.replace('.gif', '.mp4') video_path = self.photo.image.path.replace('.gif', '.mp4')
image_path = self.photo.image.path.replace('.gif', '.jpg') image_path = self.photo.image.path.replace('.gif', '.jpg')
if not os.path.exists(video_path): if os.path.exists(self.photo.image.path) and not os.path.exists(video_path):
height = self.photo.image.height height = self.photo.image.height
if height % 2: if height % 2:
height += 1 height += 1