PageSourceSearch

https://horrorworld.org/wp-content/plugins/continuous-image-carous…bnail-slider-plus-lightbox-jc.js?ver=1.0.13

js horrorworld.org collected 2026-10-02 12:16:38 UTC 71,116 bytes, 1,712 lines download raw bytes

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