PageSourceSearch

https://larachecity.com/template/js/jquery.bxslider.js

js larachecity.com collected 2026-10-03 02:35:53 UTC 65,577 bytes, 1,617 lines download raw bytes

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