/** * Convert consecutive images into a fotorama slideshow. * Code needs to run after document is loaded * JOS 20160305 */ jQuery("document").ready(function(){ 'use strict'; /** * Traverses given 'block' adding a fotorama div around blocks of consecutive img elements * * @param block */ function wrapImagesWithFotoramaDiv(block) { var images = jQuery('img', block); var newDiv; for (var index = 0; index < images.length; ++index) { var image = jQuery(images[index]); // First image or first image of block so add new div if ((index === 0) || (!image.prev().hasClass('fotorama'))) { newDiv = jQuery('
').addClass('fotorama').attr("data-loop","true").attr("data-keyboard","true").attr("data-nav","thumbs"); image.before(newDiv); } newDiv.append(image); } } wrapImagesWithFotoramaDiv(jQuery('main')); });