PageSourceSearch

https://www.starandgarterhotel.co.uk/wp-content/themes/enfold/conf…/tab_section/tab_section.js?ver=6.1.1

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