PageSourceSearch

https://www.badger.ru/bitrix/templates/aspro_max/vendor/js/jquery.bxslider.js

js badger.ru collected 2026-09-24 09:44:41 UTC 66,080 bytes, 1,616 lines download raw bytes

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