Update photoswipe gallery to hugo-easy-gallery

Using https://github.com/liwenyip/hugo-easy-gallery/ from @liwenyip
This commit is contained in:
Michael Romero 2017-03-27 21:00:24 -07:00
commit 19b620f632
10 changed files with 318 additions and 193 deletions

View file

@ -1,11 +1,17 @@
/*
Put this file in /static/js/pswp-init.js
Put this file in /static/js/load-photoswipe.js
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
*/
/* TODO: Make the share function work */
$( document ).ready(function() {
/*
Initialise Photoswipe
*/
var items = []; // array of slide objects that will be passed to PhotoSwipe()
// for every figure element on the page:
$('figure').each( function() {
if ($(this).attr('class') == 'pswp-ignore') return true; // ignore any figures where class="pswp-ignore"
if ($(this).attr('class') == 'no-photoswipe') return true; // ignore any figures where class="no-photoswipe"
// get properties from child a/img/figcaption elements,
var $figure = $(this),
$a = $figure.find('a'),
@ -22,6 +28,7 @@ $( document ).ready(function() {
title : $title,
msrc : $msrc
};
console.log("Using pre-defined dimensions for " + $src);
// if not, set temp default size then load the image to check actual size
} else {
var item = {
@ -31,6 +38,7 @@ $( document ).ready(function() {
title : $title,
msrc : $msrc
};
console.log("Using default dimensions for " + $src);
// load the image to check its dimensions
// update the item as soon as w and h are known (check every 30ms)
var img = new Image();
@ -42,6 +50,7 @@ $( document ).ready(function() {
clearInterval(wait);
item.w = w;
item.h = h;
console.log("Got actual dimensions for " + img.src);
}
}, 30);
}