PageSourceSearch

https://eagleriverhomes.net/wp-content/plugins/divi-gallery-extend…/assets/script.min.js?ver=2.0.6

js eagleriverhomes.net collected 2026-10-09 01:09:21 UTC 20,433 bytes, 556 lines download raw bytes

1jQuery( document ).ready( function($) {
2	$.fn.DynamicGalleryExtendedInsertAt = function( index, element ) {
3		let lastIndex = this.children().length;
4		if ( index < 0 ) {
5			index = Math.max(0, lastIndex + 1 + index);
6		}
7		this.append(element);
8		if ( index < lastIndex ) {
9			this.children().eq(index).before(this.children().last());
10		}
11		return this;
12	}
13	$.fn.DynamicGalleryExtendedPagination = function( $options = {} ) {
14		let $defaults = {
15				paginationClass: 'el_masonry_gallery_pagination',
16				hideOnlyOnePage: true,
17				totalPages: 1,
18				visiblePages: 10,
19				startPage: 1,
20				initiateStartPageClick: false,
21				first: false,
22				last: false,
23				prev: false,
24				next: false,
25			},
26			$pagination = this;
27
28		$pagination.twbsPagination( 'destroy' );
29
30		$options = $.extend( {}, $defaults, $options );
31		$pagination.twbsPagination( $options );
32	}
33	
34	// Dynamic Masonry Gallery Script.
35	if ( $(document).find( '.el_dynamic_masonry_gallery' ).length > 0 ) {
36		$( '.el_dynamic_masonry_gallery' ).each( function() {
37			dge_init_dynamic_masonry_gallery( $( this ) );
38		} );
39	}
40} );
41
42// Init dynamic masonry gallery.
43function dge_init_dynamic_masonry_gallery( $thisObj ) {
44	let $        = jQuery,
45		$wrapper = $thisObj.find( '.el_masonry_gallery_wrapper' ),
46		$inner   = $thisObj.find( '.el_dynamic_masonry_gallery_module__inner' );
47		$options = {
48			itemSelector: '.el_masonry_gallery_item',
49			layoutMode: 'masonry',
50			percentPosition: true,
51			resize: true,
52			transitionDuration: parseInt( $wrapper.attr( 'data-isotope_transition_duration' ) ),
53			masonry: {
54				columnWidth: '.el_masonry_gallery_item',
55				gutter: '.el_masonry_gallery_item_gutter'
56			}
57		};
58
59	// Display again, if it hide due to pagination.
60	$inner.find( '.el_masonry_gallery_item' ).css( 'display', 'inline-block' );
61
62	let $dynamicMasonryGallery = $inner.isotope( $options );
63	$dynamicMasonryGallery.imagesLoaded( function() {
64		$dynamicMasonryGallery.isotope( 'layout' );
65		$dynamicMasonryGallery.isotope( 'reloadItems' );
66	} );
67
68	// Ajax nonce.
69	let $ajaxNonce = $thisObj.find( '.dge-dynamic-masonry-gallery-nonce' ).val();
70
71	// Pagination.
72	if ( $thisObj.find('.el_masonry_gallery_pagination_wrapper ul').length > 0 ) {
73		let $pagination_wrapper = $thisObj.find( '.el_masonry_gallery_pagination_wrapper' ),
74			$pagination         = $pagination_wrapper.find( 'ul' ),
75			$perPage            = isNaN( $wrapper.attr('data-number_of_images') ) || 0 === parseInt( $wrapper.attr('data-number_of_images') ) ? 20 : parseInt( $wrapper.attr('data-number_of_images') ),
76			$totalPages         = parseInt( Math.ceil( parseInt( $wrapper.attr('data-total_images') ) / $perPage ) ),
77			$options            = {
78				totalPages: $totalPages,
79				onPageClick: function (event, page) {
80					let $props = $wrapper.data();
81					if ( $wrapper.find( '.el_masonry_gallery_item_page_' + page ).length > 0 ) {
82						$dynamicMasonryGallery.isotope( {
83							filter: function() {
84								if ( $(this).hasClass('el_masonry_gallery_item_page_'+page) ) {
85									return $(this);
86								}
87							}
88						} ).isotope( 'revealItemElements', $wrapper.find( '.el_masonry_gallery_item_page_' + page ) ).isotope( 'layout' );
89					} else {
90						$props['page'] = page;
91						$wrapper.fadeTo( '100', 0.2 );
92						$.ajax( {
93							type : 'POST',  
94							url  : DGEObj.ajaxUrl,
95							data : {
96								action: 'dge_dynamic_gallery_load_content',
97								_wpnonce: $ajaxNonce,
98								props: $props
99							},
100							success: function(response) {
101								if ( response?.success ) {
102									let $elements = $(response?.data?.items);
103									$dynamicMasonryGallery.append( $elements ).isotope( 'appended', $elements );
104									$dynamicMasonryGallery.isotope( {
105										filter: function() {
106											if ( $(this).hasClass('el_masonry_gallery_item_page_'+page) ) {
107												return $(this);
108											}
109										}
110									} ).isotope( 'revealItemElements', $wrapper.find('.el_masonry_gallery_item_page_'+page) ).isotope('layout');
111								}
112								$wrapper.fadeTo( '100', 1 );
113							}
114						} );
115					}
116
117					if ( $thisObj.offset().top > 0 ) {
118						let topHeaderHeight  = 0,
119							mainHeaderHeight = 0,
120							tbHeaderHeight   = 0;
121
122						if ( $('body').find('#top-header').length > 0 && $('body').hasClass('et_fixed_nav') ) {
123							topHeaderHeight = parseFloat( $('#top-header').innerHeight() );
124						}
125						if ( $('body').find('#main-header').length > 0 && $('body').hasClass('et_fixed_nav') ) {
126							mainHeaderHeight = parseFloat( $('#main-header').innerHeight() );
127						}
128						if ( $('body').find('.et-l--header').length > 0 && $('body').find('.et-l--header .et_builder_inner_content').hasClass('has_et_pb_sticky') ) {
129							tbHeaderHeight = parseFloat( $('.et-l--header').innerHeight() );
130						}
131						let headerHeight = topHeaderHeight + mainHeaderHeight + tbHeaderHeight + 50;
132						$( 'html, body' ).animate( {
133							scrollTop: ( $thisObj.offset().top - headerHeight )
134						} );
135					}
136				}
137			};
138
139		if ( 'on' === $wrapper.attr('data-show_prev_next') ) {
140			$options.prev = $wrapper.attr( 'data-prev_text' );
141			$options.next = $wrapper.attr( 'data-next_text' );
142		}
143
144		if ( $perPage && '' !== $perPage && ! isNaN( $perPage ) ) {
145			$pagination.DynamicGalleryExtendedPagination( $options );
146		}
147	}
148
149	// Load more button.
150	if ( $thisObj.find('.el_masonry_gallery_pagination_wrapper .el-dynamic-gallery-load-more').length > 0 ) {
151		let $pagination_wrapper = $thisObj.find('.el_masonry_gallery_pagination_wrapper');
152		$thisObj.off('click').on( 'click', '.el-dynamic-gallery-load-more', function() {
153			let $props   = $wrapper.data(),
154				$page    = isNaN( $wrapper.attr('data-load_page') ) ? 2 : parseInt( $wrapper.attr('data-load_page') ),
155				$perPage = isNaN( $wrapper.data('number_of_images') ) || 0 === parseInt( $wrapper.data('number_of_images') ) ? 20 : parseInt( $wrapper.data('number_of_images') );
156
157			$props['page'] = $page;
158
159			$pagination_wrapper.find( '.el-dynamic-gallery-load-more' ).prop( 'disabled', true );
160			$wrapper.fadeTo( '100', 0.2 );
161			$.ajax( {
162				type: 'POST',  
163				url: DGEObj.ajaxUrl,
164				data: {
165					action: 'dge_dynamic_gallery_load_content', 
166					_wpnonce: $ajaxNonce,
167					props: $props
168				},
169				success: function(response) {
170					if ( response.success ) {
171
172						let $elements = $(response?.data?.items);
173						$dynamicMasonryGallery.append( $elements ).isotope( 'appended', $elements );
174
175						let allElements = $wrapper.find('.el_masonry_gallery_item').each( function($index) {
176							let pageIndex = $( this ).prop('class').match(/(el_masonry_gallery_item_page_\_[^\s]*)/);
177							if ( pageIndex <= $page ) {
178								return $(this);
179							}
180						} );
181						$dynamicMasonryGallery.isotope( {
182							filter: function() {
183								let pageIndex = $( this ).prop('class').match(/(el_masonry_gallery_item_page_\_[^\s]*)/);
184								if ( pageIndex <= $page ) {
185									return $(this);
186								}
187							}
188						} ).isotope( 'revealItemElements', allElements ).isotope('layout');
189
190						$wrapper.attr( 'data-load_page', ( parseInt( $page ) + 1 ) );
191						if ( parseInt( $elements.length ) < parseInt( $perPage ) ) {
192							$pagination_wrapper.find( '.el-dynamic-gallery-load-more' ).hide();
193						}
194						$wrapper.fadeTo( '100', 1 );
195					}
196					$pagination_wrapper.find( '.el-dynamic-gallery-load-more' ).prop( 'disabled', false );
197				}
198			} );
199		} );
200	}
201
202	// Category Filter.
203	let $detachedImages  = [];
204	let $detachedIndices = [];
205	let $load_trigger    = false;
206	if ( $thisObj.find('.el_masonry_gallery_pagination_wrapper').length > 0 ) {
207		let $pagination_wrapper = $thisObj.find( '.el_masonry_gallery_pagination_wrapper' ),
208			$pagination         = $pagination_wrapper.find( 'ul' ),
209			$include_categories = $wrapper.attr( 'data-include_categories' );
210
211		$thisObj.find( '.el_masonry_gallery_filter_categories li' ).on( 'click', function(e) {
212			if ( $( this ).hasClass( 'el_masonry_gallery_active_category' ) ) {
213				return false;
214			}
215
216			if ( $detachedImages && $detachedIndices && $detachedIndices.length === $detachedImages.length ) {
217				$.map( $detachedImages, function( value, key ) {
218					$wrapper.DynamicGalleryExtendedInsertAt( $detachedIndices[key], $(value) );
219				} );
220			} else if ( $detachedImages ) {
221				$wrapper.append( $detachedImages );
222			}
223
224			let $thisCat  = $( this ),
225				$category = $thisCat.attr( 'data-category' ),
226				$props    = $wrapper.data();
227
228			$thisCat.parent( '.el_masonry_gallery_filter_categories' ).find( 'li' ).removeClass( 'el_masonry_gallery_active_category' );
229			$thisCat.addClass( 'el_masonry_gallery_active_category' );
230			
231			$props['page'] = 1;
232			if ( $category && '' !== $category ) {
233				$props['include_categories'] = $category;
234				$props['tax_query_field']    = 'term_id';
235				
236				if ( 1 === parseInt( $props['total_pages'] ) ) {
237					let $elements = [];
238					$wrapper.find('.el_masonry_gallery_item img').each( function() {
239						if ( $(this).data('categories') ) {
240							let $imageCats = $(this).attr('data-categories').split(',');
241							$imageCats = $.map( $imageCats, function( a ) {
242								return parseInt(a);
243							} );
244							if ( -1 === $.inArray( $category, $imageCats ) ) {
245								$detachedIndices.push( $(this).closest('.el_masonry_gallery_item').index() );
246							} else {
247								$elements.push($(this).closest('.el_masonry_gallery_item'));
248							}
249						} else {
250							$detachedIndices.push( $(this).closest('.el_masonry_gallery_item').index() );
251						}
252					} );
253					$gallery.isotope( {
254						filter: function() {
255							if ( $(this).find('img').data('categories') ) {
256								let $imageCats = $(this).find('img').attr('data-categories').split(',');
257								$imageCats = $.map( $imageCats, function( a ) {
258									return parseInt(a);
259								});
260								if ( -1 !== $.inArray( $category, $imageCats ) ) {
261									return $(this);
262								} else {
263									$detachedImages.push($(this).detach());
264								}
265							} else {
266								$detachedImages.push($(this).detach());
267							}
268						}
269					} ).isotope( 'revealItemElements', $elements ).isotope('layout');
270				}
271			} else {
272				$props['include_categories'] = $include_categories;
273				// $props['tax_query_field']    = 'term_id';
274				if ( 1 === parseInt( $props['total_pages'] ) ) {
275					$gallery.isotope({ filter: '*' });
276				}
277			}
278
279			// if ( 1 !== parseInt( $props['total_pages'] ) ) {
280				$wrapper.fadeTo( '100', 0.2 );
281				$.ajax( {
282					type : 'POST',
283					url  : DGEObj.ajaxUrl,
284					data : {
285						action: 'dge_dynamic_gallery_load_content', 
286						_wpnonce: $ajaxNonce,
287						props: $props
288					},
289					success: function( response ) {
290						if ( response.success ) {
291							let $elements = $( response?.data?.items );
292							$wrapper.find( '.el_masonry_gallery_item' ).remove();
293							$dynamicMasonryGallery.append( $elements ).isotope( 'appended', $elements );
294							$dynamicMasonryGallery.isotope( {
295								filter: function() {
296									if ( $(this).find('img').attr('data-categories') ) {
297										let $imageCats = $(this).find('img').attr('data-categories').split(',');
298										$imageCats = $.map( $imageCats, function( a ) {
299											return parseInt(a);
300										} );
301										if ( -1 !== $.inArray( $category, $imageCats ) ) {
302											return $( this );
303										}
304									}
305								}
306							} );
307
308							// Re-render Pagination.
309							let $totalPages = parseInt( response.data.total_pages ),
310								$options    = {
311									initiateStartPageClick: true,
312									totalPages: $totalPages,
313									onPageClick: function (event, page) {
314										if ( $wrapper.find( '.el_masonry_gallery_item_page_' + page ).length > 0 ) {
315											$dynamicMasonryGallery.isotope( {
316												filter: function() {
317													if ( $(this).hasClass( 'el_masonry_gallery_item_page_' + page ) ) {
318														return $(this);
319													}
320												}
321											} ).isotope( 'revealItemElements', $wrapper.find( '.el_masonry_gallery_item_page_' + page ) ).isotope( 'layout' );
322										} else {
323											$props['page'] = page;
324											$wrapper.fadeTo( '100', 0.2 );
325											$.ajax( {
326												type : 'POST',  
327												url  : DGEObj.ajaxUrl,
328												data : {
329													action: 'dge_dynamic_gallery_load_content', 
330													_wpnonce: $ajaxNonce,
331													props: $props
332												},
333												success: function(response) {
334													if ( response.success ) {
335														let $elements = $( response.data.items );
336														$dynamicMasonryGallery.append( $elements ).isotope( 'appended', $elements );
337														$dynamicMasonryGallery.isotope( {
338															filter: function() {
339																if ( $(this).hasClass( 'el_masonry_gallery_item_page_' + page ) ) {
340																	return $( this );
341																}
342															}
343														} ).isotope( 'revealItemElements', $wrapper.find( '.el_masonry_gallery_item_page_' + page ) ).isotope('layout');
344													}
345													$wrapper.fadeTo( '100', 1 );
346												}
347											} );
348										}
349
350										if ( $load_trigger === true ) {
351											if ( $thisObj.offset().top > 0 ) {
352												let topHeaderHeight  = 0,
353													mainHeaderHeight = 0,
354													tbHeaderHeight   = 0;
355
356												if ( $('body').find('#top-header').length > 0 && $('body').hasClass('et_fixed_nav') ) {
357													topHeaderHeight = parseFloat( $('#top-header').innerHeight() );
358												}
359												if ( $('body').find('#main-header').length > 0 && $('body').hasClass('et_fixed_nav') ) {
360													mainHeaderHeight = parseFloat( $('#main-header').innerHeight() );
361												}
362												if ( $('body').find('.et-l--header').length > 0 && $('body').find('.et-l--header .et_builder_inner_content').hasClass('has_et_pb_sticky') ) {
363													tbHeaderHeight = parseFloat( $('.et-l--header').innerHeight() );
364												}
365												let headerHeight = topHeaderHeight + mainHeaderHeight + tbHeaderHeight + 50;
366												$( 'html, body' ).animate( {
367													scrollTop: ( $thisObj.offset().top - headerHeight )
368												} );
369											}
370										}
371										$load_trigger = true;
372									}
373								};
374
375							if ( 'on' === $wrapper.attr( 'data-show_prev_next' ) ) {
376								$options.prev = $wrapper.attr( 'data-prev_text' );
377								$options.next = $wrapper.attr( 'data-next_text' );
378							}
379
380							$pagination.DynamicGalleryExtendedPagination( $options );
381
382							// Reset load more data.
383							if ( $pagination_wrapper.find( '.el-dynamic-gallery-load-more' ).length > 0 ) {
384								$wrapper.attr( 'data-total_pages', $totalPages );
385								$wrapper.attr( 'data-load_page', 2 );
386								$dynamicMasonryGallery.isotope( { filter: '*' } );
387
388								$pagination_wrapper.find( '.el-dynamic-gallery-load-more' ).hide();
389								if ( $totalPages > 1 ) {
390									$pagination_wrapper.find( '.el-dynamic-gallery-load-more' ).show();
391								}
392							}
393						}
394						$wrapper.fadeTo( '100', 1 );
395					}
396				} );
397			// }
398		} );
399	} else {
400		let $include_categories = $wrapper.attr( 'data-include_categories' );
401		$thisObj.on( 'click', '.el_masonry_gallery_filter_categories li', function() {
402			if ( $( this ).hasClass( 'el_masonry_gallery_active_category' ) ) {
403				return false;
404			}
405
406			if ( $detachedImages && $detachedIndices && $detachedIndices.length === $detachedImages.length ) {
407				$.map( $detachedImages, function( value, key ) {
408					$wrapper.DynamicGalleryExtendedInsertAt( $detachedIndices[key], $(value) );
409				} );
410			} else if ( $detachedImages ) {
411				$wrapper.append($detachedImages);
412			}
413
414			let $thisCat  = $( this ),
415				$category = $thisCat.data( 'category' ),
416				$props    = $wrapper.data();
417
418			$thisCat.parent( '.el_masonry_gallery_filter_categories' ).find( 'li' ).removeClass( 'el_masonry_gallery_active_category' );
419			$thisCat.addClass( 'el_masonry_gallery_active_category' );
420
421			if ( '' !== $category ) {
422				$props['include_categories'] = $category;
423			} else {
424				$props['include_categories'] = $include_categories;
425			}
426
427			$wrapper.fadeTo( '100', 0.2 );
428			$.ajax( {
429				type : 'POST',  
430				url  : DGEObj.ajaxUrl,
431				data : {
432					action: 'dge_dynamic_gallery_load_content', 
433					_wpnonce: $ajaxNonce,
434					props: $props
435				},
436				success: function(response) {
437					if ( response.success ) {
438						let $elements = $( response?.data?.items );
439						$wrapper.find( '.el_masonry_gallery_item' ).remove();
440						$dynamicMasonryGallery.append( $elements ).isotope( 'appended', $elements );
441						if ( '' !== $category ) {
442							$dynamicMasonryGallery.isotope( {
443								filter: function() {
444									if ( $(this).find('img').data('categories') ) {
445										let $imageCats = $(this).find('img').attr('data-categories').split(',');
446										$imageCats = $.map( $imageCats, function( a ) {
447											return parseInt(a);
448										} );
449										if ( -1 !== $.inArray( $category, $imageCats ) ) {
450											return $(this);
451										}
452									}
453								}
454							} );
455						} else {
456							$dynamicMasonryGallery.isotope( { filter: '*' } );
457						}
458						$wrapper.fadeTo( '100', 1 );
459					}
460				}
461			} );
462		} );
463	}
464
465	// Lightbox.
466	if ( 'on' === $wrapper.data('click_trigger') || 'lightbox' === $wrapper.data('click_trigger') || 'zoom_n_link' === $wrapper.data('click_trigger') ) {
467		let $orderClass = $thisObj.prop('class').match(/(el_dynamic_masonry_gallery\_[^\s]*)/)[0] + '_lightbox',
468			$effect     = $wrapper.data('lightbox_effect'),
469			$zoom       = 'zoom' === $effect ? true : false,
470			$duration   = 'none' !== $effect ? parseInt( $wrapper.data('lightbox_transition_duration') ) : 0,
471			$navigation = 'on' === $wrapper.data('enable_navigation') ? true : false,
472			$mainClass  = 'mfp-img-mobile dge_dynamic_masonry_gallery_lightbox ' + $orderClass + ' dipl_mfp_' + $effect,
473			$prependTo  = $( 'body' );
474
475		if ( $('body').hasClass('et-tb-has-template') ) {
476			if ( $orderClass.includes('_tb_header') ) {
477				$prependTo = $('body').find('#page-container').find('#et-boc .et-l--header');
478			} else if ( $orderClass.includes('_tb_body') ) {
479				$prependTo = $('body').find('#page-container').find('#et-boc .et-l--body');  
480			} else if ( $orderClass.includes('_tb_footer') ) {
481				$prependTo = $('body').find('#page-container').find('#et-boc .et-l--footer');
482			}
483		}
484
485		let clickDeligate = '.el_masonry_gallery_item';
486		if ( 'zoom_n_link' === $wrapper.data('click_trigger') ) {
487			clickDeligate = '.dge-overlay-lightbox';
488		}
489
490		$inner.on( 'click', '.el_masonry_gallery_item', function(e) {
491			e.stopPropagation();
492		} );
493
494		$inner.magnificPopup( {
495			delegate: clickDeligate,
496			type: 'image',
497			prependTo: $prependTo,
498			closeOnContentClick: false,
499			removalDelay: $duration,
500			closeBtnInside: false,
501			mainClass: $mainClass,
502			gallery: {
503				enabled: $navigation,
504				navigateByImgClick: false,
505				tPrev: '',
506				tNext: '',
507				tCounter: ''
508			},
509			zoom: {
510				enabled: $zoom,
511				duration: $duration,
512				easing: 'ease-in-out',
513				opener: function(element) {
514					return element;
515				}
516			},
517			image: {
518				markup: '<div class="mfp-figure">' +
519							'<div class="mfp-close"></div>' +
520							'<div class="mfp-img"></div>' +
521							'<div class="mfp-bottom-bar">' +
522								'<div class="mfp-title"></div>' +
523							'</div>' +
524						'</div>',
525				titleSrc: function(item) {
526					if ( 'zoom_n_link' === $wrapper.data('click_trigger') ) {
527						return item.el.parents( '.el_masonry_gallery_item' ).find( '.el_masonry_gallery_title_caption_wrapper' ).length > 0 ? item.el.parents( '.el_masonry_gallery_item' ).find( '.el_masonry_gallery_title_caption_wrapper' ).html() : '';
528					}
529					return item.el.find('.el_masonry_gallery_title_caption_wrapper').length > 0 ? item.el.find('.el_masonry_gallery_title_caption_wrapper').html() : '';
530				},
531				tError: '<a href="%url%">The image</a> could not be loaded.',
532			}
533		} );
534
535		let $magnificPopup = $.magnificPopup.instance;
536		$magnificPopup.open = function(data) {
537			if ( '.el_masonry_gallery_item' === data.delegate ) {
538				let $items = [];
539				$.each( data.items, function( key, value ) {
540					if ( $(value).is(':visible') && 0 !== parseFloat( $(value).css('opacity') ) ) {
541						$items.push(value);
542					}
543				} );
544				data.items = $( $items );
545			}
546			$.magnificPopup.proto.open.call( this, data );
547		};
548
549		$('body').on( 'swiperight', '.el_masonry_gallery_lightbox .mfp-img', function() {
550			$magnificPopup.prev();
551		} );
552		$('body').on( 'swipeleft', '.el_masonry_gallery_lightbox .mfp-img', function() {
553			$magnificPopup.next();
554		} );
555	}
556}

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.