PageSourceSearch

https://www.inhealthgroup.com/wp-content/plugins/destaca-masonry-gallery/scripts/functions.min.js?ver=2.6.5

js inhealthgroup.com collected 2026-10-09 22:42:24 UTC 12,254 bytes, 373 lines download raw bytes

1jQuery(function($) {
2	var updateOnScroll = false;
3	
4	$('.dmg-gallery-filter').on('click', function() {
5		var $this = $(this),
6			value = $this.attr('data-value'),
7			$wrapper = $this.parents('.dmg-gallery-wrapper'),
8			$filter = $wrapper.find('.dmg-gallery-filter-categories');
9			
10		if ($this.hasClass('dmg-filter-active'))
11			return;
12
13		$filter.attr('data-value', value);
14		$filter.find('.dmg-filter-active').removeClass('dmg-filter-active');
15		$this.addClass('dmg-filter-active');
16
17		executeFilter('category', $wrapper);
18		
19	});
20
21	$('.dmg-gallery').each(function(i, el) {
22		var $gallery = $(el);
23		$gallery.isotope({
24			itemSelector: 	'.dmg_masonry_gallery_item',
25			masonry : {
26				columnWidth: 	'.dmg-gallery-sizer',
27				gutter : 		'.dmg-gutter-sizer',
28				percentPosition: true
29			}
30		});
31
32		$gallery.imagesLoaded(function() {
33			$gallery.isotope('layout');
34		});
35
36		$gallery.imagesLoaded().progress( function() {
37			$gallery.isotope('layout');
38		});
39
40		$gallery.on('layoutComplete', function(){
41	        $(window).trigger("scroll");
42	    });
43
44	    $('img.lazyload').load(function() {
45		    $gallery.isotope('layout');
46		});
47
48		dmg_lightbox( $gallery );
49
50		var $module = $gallery.parents('.dmg_masonry_gallery');
51		if ( $module && $module.length && $module.attr('id') ) {
52			var module_id = $module.attr('id'),
53				params = new URLSearchParams(window.location.search);
54			if ( params.get(module_id) ) {
55				console.log("Llega");
56				$module.find('.dmg-gallery-filter[data-slug="' + params.get(module_id) + '"]').click();
57			}
58		}
59	});
60
61	if (updateOnScroll) {
62		var scrollTO = null;
63		$(window).scroll(function() { 
64			clearTimeout(scrollTO);
65			scrollTO = setTimeout(function() {
66				$('.dmg-gallery').isotope('layout');
67			}, 300);
68		});
69	}
70
71	$(window).on('scroll', function() {
72		var top = $(window).scrollTop();
73		$('.dmg_masonry_gallery').each(function(i, el) {
74			var $gallery = $(el),
75				sideFilters  = $gallery.find('.dmg-gallery-filter-side').eq(0);
76			if ( sideFilters.length ) {
77				var menuHeight = 0,
78					$menu = $('#main-header');
79				if ( $menu.length )
80					menuHeight = $menu.outerHeight();
81
82				var galleryTop = $gallery.offset().top
83				var max = $gallery.outerHeight() - sideFilters.outerHeight();
84				if ( top + menuHeight > galleryTop ) {
85					if ( (top - menuHeight) > max ) {
86						sideFilters.css('top', max + 'px');
87					} else {
88						sideFilters.css('top', (top - menuHeight) + 'px');
89					}
90				} else {
91					sideFilters.css('top', '0');
92				}
93				$gallery.find('.dmg-gallery').css('min-height', sideFilters.outerHeight() + 'px');
94			}
95		});
96	});
97
98	$(document).on('lazyloaded', function(e) {
99		var $gallery = $(e.target).parents('.dmg-gallery');
100		if ($gallery.length) {
101			$gallery.isotope('layout');
102		}
103		updateMonarch(e.target);
104	});
105
106
107	$('.dmg-gallery-page-button').on('click', function() {
108		var $this = $(this),
109			page = $this.attr('data-value'),
110			$wrapper = $this.parents('.dmg-gallery-wrapper'),
111			$paginator = $wrapper.find('.dmg-gallery-pagination'),
112			excludeMovement = false,
113			max = Number($paginator.attr('data-max')),
114			current = Number($paginator.attr('data-value'));
115
116		if ( page == 'more') {
117			page = 1;
118			excludeMovement = true;
119			var pageSize = Number($paginator.attr('data-page-size')),
120				more = Number($paginator.attr('data-more'));
121			$paginator.attr('data-page-size', pageSize + more);
122			if ( pageSize >= more * (max-1)) {
123				$this.addClass('dmg-page-disabled');
124			}
125		} else if (page == 'prev') {
126			if ( current > 1)
127				page = current - 1;
128			else
129				return;
130		} else if ( page == 'next') {
131			if ( current < max)
132				page = current + 1;
133			else
134				return;
135		} else if (page == $paginator.attr('data-value'))
136			return;
137
138		$paginator.attr('data-value', page);
139		$paginator.find('.dmg-gallery-page-button-active').removeClass('dmg-gallery-page-button-active');
140		$paginator.find('.dmg-gallery-page-button[data-value="' + page + '"]').addClass('dmg-gallery-page-button-active');
141
142		executeFilter('page', $wrapper, excludeMovement);
143	});
144
145	function dmg_lightbox( $gallery ) {
146		if ($gallery.hasClass('dmg-modal-gallery')) {
147			var legend = $gallery.hasClass('dmg-modal-gallery-with-title');
148			$gallery.find('a.dmg_masonry_gallery_item').on('click', function(e) {
149				e.preventDefault();
150			});
151			$gallery.find('a.dmg_masonry_gallery_item').not('.dmg-minimized-link').not('.dmg-out-filter').magnificPopup({
152				type: 'image',
153				closeOnContentClick: false,
154				closeBtnInside: false,
155				mainClass: 'mfp-with-zoom mfp-img-mobile',
156				disableOn: function(a, b, c) {
157                    if ( $gallery.hasClass('dmg-disable-modal-tablet') && $(window).width() < 981 )
158                        return false;
159                    else if ( $gallery.hasClass('dmg-disable-modal-phone') && $(window).width() < 768 )
160                        return false;
161                        
162                    return true;
163                },
164				image : {
165					titleSrc : function(item) {
166						if ( legend ) {
167							var title = '<span>' + item.el.attr('data-title') + '</span>' || '' ;
168							var caption = item.el.attr('data-caption') || '' ;
169							if ( $gallery.hasClass('dmg-modal-title__title_caption')) {
170								return '<span>' + title + '</span><br><small>' + caption + '</small>'; 
171							} else if ( $gallery.hasClass('dmg-modal-title__caption')) {
172								return '<small>' + caption + '</small>'; 
173							} else if ( $gallery.hasClass('dmg-modal-title__in_title')) {
174								return '<span>' + title + '</span><br><small>' + caption + '</small>'; 
175							} else if ( $gallery.hasClass('dmg-modal-title__in_title_caption')) {
176								return '<span>' + title + '</span><br><small>' + caption + '</small>';
177							} else if ( $gallery.hasClass('dmg-modal-title__in_caption')) {
178								return '<small>' + caption + '</small>';
179							} else
180								return title;
181						} 
182					}
183				},
184				gallery: {
185					enabled: true,
186					tPrev: '',
187					tNext: '',
188					tCounter: ''
189				},
190				zoom: {
191					enabled: true,
192					duration: 300, // don't foget to change the duration also in CSS
193					opener: function(element) {
194						return element.find('img');
195					}
196				},
197				callbacks: {
198					change: function() {
199						if (this.isOpen) {
200							this.wrap.addClass('mfp-open');
201						}
202					},
203					open: function() {
204						if ( $gallery.hasClass('dmg-modal-title__in_title') || $gallery.hasClass('dmg-modal-title__in_title_caption')  || $gallery.hasClass('dmg-modal-title__in_caption') ) {
205							$(this.container).addClass('dmg-modal-in-data');
206						}
207
208						var $module = $(this.ev[0]).parents('.dmg_masonry_gallery'),
209							classes = $module && $module.length ? $module[0].className.split(' ') : [];
210						classes.forEach(c => {
211							if ( c.match(/^dmg_masonry_gallery_\d+$/g) ) {
212								$(this.bgOverlay).addClass('mfp-dmg-masonry-gallery ' + c);
213								$(this.wrap).addClass('mfp-dmg-masonry-gallery ' + c);
214							}
215						});
216					}
217				}
218			});
219		}
220	}
221
222
223	function executeFilter(type, $wrapper, excludeMovement) {
224		var $filter = $wrapper.find('.dmg-gallery-filter-categories'),
225			withFilter = $filter.length > 0,
226			category = null,
227			
228			$paginator = $wrapper.find('.dmg-gallery-pagination'),
229			withPagination = $paginator.length > 0,
230			page = 0,
231			pageSize = 0,
232			
233			$gallery = $wrapper.find('.dmg-gallery'),
234			items = $gallery.find('.dmg_masonry_gallery_item'),
235			hasSideFilter = $gallery.parents('.dmg_masonry_gallery').find('.dmg-gallery-filter-side').length > 0;
236
237		$gallery.find('.dmg-out-page').removeClass('dmg-out-page');
238		$gallery.find('.dmg-out-filter').removeClass('dmg-out-filter');
239		items.addClass('dmg-in-filter');
240
241		if (withFilter) {
242			category = $filter.attr('data-value');
243			$.each(items, function(index, item) {
244				var $item = $(item);
245				var categories = $item.attr('data-categories')
246				if (category && categories.split(',').indexOf(category) < 0) {
247					$item.removeClass('dmg-in-filter');
248					$item.addClass('dmg-out-filter');
249				}
250			});
251		}
252
253		if (withPagination) {
254
255			pageSize = $paginator.attr('data-page-size');
256
257			if (type == 'category') {
258				$paginator.attr('data-value', 1);
259				$paginator.attr('data-page-size', $paginator.attr('data-more'));
260				$paginator.find('.dmg-page-disabled').removeClass('dmg-page-disabled');
261				$paginator.find('.dmg-gallery-page-button-active').removeClass('dmg-gallery-page-button-active');
262				$paginator.find('.dmg-gallery-page-button')
263						  .not('.dmg-gallery-page-button-prev')
264						  .not('.dmg-gallery-page-button-next')
265						  .not('.dmg-gallery-page-button-more')
266						  .eq(0).addClass('dmg-gallery-page-button-active');
267
268				var categoryTotal = $gallery.find('.dmg-in-filter').length,
269					categoryPages = Math.ceil(categoryTotal/pageSize);
270				$paginator.attr('data-max', categoryPages);
271				$paginator.find('.dmg-gallery-page-button')
272						  .not('.dmg-gallery-page-button-prev')
273						  .not('.dmg-gallery-page-button-next')
274						  .not('.dmg-gallery-page-button-more')
275						  .each(function(i, button) {
276					if (i >= categoryPages)
277						$(button).addClass('dmg-page-disabled');
278				});
279				
280				if ( categoryPages <= 1 ) {	
281					$paginator.find('.dmg-gallery-page-button-more').addClass('dmg-page-disabled');
282				} else {
283					$paginator.find('.dmg-gallery-page-button-next').removeClass('dmg-page-disabled');
284				}
285			}
286
287			page = $paginator.attr('data-value');
288			var min = pageSize * (page - 1),
289				max = pageSize * page;
290				filteredItems = [];
291			if (category) {
292				filteredItems = items.filter('.dmg-in-filter');
293			} else {
294				filteredItems = items;
295			}
296
297			if ( page == 1 ) {
298				$paginator.find('.dmg-gallery-page-button-prev').addClass('dmg-page-disabled');
299			} else {
300				$paginator.find('.dmg-gallery-page-button-prev').removeClass('dmg-page-disabled');
301			}
302
303			if ( page == $paginator.attr('data-max') ) {
304				$paginator.find('.dmg-gallery-page-button-next').addClass('dmg-page-disabled');
305			} else {
306				$paginator.find('.dmg-gallery-page-button-next').removeClass('dmg-page-disabled');
307			}
308
309
310			
311		 	$.each(filteredItems, function(index, item) {
312				if (index < min || index >= max)
313					$(item).addClass('dmg-out-page');
314			});
315		}	
316
317		if (( type == 'page' && !excludeMovement && $paginator.hasClass('dmg-gallery-pagination-scrollable')) || hasSideFilter) {
318			var offset = Number($paginator.attr('data-offset'));
319			if ( isNaN(offset) || offset < 0 )
320				offset = 0;
321			$([document.documentElement, document.body]).animate({
322				scrollTop: $gallery.offset().top - offset
323			}, 750);
324		}
325
326	    $gallery.addClass('execute-filter');	
327
328		$gallery.isotope({ filter: function() {
329				return $(this).hasClass('dmg-in-filter') && !$(this).hasClass('dmg-out-page');
330			} 
331		});
332
333		dmg_lightbox( $gallery );
334	}
335
336	function updateMonarch(img) {
337		setTimeout(function() {
338			$('.et_social_icon img[src="undefined"]').parents('.et_social_pin_image').remove();
339	
340			var pin_container = $( '.et_social_pin_images' ),
341				permalink = pin_container.data( 'permalink' ),
342				title = pin_container.data( 'title' ),
343				post_id = pin_container.data( 'post_id' );
344	
345			if ( pin_container.length ) {
346				var this_img = $( img ).attr( 'src' ),
347					this_alt = $( img ).attr( 'alt' );
348		
349					if ( '' != this_img && $('.et_social_pin_image img[src="' + this_img + '"]').length == 0 ) {
350						var	pin_link = 'http://www.pinterest.com/pin/create/button/?url=' + permalink + '&media=' + this_img + '&description=' + title,
351							this_img_container = '<div class="et_social_pin_image"><a href="' + pin_link + '" rel="nofollow" class="et_social_icon et_social_share" data-social_name="pinterest" data-post_id="' + post_id + '" data-social_type="share"><img src="' + this_img + '" alt="' + this_alt + '"/><span class="et_social_pin_overlay et_social_icon"></span></a></div>';
352						$( '.et_social_pin_images' ).append( this_img_container );
353					}
354			}
355		}, 1500);
356	}
357
358	$("img.dmg-lazyload").lazyload();
359
360	if ( $('picture.dmg-lazyload img').length ) {
361		$('picture.dmg-lazyload img').lazyload();
362		
363		$("picture.dmg-lazyload img").on("load", function() {
364			$(this).parents('.dmg-gallery').isotope('layout');
365			updateMonarch(this);
366		});
367	}
368
369	$("img.dmg-lazyload").on("load", function() {
370		$(this).parents('.dmg-gallery').isotope('layout');
371		updateMonarch(this);
372	});
373});

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.