Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdarkle committed Sep 8, 2024
1 parent 6a35e7b commit de68d6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion js/dist/forum.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/forum.js.map

Large diffs are not rendered by default.

17 changes: 3 additions & 14 deletions js/src/forum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import { Fancybox } from '@fancyapps/ui/dist/fancybox/fancybox.esm.js';
import '@fancyapps/ui/dist/fancybox/fancybox.css';

app.initializers.add('darkle/fancybox', () => {
extend(CommentPost.prototype, 'oninit', function() {
this.fancyboxInstances = [];
});

extend(CommentPost.prototype, 'oncreate', function () {
this.initFancybox();
});
Expand All @@ -21,11 +17,6 @@ app.initializers.add('darkle/fancybox', () => {
this.initFancybox();
});

extend(CommentPost.prototype, 'onremove', function () {
this.fancyboxInstances.forEach(instance => instance.destroy());
this.fancyboxInstances = [];
});

CommentPost.prototype.initFancybox = function () {
const postBody = this.element.querySelector('.Post-body');
if (!postBody) return;
Expand All @@ -43,7 +34,7 @@ app.initializers.add('darkle/fancybox', () => {
});

// Initialize Fancybox for both galleries and single images
const fancyboxInstance = Fancybox.bind(postBody, '[data-fancybox]', {
Fancybox.bind(postBody, '[data-fancybox]', {
Carousel: {
infinite: false,
},
Expand Down Expand Up @@ -71,13 +62,11 @@ app.initializers.add('darkle/fancybox', () => {
},
});

this.fancyboxInstances.push(fancyboxInstance);

// Prevent default link behavior
postBody.querySelectorAll('a[data-fancybox]').forEach(link => {
link.addEventListener('click', (e) => {
link.onclick = (e) => {
e.preventDefault();
});
};
});
};
});

0 comments on commit de68d6a

Please sign in to comment.