PageSourceSearch

https://jamespublishing.com/wp-content/themes/enfold/config-templa…/slideshow_accordion.js?ver=7.1.2

js jamespublishing.com collected 2026-09-25 04:32:00 UTC 8,312 bytes, 308 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.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,
79				counter = 0,
80				delay = 300,
81				title_delay = this.count * delay;
82
83    		if(this.cssActive)
84    		{
85    			setTimeout(function(){ _self.$slider.addClass('av-animation-active'); }, 10);
86    		}
87
88    		this.$images.each(function(i)
89    		{
90    			var current = $(this),
91					timer = delay * (i + 1);
92
93    			setTimeout(function()
94    			{
95    				current.avia_animate({opacity:1}, 400, function()
96    				{
97    					current.css($.avia_utilities.supported.transition + "transform", "none");
98    				});
99    			},timer);
100    		});
101
102    		if(_self.increaseTitle)
103			{
104				title_delay = 0;
105			}
106
107    		this.$titlePos.each(function(i)
108    		{
109    			var current = $(this),
110					new_timer = title_delay + 100 * (i + 1);
111
112    			setTimeout(function()
113    			{
114    				current.avia_animate({opacity:1}, 200, function()
115    				{
116    					current.css($.avia_utilities.supported.transition + "transform", "none");
117    				});
118    			},new_timer);
119    		});
120    	},
121
122    	_bindEvents: function()
123    	{
124    		var trigger = this.isMobile ? "click" : "mouseenter";
125
126    		this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this));
127    		this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this));
128    		this.$win.on('debouncedresize', $.proxy( this._calcMovement, this));
129    		this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this));
130
131    		if(this.isMobile)
132    		{
133    			this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}});
134    		}
135
136    	},
137
138    	_titleHeight: function()
139    	{
140    		var th = 0;
141
142    		this.$titleWrap.css({'height':'auto'}).each(function()
143    		{
144    			var new_h = $(this).outerHeight();
145
146				if( new_h > th)
147				{
148					th = new_h;
149				}
150    		}).css({'height':th + 2});
151    	},
152
153    	_calcMovement: function(event, allow_repeat)
154    	{
155    		var _self			= this,
156    			containerWidth	= this.$slider.width(),
157    			defaultPos		= this.$last.data('av-left'),
158    			imgWidth		= this.$images.last().width() || containerWidth,
159    			imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth),
160    			allImageWidth	= imgWidthPercent * _self.count,
161    			modifier		= 3, // 10 - _self.count,
162    			tempMinLeft		= 100 - imgWidthPercent,
163    			minLeft 		= tempMinLeft > defaultPos / modifier ? tempMinLeft : 0,
164    			oneLeft			= minLeft / (_self.count -1 ),
165    			titleWidth		= imgWidth;
166
167
168
169    		if(allImageWidth < 110 && allow_repeat !== false)
170    		{
171    			//set height if necessary
172    			var slideHeight = this.$slider.height(),
173    				maxHeight 	= (slideHeight / allImageWidth) * 110 ;
174
175    			this.$slider.css({'max-height': maxHeight});
176    			_self._calcMovement(event, false);
177
178    			return;
179    		}
180
181    		//backup so the minimized slides dont get too small
182    		if(oneLeft < 2)
183			{
184				minLeft = 0;
185			}
186
187			this.$slides.each(function(i)
188			{
189				var current = $(this),
190					newLeft = 0,
191					newRight = 0,
192					defaultLeft = current.data('av-left');
193
194				if( minLeft !== 0)
195				{
196					newLeft  = oneLeft * i;
197					newRight = imgWidthPercent + newLeft - oneLeft;
198				}
199				else
200				{
201					newLeft  = defaultLeft / Math.abs(modifier);
202					newRight = 100 - ((newLeft / i) * (_self.count - i));
203				}
204
205				if(i == 1 && _self.increaseTitle)
206				{
207					titleWidth = newRight + 1;
208				}
209
210				if(_self.cssActive)
211				{
212					//if we are not animating based on the css left value but on css transform we need to subtract the left value
213					newLeft = newLeft - defaultLeft;
214					newRight = newRight - defaultLeft;
215					defaultLeft = 0;
216				}
217
218				current.data('av-calc-default', defaultLeft);
219				current.data('av-calc-left', newLeft);
220				current.data('av-calc-right', newRight);
221
222			});
223
224			if(_self.increaseTitle)
225			{
226				_self.$titles.css({width: titleWidth + "%"});
227			}
228    	},
229
230    	_moveTo: function(event)
231    	{
232    		var direction = event.type == "av-next" ? 1 : -1,
233    			nextSlide = this.open === false ? 0 : this.open + direction;
234
235    		if(nextSlide >= 0 && nextSlide < this.$slides.length)
236			{
237				this._move(event, nextSlide);
238			}
239    	},
240
241    	_move: function(event, direct_open)
242    	{
243    		var _self  = this,
244    			slide  = event.currentTarget,
245    			itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide);
246
247    		this.open = itemNo;
248
249    		if(_self.autoplay && typeof slide != "undefined")
250			{
251				clearInterval(_self.autoplay);
252				_self.autoplay = false;
253			}
254
255    		this.$slides.removeClass('aviaccordion-active-slide').each(function(i)
256    		{
257    			var current 	= $(this),
258    				dataSet 	= current.data(),
259    				trans_val	= i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight,
260					transition 	= {},
261					reset		= event.type == 'mouseleave' ? 1 : 0,
262					active 		= itemNo === i ? _self.$titleWrap.eq(i) : false;
263
264    			if(active)
265				{
266					current.addClass('aviaccordion-active-slide');
267				}
268
269    			if(reset)
270    			{
271    				trans_val = dataSet.avCalcDefault;
272    				this.open = false;
273    			}
274
275				if(_self.cssActive) //do a css3 animation
276				{
277					//move the slides
278					transition[_self.property]  = _self.transform3d ? "translate3d(" + trans_val  + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform?
279					current.css(transition);
280				}
281				else
282				{
283					transition.left = trans_val + "%";
284					current.stop().animate(transition, 700, 'easeOutQuint');
285				}
286    		});
287    	}
288    };
289
290
291	$.fn.aviaccordion = function( options )
292	{
293		return this.each(function()
294		{
295			var active = $.data( this, 'AviaccordionSlider' );
296
297			if(!active)
298			{
299				//make sure that the function doesnt get aplied a second time
300				$.data( this, 'AviaccordionSlider', 1 );
301
302				//create the preparations for fullscreen slider
303				new $.AviaccordionSlider( options, this );
304			}
305		});
306	};
307
308})(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.