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 2f00ec9 commit 46c2358
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 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.

10 changes: 9 additions & 1 deletion js/src/forum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ app.initializers.add('darkle/fancybox', () => {
const group = postBody.querySelectorAll(`a[data-fancybox="${groupName}"]`);
const index = Array.from(group).indexOf(link);

Fancybox.fromNodes(Array.from(group), {
const images = Array.from(group).map(node => {
const img = node.querySelector('img');
return {
src: node.href || img.getAttribute('data-src') || img.src,
thumb: img.src,
};
});

Fancybox.show(images, {
...fancyboxOptions,
startIndex: index,
});
Expand Down
10 changes: 2 additions & 8 deletions src/DefineGalleryTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@ public function __invoke(Configurator $config)
<xsl:choose>
<xsl:when test="parent::FANCYBOX-GALLERY-ITEM">
<a data-fancybox="gallery" href="{@url}">
<img>
<img src="{@url}" data-src="{@url}">
<xsl:copy-of select="@*"/>
<xsl:attribute name="data-src">
<xsl:value-of select="@url"/>
</xsl:attribute>
</img>
</a>
</xsl:when>
<xsl:otherwise>
<a data-fancybox="single" href="{@url}">
<img>
<img src="{@url}" data-src="{@url}">
<xsl:copy-of select="@*"/>
<xsl:attribute name="data-src">
<xsl:value-of select="@url"/>
</xsl:attribute>
</img>
</a>
</xsl:otherwise>
Expand Down

0 comments on commit 46c2358

Please sign in to comment.