fix(js): merge gallery.js with main.js

This commit is contained in:
ppoffice 2020-03-09 23:13:55 -04:00
parent 46acd4fae9
commit 6833693d29
2 changed files with 20 additions and 21 deletions

View File

@ -1,21 +0,0 @@
document.addEventListener('DOMContentLoaded', () => {
$('.article img:not(".not-gallery-item")').each(function() {
// wrap images with link and add caption if possible
if ($(this).parent('a').length === 0) {
$(this).wrap('<a class="gallery-item" href="' + $(this).attr('src') + '"></a>');
if (this.alt) {
$(this).after('<p class="has-text-centered is-size-6 caption">' + this.alt + '</p>');
}
}
});
if (typeof $.fn.lightGallery === 'function') {
$('.article').lightGallery({ selector: '.gallery-item' });
}
if (typeof $.fn.justifiedGallery === 'function') {
if ($('.justified-gallery > p > .gallery-item').length) {
$('.justified-gallery > p > .gallery-item').unwrap();
}
$('.justified-gallery').justifiedGallery();
}
});

View File

@ -1,5 +1,25 @@
/* eslint-disable node/no-unsupported-features/node-builtins */
(function($, moment, ClipboardJS, config) {
$('.article img:not(".not-gallery-item")').each(function() {
// wrap images with link and add caption if possible
if ($(this).parent('a').length === 0) {
$(this).wrap('<a class="gallery-item" href="' + $(this).attr('src') + '"></a>');
if (this.alt) {
$(this).after('<p class="has-text-centered is-size-6 caption">' + this.alt + '</p>');
}
}
});
if (typeof $.fn.lightGallery === 'function') {
$('.article').lightGallery({ selector: '.gallery-item' });
}
if (typeof $.fn.justifiedGallery === 'function') {
if ($('.justified-gallery > p > .gallery-item').length) {
$('.justified-gallery > p > .gallery-item').unwrap();
}
$('.justified-gallery').justifiedGallery();
}
if (!$('.columns .column-right-shadow').children().length) {
$('.columns .column-right-shadow').append($('.columns .column-right').children().clone());
}