{namespace jh = Heilmann\JhPhotoswipe\ViewHelpers} var openPhotoSwipe{data.uid} = function(index) { var pswpElement = document.querySelectorAll('.pswp')[0]; var items = [ , ]; // define options var options = { }; options.index = parseInt(index, 10); var gallery{data.uid} = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options); gallery{data.uid}.init(); }; var onThumbnailsClick{data.uid} = function(e) { e = e || window.event; e.preventDefault ? e.preventDefault() : e.returnValue = false; var eTarget = e.target || e.srcElement; openPhotoSwipe{data.uid}(eTarget.getAttribute('data-pswp-uid')); } var galleryElements = document.querySelectorAll('.jh-photoswipe-gallery-{data.uid}'); for(var i = 0, l = galleryElements.length; i < l; i++) { galleryElements[i].setAttribute('data-pswp-uid', i); galleryElements[i].onclick = onThumbnailsClick{data.uid}; }