Skip to content

Instantly share code, notes, and snippets.

@gslin
Created May 30, 2023 01:29
Show Gist options
  • Save gslin/3466ea4d1a2128cb20489294aadbfcf7 to your computer and use it in GitHub Desktop.
Save gslin/3466ea4d1a2128cb20489294aadbfcf7 to your computer and use it in GitHub Desktop.
/**
* Event handler for clicking on an image thumbnail
*
* @param {jQuery.Event} ev
* @ignore
*/
function onClickImage(ev) {
ev.preventDefault();
routeThumbnail($(this).data("thumb"));
}
/**
* Add routes to images and handle clicks
*
* @method
* @ignore
* @param {jQuery.Object} [$container] Optional container to search within
*/
function initMediaViewer($container) {
currentPageHTMLParser.getThumbnails($container).forEach(function (thumb) {
thumb.$el.off().data("thumb", thumb).on("click", onClickImage);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment