PageSourceSearch

https://contents.oricon.co.jp/pc/js/_parts/libs/jquery.bxslider.js

js oricon.co.jp collected 2026-09-24 08:29:41 UTC 49,735 bytes, 1,320 lines download raw bytes

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