1$(document).ready(function () { 2 3 var dynamicList = [] 4 $('body').on("click", "[photo-swipe]", function (e) { 5 var index = $(this).attr("slide-index"); 6 var activeSlider; 7 window[$(this).parents('[dynamic-gallery]').attr('dynamic-gallery')] = [] 8 InitializePhotoSwipe($(this).parents('[dynamic-gallery]').addClass('initialized').find('[photo-swipe]'), window[$(this).parents('[dynamic-gallery]').attr('dynamic-gallery')]); 9 activeSlider = window[$(this).parents('[dynamic-gallery]').attr('dynamic-gallery')]; 10 $('body').addClass('opened-photo-swipe'); 11 // Define object and gallery options 12 var pswp = $('.pswp')[0], 13 options = { 14 index: parseInt(index), 15 bgOpacity: 1, 16 showHideOpacity: true 17 }; 18 19 // Initialize PhotoSwipe 20 var gallery = new PhotoSwipe(pswp, PhotoSwipeUI_Default, activeSlider, options); 21 gallery.listen('gettingData', function (index, item) { 22 if (item.w < 3 || item.h < 3) { // unknown size 23 var img = new Image(); 24 img.onload = function () { // will get size after load 25 item.w = this.width; // set image width 26 item.h = this.height; // set image height 27 gallery.invalidateCurrItems(); // reinit Items 28 gallery.updateSize(true); // reinit Items 29 } 30 img.src = item.src; // let's download image 31 } 32 }); 33 gallery.init(); 34 }); 35 36 $('body').on("click", ".pswp__button--close", function () { 37 $('body').removeClass('opened-photo-swipe'); 38 }); 39 40 41}); // end document 42function InitializePhotoSwipe(swipe, arr) { 43 var allItems = [] 44 // Loop over gallery items and push it to the array 45 $(swipe).each(function () { 46 var link = $(this), 47 item = { 48 src: link.attr('data-img'), 49 w: 2, 50 h: 2 51 // title: "ssssssss" 52 }; 53 allItems.push(item); 54 }); 55 // to remove duplicates 56 function uniqByKeepFirst(a, key) { 57 var seen = new Set(); 58 return a.filter(function (item) { 59 var k = key(item); 60 return seen.has(k) ? false : seen.add(k); 61 }); 62 } 63 allItems = uniqByKeepFirst(allItems, function (it) { 64 return it.src; 65 }); 66 allItems.map(function(e,i){arr.push(e)}) 67 68}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.