PageSourceSearch

https://www.inwit.it/wp-content/themes/inwit/assets/js/photoswipe-init.js?ver=1.6.19

js inwit.it collected 2026-10-02 17:23:15 UTC 3,680 bytes, 93 lines download raw bytes

1(function($) {
2
3  if ( typeof PhotoSwipe === 'undefined' ) {
4    return;
5  }
6
7  // Handle Photoswipe gallery.
8  function createPhotoswipeSlides(items) {
9    return $.map(items, function(item) {
10      var sizes  = $(item).find('a').data('size'),
11          source = $(item).find('a').attr('href');
12      if (!sizes && $(item).find('a[data-video]').length) {
13        var videoHTML = source.indexOf('.mp4') !== -1
14          ? '<video controls -webkit-playsinline playsinline><source src="'+ source +'" type="video/mp4" /></video>'
15          : '<iframe width="640" height="480" src="'+ source +'" frameborder="0" allow="autoplay; encrypted-media; picture-in-picture; fullscreen"></iframe>'
16        return {
17          _url: source,
18          html: '<div class="pswp__video"><div class="embed-responsive embed-responsive--16by9">'+ videoHTML +'</div></div>'
19        }
20      }
21      return {
22        src: source,
23        msrc: $(item).find('img').data('msrc'),
24        title: $(item).find('figcaption').html(),
25        w: sizes ? parseInt(sizes.split('x')[0]) : 600,
26        h: sizes ? parseInt(sizes.split('x')[1]) : 600,
27      }
28    });
29  }
30  function openPhotoswipeGallery(e) {
31    e.preventDefault();
32    var pswpElement = $('.pswp')[0],
33        eventTarget = $(e.target),
34        clicked     = e.target.tagName.toUpperCase() !== 'FIGURE'
35          ? eventTarget.parents('figure')
36          : eventTarget;
37    var items = clicked.parents('[data-gallery]').find('[data-gallery-item]:not([class*="-cloned"]) figure');
38    var slides = createPhotoswipeSlides(items);
39    var index = slides.findIndex(function(s) {
40      prop = s.hasOwnProperty('_url') ? '_url' : 'src';
41      return s[prop] === clicked.find('a').attr('href');
42    });
43    var photoswipe = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, slides, {
44      history: false,
45      shareEl: false,
46      bgOpacity: 0.8,
47      closeOnScroll: false,
48      showHideOpacity: true,
49      getThumbBoundsFn: function(index) {
50        var thumbnail = items[index];
51        if ( $(thumbnail).parents('.tns-slider').length ) {
52          return false;
53        }
54        var rect = thumbnail.getBoundingClientRect();
55        var pageYScroll = window.pageYOffset || document.documentElement.scrollTop;
56        return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
57      },
58      index: index,
59      addCaptionHTMLFn: function(item, captionEl) {
60        if ( !item.title ) {
61          captionEl.children[0].innerHTML = '';
62          return false;
63        }
64        captionEl.children[0].innerHTML = item.title;
65        return true;
66      }
67    });
68    photoswipe.listen('initialZoomInEnd', togglePhotoswipeVideo.bind(null, clicked, 'open'));
69    photoswipe.listen('afterChange', togglePhotoswipeVideo.bind(null, clicked, 'change'));
70    photoswipe.listen('close', togglePhotoswipeVideo.bind(null, clicked, 'close'));
71    return photoswipe.init();
72  }
73  function togglePhotoswipeVideo(target, eventType) {
74    if ( !target.find('a[data-video]').length ) return;
75    var autoplay = eventType === 'open';
76    var videoUrl = target.find('a[data-video]').attr('href');
77    if (videoUrl.indexOf('.mp4') !== -1) {
78      var videoElem = $('.pswp__video source[src="'+videoUrl+'"]').parent()[0];
79      if (!autoplay) {
80        videoElem.pause();
81        videoElem.currentTime = 0;
82      } else {
83        videoElem.play();
84      }
85    } else {
86      autoplay += 0;
87      var videoSrc = videoUrl.replace(/\?.*/, '');
88      $('.pswp__video iframe[src^="'+videoSrc+'"]').attr('src', videoUrl.replace(/autoplay=([0-9]+)/i, 'autoplay='+autoplay));
89    }
90  }
91  $(document).on('click', '[data-gallery-item] a', openPhotoswipeGallery);
92
93})(jQuery);

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.