PageSourceSearch

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

js tifviking.no collected 2026-09-24 10:03:51 UTC 7,370 bytes, 234 lines download raw bytes

1(function($)
2{ 
3	"use strict";
4	
5	// -------------------------------------------------------------------------------------------
6	// Tab Section
7	// -------------------------------------------------------------------------------------------
8	
9	$.fn.avia_sc_tab_section= function()
10	{
11		var win 			= $(window),
12			browserPrefix 	= $.avia_utilities.supports('transition'),
13			cssActive 		= this.browserPrefix !== false ? true : false,
14			isMobile 		= $.avia_utilities.isMobile,
15			transform3d		= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false,
16			transition		= {};
17			
18		return this.each(function()
19		{
20			var container 		= $(this),
21				tabs			= container.find('.av-section-tab-title'),
22			    	tab_outer		= container.find('.av-tab-section-outer-container'),
23				tab_wrap		= container.find('.av-tab-section-tab-title-container'),
24				tab_nav			= container.find('.av_tab_navigation'), 
25				content_wrap	= container.find('.av-tab-section-inner-container'),
26				single_tabs		= container.find('.av-animation-delay-container'), //for elements inside the tab that receive waypoint animation
27				inner_content	= container.find('.av-layout-tab-inner'),
28				sliding_active  = container.is('.av-tab-slide-transition'),
29				flexible    	= container.is('.av-tab-content-auto'),
30				current_content = container.find('.__av_init_open'),
31				min_width		= 0,
32				change_tab 		= function(e, prevent_hash)
33				{
34					e.preventDefault();
35					
36					var current_tab 	= $(e.currentTarget),
37						current_arrow	= current_tab.find('.av-tab-arrow-container span'),
38						tab_nr			= current_tab.data('av-tab-section-title');
39					
40					//	reset global scope !!
41					current_content = container.find('[data-av-tab-section-content="'+tab_nr+'"]');
42					
43					var new_bg			= current_content.data('av-tab-bg-color'),
44						new_font		= current_content.data('av-tab-color'),
45						prev_container 	= container.find('.av-active-tab-content').not('[data-av-tab-section-content="'+tab_nr+'"]');
46	
47					tabs.attr('style','').removeClass('av-active-tab-title');
48					current_tab.removeClass('no-scroll');
49					current_tab.addClass('av-active-tab-title');
50					current_content.addClass("av-active-tab-content");
51					
52					if( new_bg !== "" ) 
53					{
54						current_arrow.css('background-color', new_bg);
55					}
56					
57					if( new_font !== "" ) 
58					{
59						current_tab.css('color', new_font);
60					}
61						
62					var new_pos = ( (parseInt( tab_nr,10 ) - 1 ) * -100 );
63					    
64					if( $('body').hasClass('rtl') ) 
65					{
66						new_pos = ( ( parseInt( tab_nr,10 ) - 1 ) * 100 );
67					}
68					
69					if( cssActive )
70					{
71						//move the slides
72						new_pos = new_pos / tabs.length;
73						transition['transform']  = transform3d ? "translate3d(" + new_pos  + "%, 0, 0)" : "translate(" + new_pos + "%,0)"; //3d or 2d transform?
74						transition['left'] = "0%";
75						content_wrap.css(transition);
76					}
77					else
78					{
79						content_wrap.css('left',  new_pos + "%");
80					}
81					
82					set_tab_titlte_pos();
83					set_slide_height();
84					
85					if( ! prevent_hash ) 
86					{
87						location.hash = current_tab.attr('href');
88					}
89					
90					setTimeout(function()
91					{
92						current_content.trigger('avia_start_animation_if_current_slide_is_active');
93						single_tabs.not(current_content).trigger('avia_remove_animation');
94						
95					}, 600);	
96					
97				},
98				set_min_width = function()
99				{
100					min_width = 0;
101					tabs.each(function()
102					{ 
103						min_width += $(this).outerWidth(); 
104					});
105					
106					tab_wrap.css('min-width',min_width);
107				},
108				
109				set_slide_height = function()
110				{				
111					if(current_content.length && flexible)
112					{
113						var old_height = inner_content.height();
114						inner_content.height('auto');
115						
116						var height = current_content.find('.av-layout-tab-inner').height(),
117						    add_height = tab_wrap.height();
118						
119						tab_outer.css('max-height', height + add_height + 100);
120						inner_content.height(old_height);
121						inner_content.height(height);
122						
123						inner_content.css( 'overflow', 'hidden' );
124						
125						setTimeout(function() { win.trigger('av-height-change'); }, 600);
126					}
127				},
128				
129				set_tab_titlte_pos = function()
130				{
131					//	scroll the tabs if there is not enough room to display them all - rtl allign right to left !!
132					var current_tab = container.find('.av-active-tab-title'),
133						viewport	= container.width(),
134						left_pos	= ( current_tab.position().left * - 1) - (current_tab.outerWidth() / 2) + (viewport / 2);
135				
136					if( ! $('body').hasClass("rtl") )
137					{
138						if( viewport >= min_width )
139						{
140							left_pos = 0;
141						}
142						
143						if(left_pos + min_width < viewport) left_pos = (min_width - viewport) * -1;
144						if(left_pos > 0) left_pos = 0;
145					
146						tab_wrap.css('left',left_pos );
147					}
148					else
149					{
150						var right_pos = 0;
151						
152						if( viewport < min_width )
153						{
154							if( left_pos + min_width > viewport )
155							{
156								if( left_pos > 0 ) left_pos = 0;
157								
158								var right_pos = (left_pos + min_width - viewport) * -1;
159								tab_wrap.css('left', 'auto' );
160								tab_wrap.css('right', right_pos );
161							}
162						}
163						tab_wrap.css('left', 'auto' );
164						tab_wrap.css('right', right_pos );
165					}
166				},
167				switch_to_next_prev = function(e)
168				{
169					if(!isMobile) return;
170					
171					var clicked 		= $(e.currentTarget),
172						current_tab 	= container.find('.av-active-tab-title');
173						
174						if(clicked.is('.av_prev_tab_section'))
175						{
176							current_tab.prev('.av-section-tab-title').trigger('click');
177						}
178						else
179						{
180							current_tab.next('.av-section-tab-title').trigger('click');
181						}
182				},
183				
184				get_init_open = function()
185				{
186					if(!hash && window.location.hash) var hash = window.location.hash;
187		            		
188					var open = tabs.filter('[href="'+hash+'"]');
189					
190					if(open.length)
191					{
192						if(!open.is('.active_tab')) open.trigger('click');
193					}
194					else
195					{
196						//set correct color
197						container.find('.av-active-tab-title').trigger('click', true);
198					}
199				};
200					
201			$.avia_utilities.preload({
202				
203				container: current_content , 
204				single_callback:  function(){ 
205				
206					tabs.on('click', change_tab);
207					tab_nav.on('click', switch_to_next_prev);
208					win.on('debouncedresize', set_tab_titlte_pos);	
209					
210					/**
211					 * We had to remove av-height-change because this event is recursivly triggered in set_slide_height and lead to performance problems 
212					 * AND broken layout - content was not displayed completly
213					 * 
214					 * Content elements that can can change their height and trigger av-height-change should trigger this additional event after to
215					 * allow layout elements like tab section to react on this and then call av-height-change by themself
216					 * 
217					 * @since 4.2.3
218					 */
219					win.on('debouncedresize av-content-el-height-changed', set_slide_height);	
220					
221					set_min_width();
222					set_slide_height(); 
223					get_init_open();
224				}
225				
226			});	
227			
228			content_wrap.avia_swipe_trigger({prev:'.av_prev_tab_section', next:'.av_next_tab_section'});
229				
230		});
231	};
232	
233	
234}(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.