PageSourceSearch

https://static.lfppt.com/scripts/jquery.bxslider.js

js lfppt.com collected 2026-10-07 03:04:44 UTC 51,588 bytes, 1,334 lines download raw bytes

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