PageSourceSearch

https://extension.org/wp-content/themes/enfold/config-templatebuil…/portfolio/portfolio.js?ver=5.7

js extension.org collected 2026-09-24 08:26:35 UTC 11,266 bytes, 386 lines download raw bytes

1// -------------------------------------------------------------------------------------------
2// Avia AJAX Portfolio
3// -------------------------------------------------------------------------------------------
4
5(function($)
6{
7	"use strict";
8	$.avia_utilities = $.avia_utilities || {};
9
10
11	// -------------------------------------------------------------------------------------------
12	//Portfolio sorting
13	// -------------------------------------------------------------------------------------------
14
15    $.fn.avia_iso_sort = function(options)
16	{
17		return this.each(function()
18		{
19			var the_body		= $('body'),
20				container		= $(this),
21				portfolio_id	= container.data('portfolio-id'),
22				parentContainer	= container.closest('.av-portfolio-grid-sorting-container, .entry-content-wrapper, .avia-fullwidth-portfolio'),
23				filter			= parentContainer.find('.sort_width_container[data-portfolio-id="' + portfolio_id + '"]').find('#js_sort_items').css({visibility:"visible", opacity:0}),
24				links			= filter.find('a'),
25				imgParent		= container.find('.grid-image'),
26				isoActive		= false,
27				items			= $('.post-entry', container),
28				is_originLeft	= the_body.hasClass('rtl') ? false : true;
29
30			function applyIso()
31			{
32				container.addClass('isotope_activated').isotope({
33					layoutMode : 'fitRows', itemSelector : '.flex_column', originLeft: is_originLeft
34				});
35
36				container.isotope( 'on', 'layoutComplete', function()
37				{
38					container.css({overflow:'visible'});
39					the_body.trigger('av_resize_finished');
40				});
41
42				isoActive = true;
43				setTimeout(function(){ parentContainer.addClass('avia_sortable_active'); }, 0);
44			};
45
46			links.on('click',function()
47			{
48				var current		= $(this),
49			  		selector	= current.data('filter'),
50			  		linktext	= current.html(),
51			  		activeCat	= parentContainer.find('.av-current-sort-title');
52
53			  		if(activeCat.length) activeCat.html(linktext);
54
55					links.removeClass('active_sort');
56					current.addClass('active_sort');
57					container.attr('id', 'grid_id_'+selector);
58
59					parentContainer.find('.open_container .ajax_controlls .avia_close').trigger('click');
60					//container.css({overflow:'hidden'})
61					container.isotope({ layoutMode : 'fitRows', itemSelector : '.flex_column' , filter: '.'+selector, originLeft: is_originLeft });
62
63					return false;
64			});
65
66			// update columnWidth on window resize
67			$(window).on( 'debouncedresize', function()
68			{
69			  	applyIso();
70			});
71
72			$.avia_utilities.preload({container: container, single_callback:  function()
73				{
74					filter.animate({opacity:1}, 400); applyIso();
75
76					//call a second time to for the initial resizing
77					setTimeout(function(){ applyIso(); });
78
79					imgParent.css({height:'auto'}).each(function(i)
80					{
81						var currentLink = $(this);
82
83						setTimeout(function()
84						{
85							currentLink.animate({opacity:1},1500);
86						}, (100 * i));
87					});
88				}
89			});
90
91		});
92	};
93
94
95
96
97
98	$.fn.avia_portfolio_preview = function(passed_options)
99	{
100		var win  = $(window),
101		the_body = $('body'),
102		isMobile = $.avia_utilities.isMobile,
103		defaults =
104		{
105			open_in:	'.portfolio-details-inner',
106			easing:		'easeOutQuint',
107			timing:		800,
108			transition:	'slide' // 'fade' or 'slide'
109		},
110
111		options = $.extend({}, defaults, passed_options);
112
113		return this.each(function()
114		{
115			var container			= $(this),
116				portfolio_id		= container.data('portfolio-id'),
117				target_wrap			= $('.portfolio_preview_container[data-portfolio-id="' + portfolio_id + '"]'),
118				target_container	= target_wrap.find(options.open_in),
119				items				= container.find('.grid-entry'),
120				content_retrieved	= {},
121				is_open				= false,
122				animating			= false,
123				index_open			= false,
124				ajax_call			= false,
125				methods,
126				controls,
127				loader				= $.avia_utilities.loading();
128
129			methods =
130			{
131				load_item: function(e)
132				{
133					e.preventDefault();
134
135					var link			= $(this),
136						post_container	= link.parents('.post-entry').eq( 0 ),
137						post_id			= "ID_" + post_container.data('ajax-id'),
138						clickedIndex	= items.index(post_container);
139
140					//check if current item is the clicked item or if we are currently animating
141					if(post_id === is_open || animating == true)
142					{
143						return false;
144					}
145
146					animating = true;
147
148					container.find('.active_portfolio_item').removeClass('active_portfolio_item');
149					post_container.addClass('active_portfolio_item');
150					loader.show();
151
152					methods.ajax_get_contents(post_id, clickedIndex);
153				},
154
155				scroll_top: function()
156				{
157					setTimeout(function()
158					{
159						var target_offset = target_wrap.offset().top - 175,
160							window_offset = win.scrollTop();
161
162						if(window_offset > target_offset || target_offset - window_offset > 100  )
163						{
164							$('html:not(:animated),body:not(:animated)').animate({ scrollTop: target_offset }, options.timing, options.easing);
165						}
166					},10);
167				},
168
169				attach_item: function(post_id)
170				{
171					content_retrieved[post_id] = $(content_retrieved[post_id]).appendTo(target_container);
172					ajax_call = true;
173				},
174
175				remove_video: function()
176				{
177					var del = target_wrap.find('iframe, .avia-video').parents('.ajax_slide:not(.open_slide)');
178
179						if(del.length > 0)
180						{
181							del.remove();
182							content_retrieved["ID_" + del.data('slideId')] = undefined;
183						}
184				},
185
186				show_item: function(post_id, clickedIndex)
187				{
188
189					//check if current item is the clicked item or if we are currently animating
190					if(post_id === is_open)
191					{
192						return false;
193					}
194					animating = true;
195
196
197					loader.hide();
198
199					if(false === is_open)
200					{
201						target_wrap.addClass('open_container');
202						content_retrieved[post_id].addClass('open_slide');
203
204						methods.scroll_top();
205
206						target_wrap.css({display:'none'}).slideDown(options.timing, options.easing, function()
207						{
208							if(ajax_call)
209							{
210								$.avia_utilities.activate_shortcode_scripts(content_retrieved[post_id]);
211								$.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
212								the_body.trigger('av_resize_finished');
213								ajax_call = false;
214							}
215
216							methods.remove_video();
217							the_body.trigger('av_resize_finished');
218						});
219
220							index_open	= clickedIndex;
221							is_open		= post_id;
222							animating	= false;
223
224
225
226					}
227					else
228					{
229						methods.scroll_top();
230
231						var initCSS = { zIndex:3 },
232							easing	= options.easing;
233
234						if(index_open > clickedIndex) { initCSS.left = '-110%'; }
235						if(options.transition === 'fade'){ initCSS.left = '0%'; initCSS.opacity = 0; easing = 'easeOutQuad'; }
236
237						//fixate height for container during animation
238						target_container.height(target_container.height()); //outerHeight = border problems?
239
240						content_retrieved[post_id].css(initCSS).avia_animate({'left':"0%", opacity:1}, options.timing, easing);
241						content_retrieved[is_open].avia_animate({opacity:0}
241, options.timing, easing, function()
242						{
243							content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
244							content_retrieved[post_id].addClass('open_slide');
245																										  //+ 2 fixes border problem (slides move up and down 2 px on transition)
246							target_container.avia_animate({height: content_retrieved[post_id].outerHeight() + 2}, options.timing/2, options.easing, function()
247							{
248								target_container.attr({'style':""});
249								is_open		= post_id;
250								index_open	= clickedIndex;
251								animating	= false;
252
253								methods.remove_video();
254								if(ajax_call)
255								{
256									the_body.trigger('av_resize_finished');
257									$.avia_utilities.activate_shortcode_scripts(content_retrieved[post_id]);
258									$.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
259									ajax_call = false;
260								}
261
262							});
263
264						});
265					}
266				},
267
268				ajax_get_contents: function(post_id, clickedIndex)
269				{
270					if(content_retrieved[post_id] !== undefined)
271					{
272						methods.show_item(post_id, clickedIndex);
273						return;
274					}
275
276					/**
277					 * Possible fix for complex pages that throw a js error when user clicks item and not fully loaded
278					 */
279					var template = $('#avia-tmpl-portfolio-preview-' + post_id.replace(/ID_/,""));
280					if( template.length == 0 )
281					{
282						setTimeout( function(){ methods.ajax_get_contents( post_id, clickedIndex); return; }, 500);
283					}
284
285					content_retrieved[post_id] = template.html();
286
287					//this line is necessary to prevent w3 total cache from messing up the portfolio if inline js is compressed
288					content_retrieved[post_id] = content_retrieved[post_id].replace('/*<![CDATA[*/','').replace('*]]>','');
289
290					methods.attach_item(post_id);
291
292					$.avia_utilities.preload({container: content_retrieved[post_id] , single_callback:  function(){ methods.show_item(post_id, clickedIndex); }});
293				},
294
295				add_controls: function()
296				{
297					controls = target_wrap.find('.ajax_controlls');
298
299					target_wrap.avia_keyboard_controls({27:'.avia_close', 37:'.ajax_previous', 39:'.ajax_next'});
300					//target_wrap.avia_swipe_trigger({prev:'.ajax_previous', next:'.ajax_next'});
301
302					items.each(function(){
303
304						var current = $(this), overlay;
305
306						current.addClass('no_combo').on('click', function(event)
307						{
308							overlay = current.find('.slideshow_overlay');
309
310							if(overlay.length)
311							{
312								event.stopPropagation();
313								methods.load_item.apply(current.find('a').eq( 0 ));
314								return false;
315							}
316						});
317
318
319					});
320				},
321
322				control_click: function()
323				{
324					var showItem,
325						activeID = container.find('.active_portfolio_item').data('ajax-id'),
326						active   = container.find('.post-entry-'+activeID);
327
328					switch(this.hash)
329					{
330						case '#next':
331
332							showItem = active.nextAll('.post-entry:visible').eq( 0 ).find('a').eq( 0 );
333							if(!showItem.length) { showItem = $('.post-entry:visible', container).eq( 0 ).find('a').eq( 0 ); }
334							showItem.trigger('click');
335
336						break;
337						case '#prev':
338
339							showItem = active.prevAll('.post-entry:visible').eq( 0 ).find('a').eq( 0 );
340							if(!showItem.length) { showItem = $('.post-entry:visible', container).last().find('a').eq( 0 ); }
341							showItem.trigger('click');
342
343						break;
344						case '#close':
345
346							animating = true;
347
348							target_wrap.slideUp( options.timing, options.easing, function()
349							{
350								container.find('.active_portfolio_item').removeClass('active_portfolio_item');
351								content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
352								target_wrap.removeClass('open_container');
353								animating = is_open = index_open = false;
354								methods.remove_video();
355								the_body.trigger('av_resize_finished');
356							});
357
358						break;
359					}
360					return false;
361				},
362
363				resize_reset: function()
364				{
365					if(is_open === false)
366					{
367						target_container.html('');
368						content_retrieved = [];
369					}
370				}
371			};
372
373			methods.add_controls();
374
375			container.on("click", "a", methods.load_item);
376			controls.on("click", "a", methods.control_click);
377
378			//	removed in 4.8 as jQuery.support was deprecated with 2.0 and returns "undefined"/false
379//			if(jQuery.support.leadingWhitespace) { win.on('debouncedresize', methods.resize_reset); }
380			win.on('debouncedresize', methods.resize_reset);
381
382		});
383	};
384}(jQuery));
385
386

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.