PageSourceSearch

https://www.city.maebashi.gunma.jp/theme/base/js/jquery.bxslider.js

js city.maebashi.gunma.jp collected 2026-10-02 05:09:55 UTC 52,952 bytes, 1,375 lines download raw bytes

1/**
2 * BxSlider v4.1.2 - Fully loaded, responsive content slider
3 * http://bxslider.com
4 *
5 * Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com
6 * Written while drinking Belgian ales and listening to jazz
7 *
8 * Released under the MIT license - http://opensource.org/licenses/MIT
9 */
10
11;(function($){
12
13	var plugin = {};
14
15	var defaults = {
16
17		// GENERAL
18		mode: 'horizontal',
19		slideSelector: '',
20		infiniteLoop: true,
21		hideControlOnEnd: false,
22		speed: 500,
23		easing: null,
24		slideMargin: 0,
25		startSlide: 0,
26		randomStart: false,
27		captions: false,
28		ticker: false,
29		tickerHover: false,
30		adaptiveHeight: false,
31		adaptiveHeightSpeed: 500,
32		video: false,
33		useCSS: true,
34		preloadImages: 'visible',
35		responsive: true,
36		slideZIndex: 50,
37		wrapperClass: 'bx-wrapper',
38
39		// TOUCH
40		touchEnabled: true,
41		swipeThreshold: 50,
42		oneToOneTouch: true,
43		preventDefaultSwipeX: true,
44		preventDefaultSwipeY: false,
45
46		// PAGER
47		pager: true,
48		pagerType: 'full',
49		pagerShortSeparator: ' / ',
50		pagerSelector: null,
51		buildPager: null,
52		pagerCustom: null,
53
54		// CONTROLS
55		controls: true,
56		nextText: '次へ',
57		prevText: '前へ',
58		nextSelector: null,
59		prevSelector: null,
60		autoControls: false,
61		startText: '再生',
62		stopText: '停止',
63		autoControlsCombine: false,
64		autoControlsSelector: null,
65
66		// AUTO
67		auto: false,
68		pause: 4000,
69		autoStart: true,
70		autoDirection: 'next',
71		autoHover: false,
72		autoDelay: 0,
73		autoSlideForOnePage: false,
74
75		// CAROUSEL
76		minSlides: 1,
77		maxSlides: 1,
78		moveSlides: 0,
79		slideWidth: 0,
80
81		// CALLBACKS
82		onSliderLoad: function() {},
83		onSlideBefore: function() {},
84		onSlideAfter: function() {},
85		onSlideNext: function() {},
86		onSlidePrev: function() {},
87		onSliderResize: function() {}
88	}
89
90	$.fn.bxSlider = function(options){
91
92		if(this.length == 0) return this;
93
94		// support mutltiple elements
95		if(this.length > 1){
96			this.each(function(){$(this).bxSlider(options)});
97			return this;
98		}
99
100		// create a namespace to be used throughout the plugin
101		var slider = {};
102		// set a reference to our slider element
103		var el = this;
104		plugin.el = this;
105
106		/**
107		 * Makes slideshow responsive
108		 */
109		// first get the original window dimens (thanks alot IE)
110		var windowWidth = $(window).width();
111		var windowHeight = $(window).height();
112
113
114
115		/**
116		 * ===================================================================================
117		 * = PRIVATE FUNCTIONS
118		 * ===================================================================================
119		 */
120
121		/**
122		 * Initializes namespace settings to be used throughout plugin
123		 */
124		var init = function(){
125			// merge user-supplied options with the defaults
126			slider.settings = $.extend({}, defaults, options);
127			// parse slideWidth setting
128			slider.settings.slideWidth = parseInt(slider.settings.slideWidth);
129			// store the original children
130			slider.children = el.children(slider.settings.slideSelector);
131			// check if actual number of slides is less than minSlides / maxSlides
132			if(slider.children.length < slider.settings.minSlides) slider.settings.minSlides = slider.children.length;
133			if(slider.children.length < slider.settings.maxSlides) slider.settings.maxSlides = slider.children.length;
134			// if random start, set the startSlide setting to random number
135			if(slider.settings.randomStart) slider.settings.startSlide = Math.floor(Math.random() * slider.children.length);
136			// store active slide information
137			slider.active = { index: slider.settings.startSlide }
138			// store if the slider is in carousel mode (displaying / moving multiple slides)
139			slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1;
140			// if carousel, force preloadImages = 'all'
141			if(slider.carousel) slider.settings.preloadImages = 'all';
142			// calculate the min / max width thresholds based on min / max number of slides
143			// used to setup and update carousel slides dimensions
144			slider.minThreshold = (slider.settings.minSlides * slider.settings.slideWidth) + ((slider.settings.minSlides - 1) * slider.settings.slideMargin);
145			slider.maxThreshold = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
146			// store the current state of the slider (if currently animating, working is true)
147			slider.working = false;
148			// initialize the controls object
149			slider.controls = {};
150			// initialize an auto interval
151			slider.interval = null;
152			// determine which property to use for transitions
153			slider.animProp = slider.settings.mode == 'vertical' ? 'top' : 'left';
154			// determine if hardware acceleration can be used
155			slider.usingCSS = slider.settings.useCSS && slider.settings.mode != 'fade' && (function(){
156				// create our test div element
157				var div = document.createElement('div');
158				// css transition properties
159				var props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
160				// test for each property
161				for(var i in props){
162					if(div.style[props[i]] !== undefined){
163						slider.cssPrefix = props[i].replace('Perspective', '').toLowerCase();
164						slider.animProp = '-' + slider.cssPrefix + '-transform';
165						return true;
166					}
167				}
168				return false;
169			}());
170			// if vertical mode always make maxSlides and minSlides equal
171			if(slider.settings.mode == 'vertical') slider.settings.maxSlides = slider.settings.minSlides;
172			// save original style data
173			el.data("origStyle", el.attr("style"));
174			el.children(slider.settings.slideSelector).each(function() {
175			  $(this).data("origStyle", $(this).attr("style"));
176			});
177			// perform all DOM / CSS modifications
178			setup();
179		}
180
181		/**
182		 * Performs all DOM and CSS modifications
183		 */
184		var setup = function(){
185			// wrap el in a wrapper
186			el.wrap('<div class="' + slider.settings.wrapperClass + '"><div class="bx-viewport"></div></div>');
187			// store a namspace reference to .bx-viewport
188			slider.viewport = el.parent();
189			// add a loading div to display while images are loading
190			slider.loader = $('<div class="bx-loading" />');
191			slider.viewport.prepend(slider.loader);
192			// set el to a massive width, to hold any needed slides
193			// also strip any margin and padding from el
194			el.css({
195				width: slider.settings.mode == 'horizontal' ? (slider.children.length * 100 + 215) + '%' : 'auto',
196				position: 'relative'
197			});
198			// if using CSS, add the easing property
199			if(slider.usingCSS && slider.settings.easing){
200				el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing);
201			// if not using CSS and no easing value was supplied, use the default JS animation easing (swing)
202			}else if(!slider.settings.easing){
203				slider.settings.easing = 'swing';
204			}
205			var slidesShowing = getNumberSlidesShowing();
206			// make modifications to the viewport (.bx-viewport)
207			slider.viewport.css({
208				width: '100%',
209				overflow: 'hidden',
210				position: 'relative'
211			});
212			slider.viewport.parent().css({
213				maxWidth: getViewportMaxWidth()
214			});
215			// make modification to the wrapper (.bx-wrapper)
216			if(!slider.settings.pager) {
217				slider.viewport.parent().css({
218				margin: '0 auto 0px'
219				});
220			}
221			// apply css to all slider children
222			slider.children.css({
223				'float': slider.settings.mode == 'horizontal' ? 'left' : 'none',
224				listStyle: 'none',
225				position: 'relative'
226			});
227			// apply the calculated width after the float is applied to prevent scrollbar interference
228			slider.children.css('width', getSlideWidth());
229			// if slideMargin is supplied, add the css
230			if(slider.settings.mode == 'horizontal' && slider.settings.slideMargin > 0) slider.children.css('marginRight', slider.settings.slideMargin);
231			if(slider.settings.mode == 'vertical' && slider.settings.slideMargin > 0) slider.children.css('marginBottom', slider.settings.slideMargin);
232			// if "fade" mode, add positioning and z-index CSS
233			if(slider.settings.mode == 'fade'){
234				slider.children.css({
235					position: 'absolute',
236					zIndex: 0,
237					display: 'none'
238				});
239				// prepare the z-index on the showing element
240				slider.children.eq(slider.settings.startSlide).css({zIndex: slider.settings.slideZIndex, display: 'block'});
241			}
242			// create an element to contain all slider controls (pager, start / stop, etc)
243			slider.controls.el = $('<div class="bx-controls" />');
244			// if captions are requested, add them
245			if(slider.settings.captions) appendCaptions();
246			// check if startSlide is last slide
247			slider.active.last = slider.settings.startSlide == getPagerQty() - 1;
248			// if video is true, set up the fitVids plugin
249			if(slider.settings.video) el.fitVids();
250			// set the default preload selector (visible)
251			var preloadSelector = slider.children.eq(slider.settings.startSlide);
252			if (slider.settings.preloadImages == "all") preloadSelector = slider.children;
253			// only check for control addition if not in "ticker" mode
254			if(!slider.settings.ticker){
255				// if pager is requested, add it
256				if(slider.settings.pager) appendPager();
257				// if controls are requested, add them
258				if(slider.settings.controls) appendControls();
259				// if auto is true, and auto controls are requested, add them
260				if(slider.settings.auto && slider.settings.autoControls) appendControlsAuto();
261				// if any control option is requested, add the controls wrapper
262				if(slider.settings.controls || slider.settings.autoControls || slider.settings.pager) slider.viewport.after(slider.controls.el);
263			// if ticker mode, do not allow a pager
264			}else{
265				slider.settings.pager = false;
266			}
267			// preload all images, then perform final DOM / CSS modifications that depend on images being loaded
268			loadElements(preloadSelector, start);
269		}
270
271		var loadElements = function(selector, callback){
272			var total = selector.find('img, iframe').length;
273			if (total == 0){
274				callback();
275				return;
276			}
277			var count = 0;
278			selector.find('img, iframe').each(function(){
279				$(this).one('load', function() {
280				  if(++count == total) callback();
281				}).each(function() {
282				  if(this.complete) $(this).load();
283				});
284			});
285		}
286
287		/**
288		 * Start the slider
289		 */
290		var start = function(){
291			// if infinite loop, prepare additional slides
292			if(slider.settings.infiniteLoop && slider.settings.mode != 'fade' && !slider.settings.ticker){
293				var slice = slider.settings.mode == 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides;
294				
295				
296				
297				// 永井追記(2015/01/07)
298				// (function() {
299				// 	var allNum = slider.children.size();
300				// 	var oneSize = slider.children.outerWidth(true);
301				// 	var oneHeight = slider.children.height();
302				// 	var allSize = oneSize * allNum;
303				// 	var addPosJ = slider.children.eq(0);
304				// 	var addOneJ = function(j_,pos_,idx_) {
305				// 		j_.css({
306				// 			'position':'absolute'
307				// 			,'left':pos_ + 'px'
308				// 			,'top' :'0px'
309				// 			,'z-index':idx_
310				// 		});
311				// 		addPosJ.after(j_);
312				// 	};
313
314				// 		slider.children.each(function(idx_) {
315				// 		// 影響のないabsolute画像を後ろに追加
316				// 		addOneJ($(this).clone(), (allNum + slice) * oneSize + idx_ * oneSize,idx_);// +sliceで左に追加されたclone分を足す
317				// 		// 影響のないabsolute画像を前に追加
318				// 		addOneJ($(this).clone(), -slice * oneSize + idx_ * oneSize,idx_);// sliceで左にずらして足す
319				// 	});
320				// })();
321				
322				
323				
324				
325				
326				var sliceAppend = slider.children.slice(0, slice).clone().addClass('bx-clone');
327				var slicePrepend = slider.children.slice(-slice).clone().addClass('bx-clone');
328				el.append(sliceAppend).prepend(slicePrepend);
329			}
330			// remove the loading DOM element
331			slider.loader.remove();
332			// set the left / top position of "el"
333			setSlidePosition();
334			// if "vertical" mode, always use adaptiveHeight to prevent odd behavior
335			if (slider.settings.mode == 'vertical') slider.settings.adaptiveHeight = true;
336			// set the viewport height
337			slider.viewport.height(getViewportHeight());
338			// make sure everything is positioned just right (same as a window resize)
339			el.redrawSlider();
340			// onSliderLoad callback
341			slider.settings.onSliderLoad(slider.active.index);
342			// slider has been fully initialized
343			slider.initialized = true;
344			// bind the resize call to the window
345			if (slider.settings.responsive) $(window).bind('resize', resizeWindow);
346			// if auto is true and has more than 1 page, start the show
347			if (slider.settings.auto && slider.settings.autoStart && (getPagerQty() > 1 || slider.settings.autoSlideForOnePage)) initAuto();
348			// if ticker is true, start the ticker
349			if (slider.settings.ticker) initTicker();
350			// if pager is requested, make the appropriate pager link active
351			if (slider.settings.pager) updatePagerActive(slider.settings.startSlide);
352			// check for any updates to the controls (like hideControlOnEnd updates)
353			if (slider.settings.controls) updateDirectionControls();
354			// if touchEnabled is true, setup the touch events
355			if (slider.settings.touchEnabled && !slider.settings.ticker) initTouch();
356		}
357
358		/**
359		 * Returns the calculated height of the viewport, used to determine either adaptiveHeight or the maxHeight value
360		 */
361		var getViewportHeight = function(){
362			var height = 0;
363			// first determine which children (slides) should be used in our height calculation
364			var children = $();
365			// if mode is not "vertical" and adaptiveHeight is false, include all children
366			if(slider.settings.mode != 'vertical' && !slider.settings.adaptiveHeight){
367				children = slider.children;
368			}else{
369				// if not carousel, return the single active child
370				if(!slider.carousel){
371					children = slider.children.eq(slider.active.index);
372				// if carousel, return a slice of children
373				}else{
374					// get the individual slide index
375					var currentIndex = slider.settings.moveSlides == 1 ? slider.active.index : slider.active.index * getMoveBy();
376					// add the current slide to the children
377					children = slider.children.eq(currentIndex);
378					// cycle through the remaining "showing" slides
379					for (i = 1; i <= slider.settings.maxSlides - 1; i++){
380						// if looped back to the start
381						if(currentIndex + i >= slider.children.length){
382							children = children.add(slider.children.eq(i - 1));
383						}else{
384							children = children.add(slider.children.eq(currentIndex + i));
385						}
386					}
387				}
388			}
389			// if "vertical" mode, calculate the sum of the heights of the children
390			if(slider.settings.mode == 'vertical'){
391				children.each(function(index) {
392				  height += $(this).outerHeight();
393				});
394				// add user-supplied margins
395				if(slider.settings.slideMargin > 0){
396					height += slider.settings.slideMargin * (slider.settings.minSlides - 1);
397				}
398			// if not "vertical" mode, calculate the max height of the children
399			}else{
400				height = Math.max.apply(Math, children.map(function(){
401					return $(this).outerHeight(false);
402				}).get());
403			}
404
405			if(slider.viewport.css('box-sizing') == 'border-box'){
406				height +=	parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')) +
407							parseFloat(slider.viewport.css('border-top-width')) + parseFloat(slider.viewport.css('border-bottom-width'));
408			}else if(slider.viewport.css('box-sizing') == 'padding-box'){
409				height +=	parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom'));
410			}
411
412			return height;
413		}
414
415		/**
416		 * Returns the calculated width to be used for the outer wrapper / viewport
417		 */
418		var getViewportMaxWidth = function(){
419			var width = '100%';
420			if(slider.settings.slideWidth > 0){
421				if(slider.settings.mode == 'horizontal'){
422					width = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
423				}else{
424					width = slider.settings.slideWidth;
425				}
426			}
427			return width;
428		}
429
430		/**
431		 * Returns the calculated width to be applied to each slide
432		 */
433		var getSlideWidth = function(){
434			// start with any user-supplied slide width
435			var newElWidth = slider.settings.slideWidth;
436			// get the current viewport width
437			var wrapWidth = slider.viewport.width();
438			// if slide width was not supplied, or is larger than the viewport use the viewport width
439			if(slider.settings.slideWidth == 0 ||
440				(slider.settings.slideWidth > wrapWidth && !slider.carousel) ||
441				slider.settings.mode == 'vertical'){
442				newElWidth = wrapWidth;
443			// if carousel, use the thresholds to determine the width
444			}else if(slider.settings.maxSlides > 1 && slider.settings.mode == 'horizontal'){
445				if(wrapWidth > slider.maxThreshold){
446					// newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.maxSlides - 1))) / slider.settings.maxSlides;
447				}else if(wrapWidth < slider.minThreshold){
448					newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides;
449				}
450			}
451			return newElWidth;
452		}
453
454		/**
455		 * Returns the number of slides currently visible in the viewport (includes partially visible slides)
456		 */
457		var getNumberSlidesShowing = function(){
458			var slidesShowing = 1;
459			if(slider.settings.mode == 'horizontal' && slider.settings.slideWidth > 0){
460				// if viewport is smaller than minThreshold, return minSlides
461				if(slider.viewport.width() < slider.minThreshold){
462					slidesShowing = slider.settings.minSlides;
463				// if viewport is larger than minThreshold, return maxSlides
464				}else if(slider.viewport.width() > slider.maxThreshold){
465					slidesShowing = slider.settings.maxSlides;
466				// if viewport is between min / max thresholds, divide viewport width by first child width
467				}else{
468					var childWidth = slider.children.first().width() + slider.settings.slideMargin;
469					slidesShowing = Math.floor((slider.viewport.width() +
470						slider.settings.slideMargin) / childWidth);
471				}
472			// if "vertical" mode, slides showing will always be minSlides
473			}else if(slider.settings.mode == 'vertical'){
474				slidesShowing = slider.settings.minSlides;
475			}
476			return slidesShowing;
477		}
478
479		/**
480		 * Returns the number of pages (one full viewport of slides is one "page")
481		 */
482		var getPagerQty = function(){
483			var pagerQty = 0;
484			// if moveSlides is specified by the user
485			if(slider.settings.moveSlides > 0){
486				if(slider.settings.infiniteLoop){
487					pagerQty = Math.ceil(slider.children.length / getMoveBy());
488				}else{
489					// use a while loop to determine pages
490					var breakPoint = 0;
491					var counter = 0
492					// when breakpoint goes above children length, counter is the number of pages
493					while (breakPoint < slider.children.length){
494						++pagerQty;
495						breakPoint = counter + getNumberSlidesShowing();
496						counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing();
497					}
498				}
499			// if moveSlides is 0 (auto) divide children length by sides showing, then round up
500			}else{
501				pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing());
502			}
503			return pagerQty;
504		}
505
506		/**
507		 * Returns the number of indivual slides by which to shift the slider
508		 */
509		var getMoveBy = function(){
510			// if moveSlides was set by the user and moveSlides is less than number of slides showing
511			if(slider.settings.moveSlides > 0 && slider.settings.moveSlides <= getNumberSlidesShowing()){
512				return slider.settings.moveSlides;
513			}
514			// if moveSlides is 0 (auto)
515			return getNumberSlidesShowing();
516		}
517
518		/**
519		 * Sets the slider's (el) left or top position
520		 */
521		var setSlidePosition = function(){
522			// if last slide, not infinite loop, and number of children is larger than specified maxSlides
523			if(slider.children.length > slider.settings.maxSlides && slider.active.last && !slider.settings.infiniteLoop){
524				if (slider.settings.mode == 'horizontal'){
525					// get the last child's position
526					var lastChild = slider.children.last();
527					var position = lastChild.position();
528					// set the left position
529					setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.outerWidth())), 'reset', 0);
530				}else if(slider.settings.mode == 'vertical'){
531					// get the last showing index's position
532					var lastShowingIndex = slider.children.length - slider.settings.minSlides;
533					var position = slider.children.eq(lastShowingIndex).position();
534					// set the top position
535					setPositionProperty(-position.top, 'reset', 0);
536				}
537			// if not last slide
538			}else{
539				// get the position of the first showing slide
540				var position = slider.children.eq(slider.active.index * getMoveBy()).position();
541				// check for last slide
542				if (slider.active.index == getPagerQty() - 1) slider.active.last = true;
543				// set the repective position
544				if (position != undefined){
545					if (slider.settings.mode == 'horizontal') setPositionProperty(-position.left, 'reset', 0);
546					else if (slider.settings.mode == 'vertical') setPositionProperty(-position.top, 'reset', 0);
547				}
548			}
549		}
550
551		/**
552		 * Sets the el's animating property position (which in turn will sometimes animate el).
553		 * If using CSS, sets the transform property. If not using CSS, sets the top / left property.
554		 *
555		 * @param value (int)
556		 *  - the animating property's value
557		 *
558		 * @param type (string) 'slider', 'reset', 'ticker'
559		 *  - the type of instance for which the function is being
560		 *
561		 * @param duration (int)
562		 *  - the amount of time (in ms) the transition should occupy
563		 *
564		 * @param params (array) optional
565		 *  - an optional parameter containing any variables that need to be passed in
566		 */
567		var setPositionProperty = function(value, type, duration, params){
568			// use CSS transform
569			if(slider.usingCSS){
570				// determine the translate3d value
571				var propValue = slider.settings.mode == 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)';
572				// add the CSS transition-duration
573				el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's');
574				if(type == 'slide'){
575					// set the property value
576					el.css(slider.animProp, propValue);
577					// bind a callback method - executes when CSS transition completes
578					el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
579						// unbind the callback
580						el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
581						updateAfterSlideTransition();
582					});
583				}else if(type == 'reset'){
584					el.css(slider.animProp, propValue);
585				}else if(type == 'ticker'){
586					// make the transition use 'linear'
587					el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear');
588					el.css(slider.animProp, propValue);
589					// bind a callback method - executes when CSS transition completes
590					el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
591						// unbind the callback
592						el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
593						// reset the position
594						setPositionProperty(params['resetValue'], 'reset', 0);
595						// start the loop again
596						tickerLoop();
597					});
598				}
599			// use JS animate
600			}else{
601				var animateObj = {};
602				animateObj[slider.animProp] = value;
603				if(type == 'slide'){
604					el.animate(animateObj, duration, slider.settings.easing, function(){
605						updateAfterSlideTransition();
606					});
607				}else if(type == 'reset'){
608					el.css(slider.animProp, value)
609				}else if(type == 'ticker'){
610					el.animate(animateObj, speed, 'linear', function(){
611						setPositionProperty(params['resetValue'], 'reset', 0);
612						// run the recursive loop after animation
613						tickerLoop();
614					});
615				}
616			}
617		}
618
619		/**
620		 * Populates the pager with proper amount of pages
621		 */
622		var populatePager = function(){
623			var pagerHtml = '';
624			var pagerQty = getPagerQty();
625			// loop through each pager item
626			for(var i=0; i < pagerQty; i++){
627				var linkContent = '';
628				// if a buildPager function is supplied, use it to get pager link value, else use index + 1
629				if(slider.settings.buildPager && $.isFunction(slider.settings.buildPager)){
630					linkContent = slider.settings.buildPager(i);
631					slider.pagerEl.addClass('bx-custom-pager');
632				}else{
633					linkContent = i + 1;
634					slider.pagerEl.addClass('bx-default-pager');
635				}
636				// var linkContent = slider.settings.buildPager && $.isFunction(slider.settings.buildPager) ? slider.settings.buildPager(i) : i + 1;
637				// add the markup to the string
638				pagerHtml += '<div class="bx-pager-item"><a href="" data-slide-index="' + i + '" class="bx-pager-link">' + linkContent + '</a></div>';
639			};
640			// populate the pager element with pager links
641			slider.pagerEl.html(pagerHtml);
642		}
643
644		/**
645		 * Appends the pager to the controls element
646		 */
647		var appendPager = function(){
648			if(!slider.settings.pagerCustom){
649				// create the pager DOM element
650				slider.pagerEl = $('<div class="bx-pager" />');
651				// if a pager selector was supplied, populate it with the pager
652				if(slider.settings.pagerSelector){
653					$(slider.settings.pagerSelector).html(slider.pagerEl);
654				// if no pager selector was supplied, add it after the wrapper
655				}else{
656					slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl);
657				}
658				// populate the pager
659				populatePager();
660			}else{
661				slider.pagerEl = $(slider.settings.pagerCustom);
662			}
663			// assign the pager click binding
664			slider.pagerEl.on('click', 'a', clickPagerBind);
665		}
666
667		/**
668		 * Appends prev / next controls to the controls element
669		 */
670		var appendControls = function(){
671			slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>');
672			slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>');
673			// bind click actions to the controls
674			slider.controls.next.bind('click', clickNextBind);
675			slider.controls.prev.bind('click', clickPrevBind);
676			// if nextSlector was supplied, populate it
677			if(slider.settings.nextSelector){
678				$(slider.settings.nextSelector).append(slider.controls.next);
679			}
680			// if prevSlector was supplied, populate it
681			if(slider.settings.prevSelector){
682				$(slider.settings.prevSelector).append(slider.controls.prev);
683			}
684			// if no custom selectors were supplied
685			if(!slider.settings.nextSelector && !slider.settings.prevSelector){
686				// add the controls to the DOM
687				slider.controls.directionEl = $('<div class="bx-controls-direction" />');
688				// add the control elements to the directionEl
689				slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next);
690				// slider.viewport.append(slider.controls.directionEl);
691				slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl);
692			}
693		}
694
695		/**
696		 * Appends start / stop auto controls to the controls element
697		 */
698		var appendControlsAuto = function(){
699			slider.controls.start = $('<div class="bx-controls-auto-item"><a class="bx-start" href="">' + slider.settings.startText + '</a></div>');
700			slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>');
701			// add the controls to the DOM
702			slider.controls.autoEl = $('<div class="bx-controls-auto" />');
703			// bind click actions to the controls
704			slider.controls.autoEl.on('click', '.bx-start', clickStartBind);
705			slider.controls.autoEl.on('click', '.bx-stop', clickStopBind);
706			// if autoControlsCombine, insert only the "start" control
707			if(slider.settings.autoControlsCombine){
708				slider.controls.autoEl.append(slider.controls.start);
709			// if autoControlsCombine is false, insert both controls
710			}else{
711				slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop);
712			}
713			// if auto controls selector was supplied, populate it with the controls
714			if(slider.settings.autoControlsSelector){
715				$(slider.settings.autoControlsSelector).html(slider.controls.autoEl);
716			// if auto controls selector was not supplied, add it after the wrapper
717			}else{
718				slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl);
719			}
720			// update the auto controls
721			updateAutoControls(slider.settings.autoStart ? 'stop' : 'start');
722		}
723
724		/**
725		 * Appends image captions to the DOM
726		 */
727		var appendCaptions = function(){
728			// cycle through each child
729			slider.children.each(function(index){
730				// get the image title attribute
731				var title = $(this).find('img:first').attr('title');
732				// append the caption
733				if (title != undefined && ('' + title).length) {
734                    $(this).append('<div class="bx-caption"><span>' + title + '</span></div>');
735                }
736			});
737		}
738
739		/**
740		 * Click next binding
741		 *
742		 * @param e (event)
743		 *  - DOM event object
744		 */
745		var clickNextBind = function(e){
746			// if auto show is running, stop it
747			if (slider.settings.auto) el.stopAuto();
748			el.goToNextSlide();
749			e.preventDefault();
750		}
751
752		/**
753		 * Click prev binding
754		 *
755		 * @param e (event)
756		 *  - DOM event object
757		 */
758		var clickPrevBind = function(e){
759			// if auto show is running, stop it
760			if (slider.settings.auto) el.stopAuto();
761			el.goToPrevSlide();
762			e.preventDefault();
763		}
764
765		/**
766		 * Click start binding
767		 *
768		 * @param e (event)
769		 *  - DOM event object
770		 */
771		var clickStartBind = function(e){
772			el.startAuto();
773			e.preventDefault();
774		}
775
776		/**
777		 * Click stop binding
778		 *
779		 * @param e (event)
780		 *  - DOM event object
781		 */
782		var clickStopBind = function(e){
783			el.stopAuto();
784			e.preventDefault();
785		}
786
787		/**
788		 * Click pager binding
789		 *
790		 * @param e (event)
791		 *  - DOM event object
792		 */
793		var clickPagerBind = function(e){
794			// if auto show is running, stop it
795			if (slider.settings.auto) el.stopAuto();
796			var pagerLink = $(e.currentTarget);
797			if(pagerLink.attr('data-slide-index') !== undefined){
798				var pagerIndex = parseInt(pagerLink.attr('data-slide-index'));
799				// if clicked pager link is not active, continue with the goToSlide call
800				if(pagerIndex != slider.active.index) el.goToSlide(pagerIndex);
801				e.preventDefault();
802			}
803		}
804
805		/**
806		 * Updates the pager links with an active class
807		 *
808		 * @param slideIndex (int)
809		 *  - index of slide to make active
810		 */
811		var updatePagerActive = function(slideIndex){
812			// if "short" pager type
813			var len = slider.children.length; // nb of children
814			if(slider.settings.pagerType == 'short'){
815				if(slider.settings.maxSlides > 1) {
816					len = Math.ceil(slider.children.length/slider.settings.maxSlides);
817				}
818				slider.pagerEl.html( (slideIndex + 1) + slider.settings.pagerShortSeparator + len);
819				return;
820			}
821			// remove all pager active classes
822			slider.pagerEl.find('a').removeClass('active');
823			// apply the active class for all pagers
824			slider.pagerEl.each(function(i, el) { $(el).find('a').eq(slideIndex).addClass('active'); });
825		}
826
827		/**
828		 * Performs needed actions after a slide transition
829		 */
830		var updateAfterSlideTransition = function(){
831			// if infinte loop is true
832			if(slider.settings.infiniteLoop){
833				var position = '';
834				// first slide
835				if(slider.active.index == 0){
836					// set the new position
837					position = slider.children.eq(0).position();
838				// carousel, last slide
839				}else if(slider.active.index == getPagerQty() - 1 && slider.carousel){
840					position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position();
841				// last slide
842				}else if(slider.active.index == slider.children.length - 1){
843					position = slider.children.eq(slider.children.length - 1).position();
844				}
845				if(position){
846					if (slider.settings.mode == 'horizontal') { setPositionProperty(-position.left, 'reset', 0); }
847					else if (slider.settings.mode == 'vertical') { setPositionProperty(-position.top, 'reset', 0); }
848				}
849			}
850			// declare that the transition is complete
851			slider.working = false;
852			// onSlideAfter callback
853			slider.settings.onSlideAfter(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
854		}
855
856		/**
857		 * Updates the auto controls state (either active, or combined switch)
858		 *
859		 * @param state (string) "start", "stop"
860		 *  - the new state of the auto show
861		 */
862		var updateAutoControls = function(state){
863			// if autoControlsCombine is true, replace the current control with the new state
864			if(slider.settings.autoControlsCombine){
865				slider.controls.autoEl.html(slider.controls[state]);
866			// if autoControlsCombine is false, apply the "active" class to the appropriate control
867			}else{
868				slider.controls.autoEl.find('a').removeClass('active');
869				slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active');
870			}
871		}
872
873		/**
874		 * Updates the direction controls (checks if either should be hidden)
875		 */
876		var updateDirectionControls = function(){
877			if(getPagerQty() == 1){
878				slider.controls.prev.addClass('disabled');
879				slider.controls.next.addClass('disabled');
880			}else if(!slider.settings.infiniteLoop && slider.settings.hideControlOnEnd){
881				// if first slide
882				if (slider.active.index == 0){
883					slider.controls.prev.addClass('disabled');
884					slider.controls.next.removeClass('disabled');
885				// if last slide
886				}else if(slider.active.index == getPagerQty() - 1){
887					slider.controls.next.addClass('disabled');
888					slider.controls.prev.removeClass('disabled');
889				// if any slide in the middle
890				}else{
891					slider.controls.prev.removeClass('disabled');
892					slider.controls.next.removeClass('disabled');
893				}
894			}
895		}
896
897		/**
898		 * Initialzes the auto process
899		 */
900		var initAuto = function(){
901			// if autoDelay was supplied, launch the auto show using a setTimeout() call
902			if(slider.settings.autoDelay > 0){
903				var timeout = setTimeout(el.startAuto, slider.settings.autoDelay);
904			// if autoDelay was not supplied, start the auto show normally
905			}else{
906				el.startAuto();
907			}
908			// if autoHover is requested
909			if(slider.settings.autoHover){
910				// on el hover
911				el.hover(function(){
912					// if the auto show is currently playing (has an active interval)
913					if(slider.interval){
914						// stop the auto show and pass true agument which will prevent control update
915						el.stopAuto(true);
916						// create a new autoPaused value which will be used by the relative "mouseout" event
917						slider.autoPaused = true;
918					}
919				}, function(){
920					// if the autoPaused value was created be the prior "mouseover" event
921					if(slider.autoPaused){
922						// start the auto show and pass true agument which will prevent control update
923						el.startAuto(true);
924						// reset the autoPaused value
925						slider.autoPaused = null;
926					}
927				});
928			}
929		}
930
931		/**
932		 * Initialzes the ticker process
933		 */
934		var initTicker = function(){
935			var startPosition = 0;
936			// if autoDirection is "next", append a clone of the entire slider
937			if(slider.settings.autoDirection == 'next'){
938				el.append(slider.children.clone().addClass('bx-clone'));
939			// if autoDirection is "prev", prepend a clone of the entire slider, and set the left position
940			}else{
941				el.prepend(slider.children.clone().addClass('bx-clone'));
942				var position = slider.children.first().position();
943				startPosition = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
944			}
945			setPositionProperty(startPosition, 'reset', 0);
946			// do not allow controls in ticker mode
947			slider.settings.pager = false;
948			slider.settings.controls = false;
949			slider.settings.autoControls = false;
950			// if autoHover is requested
951			if(slider.settings.tickerHover && !slider.usingCSS){
952				// on el hover
953				slider.viewport.hover(function(){
954					el.stop();
955				}, function(){
956					// calculate the total width of children (used to calculate the speed ratio)
957					var totalDimens = 0;
958					slider.children.each(function(index){
959					  totalDimens += slider.settings.mode == 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
960					});
961					// calculate the speed ratio (used to determine the new speed to finish the paused animation)
962					var ratio = slider.settings.speed / totalDimens;
963					// determine which property to use
964					var property = slider.settings.mode == 'horizontal' ? 'left' : 'top';
965					// calculate the new speed
966					var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property)))));
967					tickerLoop(newSpeed);
968				});
969			}
970			// start the ticker loop
971			tickerLoop();
972		}
973
974		/**
975		 * Runs a continuous loop, news ticker-style
976		 */
977		var tickerLoop = function(resumeSpeed){
978			speed = resumeSpeed ? resumeSpeed : slider.settings.speed;
979			var position = {left: 0, top: 0};
980			var reset = {left: 0, top: 0};
981			// if "next" animate left position to last child, then reset left to 0
982			if(slider.settings.autoDirection == 'next'){
983				position = el.find('.bx-clone').first().position();
984			// if "prev" animate left position to 0, then reset left to first non-clone child
985			}else{
986				reset = slider.children.first().position();
987			}
988			var animateProperty = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
989			var resetValue = slider.settings.mode == 'horizontal' ? -reset.left : -reset.top;
990			var params = {resetValue: resetValue};
991			setPositionProperty(animateProperty, 'ticker', speed, params);
992		}
993
994		/**
995		 * Initializes touch events
996		 */
997		var initTouch = function(){
998			// initialize object to contain all touch values
999			slider.touch = {
1000				start: {x: 0, y: 0},
1001				end: {x: 0, y: 0}
1002			}
1003			slider.viewport.bind('touchstart', onTouchStart);
1004		}
1005
1006		/**
1007		 * Event handler for "touchstart"
1008		 *
1009		 * @param e (event)
1010		 *  - DOM event object
1011		 */
1012		var onTouchStart = function(e){
1013			if(slider.working){
1014				e.preventDefault();
1015			}else{
1016				// record the original position when touch starts
1017				slider.touch.originalPos = el.position();
1018				var orig = e.originalEvent;
1019				// record the starting touch x, y coordinates
1020				slider.touch.start.x = orig.changedTouches[0].pageX;
1021				slider.touch.start.y = orig.changedTouches[0].pageY;
1022				// bind a "touchmove" event to the viewport
1023				slider.viewport.bind('touchmove', onTouchMove);
1024				// bind a "touchend" event to the viewport
1025				slider.viewport.bind('touchend', onTouchEnd);
1026			}
1027		}
1028
1029		/**
1030		 * Event handler for "touchmove"
1031		 *
1032		 * @param e (event)
1033		 *  - DOM event object
1034		 */
1035		var onTouchMove = function(e){
1036			var orig = e.originalEvent;
1037			// if scrolling on y axis, do not prevent default
1038			var xMovement = Math.abs(orig.changedTouches[0].pageX - slider.touch.start.x);
1039			var yMovement = Math.abs(orig.changedTouches[0].pageY - slider.touch.start.y);
1040			// x axis swipe
1041			if((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX){
1042				e.preventDefault();
1043			// y axis swipe
1044			}else if((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY){
1045				e.preventDefault();
1046			}
1047			if(slider.settings.mode != 'fade' && slider.settings.oneToOneTouch){
1048				var value = 0;
1049				// if horizontal, drag along x axis
1050				if(slider.settings.mode == 'horizontal'){
1051					var change = orig.changedTouches[0].pageX - slider.touch.start.x;
1052					value = slider.touch.originalPos.left + change;
1053				// if vertical, drag along y axis
1054				}else{
1055					var change = orig.changedTouches[0].pageY - slider.touch.start.y;
1056					value = slider.touch.originalPos.top + change;
1057				}
1058				setPositionProperty(value, 'reset', 0);
1059			}
1060		}
1061
1062		/**
1063		 * Event handler for "touchend"
1064		 *
1065		 * @param e (event)
1066		 *  - DOM event object
1067		 */
1068		var onTouchEnd = function(e){
1069			slider.viewport.unbind('touchmove', onTouchMove);
1070			var orig = e.originalEvent;
1071			var value = 0;
1072			// record end x, y positions
1073			slider.touch.end.x = orig.changedTouches[0].pageX;
1074			slider.touch.end.y = orig.changedTouches[0].pageY;
1075			// if fade mode, check if absolute x distance clears the threshold
1076			if(slider.settings.mode == 'fade'){
1077				var distance = Math.abs(slider.touch.start.x - slider.touch.end.x);
1078				if(distance >= slider.settings.swipeThreshold){
1079					slider.touch.start.x > slider.touch.end.x ? el.goToNextSlide() : el.goToPrevSlide();
1080					el.stopAuto();
1081				}
1082			// not fade mode
1083			}else{
1084				var distance = 0;
1085				// calculate distance and el's animate property
1086				if(slider.settings.mode == 'horizontal'){
1087					distance = slider.touch.end.x - slider.touch.start.x;
1088					value = slider.touch.originalPos.left;
1089				}else{
1090					distance = slider.touch.end.y - slider.touch.start.y;
1091					value = slider.touch.originalPos.top;
1092				}
1093				// if not infinite loop and first / last slide, do not attempt a slide transition
1094				if(!slider.settings.infiniteLoop && ((slider.active.index == 0 && distance > 0) || (slider.active.last && distance < 0))){
1095					setPositionProperty(value, 'reset', 200);
1096				}else{
1097					// check if distance clears threshold
1098					if(Math.abs(distance) >= slider.settings.swipeThreshold){
1099						distance < 0 ? el.goToNextSlide() : el.goToPrevSlide();
1100						el.stopAuto();
1101					}else{
1102						// el.animate(property, 200);
1103						setPositionProperty(value, 'reset', 200);
1104					}
1105				}
1106			}
1107			slider.viewport.unbind('touchend', onTouchEnd);
1108		}
1109
1110		/**
1111		 * Window resize event callback
1112		 */
1113		var resizeWindow = function(e){
1114			// don't do anything if slider isn't initialized.
1115			if(!slider.initialized) return;
1116			// get the new window dimens (again, thank you IE)
1117			var windowWidthNew = $(window).width();
1118			var windowHeightNew = $(window).height();
1119			// make sure that it is a true window resize
1120			// *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
1121			// are resized. Can you just die already?*
1122			if(windowWidth != windowWidthNew || windowHeight != windowHeightNew){
1123				// set the new window dimens
1124				windowWidth = windowWidthNew;
1125				windowHeight = windowHeightNew;
1126				// update all dynamic elements
1127				el.redrawSlider();
1128				// Call user resize handler
1129				slider.settings.onSliderResize.call(el, slider.active.index);
1130			}
1131		}
1132
1133		/**
1134		 * ===================================================================================
1135		 * = PUBLIC FUNCTIONS
1136		 * ===================================================================================
1137		 */
1138
1139		/**
1140		 * Performs slide transition to the specified slide
1141		 *
1142		 * @param slideIndex (int)
1143		 *  - the destination slide's index (zero-based)
1144		 *
1145		 * @param direction (string)
1146		 *  - INTERNAL USE ONLY - the direction of travel ("prev" / "next")
1147		 */
1148		el.goToSlide = function(slideIndex, direction){
1149			// if plugin is currently in motion, ignore request
1150			if(slider.working || slider.active.index == slideIndex) return;
1151			// declare that plugin is in motion
1152			slider.working = true;
1153			// store the old index
1154			slider.oldIndex = slider.active.index;
1155			// if slideIndex is less than zero, set active index to last child (this happens during infinite loop)
1156			if(slideIndex < 0){
1157				slider.active.index = getPagerQty() - 1;
1158			// if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop)
1159			}else if(slideIndex >= getPagerQty()){
1160				slider.active.index = 0;
1161			// set active index to requested slide
1162			}else{
1163				slider.active.index = slideIndex;
1164			}
1165			// onSlideBefore, onSlideNext, onSlidePrev callbacks
1166			slider.settings.onSlideBefore(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
1167			if(direction == 'next'){
1168				slider.settings.onSlideNext(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
1169			}else if(direction == 'prev'){
1170				slider.settings.onSlidePrev(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
1171			}
1172			// check if last slide
1173			slider.active.last = slider.active.index >= getPagerQty() - 1;
1174			// update the pager with active class
1175			if(slider.settings.pager) updatePagerActive(slider.active.index);
1176			// // check for direction control update
1177			if(slider.settings.controls) updateDirectionControls();
1178			// if slider is set to mode: "fade"
1179			if(slider.settings.mode == 'fade'){
1180				// if adaptiveHeight is true and next height is different from current height, animate to the new height
1181				if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){
1182					slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
1183				}
1184				// fade out the visible child and reset its z-index value
1185				slider.children.filter(':visible').fadeOut(slider.settings.speed).css({zIndex: 0});
1186				// fade in the newly requested slide
1187				slider.children.eq(slider.active.index).css('zIndex', slider.settings.slideZIndex+1).fadeIn(slider.settings.speed, function(){
1188					$(this).css('zIndex', slider.settings.slideZIndex);
1189					updateAfterSlideTransition();
1190				});
1191			// slider mode is not "fade"
1192			}else{
1193				// if adaptiveHeight is true and next height is different from current height, animate to the new height
1194				if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHe
1194ight()){
1195					slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
1196				}
1197				var moveBy = 0;
1198				var position = {left: 0, top: 0};
1199				// if carousel and not infinite loop
1200				if(!slider.settings.infiniteLoop && slider.carousel && slider.active.last){
1201					if(slider.settings.mode == 'horizontal'){
1202						// get the last child position
1203						var lastChild = slider.children.eq(slider.children.length - 1);
1204						position = lastChild.position();
1205						// calculate the position of the last slide
1206						moveBy = slider.viewport.width() - lastChild.outerWidth();
1207					}else{
1208						// get last showing index position
1209						var lastShowingIndex = slider.children.length - slider.settings.minSlides;
1210						position = slider.children.eq(lastShowingIndex).position();
1211					}
1212					// horizontal carousel, going previous while on first slide (infiniteLoop mode)
1213				}else if(slider.carousel && slider.active.last && direction == 'prev'){
1214					// get the last child position
1215					var eq = slider.settings.moveSlides == 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides);
1216					var lastChild = el.children('.bx-clone').eq(eq);
1217					position = lastChild.position();
1218				// if infinite loop and "Next" is clicked on the last slide
1219				}else if(direction == 'next' && slider.active.index == 0){
1220					// get the last clone position
1221					position = el.find('> .bx-clone').eq(slider.settings.maxSlides).position();
1222					slider.active.last = false;
1223				// normal non-zero requests
1224				}else if(slideIndex >= 0){
1225					var requestEl = slideIndex * getMoveBy();
1226					position = slider.children.eq(requestEl).position();
1227				}
1228
1229				/* If the position doesn't exist
1230				 * (e.g. if you destroy the slider on a next click),
1231				 * it doesn't throw an error.
1232				 */
1233				if ("undefined" !== typeof(position)) {
1234					var value = slider.settings.mode == 'horizontal' ? -(position.left - moveBy) : -position.top;
1235					// plugin values to be animated
1236					setPositionProperty(value, 'slide', slider.settings.speed);
1237				}
1238			}
1239		}
1240
1241		/**
1242		 * Transitions to the next slide in the show
1243		 */
1244		el.goToNextSlide = function(){
1245			// if infiniteLoop is false and last page is showing, disregard call
1246			if (!slider.settings.infiniteLoop && slider.active.last) return;
1247			var pagerIndex = parseInt(slider.active.index) + 1;
1248			el.goToSlide(pagerIndex, 'next');
1249		}
1250
1251		/**
1252		 * Transitions to the prev slide in the show
1253		 */
1254		el.goToPrevSlide = function(){
1255			// if infiniteLoop is false and last page is showing, disregard call
1256			if (!slider.settings.infiniteLoop && slider.active.index == 0) return;
1257			var pagerIndex = parseInt(slider.active.index) - 1;
1258			el.goToSlide(pagerIndex, 'prev');
1259		}
1260
1261		/**
1262		 * Starts the auto show
1263		 *
1264		 * @param preventControlUpdate (boolean)
1265		 *  - if true, auto controls state will not be updated
1266		 */
1267		el.startAuto = function(preventControlUpdate){
1268			// if an interval already exists, disregard call
1269			if(slider.interval) return;
1270			// create an interval
1271			slider.interval = setInterval(function(){
1272				slider.settings.autoDirection == 'next' ? el.goToNextSlide() : el.goToPrevSlide();
1273			}, slider.settings.pause);
1274			// if auto controls are displayed and preventControlUpdate is not true
1275			if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('stop');
1276		}
1277
1278		/**
1279		 * Stops the auto show
1280		 *
1281		 * @param preventControlUpdate (boolean)
1282		 *  - if true, auto controls state will not be updated
1283		 */
1284		el.stopAuto = function(preventControlUpdate){
1285			// if no interval exists, disregard call
1286			if(!slider.interval) return;
1287			// clear the interval
1288			clearInterval(slider.interval);
1289			slider.interval = null;
1290			// if auto controls are displayed and preventControlUpdate is not true
1291			if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('start');
1292		}
1293
1294		/**
1295		 * Returns current slide index (zero-based)
1296		 */
1297		el.getCurrentSlide = function(){
1298			return slider.active.index;
1299		}
1300
1301		/**
1302		 * Returns current slide element
1303		 */
1304		el.getCurrentSlideElement = function(){
1305			return slider.children.eq(slider.active.index);
1306		}
1307
1308		/**
1309		 * Returns number of slides in show
1310		 */
1311		el.getSlideCount = function(){
1312			return slider.children.length;
1313		}
1314
1315		/**
1316		 * Update all dynamic slider elements
1317		 */
1318		el.redrawSlider = function(){
1319			// resize all children in ratio to new screen size
1320			slider.children.add(el.find('.bx-clone')).width(getSlideWidth());
1321			// adjust the height
1322			slider.viewport.css('height', getViewportHeight());
1323			// update the slide position
1324			if(!slider.settings.ticker) setSlidePosition();
1325			// if active.last was true before the screen resize, we want
1326			// to keep it last no matter what screen size we end on
1327			if (slider.active.last) slider.active.index = getPagerQty() - 1;
1328			// if the active index (page) no longer exists due to the resize, simply set the index as last
1329			if (slider.active.index >= getPagerQty()) slider.active.last = true;
1330			// if a pager is being displayed and a custom pager is not being used, update it
1331			if(slider.settings.pager && !slider.settings.pagerCustom){
1332				populatePager();
1333				updatePagerActive(slider.active.index);
1334			}
1335		}
1336
1337		/**
1338		 * Destroy the current instance of the slider (revert everything back to original state)
1339		 */
1340		el.destroySlider = function(){
1341			// don't do anything if slider has already been destroyed
1342			if(!slider.initialized) return;
1343			slider.initialized = false;
1344			$('.bx-clone', this).remove();
1345			slider.children.each(function() {
1346				$(this).data("origStyle") != undefined ? $(this).attr("style", $(this).data("origStyle")) : $(this).removeAttr('style');
1347			});
1348			$(this).data("origStyle") != undefined ? this.attr("style", $(this).data("origStyle")) : $(this).removeAttr('style');
1349			$(this).unwrap().unwrap();
1350			if(slider.controls.el) slider.controls.el.remove();
1351			if(slider.controls.next) slider.controls.next.remove();
1352			if(slider.controls.prev) slider.controls.prev.remove();
1353			if(slider.pagerEl && slider.settings.controls) slider.pagerEl.remove();
1354			$('.bx-caption', this).remove();
1355			if(slider.controls.autoEl) slider.controls.autoEl.remove();
1356			clearInterval(slider.interval);
1357			if(slider.settings.responsive) $(window).unbind('resize', resizeWindow);
1358		}
1359
1360		/**
1361		 * Reload the slider (revert all DOM changes, and re-initialize)
1362		 */
1363		el.reloadSlider = function(settings){
1364			if (settings != undefined) options = settings;
1365			el.destroySlider();
1366			init();
1367		}
1368
1369		init();
1370
1371		// returns the current jQuery object
1372		return this;
1373	}
1374
1375})(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.