PageSourceSearch

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

js tifviking.no collected 2026-09-24 10:03:48 UTC 8,442 bytes, 275 lines download raw bytes

1(function($)
2{
3	"use strict";
4// -------------------------------------------------------------------------------------------
5// Aviaccordion Slideshow 
6// 
7// accordion slider script
8// -------------------------------------------------------------------------------------------
9
10	$.AviaccordionSlider  =  function(options, slider)
11	{
12	    this.$slider  	= $( slider );
13	    this.$inner	  	= this.$slider.find('.aviaccordion-inner');
14	    this.$slides	= this.$inner.find('.aviaccordion-slide');
15	    this.$images	= this.$inner.find('.aviaccordion-image');
16	    this.$last		= this.$slides.filter(':last');
17	    this.$titles  	= this.$slider.find('.aviaccordion-preview');
18	    this.$titlePos  = this.$slider.find('.aviaccordion-preview-title-pos');
19	    this.$titleWrap = this.$slider.find('.aviaccordion-preview-title-wrap');
20	    this.$win	  	= $( window );
21	    
22	    if($.avia_utilities.supported.transition === undefined)
23		{
24			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
25		}
26		
27		this.browserPrefix 	= $.avia_utilities.supported.transition;
28	    this.cssActive 		= this.browserPrefix !== false ? true : false;
29	    this.transform3d	= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
30		this.isMobile 		= $.avia_utilities.isMobile;
31		this.property		= this.browserPrefix + 'transform',
32		this.count			= this.$slides.length;
33		this.open			= false;
34		this.autoplay		= false;
35		this.increaseTitle  = this.$slider.is(".aviaccordion-title-on-hover");
36		// this.cssActive    = false; //testing no css3 browser
37		
38	    this._init( options );
39	}
40
41  	$.AviaccordionSlider.prototype =
42    {
43    	_init: function( options )
44    	{
45    		var _self = this;
46    		_self.options = $.extend({}, options, this.$slider.data());
47			 $.avia_utilities.preload({container: this.$slider , single_c
47allback:  function(){ _self._kickOff(); }});
48    	},
49    	
50    	_kickOff: function()
51    	{
52    		var _self = this;
53    		
54    		_self._calcMovement();
55    		_self._bindEvents();
56    		_self._showImages();
57    		_self._autoplay();
58    	},
59    	
60    	_autoplay: function()
61    	{
62    		var _self = this;
63    		
64    		if(_self.options.autoplay)
65    		{
66    			_self.autoplay = setInterval(function()
67    			{
68    				_self.open = _self.open === false ? 0 : _self.open + 1;
69    				if(_self.open >= _self.count) _self.open = 0;
70    				_self._move({}, _self.open);
71    				
72    			}, _self.options.interval * 1000)
73    		}
74    	},
75    	
76    	_showImages: function()
77    	{
78    		var _self = this, counter = 0, delay = 300, title_delay = this.count * delay;
79    		
80    		if(this.cssActive)
81    		{
82    			setTimeout(function(){ _self.$slider.addClass('av-animation-active'); } , 10);
83    		}
84    		
85    		this.$images.each(function(i)
86    		{
87    			var current = $(this), timer = delay * (i + 1);
88    				
89    			setTimeout(function()
90    			{ 
91    				current.avia_animate({opacity:1}, 400, function()
92    				{
93    					current.css($.avia_utilities.supported.transition + "transform", "none");
94    				}); 
95    			},timer);
96    		});
97    		
98    		if(_self.increaseTitle) title_delay = 0;
99    		
100    		this.$titlePos.each(function(i)
101    		{
102    			var current = $(this), new_timer = title_delay + 100 * (i + 1);
103    					
104    			setTimeout(function()
105    			{ 
106    				current.avia_animate({opacity:1}, 200, function()
107    				{
108    					current.css($.avia_utilities.supported.transition + "transform", "none");
109    				}); 
110    			},new_timer);
111    		});
112    	},
113    	
114    	_bindEvents: function()
115    	{
116    		var trigger = this.isMobile ? "click" : "mouseenter";
117    	
118    		this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this));
119    		this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this));
120    		this.$win.on('debouncedresize', $.proxy( this._calcMovement, this));
121    		this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this));
122    		
123    		if(this.isMobile)
124    		{
125    			this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}});
126    		}
127    		
128    	},
129    	
130    	_titleHeight: function()
131    	{
132    		var th = 0;
133    		
134    		this.$titleWrap.css({'height':'auto'}).each(function()
135    		{
136    			var new_h = $(this).outerHeight();
137    			if( new_h > th) th = new_h;
138    		
139    		}).css({'height':th + 2});
140    		
141    	},
142    	
143    	_calcMovement: function(event, allow_repeat)
144    	{ 
145    		var _self			= this,
146    			containerWidth	= this.$slider.width(),
147    			defaultPos		= this.$last.data('av-left'),
148    			imgWidth		= this.$images.filter(':last').width() || containerWidth,
149    			imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth),
150    			allImageWidth	= imgWidthPercent * _self.count,
151    			modifier		= 3, // 10 - _self.count,
152    			tempMinLeft		= 100 - imgWidthPercent,
153    			minLeft 		= tempMinLeft > defaultPos / modifier ? tempMinLeft : 0,
154    			oneLeft			= minLeft / (_self.count -1 ),
155    			titleWidth		= imgWidth;
156    		
157    		
158    		
159    		if(allImageWidth < 110 && allow_repeat !== false)
160    		{
161    			//set height if necessary	
162    			var slideHeight = this.$slider.height(), 
163    				maxHeight 	= (slideHeight / allImageWidth) * 110 ;
164    			
165    			this.$slider.css({'max-height': maxHeight});
166    			_self._calcMovement(event, false);
167    			return;
168    		}
169    		
170    		//backup so the minimized slides dont get too small
171    		if(oneLeft < 2) minLeft = 0;
172    		
173			this.$slides.each(function(i)
174			{
175				var current = $(this), newLeft = 0, newRight = 0, defaultLeft = current.data('av-left');
176					
177				if( minLeft !== 0)
178				{
179					newLeft  = oneLeft * i;
180					newRight = imgWidthPercent + newLeft - oneLeft;
181				}
182				else
183				{
184					newLeft  = defaultLeft / Math.abs(modifier);
185					newRight = 100 - ((newLeft / i) * (_self.count - i));
186				}
187				
188				if(i == 1 && _self.increaseTitle) { titleWidth = newRight + 1; } 
189				
190				if(_self.cssActive)
191				{	
192					//if we are not animating based on the css left value but on css transform we need to subtract the left value
193					newLeft = newLeft - defaultLeft;
194					newRight = newRight - defaultLeft;
195					defaultLeft = 0;
196				}
197				
198				current.data('av-calc-default', defaultLeft);
199				current.data('av-calc-left', newLeft);
200				current.data('av-calc-right', newRight);
201				
202			});
203			
204			if(_self.increaseTitle) { _self.$titles.css({width: titleWidth + "%"});} 
205    	},
206    	
207    	_moveTo: function(event)
208    	{
209    		var direction 	= event.type == "av-next" ? 1 : -1,
210    			nextSlide 	= this.open === false ? 0 : this.open + direction;
211    			
212    		if(nextSlide >= 0 && nextSlide < this.$slides.length) this._move(event, nextSlide);
213    	},
214    	
215    	_move: function(event, direct_open)
216    	{
217    		var _self  = this,
218    			slide  = event.currentTarget,
219    			itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide);
220    			
221    		this.open = itemNo;
222    		
223    		if(_self.autoplay && typeof slide != "undefined") { clearInterval(_self.autoplay); _self.autoplay = false; }
224    		
225    		this.$slides.removeClass('aviaccordion-active-slide').each(function(i)
226    		{
227    			var current 	= $(this),
228    				dataSet 	= current.data(),
229    				trans_val	= i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight,
230					transition 	= {},
231					reset		= event.type == 'mouseleave' ? 1 : 0,
232					active 		= itemNo === i ? _self.$titleWrap.eq(i) : false;
233    			
234    			if(active) current.addClass('aviaccordion-active-slide');
235    				
236    			if(reset)
237    			{
238    				trans_val = dataSet.avCalcDefault; 
239    				this.open = false;
240    			}
241    				
242				if(_self.cssActive) //do a css3 animation
243				{
244					//move the slides
245					transition[_self.property]  = _self.transform3d ? "translate3d(" + trans_val  + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform?
246					current.css(transition);
247				}
248				else
249				{
250					transition.left =  trans_val + "%";
251					current.stop().animate(transition, 700, 'easeOutQuint');
252				}	
253    		});
254    	}
255    };
256
257
258$.fn.aviaccordion = function( options )
259{
260	return this.each(function()
261	{
262		var active = $.data( this, 'AviaccordionSlider' );
263
264		if(!active)
265		{
266			//make sure that the function doesnt get aplied a second time
267			$.data( this, 'AviaccordionSlider', 1 );
268			
269			//create the preparations for fullscreen slider
270			new $.AviaccordionSlider( options, this );
271		}
272	});
273}
274
275})(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.