";
return caption;
},
},
gallery:{
enabled:true,
arrowMarkup: '',
},
callbacks: {
change: function() {
// Replace the current history state with a URL with
// a new hash part. The hash part tells the site to load
// a specific image in fullscreen. Replacing the history
// causes the back and forward buttons to now go to the
// URL with the hash version... Simply changing the URL
// will instead cause a browser to add a new URL to the
// history with the hash part. Then if you look at a ton
// of images on one page, they'll all clutter up your history
// and you'll have to back through them all to get back to
// what seems like the previous page. I think this
// replaceState version is a better behavior.
const hash = "#" + this.currItem.el.attr("id");
window.history.replaceState(undefined, undefined, hash);
},
close: function() {
// Clear the hash part without adding new things to the history
window.history.replaceState(undefined, undefined, "");
},
},
fixedContentPos: true,
});
// If there's a fragment id, see if it's an image index
// If it is, and it's really a gallery_item then click on it
let click_hash = function () {
let fid = $(window.location.hash);
if( fid.length == 1 &&
(
fid[0].classList.contains("gallery-item") ||
fid[0].classList.contains("gallery-item-marker")
)
) {
let curr_item = $.magnificPopup.instance.currItem;
if( curr_item &&
curr_item.el.attr("id") == fid[0].id )
{
// Nothing needs to happen in this case...
return false;
} else
{
// Otherwise we need to update the popup, so click it
fid.click();
return false;
}
} else {
// Some other hash was present, let the browser handle it
$.magnificPopup.close();
return true;
}
return true;
}
// Check the fragment id at load
if( window.location.hash != "" ) {
click_hash();
}
// Check the fragment id on hashchange
$(window).on("hashchange", click_hash);
});
})(jQuery);