Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed assets/images/camera.png
Binary file not shown.
Binary file added assets/images/camera.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/nina.png
Binary file not shown.
Binary file added assets/images/nina.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Diff not rendered.
117 changes: 72 additions & 45 deletions assets/maugallery.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function($) {
$.fn.mauGallery = function(options) {
(function ($) {
$.fn.mauGallery = function (options) {
var options = $.extend($.fn.mauGallery.defaults, options);
var tagsCollection = [];
return this.each(function() {
return this.each(function () {
$.fn.mauGallery.methods.createRowWrapper($(this));
if (options.lightBox) {
$.fn.mauGallery.methods.createLightBox(
Expand All @@ -15,7 +15,7 @@

$(this)
.children(".gallery-item")
.each(function(index) {
.each(function (index) {
$.fn.mauGallery.methods.responsiveImageItem($(this));
$.fn.mauGallery.methods.moveItemInRowWrapper($(this));
$.fn.mauGallery.methods.wrapItemInColumn($(this), options.columns);
Expand Down Expand Up @@ -48,8 +48,8 @@
tagsPosition: "bottom",
navigation: true
};
$.fn.mauGallery.listeners = function(options) {
$(".gallery-item").on("click", function() {
$.fn.mauGallery.listeners = function (options) {
$(".gallery-item").on("click", function () {
if (options.lightBox && $(this).prop("tagName") === "IMG") {
$.fn.mauGallery.methods.openLightBox($(this), options.lightboxId);
} else {
Expand Down Expand Up @@ -121,21 +121,21 @@
},
prevImage() {
let activeImage = null;
$("img.gallery-item").each(function() {
$("img.gallery-item").each(function () {
if ($(this).attr("src") === $(".lightboxImage").attr("src")) {
activeImage = $(this);
}
});
let activeTag = $(".tags-bar span.active-tag").data("images-toggle");
let imagesCollection = [];
if (activeTag === "all") {
$(".item-column").each(function() {
$(".item-column").each(function () {
if ($(this).children("img").length) {
imagesCollection.push($(this).children("img"));
}
});
} else {
$(".item-column").each(function() {
$(".item-column").each(function () {
if (
$(this)
.children("img")
Expand All @@ -145,74 +145,95 @@
}
});
}
let index = 0,
next = null;
let index = 0;

$(imagesCollection).each(function(i) {
$(imagesCollection).each(function (i) {
if ($(activeImage).attr("src") === $(this).attr("src")) {
index = i ;
index = i;
}
});
next =
imagesCollection[index] ||
imagesCollection[imagesCollection.length - 1];
$(".lightboxImage").attr("src", $(next).attr("src"));
/*
CORRECTION APPLIQUÉE ICI
- Les boutons "précédent" et "suivant" de la modale ne permettaient pas
de naviguer correctement entre les images.
- Maintenant : - On calcule l’index de l’image courante.
- Pour PREV : on recule d’une image (si on est au début, on va à la dernière).
- Pour NEXT : on avance d’une image (si on est à la fin, on revient à la première).
*/

// on recule d’une image
let prevIndex = index - 1;

// si on est au début, on va à la dernière
if (prevIndex < 0) {
prevIndex = imagesCollection.length - 1;
}

let prev = imagesCollection[prevIndex];

$(".lightboxImage").attr("src", $(prev).attr("src"));
},
nextImage() {
let activeImage = null;
$("img.gallery-item").each(function() {

$("img.gallery-item").each(function () {
if ($(this).attr("src") === $(".lightboxImage").attr("src")) {
activeImage = $(this);
}
});

let activeTag = $(".tags-bar span.active-tag").data("images-toggle");
let imagesCollection = [];

if (activeTag === "all") {
$(".item-column").each(function() {
$(".item-column").each(function () {
if ($(this).children("img").length) {
imagesCollection.push($(this).children("img"));
}
});
} else {
$(".item-column").each(function() {
if (
$(this)
.children("img")
.data("gallery-tag") === activeTag
) {
$(".item-column").each(function () {
if ($(this).children("img").data("gallery-tag") === activeTag) {
imagesCollection.push($(this).children("img"));
}
});
}
let index = 0,
next = null;

$(imagesCollection).each(function(i) {
let index = 0;

$(imagesCollection).each(function (i) {
if ($(activeImage).attr("src") === $(this).attr("src")) {
index = i;
}
});
next = imagesCollection[index] || imagesCollection[0];

// on avance d’une image
let nextIndex = index + 1;

// si on est à la fin, on revient à la première
if (nextIndex >= imagesCollection.length) {
nextIndex = 0;
}

let next = imagesCollection[nextIndex];

$(".lightboxImage").attr("src", $(next).attr("src"));
},
createLightBox(gallery, lightboxId, navigation) {
gallery.append(`<div class="modal fade" id="${
lightboxId ? lightboxId : "galleryLightbox"
}" tabindex="-1" role="dialog" aria-hidden="true">
gallery.append(`<div class="modal fade" id="${lightboxId ? lightboxId : "galleryLightbox"
}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
${
navigation
? '<div class="mg-prev" style="cursor:pointer;position:absolute;top:50%;left:-15px;background:white;"><</div>'
: '<span style="display:none;" />'
}
${navigation
? '<div class="mg-prev" style="cursor:pointer;position:absolute;top:50%;left:-15px;background:white;"><</div>'
: '<span style="display:none;" />'
}
<img class="lightboxImage img-fluid" alt="Contenu de l'image affichée dans la modale au clique"/>
${
navigation
? '<div class="mg-next" style="cursor:pointer;position:absolute;top:50%;right:-15px;background:white;}">></div>'
: '<span style="display:none;" />'
}
${navigation
? '<div class="mg-next" style="cursor:pointer;position:absolute;top:50%;right:-15px;background:white;}">></div>'
: '<span style="display:none;" />'
}
</div>
</div>
</div>
Expand All @@ -221,7 +242,7 @@
showItemTags(gallery, position, tags) {
var tagItems =
'<li class="nav-item"><span class="nav-link active active-tag" data-images-toggle="all">Tous</span></li>';
$.each(tags, function(index, value) {
$.each(tags, function (index, value) {
tagItems += `<li class="nav-item active">
<span class="nav-link" data-images-toggle="${value}">${value}</span></li>`;
});
Expand All @@ -235,16 +256,22 @@
console.error(`Unknown tags position: ${position}`);
}
},
/*
CORRECTION APPLIQUÉE ICI
- Avant . on ajoutait seulement "active-tag"
- Maintenant : on ajoute "active" + "active-tag"
=> le filtre sélectionné redevient doré
*/
filterByTag() {
if ($(this).hasClass("active-tag")) {
return;
}
$(".active-tag").removeClass("active active-tag");
$(this).addClass("active-tag");
$(this).addClass("active active-tag");

var tag = $(this).data("images-toggle");

$(".gallery-item").each(function() {
$(".gallery-item").each(function () {
$(this)
.parents(".item-column")
.hide();
Expand Down
Loading