PageSourceSearch

https://www.surfshop.fr/blog/wp-content/plugins/instagram-widget-by-wpzoom/js/instagram-widget.js?ver=1.9.1

js surfshop.fr collected 2026-10-08 17:31:54 UTC 5,688 bytes, 207 lines download raw bytes

1jQuery(function ($) {
2	var ticking = false;
3
4	$.fn.zoomLoadAsyncImages = function () {
5		return $(this).each(function () {
6			var $list = $(this);
7
8			var desiredItemWidth = $list.data('image-width');
9			var imageResolution = $list.data('image-resolution');
10
11			var delayedItems = $list.find('li').filter(function () {
12				return $(this).data('media-id');
13			}).map(function () {
14				return {
15					'media-id': $(this).attr('data-media-id'),
16					'nonce': $(this).attr('data-nonce'),
17					'regenerate-thumbnails': $(this)[0].hasAttribute("data-regenerate-thumbnails")
18				};
19			});
20
21			var getAsyncImages = function (images) {
22
23				var isLastImage = images.length == 0;
24
25				if (isLastImage) {
26					return;
27				}
28
29				var image = images.shift();
30
31				wp.ajax.post('wpzoom_instagram_get_image_async', {
32					'media-id': image['media-id'],
33					nonce: image['nonce'],
34					'image-resolution': imageResolution,
35					'image-width': desiredItemWidth,
36					'regenerate-thumbnails': image['regenerate-thumbnails']
37				}).done(function (data) {
38					$list.find('li[data-media-id="' + image['media-id'] + '"] .zoom-instagram-link').css('background-image', 'url(' + data.image_src + ')');
39				}).fail(function () {
40				}).always(function () {
41					getAsyncImages(images);
42				});
43			};
44
45			if (delayedItems.length) {
46				getAsyncImages(delayedItems.toArray());
47			}
48		});
49	};
50
51	$.fn.zoomLightbox = function () {
52		return $( this ).each( function () {
53			const $swipe_el = $( this ).closest( '.widget' ).find( '> .wpz-insta-lightbox-wrapper > .swiper-container' );
54
55			if ( $swipe_el.length > 0 ) {
56				const $nested   = $swipe_el.find( '.image-wrapper > .swiper-container' );
57
58				new Swiper( $swipe_el.get(0), {
59					direction: 'horizontal',
60					loop: false,
61					spaceBetween: 20,
62					autoHeight: true,
63					watchOverflow: true,
64					navigation: {
65						nextEl: $swipe_el.find( '> .swiper-button-next' ).get(0),
66						prevEl: $swipe_el.find( '> .swiper-button-prev' ).get(0)
67					},
68					keyboard: {
69						enabled: true,
70						onlyInViewport: true
71					}
72				} );
73
74				$nested.each( function() {
75					new Swiper( $( this ).get(0), {
76						direction: 'horizontal',
77						loop: false,
78						spaceBetween: 20,
79						nested: true,
80						watchOverflow: true,
81						pagination: {
82							el: $( this ).find( '> .swiper-pagination' ).get(0),
83							type: 'bullets',
84							clickable: true,
85							hideOnClick: false
86						},
87						navigation: {
88							nextEl: $( this ).find( '> .swiper-button-next' ).get(0),
89							prevEl: $( this ).find( '> .swiper-button-prev' ).get(0)
90						},
91						keyboard: {
92							enabled: true,
93							onlyInViewport: true
94						}
95					} );
96				} );
97
98				$( this ).find( '.zoom-instagram-link' ).magnificPopup( {
99					items: {
100						type: 'inline',
101						src: $( this ).closest( '.widget' ).find( '.wpz-insta-lightbox-wrapper' )
102					},
103					closeBtnInside: false,
104					mainClass: 'wpzoom-lightbox',
105					midClick: true,
106					callbacks: {
107						open: function () {
108							this.content.find( '> .swiper-container' ).get(0).swiper.slideTo(
109								this.content.find( '> .swiper-container > .swiper-wrapper > .swiper-slide[data-uid="' + $( this._lastFocusedEl ).data( 'mfp-src' ) + '"]' ).index()
110							);
111						}
112					}
113				} );
114			}
115		} );
116	};
117
118	$.fn.zoomInstagramWidget = function () {
119		return $(this).each(function () {
120			var $list = $(this);
121
122			var minItemsPerRow = $list.data('images-per-row');
123			var desiredItemWidth = $list.data('image-width');
124			var itemSpacing = $list.data('image-spacing');
125			var imageLazyLoading = $list.data('image-lazy-loading');
126
127			var containerWidth = $list.width();
128
129			var fitPerRow;
130			var itemWidth;
131
132			if (containerWidth / desiredItemWidth < minItemsPerRow) {
133				fitPerRow = minItemsPerRow;
134				itemWidth = Math.floor(((containerWidth - 1 - (minItemsPerRow - 1) * itemSpacing) / minItemsPerRow));
135			} else {
136				fitPerRow = Math.floor((containerWidth - 1) / desiredItemWidth);
137				itemWidth = Math.floor(((containerWidth - 1 - (fitPerRow - 1) * itemSpacing) / fitPerRow));
138			}
139
140			$list.find('li').each(function (i) {
141				var loop = ++i;
142				if (loop % fitPerRow == 1) {
143					$(this).css('clear', 'left');
144				} else {
145					$(this).css('clear', 'none');
146				}
147				if (loop % fitPerRow == 0) {
148					$(this).css('margin-right', '0');
149				} else {
150					$(this).css('margin-right', itemSpacing + 'px');
151					$(this).css('margin-bottom', itemSpacing + 'px');
152				}
153			});
154
155			$list.find('a.zoom-instagram-link').css({
156				width: itemWidth,
157				height: itemWidth
158			});
159
160			if (imageLazyLoading) {
161				$list.find('a.zoom-instagram-link').lazy();
162			}
163
164			$list.removeClass('zoom-instagram-widget__items--no-js');
165		});
166	};
167
168	function requestTick() {
169		if (!ticking) {
170			ticking = true;
171			requestAnimationFrame()(update);
172		}
173	}
174
175	function requestAnimationFrame() {
176		return window.requestAnimationFrame ||
177			window.webkitRequestAnimationFrame ||
178			window.mozRequestAnimationFrame ||
179			function (callback) {
180				window.setTimeout(callback, 1000 / 60);
181			};
182	}
183
184	function update() {
185		$('.zoom-instagram-widget__items').zoomInstagramWidget();
186		ticking = false;
187	}
188
189	$(window).on('resize orientationchange', requestTick);
190	requestTick();
191
192	$('.zoom-instagram-widget__items').zoomLoadAsyncImages();
193	$('.zoom-instagram-widget__items[data-lightbox="1"]').zoomLightbox();
194
195	var siteOriginInit = function () {
196		var $widgets = $('.zoom-instagram-widget__items');
197		if ($widgets.length) {
198			$('.zoom-instagram-widget__items').zoomInstagramWidget();
199			$('.zoom-instagram-widget__items').zoomLoadAsyncImages();
200		}
201
202	};
203
204	var debounceInit = _.debounce(siteOriginInit, 1500);
205	$(document).on('panels_setup_preview', debounceInit);
206
207});

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.