PageSourceSearch

https://musiqueduboutdumonde.com/wp-content/themes/thegem/js/thegem-gallery.js?ver=5.7.1.1

js musiqueduboutdumonde.com collected 2026-10-08 07:50:53 UTC 16,709 bytes, 514 lines download raw bytes

1(function($) {
2
3	$.fn.buildSimpleGalleries = function() {
4		$('.gem-simple-gallery:not(.activated)', this).each(function() {
5
6			var $galleryElement = $(this);
7			$galleryElement.addClass('activated');
8
9			var $thumbItems = $('.gem-gallery-item', $galleryElement);
10
11			var $galleryItemsWrap = $('<div class="gem-gallery-items-carousel-wrap"/>')
12				.appendTo($galleryElement);
13			var $galleryItemsCarousel = $('<div class="gem-gallery-items-carousel"/>')
14				.appendTo($galleryItemsWrap);
15			var $galleryItemsNavigation = $('<div class="gem-gallery-items-navigation"/>')
16				.appendTo($galleryItemsWrap);
17			var $galleryItemsPrev = $('<a href="#" class="gem-prev gem-gallery-items-prev"></a>')
18				.appendTo($galleryItemsNavigation);
19			var $galleryItemsNext = $('<a href="#" class="gem-next gem-gallery-items-next"></a>')
20				.appendTo($galleryItemsNavigation);
21			$thumbItems.appendTo($galleryItemsCarousel);
22			$('a', $galleryItemsCarousel).addClass('fancy-gallery');
23			$galleryItemsCarousel.initGalleryFancybox();
24		});
25	}
26
27	$.fn.updateGalleries = function() {
28		$('.gem-gallery', this).each(updateGallery);
29	}
30
31	$.fn.updateSimpleGalleries = function() {
32		$('.gem-simple-gallery', this).each(updateSimpleGallery);
33	}
34
35
36	$(function() {
37
38		function gallery_images_loaded($box, image_selector, callback) {
39			function check_image_loaded(img) {
40				return img.complete && img.naturalWidth !== undefined && img.naturalWidth != 0;
41			}
42
43			var $images = $(image_selector, $box).filter(function() {
44					return !check_image_loaded(this);
45				}),
46				images_count = $images.length;
47
48			if (images_count == 0) {
49				return callback();
50			}
51
52			if (window.gemBrowser.name == 'ie' && !isNaN(parseInt(window.gemBrowser.version)) && parseInt(window.gemBrowser.version) <= 10) {
53				function image_load_event() {
54					images_count--;
55					if (images_count == 0) {
56						callback();
57					}
58				}
59
60				$images.each(function() {
61					if (check_image_loaded(this)) {
62						return;
63					}
64
65					var proxyImage = new Image();
66					proxyImage.addEventListener( 'load', image_load_event );
67					proxyImage.addEventListener( 'error', image_load_event );
68					proxyImage.src = this.src;
69				});
70				return;
71			}
72
73			$images.on('load error', function() {
74				images_count--;
75				if (images_count == 0) {
76					callback();
77				}
78			});
79		}
80
81		function init_circular_overlay($gallery, $set) {
82			if (!$gallery.hasClass('hover-circular')) {
83				return;
84			}
85
86			$('.gallery-item', $set).on('mouseenter touchstart', function() {
87				var overlayWidth = $('.overlay', this).width(),
88					overlayHeight = $('.overlay', this).height(),
89					$overlayCircle = $('.overlay-circle', this),
90					maxSize = 0;
91
92				if (overlayWidth > overlayHeight) {
93					maxSize = overlayWidth;
94					$overlayCircle.height(overlayWidth)
95				} else {
96					maxSize = overlayHeight;
97					$overlayCircle.width(overlayHeight);
98				}
99				maxSize += overlayWidth * 0.3;
100
101				$overlayCircle.css({
102					marginLeft: -maxSize / 2,
103					marginTop: -maxSize / 2
104				});
105			});
106		}
107
108		function initGalleryGrid() {
109			var layoutMode = 'masonry-custom';
110			if ($(this).hasClass('metro')) {
111				layoutMode = 'metro'
112			}
113
114			if (window.tgpLazyItems !== undefined) {
115				var isShowed = window.tgpLazyItems.checkGroupShowed(this, function (node) {
116					initGalleryGrid.call(node);
117				});
118				if (!isShowed) {
119					return;
120				}
121			}
122
123			var $gallery = $(this);
124			var $set = $('.gallery-set', this);
125
126			gallery_images_loaded($set, '.image-wrap img', function () {
127				$gallery.closest('.gallery-preloader-wrapper').prev('.preloader').remove();
128
129				init_circular_overlay($gallery, $set);
130
131				if ($gallery.hasClass('loading-animation')) {
132					var itemsAnimations = $gallery.itemsAnimations({
133						itemSelector: '.gallery-item',
134						scrollMonitor: true
135					});
136				}
137
138				var init_gallery = true;
139
140				if (!$gallery.hasClass('disable-isotope')) {
141					$set
142						.on('arrangeComplete', function (event, filteredItems) {
143							if (init_gallery) {
144								init_gallery = false;
145
146								var items = [];
147								filteredItems.forEach(function (item) {
148									items.push(item.element);
149								});
150
151								if ($gallery.hasClass('loading-animation')) {
152									itemsAnimations.show($(items));
153								}
154							}
155						})
156						.isotope({
157							itemSelector: '.gallery-item',
158							itemImageWrapperSelector: '.image-wrap',
159							fixHeightDoubleItems: $gallery.hasClass('gallery-style-justified'),
160							layoutMode: layoutMode,
161							'masonry-custom': {
162								columnWidth: '.gallery-item:not(.double-item)'
163							}
164						});
165				} else {
166					if ($gallery.hasClass('loading-animation')) {
167						$gallery.itemsAnimations('instance').show($('.gallery-item', $gallery));
168					}
169				}
170
171
172			});
173
174			if ($set.closest('.gem_tab').size() > 0) {
175				$set.closest('.gem_tab').bind('tab-update', function () {
176					if (!$gallery.hasClass('disable-isotope')) {
177						$set.isotope('layout');
178					}
179				});
180			}
181			$(document).on('show.vc.tab', '[data-vc-tabs]', function () {
182				var $tab = $(this).data('vc.tabs').getTarget();
183				if ($tab.find($set).length && !$gallery.hasClass('disable-isotope')) {
184					$set.isotope('layout');
185				}
186			});
187		}
188
189		function initGallerySlider() {
190			if (window.tgpLazyItems !== undefined) {
191				var isShowed = window.tgpLazyItems.checkGroupShowed(this, function(node) {
192					initGallerySlider.call(node);
193				});
194				if (!isShowed) {
195					return;
196				}
197			}
198
199			var $gallery = $(this);
200			var $set = $('.gallery-set', this);
201			var $items = $('.gallery-item', $set);
202
203			init_circular_overlay($gallery, $set);
204
205			// update images list
206			$set.wrap('<div class="gem-gallery-preview-carousel-wrap clearfix"/>');
207			var $galleryPreviewWrap = $('.gem-gallery-preview-carousel-wrap', this);
208			$galleryPreviewWrap.wrap('<div class="gem-gallery-preview-carousel-padding clearfix"/>');
209			var $galleryPreviewNavigation = $('<div class="gem-gallery-preview-navigation"/>')
210				.appendTo($galleryPreviewWrap);
211			var $galleryPreviewPrev = $('<a href="#" class="gem-prev gem-gallery-preview-prev"></a>')
212				.appendTo($galleryPreviewNavigation);
213			var $galleryPreviewNext = $('<a href="#" class="gem-next gem-gallery-preview-next"></a>')
214				.appendTo($galleryPreviewNavigation);
215
216			// create thumbs list
217			var $galleryThumbsWrap = $('<div class="gem-gallery-thumbs-carousel-wrap col-lg-12 col-md-12 col-sm-12 clearfix" style="opacity: 0"/>')
218				.appendTo($gallery);
219			var $galleryThumbsCarousel = $('<ul class="gem-gallery-thumbs-carousel"/>')
220				.appendTo($galleryThumbsWrap);
221			var $galleryThumbsNavigation = $('<div class="gem-gallery-thumbs-navigation"/>')
222				.appendTo($galleryThumbsWrap);
223			var $galleryThumbsPrev = $('<a href="#" class="gem-prev gem-gallery-thumbs-prev"></a>')
224				.appendTo($galleryThumbsNavigation);
225			var $galleryThumbsNext = $('<a href="#" class="gem-next gem-gallery-thumbs-next"></a>')
226				.appendTo($galleryThumbsNavigation);
227			var thumbItems = '';
228			$items.each(function() {
229				thumbItems += '<li><span><img src="' + $('.image-wrap img', this).data('thumb-url') + '" alt="" /></span></li>';
230			});
231			var $thumbItems = $(thumbItems);
232			$thumbItems.appendTo($galleryThumbsCarousel);
233			$thumbItems.each(function(index) {
234				$(this).data('gallery-item-num', index);
235			});
236
237			var $galleryPreview = $set.carouFredSel({
238				auto: false,
239				circular: false,
240				infinite: false,
241				responsive: true,
242				width: '100%',
243				height: '100%',
244				items: 1,
245				align: 'center',
246				prev: $galleryPreviewPrev,
247				next: $galleryPreviewNext,
248				swipe: true,
249				scroll: {
250					items: 1,
251					onBefore: function(data) {
252						var current = $(this).triggerHandler('currentPage');
253						var thumbCurrent = $galleryThumbs.triggerHandler('slice', [current, current+1]);
254						var thumbsVisible = $galleryThumbs.triggerHandler('currentVisible');
255						$thumbItems.filter('.active').removeClass('active');
256						if(thumbsVisible.index(thumbCurrent) === -1) {
257							$galleryThumbs.trigger('slideTo', current);
258						}
259						$('span', thumbCurrent).trigger('click');
260					}
261				}
262			});
263
264			var $galleryThumbs = null;
265			gallery_images_loaded($galleryThumbsCarousel, 'img', function() {
266				$galleryThumbs = $galleryThumbsCarousel.carouFredSel({
267					auto: false,
268					circular: false,
269					infinite: false,
270					width: '100%',
271					height: 'variable',
272					align: 'center',
273					prev: $galleryThumbsPrev,
274					next: $galleryThumbsNext,
275					swipe: true,
276					onCreate: function(data) {
277						$('span', $thumbItems).click(function(e) {
278							e.preventDefault();
279							$thumbItems.filter('.active').removeClass('active');
280							$(this).closest('li').addClass('active');
281							$galleryPreview.trigger('slideTo', $(this).closest('li').data('gallery-item-num'));
282						});
283						$thumbItems.eq(0).addClass('active');
284					}
285				});
286				$galleryThumbsWrap.animate({opacity: 1}, 400);
287				if($thumbItems.length < 2) {
288					$galleryThumbsWrap.hide();
289				}
290			});
291		}
292
293		function initGallery() {
294			if (window.tgpLazyItems !== undefined) {
295				var isShowed = window.tgpLazyItems.checkGroupShowed(this, function(node) {
296					initGallery.call(node);
297				});
298				if (!isShowed) {
299					return;
300				}
301			}
302
303			var $galleryElement = $(this);
304
305			var $thumbItems = $('.gem-gallery-item', $galleryElement);
306
307			var $galleryPreviewWrap = $('<div class="gem-gallery-preview-carousel-wrap"/>')
308				.appendTo($galleryElement);
309			var $galleryPreviewCarousel = $('<div class="gem-gallery-preview-carousel "/>')
310				.appendTo($galleryPreviewWrap);
311			var $galleryPreviewNavigation = $('<div class="gem-gallery-preview-navigation"/>')
312				.appendTo($galleryPreviewWrap);
313			var $galleryPreviewPrev = $('<a href="#" class="gem-prev gem-gallery-preview-prev"></a>')
314				.appendTo($galleryPreviewNavigation);
315			var $galleryPreviewNext = $('<a href="#" class="gem-next gem-gallery-preview-next"></a>')
316				.appendTo($galleryPreviewNavigation);
317			if($galleryElement.hasClass('with-pagination')) {
318				var $galleryPreviewPagination = $('<div class="gem-gallery-preview-pagination gem-mini-pagination"/>')
319					.appendTo($galleryPreviewWrap);
320			}
321			var $previewItems = $thumbItems.clone(true, true);
322			$previewItems.appendTo($galleryPreviewCarousel);
323			$previewItems.each(function() {
324				$('img', this).attr('src', $('a', this).attr('href'));
325				$('a', this)
326					.attr('href', $('a', this)
327					.data('full-image-url'))
328					.attr('data-fancybox', $('a', this).data('fancybox-group'))
329					.addClass('fancy-gallery');
330			});
331
332			$galleryPreviewCarousel.initGalleryFancybox();
333
334			var $galleryThumbsWrap = $('<div class="gem-gallery-thumbs-carousel-wrap"/>')
335				.appendTo($galleryElement);
336			var $galleryThumbsCarousel = $('<div class="gem-gallery-thumbs-carousel"/>')
337				.appendTo($galleryThumbsWrap);
338			var $galleryThumbsNavigation = $('<div class="gem-gallery-thumbs-navigation"/>')
339				.appendTo($galleryThumbsWrap);
340			var $galleryThumbsPrev = $('<a href="#" class="gem-prev gem-gallery-thumbs-prev"></a>')
341				.appendTo($galleryThumbsNavigation);
342			var $galleryThumbsNext = $('<a href="#" class="gem-next gem-gallery-thumbs-next"></a>')
343				.appendTo($galleryThumbsNavigation);
344			$thumbItems.appendTo($galleryThumbsCarousel);
345			$thumbItems.each(function(index) {
346				$(this).data('gallery-item-num', index);
347			});
348		}
349
350		$('.gem-gallery-grid').not('.gallery-slider').each(initGalleryGrid);
351		$('.gallery-slider').each(initGallerySlider);
352
353		$('.gem-gallery-grid').on('click', '.gallery-item', function() {
354			$(this).mouseover();
355		});
356
357		$('.gem-gallery').each(initGallery);
358
359		$('body').updateGalleries();
360		$('body').buildSimpleGalleries();
361		$('body').updateSimpleGalleries();
362
363		$('.gem_tab').on('tab-update', function() {
364			$(this).updateGalleries();
365		});
366		$(document).on('gem.show.vc.tabs', '[data-vc-accordion]', function() {
367			$(this).data('vc.accordion').getTarget().updateGalleries();
368		});
369		$(document).on('gem.show.vc.accordion', '[data-vc-accordion]', function() {
370			$(this).data('vc.accordion').getTarget().updateGalleries();
371		});
372	});
373
374	function updateGallery() {
375		if (window.tgpLazyItems !== undefined) {
376			var isShowed = window.tgpLazyItems.checkGroupShowed(this, function(node) {
377				updateGallery.call(node);
378			});
379			if (!isShowed) {
380				return;
381			}
382		}
383
384		var $galleryElement = $(this);
385
386		var $galleryPreviewCarousel = $('.gem-gallery-preview-carousel', $galleryElement);
387		var $galleryThumbsWrap = $('.gem-gallery-thumbs-carousel-wrap', $galleryElement);
388		var $galleryThumbsCarousel = $('.gem-gallery-thumbs-carousel', $galleryElement);
389		var $thumbItems = $('.gem-gallery-item', $galleryThumbsCarousel);
390		var $galleryPreviewPrev = $('.gem-gallery-preview-prev', $galleryElement);
391		var $galleryPreviewNext = $('.gem-gallery-preview-next', $galleryElement);
392		var $galleryPreviewPagination = $('.gem-gallery-preview-pagination', $galleryElement);
393		var $galleryThumbsPrev = $('.gem-gallery-thumbs-prev', $galleryElement);
394		var $galleryThumbsNext = $('.gem-gallery-thumbs-next', $galleryElement);
395
396		$galleryElement.thegemPreloader(function() {
397
398			var $galleryThumbs = $galleryThumbsCarousel, $galleryPreview = $galleryPreviewCarousel;
399
400			$('img', $galleryPreviewCarousel).removeAttr('data-tgpli-image-inited');
401
402			$galleryPreview = $galleryPreviewCarousel.carouFredSel({
403				auto: $galleryElement.data('autoscroll') ? $galleryElement.data('autoscroll') : false,
404				circular: true,
405				infinite: true,
406				responsive: true,
407				width: '100%',
408				height: 'auto',
409				items: 1,
410				align: 'center',
411				prev: $galleryPreviewPrev,
412				next: $galleryPreviewNext,
413				pagination: $galleryElement.hasClass('with-pagination') ? $galleryPreviewPagination : false,
414				swipe: true,
415				scroll: {
416					pauseOnHover: true,
417					items: 1,
418					onBefore: function(data) {
419						var current = $(this).triggerHandler('currentPage');
420						var thumbCurrent = $galleryThumbs.triggerHandler('slice', [current, current+1]);
421						var thumbsVisible = $galleryThumbs.triggerHandler('currentVisible');
422						$thumbItems.filter('.active').removeClass('active');
423						if(thumbsVisible.index(thumbCurrent) === -1) {
424							$galleryThumbs.trigger('slideTo', current);
425						}
426						$('a', thumbCurrent).trigger('gemActivate');
427					}
428				},
429				onCreate: function () {
430					$(window).on('resize', function () {
431						$galleryPreviewCarousel.parent().add($galleryPreviewCarousel).height($galleryPreviewCarousel.children().first().height());
432					}).trigger('resize');
433				}
434			});
435
436			$('img', $galleryThumbsCarousel).removeAttr('data-tgpli-image-inited');
437
438			$galleryThumbs = $galleryThumbsCarousel.carouFredSel({
439				auto: false,
440				circular: true,
441				infinite: true,
442				width: '100%',
443				height: 'variable',
444				align: 'center',
445				prev: $galleryThumbsPrev,
446				next: $galleryThumbsNext,
447				swipe: true,
448				onCreate: function(data) {
449					$('a', $thumbItems).on('gemActivate', function(e) {
450						$thumbItems.filter('.active').removeClass('active');
451						$(this).closest('.gem-gallery-item').addClass('active');
452						$galleryPreview.trigger('slideTo', $(this).closest('.gem-gallery-item').data('gallery-item-num'));
453					});
454					$('a', $thumbItems).click(function(e) {
455						e.preventDefault();
456						$(this).trigger('gemActivate');
457					});
458				}
459			});
460
461			if($thumbItems.filter('.active').length) {
462				$thumbItems.filter('.active').eq(0).find('a').trigger('click');
463			} else {
464				$thumbItems.eq(0).find('a').trigger('gemActivate');
465			}
466
467			if($thumbItems.length < 2) {
468				$galleryThumbsWrap.hide();
469			}
470
471		});
472	}
473
474	function updateSimpleGallery() {
475		if (window.tgpLazyItems !== undefined) {
476			var isShowed = window.tgpLazyItems.checkGroupShowed(this, function(node) {
477				updateSimpleGallery.call(node);
478			});
479			if (!isShowed) {
480				return;
481			}
482		}
483
484		var $galleryElement = $(this);
485
486		var $galleryItemsCarousel = $('.gem-gallery-items-carousel', $galleryElement);
487		var $thumbItems = $('.gem-gallery-item', $galleryItemsCarousel);
488		var $galleryItemsPrev = $('.gem-gallery-items-prev', $galleryElement);
489		var $galleryItemsNext = $('.gem-gallery-items-next', $galleryElement);
490
491		$galleryElement.thegemPreloader(function() {
492			var $galleryItems = $galleryItemsCarousel.carouFredSel({
493				auto: ($galleryElement.data('autoscroll') > 0 ? $galleryElement.data('autoscroll') : false),
494				circular: true,
495				infinite: true,
496				responsive: $galleryElement.hasClass('responsive'),
497				width: '100%',
498				height: 'variable',
499				align: 'center',
500				prev: $galleryItemsPrev,
501				next: $galleryItemsNext,
502				swipe: true,
503				scroll: {
504					pauseOnHover: true
505				},
506				onCreate: function(data) {
507					$galleryElement.trigger('gallery-inited');
508				}
509			});
510
511		});
512	}
513
514})(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.