PageSourceSearch

https://www.tifviking.no/wp-content/themes/enfold/config-templateb…/gallery_horizontal.js?ver=7.1.2

js tifviking.no collected 2026-09-24 10:03:34 UTC 5,081 bytes, 176 lines download raw bytes

1// -------------------------------------------------------------------------------------------
2// Horizontal Gallery
3// -------------------------------------------------------------------------------------------
4
5(function($)
6{ 
7	"use strict";
8
9	$.fn.avia_hor_gallery= function(options)
10	{
11		var defaults =
12			{
13				slide_container	: '.av-horizontal-gallery-inner', //element with max width
14				slide_element	: '.av-horizontal-gallery-slider', //element that gets moved
15				slide_content	: '.av-horizontal-gallery-wrap',
16				active			: 'av-active-gal-item',				// must be a class string without the . in front
17				prev			: '.av-horizontal-gallery-prev',
18				next			: '.av-horizontal-gallery-next'
19			};
20	
21		var options = $.extend(defaults, options);
22		
23		var win 			= $(window),
24			browserPrefix 	= $.avia_utilities.supports('transition'),
25			cssActive 		= this.browserPrefix !== false ? true : false,
26			isMobile 		= $.avia_utilities.isMobile,
27			transform3d		= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false,
28			transition		= {};
29			
30		return this.each(function()
31		{
32			var container 			= $(this),
33				slide_container 	= container.find(options.slide_container),
34				slide_element		= container.find(options.slide_element),
35				slide_content		= container.find(options.slide_content),
36				prev				= container.find(options.prev),
37				next				= container.find(options.next),
38				imgs				= container.find('img'),
39				
40				all_elements_width 	= 0,
41				currentIndex		= false,
42				initial				= container.data('av-initial'),
43				
44				set_up = function( init )
45				{
46					var sl_height = (slide_container.width() / 100 ) * slide_container.data('av-height');
47					
48					slide_container.css({'padding':0}).height(sl_height);
49					
50					//fixes img distortion when resizing browser:
51					imgs.css('display','inline-block');
52					setTimeout(function(){ imgs.css('display','block'); }, 10);
53					
54					//calculate the slidelement width based on the elements inside
55					all_elements_width = 0;
56					
57					slide_content.each(function()
58					{ 
59						all_elements_width += $(this).outerWidth( true ); 
60					});
61					
62					slide_element.css( 'min-width' , all_elements_width );
63					
64					if(currentIndex !== false )
65					{
66						change_active(currentIndex);
67					}
68				},
69				change_active = function(index)
70				{
71					//scroll the tabs if there is not enough room to display them all
72					var current 	= slide_element.find(options.slide_content).eq(index),
73						viewport	= slide_container.width(),
74						modifier	= container.data('av-enlarge') > 1  && currentIndex == index ? container.data('av-enlarge') : 1,
75						outerWidth	= current.outerWidth( true ) * modifier,
76						margin_right= parseInt( current.css('margin-right') , 10 ) / 2,
77						left_pos	= viewport < all_elements_width ? (current.position().left * - 1) - (outerWidth / 2) + (viewport / 2): 0;
78					
79					//center properly
80					left_pos = left_pos + margin_right;
81					
82					//out of bounce right side
83					if(left_pos + all_elements_width < viewport) left_pos = (all_elements_width - viewport - parseInt(current.css('margin-right'),10) ) * -1;
84					
85					//out of bounce left side
86					if(left_pos > 0) left_pos = 0;
87					
88					//set pos
89					slide_element.css('left',left_pos );
90					
91					slide_container.find("." +options.active).removeClass(options.active);
92					current.addClass(options.active);
93					currentIndex = index;
94					
95				};
96	
97				
98			 $.avia_utilities.preload({container: container , global_callback:  function()
99			 {
100				 // activate behavior
101				set_up( 'init' );
102				win.on('debouncedresize', set_up);
103				if(initial) change_active(initial - 1);
104				
105				setTimeout(function(){
106					container.addClass('av-horizontal-gallery-animated');
107				},10); 
108			
109			  }});
110				
111			
112			
113			
114			
115			
116			
117			//swipe on mobile
118			slide_element.avia_swipe_trigger({prev:options.prev, next:options.next});
119			
120			//element click
121			slide_content.on('click', function(e)
122			{
123				var current = $(this);
124				var index = slide_content.index(current);
125				
126				if(currentIndex === index)
127				{
128					if(container.data('av-enlarge') > 1 && !$(e.target).is('a') )
129					{
130						//slide_container.find("." +options.active).removeClass(options.active);
131						//currentIndex = false;	
132					}
133					return;
134				}
135				
136				change_active(index);
137			});
138			
139			prev.on('click', function(e)
140			{
141				if(currentIndex === false) currentIndex = 1;
142				var index = currentIndex - 1;
143				if(index < 0) index = 0;
144				
145				change_active(index);
146			});
147			
148			next.on('click', function(e)
149			{
150				if(currentIndex === false) currentIndex = -1;
151				var index = currentIndex + 1;
152				if(index > slide_content.length - 1) index = slide_content.length - 1;
153				
154				change_active(index);
155			});
156			
157			//if its a desktop browser add arrow navigation, otherwise add touch nav
158			if(!isMobile)
159			{
160				container.avia_keyboard_controls({ 37: options.prev, 39: options.next });
161			}
162			else
163			{
164				container.avia_swipe_trigger({next: options.next, prev: options.prev});
165			}
166			
167			
168		
169		});
170	};
171
172
173	
174}(jQuery));
175
176

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.