PageSourceSearch

https://www.perfectautocollection.com/wp-content/themes/aanWordpress/assets/js/owl.carousel.js

js perfectautocollection.com collected 2026-10-01 05:32:04 UTC 113,052 bytes, 3,461 lines download raw bytes

vendor: 112,933 bytes, lines 1-3457
1/**
2 * Owl Carousel v2.3.4
3 * Copyright 2013-2018 David Deutsch
4 * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
5 */
6/**
7 * Owl carousel
8 * @version 2.3.4
9 * @author Bartosz Wojciechowski
10 * @author David Deutsch
11 * @license The MIT License (MIT)
12 * @todo Lazy Load Icon
13 * @todo prevent animationend bubling
14 * @todo itemsScaleUp
15 * @todo Test Zepto
16 * @todo stagePadding calculate wrong active classes
17 */
18;
19(function($, window, document, undefined) {
20
21    /**
22     * Creates a carousel.
23     * @class The Owl Carousel.
24     * @public
25     * @param {HTMLElement|jQuery} element - The element to create the carousel for.
26     * @param {Object} [options] - The options
27     */
28    function Owl(element, options) {
29
30        /**
31         * Current settings for the carousel.
32         * @public
33         */
34        this.settings = null;
35
36        /**
37         * Current options set by the caller including defaults.
38         * @public
39         */
40        this.options = $.extend({}, Owl.Defaults, options);
41
42        /**
43         * Plugin element.
44         * @public
45         */
46        this.$element = $(element);
47
48        /**
49         * Proxied event handlers.
50         * @protected
51         */
52        this._handlers = {};
53
54        /**
55         * References to the running plugins of this carousel.
56         * @protected
57         */
58        this._plugins = {};
59
60        /**
61         * Currently suppressed events to prevent them from being retriggered.
62         * @protected
63         */
64        this._supress = {};
65
66        /**
67         * Absolute current position.
68         * @protected
69         */
70        this._current = null;
71
72        /**
73         * Animation speed in milliseconds.
74         * @protected
75         */
76        this._speed = null;
77
78        /**
79         * Coordinates of all items in pixel.
80         * @todo The name of this member is missleading.
81         * @protected
82         */
83        this._coordinates = [];
84
85        /**
86         * Current breakpoint.
87         * @todo Real media queries would be nice.
88         * @protected
89         */
90        this._breakpoint = null;
91
92        /**
93         * Current width of the plugin element.
94         */
95        this._width = null;
96
97        /**
98         * All real items.
99         * @protected
100         */
101        this._items = [];
102
103        /**
104         * All cloned items.
105         * @protected
106         */
107        this._clones = [];
108
109        /**
110         * Merge values of all items.
111         * @todo Maybe this could be part of a plugin.
112         * @protected
113         */
114        this._mergers = [];
115
116        /**
117         * Widths of all items.
118         */
119        this._widths = [];
120
121        /**
122         * Invalidated parts within the update process.
123         * @protected
124         */
125        this._invalidated = {};
126
127        /**
128         * Ordered list of workers for the update process.
129         * @protected
130         */
131        this._pipe = [];
132
133        /**
134         * Current state information for the drag operation.
135         * @todo #261
136         * @protected
137         */
138        this._drag = {
139            time: null,
140            target: null,
141            pointer: null,
142            stage: {
143                start: null,
144                current: null
145            },
146            direction: null
147        };
148
149        /**
150         * Current state information and their tags.
151         * @type {Object}
152         * @protected
153         */
154        this._states = {
155            current: {},
156            tags: {
157                'initializing': ['busy'],
158                'animating': ['busy'],
159                'dragging': ['interacting']
160            }
161        };
162
163        $.each(['onResize', 'onThrottledResize'], $.proxy(function(i, handler) {
164            this._handlers[handler] = $.proxy(this[handler], this);
165        }, this));
166
167        $.each(Owl.Plugins, $.proxy(function(key, plugin) {
168            this._plugins[key.charAt(0).toLowerCase() + key.slice(1)] = new plugin(this);
169        }, this));
170
171        $.each(Owl.Workers, $.proxy(function(priority, worker) {
172            this._pipe.push({
173                'filter': worker.filter,
174                'run': $.proxy(worker.run, this)
175            });
176        }, this));
177
178        this.setup();
179        this.initialize();
180    }
181
182    /**
183     * Default options for the carousel.
184     * @public
185     */
186    Owl.Defaults = {
187        items: 3,
188        loop: false,
189        center: false,
190        rewind: false,
191        checkVisibility: true,
192
193        mouseDrag: true,
194        touchDrag: true,
195        pullDrag: true,
196        freeDrag: false,
197
198        margin: 0,
199        stagePadding: 0,
200
201        merge: false,
202        mergeFit: true,
203        autoWidth: false,
204
205        startPosition: 0,
206        rtl: false,
207
208        smartSpeed: 250,
209        fluidSpeed: false,
210        dragEndSpeed: false,
211
212        responsive: {},
213        responsiveRefreshRate: 200,
214        responsiveBaseElement: window,
215
216        fallbackEasing: 'swing',
217        slideTransition: '',
218
219        info: false,
220
221        nestedItemSelector: false,
222        itemElement: 'div',
223        stageElement: 'div',
224
225        refreshClass: 'owl-refresh',
226        loadedClass: 'owl-loaded',
227        loadingClass: 'owl-loading',
228        rtlClass: 'owl-rtl',
229        responsiveClass: 'owl-responsive',
230        dragClass: 'owl-drag',
231        itemClass: 'owl-item',
232        stageClass: 'owl-stage',
233        stageOuterClass: 'owl-stage-outer',
234        grabClass: 'owl-grab'
235    };
236
237    /**
238     * Enumeration for width.
239     * @public
240     * @readonly
241     * @enum {String}
242     */
243    Owl.Width = {
244        Default: 'default',
245        Inner: 'inner',
246        Outer: 'outer'
247    };
248
249    /**
250     * Enumeration for types.
251     * @public
252     * @readonly
253     * @enum {String}
254     */
255    Owl.Type = {
256        Event: 'event',
257        State: 'state'
258    };
259
260    /**
261     * Contains all registered plugins.
262     * @public
263     */
264    Owl.Plugins = {};
265
266    /**
267     * List of workers involved in the update process.
268     */
269    Owl.Workers = [{
270        filter: ['width', 'settings'],
271        run: function() {
272            this._width = this.$element.width();
273        }
274    }, {
275        filter: ['width', 'items', 'settings'],
276        run: function(cache) {
277            cache.current = this._items && this._items[this.relative(this._current)];
278        }
279    }, {
280        filter: ['items', 'settings'],
281        run: function() {
282            this.$stage.children('.cloned').remove();
283        }
284    }, {
285        filter: ['width', 'items', 'settings'],
286        run: function(cache) {
287            var margin = this.settings.margin || '',
288                grid = !this.settings.autoWidth,
289                rtl = this.settings.rtl,
290                css = {
291                    'width': 'auto',
292                    'margin-left': rtl ? margin : '',
293                    'margin-right': rtl ? '' : margin
294                };
295
296            !grid && this.$stage.children().css(css);
297
298            cache.css = css;
299        }
300    }, {
301        filter: ['width', 'items', 'settings'],
302        run: function(cache) {
303            var width = (this.width() / this.settings.items).toFixed(3) - this.settings.margin,
304                merge = null,
305                iterator = this._items.length,
306                grid = !this.settings.autoWidth,
307                widths = [];
308
309            cache.items = {
310                merge: false,
311                width: width
312            };
313
314            while (iterator--) {
315                merge = this._mergers[iterator];
316                merge = this.settings.mergeFit && Math.min(merge, this.settings.items) || merge;
317
318                cache.items.merge = merge > 1 || cache.items.merge;
319
320                widths[iterator] = !grid ? this._items[iterator].width() : width * merge;
321            }
322
323            this._widths = widths;
324        }
325    }, {
326        filter: ['items', 'settings'],
327        run: function() {
328            var clones = [],
329                items = this._items,
330                settings = this.settings,
331                // TODO: Should be computed from number of min width items in stage
332                view = Math.max(settings.items * 2, 4),
333                size = Math.ceil(items.length / 2) * 2,
334                repeat = settings.loop && items.length ? settings.rewind ? view : Math.max(view, size) : 0,
335                append = '',
336                prepend = '';
337
338            repeat /= 2;
339
340            while (repeat > 0) {
341                // Switch to only using appended clones
342                clones.push(this.normalize(clones.length / 2, true));
343                append = append + items[clones[clones.length - 1]][0].outerHTML;
344                clones.push(this.normalize(items.length - 1 - (clones.length - 1) / 2, true));
345                prepend = items[clones[clones.length - 1]][0].outerHTML + prepend;
346                repeat -= 1;
347            }
348
349            this._clones = clones;
350
351            $(append).addClass('cloned').appendTo(this.$stage);
352            $(prepend).addClass('cloned').prependTo(this.$stage);
353        }
354    }, {
355        filter: ['width', 'items', 'settings'],
356        run: function() {
357            var rtl = this.settings.rtl ? 1 : -1,
358                size = this._clones.length + this._items.length,
359                iterator = -1,
360                previous = 0,
361                current = 0,
362                coordinates = [];
363
364            while (++iterator < size) {
365                previous = coordinates[iterator - 1] || 0;
366                current = this._widths[this.relative(iterator)] + this.settings.margin;
367                coordinates.push(previous + current * rtl);
368            }
369
370            this._coordinates = coordinates;
371        }
372    }, {
373        filter: ['width', 'items', 'settings'],
374        run: function() {
375            var padding = this.settings.stagePadding,
376                coordinates = this._coordinates,
377                css = {
378                    'width': Math.ceil(Math.abs(coordinates[coordinates.length - 1])) + padding * 2,
379                    'padding-left': padding || '',
380                    'padding-right': padding || ''
381                };
382
383            this.$stage.css(css);
384        }
385    }, {
386        filter: ['width', 'items', 'settings'],
387        run: function(cache) {
388            var iterator = this._coordinates.length,
389                grid = !this.settings.autoWidth,
390                items = this.$stage.children();
391
392            if (grid && cache.items.merge) {
393                while (iterator--) {
394                    cache.css.width = this._widths[this.relative(iterator)];
395                    items.eq(iterator).css(cache.css);
396                }
397            } else if (grid) {
398                cache.css.width = cache.items.width;
399                items.css(cache.css);
400            }
401        }
402    }, {
403        filter: ['items'],
404        run: function() {
405            this._coordinates.length < 1 && this.$stage.removeAttr('style');
406        }
407    }, {
408        filter: ['width', 'items', 'settings'],
409        run: function(cache) {
410            cache.current = cache.current ? this.$stage.children().index(cache.current) : 0;
411            cache.current = Math.max(this.minimum(), Math.min(this.maximum(), cache.current));
412            this.reset(cache.current);
413        }
414    }, {
415        filter: ['position'],
416        run: function() {
417            this.animate(this.coordinates(this._current));
418        }
419    }, {
420        filter: ['width', 'position', 'items', 'settings'],
421        run: function() {
422            var rtl = this.settings.rtl ? 1 : -1,
423                padding = this.settings.stagePadding * 2,
424                begin = this.coordinates(this.current()) + padding,
425                end = begin + this.width() * rtl,
426                inner, outer, matches = [],
427                i, n;
428
429            for (i = 0, n = this._coordinates.length; i < n; i++) {
430                inner = this._coordinates[i - 1] || 0;
431                outer = Math.abs(this._coordinates[i]) + padding * rtl;
432
433                if ((this.op(inner, '<=', begin) && (this.op(inner, '>', end))) ||
434                    (this.op(outer, '<', begin) && this.op(outer, '>', end))) {
435                    matches.push(i);
436                }
437            }
438
439            this.$stage.children('.active').removeClass('active');
440            this.$stage.children(':eq(' + matches.join('), :eq(') + ')').addClass('active');
441
442            this.$stage.children('.center').removeClass('center');
443            if (this.settings.center) {
444                this.$stage.children().eq(this.current()).addClass('center');
445            }
446        }
447    }];
448
449    /**
450     * Create the stage DOM element
451     */
452    Owl.prototype.initializeStage = function() {
453        this.$stage = this.$element.find('.' + this.settings.stageClass);
454
455        // if the stage is already in the DOM, grab it and skip stage initialization
456        if (this.$stage.length) {
457            return;
458        }
459
460        this.$element.addClass(this.options.loadingClass);
461
462        // create stage
463        this.$stage = $('<' + this.settings.stageElement + '>', {
464            "class": this.settings.stageClass
465        }).wrap($('<div/>', {
466            "class": this.settings.stageOuterClass
467        }));
468
469        // append stage
470        this.$element.append(this.$stage.parent());
471    };
472
473    /**
474     * Create item DOM elements
475     */
476    Owl.prototype.initializeItems = function() {
477        var $items = this.$element.find('.owl-item');
478
479        // if the items are already in the DOM, grab them and skip item initialization
480        if ($items.length) {
481            this._items = $items.get().map(function(item) {
482                return $(item);
483            });
484
485            this._mergers = this._items.map(function() {
486                return 1;
487            });
488
489            this.refresh();
490
491            return;
492        }
493
494        // append content
495        this.replace(this.$element.children().not(this.$stage.parent()));
496
497        // check visibility
498        if (this.isVisible()) {
499            // update view
500            this.refresh();
501        } else {
502            // invalidate width
503            this.invalidate('width');
504        }
505
506        this.$element
507            .removeClass(this.options.loadingClass)
508            .addClass(this.options.loadedClass);
509    };
510
511    /**
512     * Initializes the carousel.
513     * @protected
514     */
515    Owl.prototype.initialize = function() {
516        this.enter('initializing');
517        this.trigger('initialize');
518
519        this.$element.toggleClass(this.settings.rtlClass, this.settings.rtl);
520
521        if (this.settings.autoWidth && !this.is('pre-loading')) {
522            var imgs, nestedSelector, width;
523            imgs = this.$element.find('img');
524            nestedSelector = this.settings.nestedItemSelector ? '.' + this.settings.nestedItemSelector : undefined;
525            width = this.$element.children(nestedSelector).width();
526
527            if (imgs.length && width <= 0) {
528                this.preloadAutoWidthImages(imgs);
529            }
530        }
531
532        this.initializeStage();
533        this.initializeItems();
534
535        // register event handlers
536        this.registerEventHandlers();
537
538        this.leave('initializing');
539        this.trigger('initialized');
540    };
541
542    /**
543     * @returns {Boolean} visibility of $element
544     *                    if you know the carousel will always be visible you can set `checkVisibility` to `false` to
545     *                    prevent the expensive browser layout forced reflow the $element.is(':visible') does
546     */
547    Owl.prototype.isVisible = function() {
548        return this.settings.checkVisibility ?
549            this.$element.is(':visible') :
550            true;
551    };
552
553    /**
554     * Setups the current settings.
555     * @todo Remove responsive classes. Why should adaptive designs be brought into IE8?
556     * @todo Support for media queries by using `matchMedia` would be nice.
557     * @public
558     */
559    Owl.prototype.setup = function() {
560        var viewport = this.viewport(),
561            overwrites = this.options.responsive,
562            match = -1,
563            settings = null;
564
565        if (!overwrites) {
566            settings = $.extend({}, this.options);
567        } else {
568            $.each(overwrites, function(breakpoint) {
569                if (breakpoint <= viewport && breakpoint > match) {
570                    match = Number(breakpoint);
571                }
572            });
573
574            settings = $.extend({}, this.options, overwrites[match]);
575            if (typeof settings.stagePadding === 'function') {
576                settings.stagePadding = settings.stagePadding();
577            }
578            delete settings.responsive;
579
580            // responsive class
581            if (settings.responsiveClass) {
582                this.$element.attr('class',
583                    this.$element.attr('class').replace(new RegExp('(' + this.options.responsiveClass + '-)\\S+\\s', 'g'), '$1' + match)
584                );
585            }
586        }
587
588        this.trigger('change', { property: { name: 'settings', value: settings } });
589        this._breakpoint = match;
590        this.settings = settings;
591        this.invalidate('settings');
592        this.trigger('changed', { property: { name: 'settings', value: this.settings } });
593    };
594
595    /**
596     * Updates option logic if necessery.
597     * @protected
598     */
599    Owl.prototype.optionsLogic = function() {
600        if (this.settings.autoWidth) {
601            this.settings.stagePadding = false;
602            this.settings.merge = false;
603        }
604    };
605
606    /**
607     * Prepares an item before add.
608     * @todo Rename event parameter `content` to `item`.
609     * @protected
610     * @returns {jQuery|HTMLElement} - The item container.
611     */
612    Owl.prototype.prepare = function(item) {
613        var event = this.trigger('prepare', { content: item });
614
615        if (!event.data) {
616            event.data = $('<' + this.settings.itemElement + '/>')
617                .addClass(this.options.itemClass).append(item)
618        }
619
620        this.trigger('prepared', { content: event.data });
621
622        return event.data;
623    };
624
625    /**
626     * Updates the view.
627     * @public
628     */
629    Owl.prototype.update = function() {
630        var i = 0,
631            n = this._pipe.length,
632            filter = $.proxy(function(p) { return this[p] }, this._invalidated),
633            cache = {};
634
635        while (i < n) {
636            if (this._invalidated.all || $.grep(this._pipe[i].filter, filter).length > 0) {
637                this._pipe[i].run(cache);
638            }
639            i++;
640        }
641
642        this._invalidated = {};
643
644        !this.is('valid') && this.enter('valid');
645    };
646
647    /**
648     * Gets the width of the view.
649     * @public
650     * @param {Owl.Width} [dimension=Owl.Width.Default] - The dimension to return.
651     * @returns {Number} - The width of the view in pixel.
652     */
653    Owl.prototype.width = function(dimension) {
654        dimension = dimension || Owl.Width.Default;
655        switch (dimension) {
656            case Owl.Width.Inner:
657            case Owl.Width.Outer:
658                return this._width;
659            default:
660                return this._width - this.settings.stagePadding * 2 + this.settings.margin;
661        }
662    };
663
664    /**
665     * Refreshes the carousel primarily for adaptive purposes.
666     * @public
667     */
668    Owl.prototype.refresh = function() {
669        this.enter('refreshing');
670        this.trigger('refresh');
671
672        this.setup();
673
674        this.optionsLogic();
675
676        this.$element.addClass(this.options.refreshClass);
677
678        this.update();
679
680        this.$element.removeClass(this.options.refreshClass);
681
682        this.leave('refreshing');
683        this.trigger('refreshed');
684    };
685
686    /**
687     * Checks window `resize` event.
688     * @protected
689     */
690    Owl.prototype.onThrottledResize = function() {
691        window.clearTimeout(this.resizeTimer);
692        this.resizeTimer = window.setTimeout(this._handlers.onResize, this.settings.responsiveRefreshRate);
693    };
694
695    /**
696     * Checks window `resize` event.
697     * @protected
698     */
699    Owl.prototype.onResize = function() {
700        if (!this._items.length) {
701            return false;
702        }
703
704        if (this._width === this.$element.width()) {
705            return false;
706        }
707
708        if (!this.isVisible()) {
709            return false;
710        }
711
712        this.enter('resizing');
713
714        if (this.trigger('resize').isDefaultPrevented()) {
715            this.leave('resizing');
716            return false;
717        }
718
719        this.invalidate('width');
720
721        this.refresh();
722
723        this.leave('resizing');
724        this.trigger('resized');
725    };
726
727    /**
728     * Registers event handlers.
729     * @todo Check `msPointerEnabled`
730     * @todo #261
731     * @protected
732     */
733    Owl.prototype.registerEventHandlers = function() {
734        if ($.support.transition) {
735            this.$stage.on($.support.transition.end + '.owl.core', $.proxy(this.onTransitionEnd, this));
736        }
737
738        if (this.settings.responsive !== false) {
739            this.on(window, 'resize', this._handlers.onThrottledResize);
740        }
741
742        if (this.settings.mouseDrag) {
743            this.$element.addClass(this.options.dragClass);
744            this.$stage.on('mousedown.owl.core', $.proxy(this.onDragStart, this));
745            this.$stage.on('dragstart.owl.core selectstart.owl.core', function() { return false });
746        }
747
748        if (this.settings.touchDrag) {
749            this.$stage.on('touchstart.owl.core', $.proxy(this.onDragStart, this));
750            this.$stage.on('touchcancel.owl.core', $.proxy(this.onDragEnd, this));
751        }
752    };
753
754    /**
755     * Handles `touchstart` and `mousedown` events.
756     * @todo Horizontal swipe threshold as option
757     * @todo #261
758     * @protected
759     * @param {Event} event - The event arguments.
760     */
761    Owl.prototype.onDragStart = function(event) {
762        var stage = null;
763
764        if (event.which === 3) {
765            return;
766        }
767
768        if ($.support.transform) {
769            stage = this.$stage.css('transform').replace(/.*\(|\)| /g, '').split(',');
770            stage = {
771                x: stage[stage.length === 16 ? 12 : 4],
772                y: stage[stage.length === 16 ? 13 : 5]
773            };
774        } else {
775            stage = this.$stage.position();
776            stage = {
777                x: this.settings.rtl ?
778                    stage.left + this.$stage.width() - this.width() + this.settings.margin : stage.left,
779                y: stage.top
780            };
781        }
782
783        if (this.is('animating')) {
784            $.support.transform ? this.animate(stage.x) : this.$stage.stop()
785            this.invalidate('position');
786        }
787
788        this.$element.toggleClass(this.options.grabClass, event.type === 'mousedown');
789
790        this.speed(0);
791
792        this._drag.time = new Date().getTime();
793        this._drag.target = $(event.target);
794        this._drag.stage.start = stage;
795        this._drag.stage.current = stage;
796        this._drag.pointer = this.pointer(event);
797
798        $(document).on('mouseup.owl.core touchend.owl.core', $.proxy(this.onDragEnd, this));
799
800        $(document).one('mousemove.owl.core touchmove.owl.core', $.proxy(function(event) {
801            var delta = this.difference(this._drag.pointer, this.pointer(event));
802
803            $(document).on('mousemove.owl.core touchmove.owl.core', $.proxy(this.onDragMove, this));
804
805            if (Math.abs(delta.x) < Math.abs(delta.y) && this.is('valid')) {
806                return;
807            }
808
809            event.preventDefault();
810
811            this.enter('dragging');
812            this.trigger('drag');
813        }, this));
814    };
815
816    /**
817     * Handles the `touchmove` and `mousemove` events.
818     * @todo #261
819     * @protected
820     * @param {Event} event - The event arguments.
821     */
822    Owl.prototype.onDragMove = function(event) {
823        var minimum = null,
824            maximum = null,
825            pull = null,
826            delta = this.difference(this._drag.pointer, this.pointer(event)),
827            stage = this.difference(this._drag.stage.start, delta);
828
829        if (!this.is('dragging')) {
830            return;
831        }
832
833        event.preventDefault();
834
835        if (this.settings.loop) {
836            minimum = this.coordinates(this.minimum());
837            maximum = this.coordinates(this.maximum() + 1) - minimum;
838            stage.x = (((stage.x - minimum) % maximum + maximum) % maximum) + minimum;
839        } else {
840            minimum = this.settings.rtl ? this.coordinates(this.maximum()) : this.coordinates(this.minimum());
841            maximum = this.settings.rtl ? this.coordinates(this.minimum()) : this.coordinates(this.maximum());
842            pull = this.settings.pullDrag ? -1 * delta.x / 5 : 0;
843            stage.x = Math.max(Math.min(stage.x, minimum + pull), maximum + pull);
844        }
845
846        this._drag.stage.current = stage;
847
848        this.animate(stage.x);
849    };
850
851    /**
852     * Handles the `touchend` and `mouseup` events.
853     * @todo #261
854     * @todo Threshold for click event
855     * @protected
856     * @param {Event} event - The event arguments.
857     */
858    Owl.prototype.onDragEnd = function(event) {
859        var delta = this.difference(this._drag.pointer, this.pointer(event)),
860            stage = this._drag.stage.current,
861            direction = delta.x > 0 ^ this.settings.rtl ? 'left' : 'right';
862
863        $(document).off('.owl.core');
864
865        this.$element.removeClass(this.options.grabClass);
866
867        if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) {
868            this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed);
869            this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction));
870            this.invalidate('position');
871            this.update();
872
873            this._drag.direction = direction;
874
875            if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) {
876                this._drag.target.one('click.owl.core', function() { return false; });
877            }
878        }
879
880        if (!this.is('dragging')) {
881            return;
882        }
883
884        this.leave('dragging');
885        this.trigger('dragged');
886    };
887
888    /**
889     * Gets absolute position of the closest item for a coordinate.
890     * @todo Setting `freeDrag` makes `closest` not reusable. See #165.
891     * @protected
892     * @param {Number} coordinate - The coordinate in pixel.
893     * @param {String} direction - The direction to check for the closest item. Ether `left` or `right`.
894     * @return {Number} - The absolute position of the closest item.
895     */
896    Owl.prototype.closest = function(coordinate, direction) {
897        var position = -1,
898            pull = 30,
899            width = this.width(),
900            coordinates = this.coordinates();
901
902        if (!this.settings.freeDrag) {
903            // check closest item
904            $.each(coordinates, $.proxy(function(index, value) {
905                // on a left pull, check on current index
906                if (direction === 'left' && coordinate > value - pull && coordinate < value + pull) {
907                    position = index;
908                    // on a right pull, check on previous index
909                    // to do so, subtract width from value and set position = index + 1
910                } else if (direction === 'right' && coordinate > value - width - pull && coordinate < value - width + pull) {
911                    position = index + 1;
912                } else if (this.op(coordinate, '<', value) &&
913                    this.op(coordinate, '>', coordinates[index + 1] !== undefined ? coordinates[index + 1] : value - width)) {
914                    position = direction === 'left' ? index + 1 : index;
915                }
916                return position === -1;
917            }, this));
918        }
919
920        if (!this.settings.loop) {
921            // non loop boundries
922            if (this.op(coordinate, '>', coordinates[this.minimum()])) {
923                position = coordinate = this.minimum();
924            } else if (this.op(coordinate, '<', coordinates[this.maximum()])) {
925                position = coordinate = this.maximum();
926            }
927        }
928
929        return position;
930    };
931
932    /**
933     * Animates the stage.
934     * @todo #270
935     * @public
936     * @param {Number} coordinate - The coordinate in pixels.
937     */
938    Owl.prototype.animate = function(coordinate) {
939        var animate = this.speed() > 0;
940
941        this.is('animating') && this.onTransitionEnd();
942
943        if (animate) {
944            this.enter('animating');
945            this.trigger('translate');
946        }
947
948        if ($.support.transform3d && $.support.transition) {
949            this.$stage.css({
950                transform: 'translate3d(' + coordinate + 'px,0px,0px)',
951                transition: (this.speed() / 1000) + 's' + (
952                    this.settings.slideTransition ? ' ' + this.settings.slideTransition : ''
953                )
954            });
955        } else if (animate) {
956            this.$stage.animate({
957                left: coordinate + 'px'
958            }, this.speed(), this.settings.fallbackEasing, $.proxy(this.onTransitionEnd, this));
959        } else {
960            this.$stage.css({
961                left: coordinate + 'px'
962            });
963        }
964    };
965
966    /**
967     * Checks whether the carousel is in a specific state or not.
968     * @param {String} state - The state to check.
969     * @returns {Boolean} - The flag which indicates if the carousel is busy.
970     */
971    Owl.prototype.is = function(state) {
972        return this._states.current[state] && this._states.current[state] > 0;
973    };
974
975    /**
976     * Sets the absolute position of the current item.
977     * @public
978     * @param {Number} [position] - The new absolute position or nothing to leave it unchanged.
979     * @returns {Number} - The absolute position of the current item.
980     */
981    Owl.prototype.current = function(position) {
982        if (position === undefined) {
983            return this._current;
984        }
985
986        if (this._items.length === 0) {
987            return undefined;
988        }
989
990        position = this.normalize(position);
991
992        if (this._current !== position) {
993            var event = this.trigger('change', { property: { name: 'position', value: position } });
994
995            if (event.data !== undefined) {
996                position = this.normalize(event.data);
997            }
998
999            this._current = position;
1000
1001            this.invalidate('position');
1002
1003            this.trigger('changed', { property: { name: 'position', value: this._current } });
1004        }
1005
1006        return this._current;
1007    };
1008
1009    /**
1010     * Invalidates the given part of the update routine.
1011     * @param {String} [part] - The part to invalidate.
1012     * @returns {Array.<String>} - The invalidated parts.
1013     */
1014    Owl.prototype.invalidate = function(part) {
1015        if ($.type(part) === 'string') {
1016            this._invalidated[part] = true;
1017            this.is('valid') && this.leave('valid');
1018        }
1019        return $.map(this._invalidated, function(v, i) { return i });
1020    };
1021
1022    /**
1023     * Resets the absolute position of the current item.
1024     * @public
1025     * @param {Number} position - The absolute position of the new item.
1026     */
1027    Owl.prototype.reset = function(position) {
1028        position = this.normalize(position);
1029
1030        if (position === undefined) {
1031            return;
1032        }
1033
1034        this._speed = 0;
1035        this._current = position;
1036
1037        this.suppress(['translate', 'translated']);
1038
1039        this.animate(this.coordinates(position));
1040
1041        this.release(['translate', 'translated']);
1042    };
1043
1044    /**
1045     * Normalizes an absolute or a relative position of an item.
1046     * @public
1047     * @param {Number} position - The absolute or relative position to normalize.
1048     * @param {Boolean} [relative=false] - Whether the given position is relative or not.
1049     * @returns {Number} - The normalized position.
1050     */
1051    Owl.prototype.normalize = function(position, relative) {
1052        var n = this._items.length,
1053            m = relative ? 0 : this._clones.length;
1054
1055        if (!this.isNumeric(position) || n < 1) {
1056            position = undefined;
1057        } else if (position < 0 || position >= n + m) {
1058            position = ((position - m / 2) % n + n) % n + m / 2;
1059        }
1060
1061        return position;
1062    };
1063
1064    /**
1065     * Converts an absolute position of an item into a relative one.
1066     * @public
1067     * @param {Number} position - The absolute position to convert.
1068     * @returns {Number} - The converted position.
1069     */
1070    Owl.prototype.relative = function(position) {
1071        position -= this._clones.length / 2;
1072        return this.normalize(position, true);
1073    };
1074
1075    /**
1076     * Gets the maximum position for the current item.
1077     * @public
1078     * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1079     * @returns {Number}
1080     */
1081    Owl.prototype.maximum = function(relative) {
1082        var settings = this.settings,
1083            maximum = this._coordinates.length,
1084            iterator,
1085            reciprocalItemsWidth,
1086            elementWidth;
1087
1088        if (settings.loop) {
1089            maximum = this._clones.length / 2 + this._items.length - 1;
1090        } else if (settings.autoWidth || settings.merge) {
1091            iterator = this._items.length;
1092            if (iterator) {
1093                reciprocalItemsWidth = this._items[--iterator].width();
1094                elementWidth = this.$element.width();
1095                while (iterator--) {
1096                    reciprocalItemsWidth += this._items[iterator].width() + this.settings.margin;
1097                    if (reciprocalItemsWidth > elementWidth) {
1098                        break;
1099                    }
1100                }
1101            }
1102            maximum = iterator + 1;
1103        } else if (settings.center) {
1104            maximum = this._items.length - 1;
1105        } else {
1106            maximum = this._items.length - settings.items;
1107        }
1108
1109        if (relative) {
1110            maximum -= this._clones.length / 2;
1111        }
1112
1113        return Math.max(maximum, 0);
1114    };
1115
1116    /**
1117     * Gets the minimum position for the current item.
1118     * @public
1119     * @param {Boolean} [relative=false] - Whether to return an absolute position or a relative position.
1120     * @returns {Number}
1121     */
1122    Owl.prototype.minimum = function(relative) {
1123        return relative ? 0 : this._clones.length / 2;
1124    };
1125
1126    /**
1127     * Gets an item at the specified relative position.
1128     * @public
1129     * @param {Number} [position] - The relative position of the item.
1130     * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1131     */
1132    Owl.prototype.items = function(position) {
1133        if (position === undefined) {
1134            return this._items.slice();
1135        }
1136
1137        position = this.normalize(position, true);
1138        return this._items[position];
1139    };
1140
1141    /**
1142     * Gets an item at the specified relative position.
1143     * @public
1144     * @param {Number} [position] - The relative position of the item.
1145     * @return {jQuery|Array.<jQuery>} - The item at the given position or all items if no position was given.
1146     */
1147    Owl.prototype.mergers = function(position) {
1148        if (position === undefined) {
1149            return this._mergers.slice();
1150        }
1151
1152        position = this.normalize(position, true);
1153        return this._mergers[position];
1154    };
1155
1156    /**
1157     * Gets the absolute positions of clones for an item.
1158     * @public
1159     * @param {Number} [position] - The relative position of the item.
1160     * @returns {Array.<Number>} - The absolute positions of clones for the item or all if no position was given.
1161     */
1162    Owl.prototype.clones = function(position) {
1163        var odd = this._clones.length / 2,
1164            even = odd + this._items.length,
1165            map = function(index) { return index % 2 === 0 ? even + index / 2 : odd - (index + 1) / 2 };
1166
1167        if (position === undefined) {
1168            return $.map(this._clones, function(v, i) { return map(i) });
1169        }
1170
1171        return $.map(this._clones, function(v, i) { return v === position ? map(i) : null });
1172    };
1173
1174    /**
1175     * Sets the current animation speed.
1176     * @public
1177     * @param {Number} [speed] - The animation speed in milliseconds or nothing to leave it unchanged.
1178     * @returns {Number} - The current animation speed in milliseconds.
1179     */
1180    Owl.prototype.speed = function(speed) {
1181        if (speed !== undefined) {
1182            this._speed = speed;
1183        }
1184
1185        return this._speed;
1186    };
1187
1188    /**
1189     * Gets the coordinate of an item.
1190     * @todo The name of this method is missleanding.
1191     * @public
1192     * @param {Number} position - The absolute position of the item within `minimum()` and `maximum()`.
1193     * @returns {Number|Array.<Number>} - The coordinate of the item in pixel or all coordinates.
1194     */
1195    Owl.prototype.coordinates = function(position) {
1196        var multiplier = 1,
1197            newPosition = position - 1,
1198            coordinate;
1199
1200        if (position === undefined) {
1201            return $.map(this._coordinates, $.proxy(function(coordinate, index) {
1202                return this.coordinates(index);
1203            }, this));
1204        }
1205
1206        if (this.settings.center) {
1207            if (this.settings.rtl) {
1208                multiplier = -1;
1209                newPosition = position + 1;
1210            }
1211
1212            coordinate = this._coordinates[position];
1213            coordinate += (this.width() - coordinate + (this._coordinates[newPosition] || 0)) / 2 * multiplier;
1214        } else {
1215            coordinate = this._coordinates[newPosition] || 0;
1216        }
1217
1218        coordinate = Math.ceil(coordinate);
1219
1220        return coordinate;
1221    };
1222
1223    /**
1224     * Calculates the speed for a translation.
1225     * @protected
1226     * @param {Number} from - The absolute position of the start item.
1227     * @param {Number} to - The absolute position of the target item.
1228     * @param {Number} [factor=undefined] - The time factor in milliseconds.
1229     * @returns {Number} - The time in milliseconds for the translation.
1230     */
1231    Owl.prototype.duration = function(from, to, factor) {
1232        if (factor === 0) {
1233            return 0;
1234        }
1235
1236        return Math.min(Math.max(Math.abs(to - from), 1), 6) * Math.abs((factor || this.settings.smartSpeed));
1237    };
1238
1239    /**
1240     * Slides to the specified item.
1241     * @public
1242     * @param {Number} position - The position of the item.
1243     * @param {Number} [speed] - The time in milliseconds for the transition.
1244     */
1245    Owl.prototype.to = function(position, speed) {
1246        var current = this.current(),
1247            revert = null,
1248            distance = position - this.relative(current),
1249            direction = (distance > 0) - (distance < 0),
1250            items = this._items.length,
1251            minimum = this.minimum(),
1252            maximum = this.maximum();
1253
1254        if (this.settings.loop) {
1255            if (!this.settings.rewind && Math.abs(distance) > items / 2) {
1256                distance += direction * -1 * items;
1257            }
1258
1259            position = current + distance;
1260            revert = ((position - minimum) % items + items) % items + minimum;
1261
1262            if (revert !== position && revert - distance <= maximum && revert - distance > 0) {
1263                current = revert - distance;
1264                position = revert;
1265                this.reset(current);
1266            }
1267        } else if (this.settings.rewind) {
1268            maximum += 1;
1269            position = (position % maximum + maximum) % maximum;
1270        } else {
1271            position = Math.max(minimum, Math.min(maximum, position));
1272        }
1273
1274        this.speed(this.duration(current, position, speed));
1275        this.current(position);
1276
1277        if (this.isVisible()) {
1278            this.update();
1279        }
1280    };
1281
1282    /**
1283     * Slides to the next item.
1284     * @public
1285     * @param {Number} [speed] - The time in milliseconds for the transition.
1286     */
1287    Owl.prototype.next = function(speed) {
1288        speed = speed || false;
1289        this.to(this.relative(this.current()) + 1, speed);
1290    };
1291
1292    /**
1293     * Slides to the previous item.
1294     * @public
1295     * @param {Number} [speed] - The time in milliseconds for the transition.
1296     */
1297    Owl.prototype.prev = function(speed) {
1298        speed = speed || false;
1299        this.to(this.relative(this.current()) - 1, speed);
1300    };
1301
1302    /**
1303     * Handles the end of an animation.
1304     * @protected
1305     * @param {Event} event - The event arguments.
1306     */
1307    Owl.prototype.onTransitionEnd = function(event) {
1308
1309        // if css2 animation then event object is undefined
1310        if (event !== undefined) {
1311            event.stopPropagation();
1312
1313            // Catch only owl-stage transitionEnd event
1314            if ((event.target || event.srcElement || event.originalTarget) !== this.$stage.get(0)) {
1315                return false;
1316            }
1317        }
1318
1319        this.leave('animating');
1320        this.trigger('translated');
1321    };
1322
1323    /**
1324     * Gets viewport width.
1325     * @protected
1326     * @return {Number} - The width in pixel.
1327     */
1328    Owl.prototype.viewport = function() {
1329        var width;
1330        if (this.options.responsiveBaseElement !== window) {
1331            width = $(this.options.responsiveBaseElement).width();
1332        } else if (window.innerWidth) {
1333            width = window.innerWidth;
1334        } else if (document.documentElement && document.documentElement.clientWidth) {
1335            width = document.documentElement.clientWidth;
1336        } else {
1337            console.warn('Can not detect viewport width.');
1338        }
1339        return width;
1340    };
1341
1342    /**
1343     * Replaces the current content.
1344     * @public
1345     * @param {HTMLElement|jQuery|String} content - The new content.
1346     */
1347    Owl.prototype.replace = function(content) {
1348        this.$stage.empty();
1349        this._items = [];
1350
1351        if (content) {
1352            content = (content instanceof jQuery) ? content : $(content);
1353        }
1354
1355        if (this.settings.nestedItemSelector) {
1356            content = content.find('.' + this.settings.nestedItemSelector);
1357        }
1358
1359        content.filter(function() {
1360            return this.nodeType === 1;
1361        }).each($.proxy(function(index, item) {
1362            item = this.prepare(item);
1363            this.$stage.append(item);
1364            this._items.push(item);
1365            this._mergers.push(item.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1366        }, this));
1367
1368        this.reset(this.isNumeric(this.settings.startPosition) ? this.settings.startPosition : 0);
1369
1370        this.invalidate('items');
1371    };
1372
1373    /**
1374     * Adds an item.
1375     * @todo Use `item` instead of `content` for the event arguments.
1376     * @public
1377     * @param {HTMLElement|jQuery|String} content - The item content to add.
1378     * @param {Number} [position] - The relative position at which to insert the item otherwise the item will be added to the end.
1379     */
1380    Owl.prototype.add = function(content, position) {
1381        var current = this.relative(this._current);
1382
1383        position = position === undefined ? this._items.length : this.normalize(position, true);
1384        content = content instanceof jQuery ? content : $(content);
1385
1386        this.trigger('add', { content: content, position: position });
1387
1388        content = this.prepare(content);
1389
1390        if (this._items.length === 0 || position === this._items.length) {
1391            this._items.length === 0 && this.$stage.append(content);
1392            this._items.length !== 0 && this._items[position - 1].after(content);
1393            this._items.push(content);
1394            this._mergers.push(content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1395        } else {
1396            this._items[position].before(content);
1397            this._items.splice(position, 0, content);
1398            this._mergers.splice(position, 0, content.find('[data-merge]').addBack('[data-merge]').attr('data-merge') * 1 || 1);
1399        }
1400
1401        this._items[current] && this.reset(this._items[current].index());
1402
1403        this.invalidate('items');
1404
1405        this.trigger('added', { content: content, position: position });
1406    };
1407
1408    /**
1409     * Removes an item by its position.
1410     * @todo Use `item` instead of `content` for the event arguments.
1411     * @public
1412     * @param {Number} position - The relative position of the item to remove.
1413     */
1414    Owl.prototype.remove = function(position) {
1415        position = this.normalize(position, true);
1416
1417        if (position === undefined) {
1418            return;
1419        }
1420
1421        this.trigger('remove', { content: this._items[position], position: position });
1422
1423        this._items[position].remove();
1424        this._items.splice(position, 1);
1425        this._mergers.splice(position, 1);
1426
1427        this.invalidate('items');
1428
1429        this.trigger('removed', { content: null, position: position });
1430    };
1431
1432    /**
1433     * Preloads images with auto width.
1434     * @todo Replace by a more generic approach
1435     * @protected
1436     */
1437    Owl.prototype.preloadAutoWidthImages = function(images) {
1438        images.each($.proxy(function(i, element) {
1439            this.enter('pre-loading');
1440            element = $(element);
1441            $(new Image()).one('load', $.proxy(function(e) {
1442                element.attr('src', e.target.src);
1443                element.css('opacity', 1);
1444                this.leave('pre-loading');
1445                !this.is('pre-loading') && !this.is('initializing') && this.refresh();
1446            }, this)).attr('src', element.attr('src') || element.attr('data-src') || element.attr('data-src-retina'));
1447        }, this));
1448    };
1449
1450    /**
1451     * Destroys the carousel.
1452     * @public
1453     */
1454    Owl.prototype.destroy = function() {
1455
1456        this.$element.off('.owl.core');
1457        this.$stage.off('.owl.core');
1458        $(document).off('.owl.core');
1459
1460        if (this.settings.responsive !== false) {
1461            window.clearTimeout(this.resizeTimer);
1462            this.off(window, 'resize', this._handlers.onThrottledResize);
1463        }
1464
1465        for (var i in this._plugins) {
1466            this._plugins[i].destroy();
1467        }
1468
1469        this.$stage.children('.cloned').remove();
1470
1471        this.$stage.unwrap();
1472        this.$stage.children().contents().unwrap();
1473        this.$stage.children().unwrap();
1474        this.$stage.remove();
1475        this.$element
1476            .removeClass(this.options.refreshClass)
1477            .removeClass(this.options.loadingClass)
1478            .removeClass(this.options.loadedClass)
1479            .removeClass(this.options.rtlClass)
1480            .removeClass(this.options.dragClass)
1481            .removeClass(this.options.grabClass)
1482            .attr('class', this.$element.attr('class').replace(new RegExp(this.options.responsiveClass + '-\\S+\\s', 'g'), ''))
1483            .removeData('owl.carousel');
1484    };
1485
1486    /**
1487     * Operators to calculate right-to-left and left-to-right.
1488     * @protected
1489     * @param {Number} [a] - The left side operand.
1490     * @param {String} [o] - The operator.
1491     * @param {Number} [b] - The right side operand.
1492     */
1493    Owl.prototype.op = function(a, o, b) {
1494        var rtl = this.settings.rtl;
1495        switch (o) {
1496            case '<':
1497                return rtl ? a > b : a < b;
1498            case '>':
1499                return rtl ? a < b : a > b;
1500            case '>=':
1501                return rtl ? a <= b : a >= b;
1502            case '<=':
1503                return rtl ? a >= b : a <= b;
1504            default:
1505                break;
1506        }
1507    };
1508
1509    /**
1510     * Attaches to an internal event.
1511     * @protected
1512     * @param {HTMLElement} element - The event source.
1513     * @param {String} event - The event name.
1514     * @param {Function} listener - The event handler to attach.
1515     * @param {Boolean} capture - Wether the event should be handled at the capturing phase or not.
1516     */
1517    Owl.prototype.on = function(element, event, listener, capture) {
1518        if (element.addEventListener) {
1519            element.addEventListener(event, listener, capture);
1520        } else if (element.attachEvent) {
1521            element.attachEvent('on' + event, listener);
1522        }
1523    };
1524
1525    /**
1526     * Detaches from an internal event.
1527     * @protected
1528     * @param {HTMLElement} element - The event source.
1529     * @param {String} event - The event name.
1530     * @param {Function} listener - The attached event handler to detach.
1531     * @param {Boolean} capture - Wether the attached event handler was registered as a capturing listener or not.
1532     */
1533    Owl.prototype.off = function(element, event, listener, capture) {
1534        if (element.removeEventListener) {
1535            element.removeEventListener(event, listener, capture);
1536        } else if (element.detachEvent) {
1537            element.detachEvent('on' + event, listener);
1538        }
1539    };
1540
1541    /**
1542     * Triggers a public event.
1543     * @todo Remove `status`, `relatedTarget` should be used instead.
1544     * @protected
1545     * @param {String} name - The event name.
1546     * @param {*} [data=null] - The event data.
1547     * @param {String} [namespace=carousel] - The event namespace.
1548     * @param {String} [state] - The state which is associated with the event.
1549     * @param {Boolean} [enter=false] - Indicates if the call enters the specified state or not.
1550     * @returns {Event} - The event arguments.
1551     */
1552    Owl.prototype.trigger = function(name, data, namespace, state, enter) {
1553        var status = {
1554                item: { count: this._items.length, index: this.current() }
1555            },
1556            handler = $.camelCase(
1557                $.grep(['on', name, namespace], function(v) { return v })
1558                .join('-').toLowerCase()
1559            ),
1560            event = $.Event(
1561                [name, 'owl', namespace || 'carousel'].join('.').toLowerCase(),
1562                $.extend({ relatedTarget: this }, status, data)
1563            );
1564
1565        if (!this._supress[name]) {
1566            $.each(this._plugins, function(name, plugin) {
1567                if (plugin.onTrigger) {
1568                    plugin.onTrigger(event);
1569                }
1570            });
1571
1572            this.register({ type: Owl.Type.Event, name: name });
1573            this.$element.trigger(event);
1574
1575            if (this.settings && typeof this.settings[handler] === 'function') {
1576                this.settings[handler].call(this, event);
1577            }
1578        }
1579
1580        return event;
1581    };
1582
1583    /**
1584     * Enters a state.
1585     * @param name - The state name.
1586     */
1587    Owl.prototype.enter = function(name) {
1588        $.each([name].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
1589            if (this._states.current[name] === undefined) {
1590                this._states.current[name] = 0;
1591            }
1592
1593            this._states.current[name]++;
1594        }, this));
1595    };
1596
1597    /**
1598     * Leaves a state.
1599     * @param name - The state name.
1600     */
1601    Owl.prototype.leave = function(name) {
1602        $.each([name].concat(this._states.tags[name] || []), $.proxy(function(i, name) {
1603            this._states.current[name]--;
1604        }, this));
1605    };
1606
1607    /**
1608     * Registers an event or state.
1609     * @public
1610     * @param {Object} object - The event or state to register.
1611     */
1612    Owl.prototype.register = function(object) {
1613        if (object.type === Owl.Type.Event) {
1614            if (!$.event.special[object.name]) {
1615                $.event.special[object.name] = {};
1616            }
1617
1618            if (!$.event.special[object.name].owl) {
1619                var _default = $.event.special[object.name]._default;
1620                $.event.special[object.name]._default = function(e) {
1621                    if (_default && _default.apply && (!e.namespace || e.namespace.indexOf('owl') === -1)) {
1622                        return _default.apply(this, arguments);
1623                    }
1624                    return e.namespace && e.namespace.indexOf('owl') > -1;
1625                };
1626                $.event.special[object.name].owl = true;
1627            }
1628        } else if (object.type === Owl.Type.State) {
1629            if (!this._states.tags[object.name]) {
1630                this._states.tags[object.name] = object.tags;
1631            } else {
1632                this._states.tags[object.name] = this._states.tags[object.name].concat(object.tags);
1633            }
1634
1635            this._states.tags[object.name] = $.grep(this._states.tags[object.name], $.proxy(function(tag, i) {
1636                return $.inArray(tag, this._states.tags[object.name]) === i;
1637            }, this));
1638        }
1639    };
1640
1641    /**
1642     * Suppresses events.
1643     * @protected
1644     * @param {Array.<String>} events - The events to suppress.
1645     */
1646    Owl.prototype.suppress = function(events) {
1647        $.each(events, $.proxy(function(index, event) {
1648            this._supress[event] = true;
1649        }, this));
1650    };
1651
1652    /**
1653     * Releases suppressed events.
1654     * @protected
1655     * @param {Array.<String>} events - The events to release.
1656     */
1657    Owl.prototype.release = function(events) {
1658        $.each(events, $.proxy(function(index, event) {
1659            delete this._supress[event];
1660        }, this));
1661    };
1662
1663    /**
1664     * Gets unified pointer coordinates from event.
1665     * @todo #261
1666     * @protected
1667     * @param {Event} - The `mousedown` or `touchstart` event.
1668     * @returns {Object} - Contains `x` and `y` coordinates of current pointer position.
1669     */
1670    Owl.prototype.pointer = function(event) {
1671        var result = { x: null, y: null };
1672
1673        event = event.originalEvent || event || window.event;
1674
1675        event = event.touches && event.touches.length ?
1676            event.touches[0] : event.changedTouches && event.changedTouches.length ?
1677            event.changedTouches[0] : event;
1678
1679        if (event.pageX) {
1680            result.x = event.pageX;
1681            result.y = event.pageY;
1682        } else {
1683            result.x = event.clientX;
1684            result.y = event.clientY;
1685        }
1686
1687        return result;
1688    };
1689
1690    /**
1691     * Determines if the input is a Number or something that can be coerced to a Number
1692     * @protected
1693     * @param {Number|String|Object|Array|Boolean|RegExp|Function|Symbol} - The input to be tested
1694     * @returns {Boolean} - An indication if the input is a Number or can be coerced to a Number
1695     */
1696    Owl.prototype.isNumeric = function(number) {
1697        return !isNaN(parseFloat(number));
1698    };
1699
1700    /**
1701     * Gets the difference of two vectors.
1702     * @todo #261
1703     * @protected
1704     * @param {Object} - The first vector.
1705     * @param {Object} - The second vector.
1706     * @returns {Object} - The difference.
1707     */
1708    Owl.prototype.difference = function(first, second) {
1709        return {
1710            x: first.x - second.x,
1711            y: first.y - second.y
1712        };
1713    };
1714
1715    /**
1716     * The jQuery Plugin for the Owl Carousel
1717     * @todo Navigation plugin `next` and `prev`
1718     * @public
1719     */
1720    $.fn.owlCarousel = function(option) {
1721        var args = Array.prototype.slice.call(arguments, 1);
1722
1723        return this.each(function() {
1724            var $this = $(this),
1725                data = $this.data('owl.carousel');
1726
1727            if (!data) {
1728                data = new Owl(this, typeof option == 'object' && option);
1729                $this.data('owl.carousel', data);
1730
1731                $.each([
1732                    'next', 'prev', 'to', 'destroy', 'refresh', 'replace', 'add', 'remove'
1733                ], function(i, event) {
1734                    data.register({ type: Owl.Type.Event, name: event });
1735                    data.$element.on(event + '.owl.carousel.core', $.proxy(function(e) {
1736                        if (e.namespace && e.relatedTarget !== this) {
1737                            this.suppress([event]);
1738                            data[event].apply(this, [].slice.call(arguments, 1));
1739                            this.release([event]);
1740                        }
1741                    }, data));
1742                });
1743            }
1744
1745            if (typeof option == 'string' && option.charAt(0) !== '_') {
1746                data[option].apply(data, args);
1747            }
1748        });
1749    };
1750
1751    /**
1752     * The constructor for the jQuery Plugin
1753     * @public
1754     */
1755    $.fn.owlCarousel.Constructor = Owl;
1756
1757})(window.Zepto || window.jQuery, window, document);
1758
1759/**
1760 * AutoRefresh Plugin
1761 * @version 2.3.4
1762 * @author Artus Kolanowski
1763 * @author David Deutsch
1764 * @license The MIT License (MIT)
1765 */
1766;
1767(function($, window, document, undefined) {
1768
1769    /**
1770     * Creates the auto refresh plugin.
1771     * @class The Auto Refresh Plugin
1772     * @param {Owl} carousel - The Owl Carousel
1773     */
1774    var AutoRefresh = function(carousel) {
1775        /**
1776         * Reference to the core.
1777         * @protected
1778         * @type {Owl}
1779         */
1780        this._core = carousel;
1781
1782        /**
1783         * Refresh interval.
1784         * @protected
1785         * @type {number}
1786         */
1787        this._interval = null;
1788
1789        /**
1790         * Whether the element is currently visible or not.
1791         * @protected
1792         * @type {Boolean}
1793         */
1794        this._visible = null;
1795
1796        /**
1797         * All event handlers.
1798         * @protected
1799         * @type {Object}
1800         */
1801        this._handlers = {
1802            'initialized.owl.carousel': $.proxy(function(e) {
1803                if (e.namespace && this._core.settings.autoRefresh) {
1804                    this.watch();
1805                }
1806            }, this)
1807        };
1808
1809        // set default options
1810        this._core.options = $.extend({}, AutoRefresh.Defaults, this._core.options);
1811
1812        // register event handlers
1813        this._core.$element.on(this._handlers);
1814    };
1815
1816    /**
1817     * Default options.
1818     * @public
1819     */
1820    AutoRefresh.Defaults = {
1821        autoRefresh: true,
1822        autoRefreshInterval: 500
1823    };
1824
1825    /**
1826     * Watches the element.
1827     */
1828    AutoRefresh.prototype.watch = function() {
1829        if (this._interval) {
1830            return;
1831        }
1832
1833        this._visible = this._core.isVisible();
1834        this._interval = window.setInterval($.proxy(this.refresh, this), this._core.settings.autoRefreshInterval);
1835    };
1836
1837    /**
1838     * Refreshes the element.
1839     */
1840    AutoRefresh.prototype.refresh = function() {
1841        if (this._core.isVisible() === this._visible) {
1842            return;
1843        }
1844
1845        this._visible = !this._visible;
1846
1847        this._core.$element.toggleClass('owl-hidden', !this._visible);
1848
1849        this._visible && (this._core.invalidate('width') && this._core.refresh());
1850    };
1851
1852    /**
1853     * Destroys the plugin.
1854     */
1855    AutoRefresh.prototype.destroy = function() {
1856        var handler, property;
1857
1858        window.clearInterval(this._interval);
1859
1860        for (handler in this._handlers) {
1861            this._core.$element.off(handler, this._handlers[handler]);
1862        }
1863        for (property in Object.getOwnPropertyNames(this)) {
1864            typeof this[property] != 'function' && (this[property] = null);
1865        }
1866    };
1867
1868    $.fn.owlCarousel.Constructor.Plugins.AutoRefresh = AutoRefresh;
1869
1870})(window.Zepto || window.jQuery, window, document);
1871
1872/**
1873 * Lazy Plugin
1874 * @version 2.3.4
1875 * @author Bartosz Wojciechowski
1876 * @author David Deutsch
1877 * @license The MIT License (MIT)
1878 */
1879;
1880(function($, window, document, undefined) {
1881
1882    /**
1883     * Creates the lazy plugin.
1884     * @class The Lazy Plugin
1885     * @param {Owl} carousel - The Owl Carousel
1886     */
1887    var Lazy = function(carousel) {
1888
1889        /**
1890         * Reference to the core.
1891         * @protected
1892         * @type {Owl}
1893         */
1894        this._core = carousel;
1895
1896        /**
1897         * Already loaded items.
1898         * @protected
1899         * @type {Array.<jQuery>}
1900         */
1901        this._loaded = [];
1902
1903        /**
1904         * Event handlers.
1905         * @protected
1906         * @type {Object}
1907         */
1908        this._handlers = {
1909            'initialized.owl.carousel change.owl.carousel resized.owl.carousel': $.proxy(function(e) {
1910                if (!e.namespace) {
1911                    return;
1912                }
1913
1914                if (!this._core.settings || !this._core.settings.lazyLoad) {
1915                    return;
1916                }
1917
1918                if ((e.property && e.property.name == 'position') || e.type == 'initialized') {
1919                    var settings = this._core.settings,
1920                        n = (settings.center && Math.ceil(settings.items / 2) || settings.items),
1921                        i = ((settings.center && n * -1) || 0),
1922                        position = (e.property && e.property.value !== undefined ? e.property.value : this._core.current()) + i,
1923                        clones = this._core.clones().length,
1924                        load = $.proxy(function(i, v) { this.load(v) }, this);
1925                    //TODO: Need documentation for this new option
1926                    if (settings.lazyLoadEager > 0) {
1927                        n += settings.lazyLoadEager;
1928                        // If the carousel is looping also preload images that are to the "left"
1929                        if (settings.loop) {
1930                            position -= settings.lazyLoadEager;
1931                            n++;
1932                        }
1933                    }
1934
1935                    while (i++ < n) {
1936                        this.load(clones / 2 + this._core.relative(position));
1937                        clones && $.each(this._core.clones(this._core.relative(position)), load);
1938                        position++;
1939                    }
1940                }
1941            }, this)
1942        };
1943
1944        // set the default options
1945        this._core.options = $.extend({}, Lazy.Defaults, this._core.options);
1946
1947        // register event handler
1948        this._core.$element.on(this._handlers);
1949    };
1950
1951    /**
1952     * Default options.
1953     * @public
1954     */
1955    Lazy.Defaults = {
1956        lazyLoad: false,
1957        lazyLoadEager: 0
1958    };
1959
1960    /**
1961     * Loads all resources of an item at the specified position.
1962     * @param {Number} position - The absolute position of the item.
1963     * @protected
1964     */
1965    Lazy.prototype.load = function(position) {
1966        var $item = this._core.$stage.children().eq(position),
1967            $elements = $item && $item.find('.owl-lazy');
1968
1969        if (!$elements || $.inArray($item.get(0), this._loaded) > -1) {
1970            return;
1971        }
1972
1973        $elements.each($.proxy(function(index, element) {
1974            var $element = $(element),
1975                image,
1976                url = (window.devicePixelRatio > 1 && $element.attr('data-src-retina')) || $element.attr('data-src') || $element.attr('data-srcset');
1977
1978            this._core.trigger('load', { element: $element, url: url }, 'lazy');
1979
1980            if ($element.is('img')) {
1981                $element.one('load.owl.lazy', $.proxy(function() {
1982                    $element.css('opacity', 1);
1983                    this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1984                }, this)).attr('src', url);
1985            } else if ($element.is('source')) {
1986                $element.one('load.owl.lazy', $.proxy(function() {
1987                    this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1988                }, this)).attr('srcset', url);
1989            } else {
1990                image = new Image();
1991                image.onload = $.proxy(function() {
1992                    $element.css({
1993                        'background-image': 'url("' + url + '")',
1994                        'opacity': '1'
1995                    });
1996                    this._core.trigger('loaded', { element: $element, url: url }, 'lazy');
1997                }, this);
1998                image.src = url;
1999            }
2000        }, this));
2001
2002        this._loaded.push($item.get(0));
2003    };
2004
2005    /**
2006     * Destroys the plugin.
2007     * @public
2008     */
2009    Lazy.prototype.destroy = function() {
2010        var handler, property;
2011
2012        for (handler in this.handlers) {
2013            this._core.$element.off(handler, this.handlers[handler]);
2014        }
2015        for (property in Object.getOwnPropertyNames(this)) {
2016            typeof this[property] != 'function' && (this[property] = null);
2017        }
2018    };
2019
2020    $.fn.owlCarousel.Constructor.Plugins.Lazy = Lazy;
2021
2022})(window.Zepto || window.jQuery, window, document);
2023
2024/**
2025 * AutoHeight Plugin
2026 * @version 2.3.4
2027 * @author Bartosz Wojciechowski
2028 * @author David Deutsch
2029 * @license The MIT License (MIT)
2030 */
2031;
2032(function($, window, document, undefined) {
2033
2034    /**
2035     * Creates the auto height plugin.
2036     * @class The Auto Height Plugin
2037     * @param {Owl} carousel - The Owl Carousel
2038     */
2039    var AutoHeight = function(carousel) {
2040        /**
2041         * Reference to the core.
2042         * @protected
2043         * @type {Owl}
2044         */
2045        this._core = carousel;
2046
2047        this._previousHeight = null;
2048
2049        /**
2050         * All event handlers.
2051         * @protected
2052         * @type {Object}
2053         */
2054        this._handlers = {
2055            'initialized.owl.carousel refreshed.owl.carousel': $.proxy(function(e) {
2056                if (e.namespace && this._core.settings.autoHeight) {
2057                    this.update();
2058                }
2059            }, this),
2060            'changed.owl.carousel': $.proxy(function(e) {
2061                if (e.namespace && this._core.settings.autoHeight && e.property.name === 'position') {
2062                    this.update();
2063                }
2064            }, this),
2065            'loaded.owl.lazy': $.proxy(function(e) {
2066                if (e.namespace && this._core.settings.autoHeight &&
2067                    e.element.closest('.' + this._core.settings.itemClass).index() === this._core.current()) {
2068                    this.update();
2069                }
2070            }, this)
2071        };
2072
2073        // set default options
2074        this._core.options = $.extend({}, AutoHeight.Defaults, this._core.options);
2075
2076        // register event handlers
2077        this._core.$element.on(this._handlers);
2078        this._intervalId = null;
2079        var refThis = this;
2080
2081        // These changes have been taken from a PR by gavrochelegnou proposed in #1575
2082        // and have been made compatible with the latest jQuery version
2083        $(window).on('load', function() {
2084            if (refThis._core.settings.autoHeight) {
2085                refThis.update();
2086            }
2087        });
2088
2089        // Autoresize the height of the carousel when window is resized
2090        // When carousel has images, the height is dependent on the width
2091        // and should also change on resize
2092        $(window).resize(function() {
2093            if (refThis._core.settings.autoHeight) {
2094                if (refThis._intervalId != null) {
2095                    clearTimeout(refThis._intervalId);
2096                }
2097
2098                refThis._intervalId = setTimeout(function() {
2099                    refThis.update();
2100                }, 250);
2101            }
2102        });
2103
2104    };
2105
2106    /**
2107     * Default options.
2108     * @public
2109     */
2110    AutoHeight.Defaults = {
2111        autoHeight: false,
2112        autoHeightClass: 'owl-height'
2113    };
2114
2115    /**
2116     * Updates the view.
2117     */
2118    AutoHeight.prototype.update = function() {
2119        var start = this._core._current,
2120            end = start + this._core.settings.items,
2121            lazyLoadEnabled = this._core.settings.lazyLoad,
2122            visible = this._core.$stage.children().toArray().slice(start, end),
2123            heights = [],
2124            maxheight = 0;
2125
2126        $.each(visible, function(index, item) {
2127            heights.push($(item).height());
2128        });
2129
2130        maxheight = Math.max.apply(null, heights);
2131
2132        if (maxheight <= 1 && lazyLoadEnabled && this._previousHeight) {
2133            maxheight = this._previousHeight;
2134        }
2135
2136        this._previousHeight = maxheight;
2137
2138        this._core.$stage.parent()
2139            .height(maxheight)
2140            .addClass(this._core.settings.autoHeightClass);
2141    };
2142
2143    AutoHeight.prototype.destroy = function() {
2144        var handler, property;
2145
2146        for (handler in this._handlers) {
2147            this._core.$element.off(handler, this._handlers[handler]);
2148        }
2149        for (property in Object.getOwnPropertyNames(this)) {
2150            typeof this[property] !== 'function' && (this[property] = null);
2151        }
2152    };
2153
2154    $.fn.owlCarousel.Constructor.Plugins.AutoHeight = AutoHeight;
2155
2156})(window.Zepto || window.jQuery, window, document);
2157
2158/**
2159 * Video Plugin
2160 * @version 2.3.4
2161 * @author Bartosz Wojciechowski
2162 * @author David Deutsch
2163 * @license The MIT License (MIT)
2164 */
2165;
2166(function($, window, document, undefined) {
2167
2168    /**
2169     * Creates the video plugin.
2170     * @class The Video Plugin
2171     * @param {Owl} carousel - The Owl Carousel
2172     */
2173    var Video = function(carousel) {
2174        /**
2175         * Reference to the core.
2176         * @protected
2177         * @type {Owl}
2178         */
2179        this._core = carousel;
2180
2181        /**
2182         * Cache all video URLs.
2183         * @protected
2184         * @type {Object}
2185         */
2186        this._videos = {};
2187
2188        /**
2189         * Current playing item.
2190         * @protected
2191         * @type {jQuery}
2192         */
2193        this._playing = null;
2194
2195        /**
2196         * All event handlers.
2197         * @todo The cloned content removale is too late
2198         * @protected
2199         * @type {Object}
2200         */
2201        this._handlers = {
2202            'initialized.owl.carousel': $.proxy(function(e) {
2203                if (e.namespace) {
2204                    this._core.register({ type: 'state', name: 'playing', tags: ['interacting'] });
2205                }
2206            }, this),
2207            'resize.owl.carousel': $.proxy(function(e) {
2208                if (e.namespace && this._core.settings.video && this.isInFullScreen()) {
2209                    e.preventDefault();
2210                }
2211            }, this),
2212            'refreshed.owl.carousel': $.proxy(function(e) {
2213                if (e.namespace && this._core.is('resizing')) {
2214                    this._core.$stage.find('.cloned .owl-video-frame').remove();
2215                }
2216            }, this),
2217            'changed.owl.carousel': $.proxy(function(e) {
2218                if (e.namespace && e.property.name === 'position' && this._playing) {
2219                    this.stop();
2220                }
2221            }, this),
2222            'prepared.owl.carousel': $.proxy(function(e) {
2223                if (!e.namespace) {
2224                    return;
2225                }
2226
2227                var $element = $(e.content).find('.owl-video');
2228
2229                if ($element.length) {
2230                    $element.css('display', 'none');
2231                    this.fetch($element, $(e.content));
2232                }
2233            }, this)
2234        };
2235
2236        // set default options
2237        this._core.options = $.extend({}, Video.Defaults, this._core.options);
2238
2239        // register event handlers
2240        this._core.$element.on(this._handlers);
2241
2242        this._core.$element.on('click.owl.video', '.owl-video-play-icon', $.proxy(function(e) {
2243            this.play(e);
2244        }, this));
2245    };
2246
2247    /**
2248     * Default options.
2249     * @public
2250     */
2251    Video.Defaults = {
2252        video: false,
2253        videoHeight: false,
2254        videoWidth: false
2255    };
2256
2257    /**
2258     * Gets the video ID and the type (YouTube/Vimeo/vzaar only).
2259     * @protected
2260     * @param {jQuery} target - The target containing the video data.
2261     * @param {jQuery} item - The item containing the video.
2262     */
2263    Video.prototype.fetch = function(target, item) {
2264        var type = (function() {
2265                if (target.attr('data-vimeo-id')) {
2266                    return 'vimeo';
2267                } else if (target.attr('data-vzaar-id')) {
2268                    return 'vzaar'
2269                } else {
2270                    return 'youtube';
2271                }
2272            })(),
2273            id = target.attr('data-vimeo-id') || target.attr('data-youtube-id') || target.attr('data-vzaar-id'),
2274            width = target.attr('data-width') || this._core.settings.videoWidth,
2275            height = target.attr('data-height') || this._core.settings.videoHeight,
2276            url = target.attr('href');
2277
2278        if (url) {
2279
2280            /*
2281            		Parses the id's out of the following urls (and probably more):
2282            		https://www.youtube.com/watch?v=:id
2283            		https://youtu.be/:id
2284            		https://vimeo.com/:id
2285            		https://vimeo.com/channels/:channel/:id
2286            		https://vimeo.com/groups/:group/videos/:id
2287            		https://app.vzaar.com/videos/:id
2288
2289            		Visual example: https://regexper.com/#(http%3A%7Chttps%3A%7C)%5C%2F%5C%2F(player.%7Cwww.%7Capp.)%3F(vimeo%5C.com%7Cyoutu(be%5C.com%7C%5C.be%7Cbe%5C.googleapis%5C.com)%7Cvzaar%5C.com)%5C%2F(video%5C%2F%7Cvideos%5C%2F%7Cembed%5C%2F%7Cchannels%5C%2F.%2B%5C%2F%7Cgroups%5C%2F.%2B%5C%2F%7Cwatch%5C%3Fv%3D%7Cv%5C%2F)%3F(%5BA-Za-z0-9._%25-%5D*)(%5C%26%5CS%2B)%3F
2290            */
2291
2292            id = url.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/);
2293
2294            if (id[3].indexOf('youtu') > -1) {
2295                type = 'youtube';
2296            } else if (id[3].indexOf('vimeo') > -1) {
2297                type = 'vimeo';
2298            } else if (id[3].indexOf('vzaar') > -1) {
2299                type = 'vzaar';
2300            } else {
2301                throw new Error('Video URL not supported.');
2302            }
2303            id = id[6];
2304        } else {
2305            throw new Error('Missing video URL.');
2306        }
2307
2308        this._videos[url] = {
2309            type: type,
2310            id: id,
2311            width: width,
2312            height: height
2313        };
2314
2315        item.attr('data-video', url);
2316
2317        this.thumbnail(target, this._videos[url]);
2318    };
2319
2320    /**
2321     * Creates video thumbnail.
2322     * @protected
2323     * @param {jQuery} target - The target containing the video data.
2324     * @param {Object} info - The video info object.
2325     * @see `fetch`
2326     */
2327    Video.prototype.thumbnail = function(target, video) {
2328        var tnLink,
2329            icon,
2330            path,
2331            dimensions = video.width && video.height ? 'width:' + video.width + 'px;height:' + video.height + 'px;' : '',
2332            customTn = target.find('img'),
2333            srcType = 'src',
2334            lazyClass = '',
2335            settings = this._core.settings,
2336            create = function(path) {
2337                icon = '<div class="owl-video-play-icon"></div>';
2338
2339                if (settings.lazyLoad) {
2340                    tnLink = $('<div/>', {
2341                        "class": 'owl-video-tn ' + lazyClass,
2342                        "srcType": path
2343                    });
2344                } else {
2345                    tnLink = $('<div/>', {
2346                        "class": "owl-video-tn",
2347                        "style": 'opacity:1;background-image:url(' + path + ')'
2348                    });
2349                }
2350                target.after(tnLink);
2351                target.after(icon);
2352            };
2353
2354        // wrap video content into owl-video-wrapper div
2355        target.wrap($('<div/>', {
2356            "class": "owl-video-wrapper",
2357            "style": dimensions
2358        }));
2359
2360        if (this._core.settings.lazyLoad) {
2361            srcType = 'data-src';
2362            lazyClass = 'owl-lazy';
2363        }
2364
2365        // custom thumbnail
2366        if (customTn.length) {
2367            create(customTn.attr(srcType));
2368            customTn.remove();
2369            return false;
2370        }
2371
2372        if (video.type === 'youtube') {
2373            path = "//img.youtube.com/vi/" + video.id + "/hqdefault.jpg";
2374            create(path);
2375        } else if (video.type === 'vimeo') {
2376            $.ajax({
2377                type: 'GET',
2378                url: '//vimeo.com/api/v2/video/' + video.id + '.json',
2379                jsonp: 'callback',
2380                dataType: 'jsonp',
2381                success: function(data) {
2382                    path = data[0].thumbnail_large;
2383                    create(path);
2384                }
2385            });
2386        } else if (video.type === 'vzaar') {
2387            $.ajax({
2388                type: 'GET',
2389                url: '//vzaar.com/api/videos/' + video.id + '.json',
2390                jsonp: 'callback',
2391                dataType: 'jsonp',
2392                success: function(data) {
2393                    path = data.framegrab_url;
2394                    create(path);
2395                }
2396            });
2397        }
2398    };
2399
2400    /**
2401     * Stops the current video.
2402     * @public
2403     */
2404    Video.prototype.stop = function() {
2405        this._core.trigger('stop', null, 'video');
2406        this._playing.find('.owl-video-frame').remove();
2407        this._playing.removeClass('owl-video-playing');
2408        this._playing = null;
2409        this._core.leave('playing');
2410        this._core.trigger('stopped', null, 'video');
2411    };
2412
2413    /**
2414     * Starts the current video.
2415     * @public
2416     * @param {Event} event - The event arguments.
2417     */
2418    Video.prototype.play = function(event) {
2419        var target = $(event.target),
2420            item = target.closest('.' + this._core.settings.itemClass),
2421            video = this._videos[item.attr('data-video')],
2422            width = video.width || '100%',
2423            height = video.height || this._core.$stage.height(),
2424            html,
2425            iframe;
2426
2427        if (this._playing) {
2428            return;
2429        }
2430
2431        this._core.enter('playing');
2432        this._core.trigger('play', null, 'video');
2433
2434        item = this._core.items(this._core.relative(item.index()));
2435
2436        this._core.reset(item.index());
2437
2438        html = $('<iframe frameborder="0" allowfullscreen mozallowfullscreen webkitAllowFullScreen ></iframe>');
2439        html.attr('height', height);
2440        html.attr('width', width);
2441        if (video.type === 'youtube') {
2442            html.attr('src', '//www.youtube.com/embed/' + video.id + '?autoplay=1&rel=0&v=' + video.id);
2443        } else if (video.type === 'vimeo') {
2444            html.attr('src', '//player.vimeo.com/video/' + video.id + '?autoplay=1');
2445        } else if (video.type === 'vzaar') {
2446            html.attr('src', '//view.vzaar.com/' + video.id + '/player?autoplay=true');
2447        }
2448
2449        iframe = $(html).wrap('<div class="owl-video-frame" />').insertAfter(item.find('.owl-video'));
2450
2451        this._playing = item.addClass('owl-video-playing');
2452    };
2453
2454    /**
2455     * Checks whether an video is currently in full screen mode or not.
2456     * @todo Bad style because looks like a readonly method but changes members.
2457     * @protected
2458     * @returns {Boolean}
2459     */
2460    Video.prototype.isInFullScreen = function() {
2461        var element = document.fullscreenElement || document.mozFullScreenElement ||
2462            document.webkitFullscreenElement;
2463
2464        return element && $(element).parent().hasClass('owl-video-frame');
2465    };
2466
2467    /**
2468     * Destroys the plugin.
2469     */
2470    Video.prototype.destroy = function() {
2471        var handler, property;
2472
2473        this._core.$element.off('click.owl.video');
2474
2475        for (handler in this._handlers) {
2476            this._core.$element.off(handler, this._handlers[handler]);
2477        }
2478        for (property in Object.getOwnPropertyNames(this)) {
2479            typeof this[property] != 'function' && (this[property] = null);
2480        }
2481    };
2482
2483    $.fn.owlCarousel.Constructor.Plugins.Video = Video;
2484
2485})(window.Zepto || window.jQuery, window, document);
2486
2487/**
2488 * Animate Plugin
2489 * @version 2.3.4
2490 * @author Bartosz Wojciechowski
2491 * @author David Deutsch
2492 * @license The MIT License (MIT)
2493 */
2494;
2495(function($, window, document, undefined) {
2496
2497    /**
2498     * Creates the animate plugin.
2499     * @class The Navigation Plugin
2500     * @param {Owl} scope - The Owl Carousel
2501     */
2502    var Animate = function(scope) {
2503        this.core = scope;
2504        this.core.options = $.extend({}, Animate.Defaults, this.core.options);
2505        this.swapping = true;
2506        this.previous = undefined;
2507        this.next = undefined;
2508
2509        this.handlers = {
2510            'change.owl.carousel': $.proxy(function(e) {
2511                if (e.namespace && e.property.name == 'position') {
2512                    this.previous = this.core.current();
2513                    this.next = e.property.value;
2514                }
2515            }, this),
2516            'drag.owl.carousel dragged.owl.carousel translated.owl.carousel': $.proxy(function(e) {
2517                if (e.namespace) {
2518                    this.swapping = e.type == 'translated';
2519                }
2520            }, this),
2521            'translate.owl.carousel': $.proxy(function(e) {
2522                if (e.namespace && this.swapping && (this.core.options.animateOut || this.core.options.animateIn)) {
2523                    this.swap();
2524                }
2525            }, this)
2526        };
2527
2528        this.core.$element.on(this.handlers);
2529    };
2530
2531    /**
2532     * Default options.
2533     * @public
2534     */
2535    Animate.Defaults = {
2536        animateOut: false,
2537        animateIn: false
2538    };
2539
2540    /**
2541     * Toggles the animation classes whenever an translations starts.
2542     * @protected
2543     * @returns {Boolean|undefined}
2544     */
2545    Animate.prototype.swap = function() {
2546
2547        if (this.core.settings.items !== 1) {
2548            return;
2549        }
2550
2551        if (!$.support.animation || !$.support.transition) {
2552            return;
2553        }
2554
2555        this.core.speed(0);
2556
2557        var left,
2558            clear = $.proxy(this.clear, this),
2559            previous = this.core.$stage.children().eq(this.previous),
2560            next = this.core.$stage.children().eq(this.next),
2561            incoming = this.core.settings.animateIn,
2562            outgoing = this.core.settings.animateOut;
2563
2564        if (this.core.current() === this.previous) {
2565            return;
2566        }
2567
2568        if (outgoing) {
2569            left = this.core.coordinates(this.previous) - this.core.coordinates(this.next);
2570            previous.one($.support.animation.end, clear)
2571                .css({ 'left': left + 'px' })
2572                .addClass('animated owl-animated-out')
2573                .addClass(outgoing);
2574        }
2575
2576        if (incoming) {
2577            next.one($.support.animation.end, clear)
2578                .addClass('animated owl-animated-in')
2579                .addClass(incoming);
2580        }
2581    };
2582
2583    Animate.prototype.clear = function(e) {
2584        $(e.target).css({ 'left': '' })
2585            .removeClass('animated owl-animated-out owl-animated-in')
2586            .removeClass(this.core.settings.animateIn)
2587            .removeClass(this.core.settings.animateOut);
2588        this.core.onTransitionEnd();
2589    };
2590
2591    /**
2592     * Destroys the plugin.
2593     * @public
2594     */
2595    Animate.prototype.destroy = function() {
2596        var handler, property;
2597
2598        for (handler in this.handlers) {
2599            this.core.$element.off(handler, this.handlers[handler]);
2600        }
2601        for (property in Object.getOwnPropertyNames(this)) {
2602            typeof this[property] != 'function' && (this[property] = null);
2603        }
2604    };
2605
2606    $.fn.owlCarousel.Constructor.Plugins.Animate = Animate;
2607
2608})(window.Zepto || window.jQuery, window, document);
2609
2610/**
2611 * Autoplay Plugin
2612 * @version 2.3.4
2613 * @author Bartosz Wojciechowski
2614 * @author Artus Kolanowski
2615 * @author David Deutsch
2616 * @author Tom De Caluwé
2617 * @license The MIT License (MIT)
2618 */
2619;
2620(function($, window, document, undefined) {
2621
2622    /**
2623     * Creates the autoplay plugin.
2624     * @class The Autoplay Plugin
2625     * @param {Owl} scope - The Owl Carousel
2626     */
2627    var Autoplay = function(carousel) {
2628        /**
2629         * Reference to the core.
2630         * @protected
2631         * @type {Owl}
2632         */
2633        this._core = carousel;
2634
2635        /**
2636         * The autoplay timeout id.
2637         * @type {Number}
2638         */
2639        this._call = null;
2640
2641        /**
2642         * Depending on the state of the plugin, this variable contains either
2643         * the start time of the timer or the current timer value if it's
2644         * paused. Since we start in a paused state we initialize the timer
2645         * value.
2646         * @type {Number}
2647         */
2648        this._time = 0;
2649
2650        /**
2651         * Stores the timeout currently used.
2652         * @type {Number}
2653         */
2654        this._timeout = 0;
2655
2656        /**
2657         * Indicates whenever the autoplay is paused.
2658         * @type {Boolean}
2659         */
2660        this._paused = true;
2661
2662        /**
2663         * All event handlers.
2664         * @protected
2665         * @type {Object}
2666         */
2667        this._handlers = {
2668            'changed.owl.carousel': $.proxy(function(e) {
2669                if (e.namespace && e.property.name === 'settings') {
2670                    if (this._core.settings.autoplay) {
2671                        this.play();
2672                    } else {
2673                        this.stop();
2674                    }
2675                } else if (e.namespace && e.property.name === 'position' && this._paused) {
2676                    // Reset the timer. This code is triggered when the position
2677                    // of the carousel was changed through user interaction.
2678                    this._time = 0;
2679                }
2680            }, this),
2681            'initialized.owl.carousel': $.proxy(function(e) {
2682                if (e.namespace && this._core.settings.autoplay) {
2683                    this.play();
2684                }
2685            }, this),
2686            'play.owl.autoplay': $.proxy(function(e, t, s) {
2687                if (e.namespace) {
2688                    this.play(t, s);
2689                }
2690            }, this),
2691            'stop.owl.autoplay': $.proxy(function(e) {
2692                if (e.namespace) {
2693                    this.stop();
2694                }
2695            }, this),
2696            'mouseover.owl.autoplay': $.proxy(function() {
2697                if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
2698                    this.pause();
2699                }
2700            }, this),
2701            'mouseleave.owl.autoplay': $.proxy(function() {
2702                if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
2703                    this.play();
2704                }
2705            }, this),
2706            'touchstart.owl.core': $.proxy(function() {
2707                if (this._core.settings.autoplayHoverPause && this._core.is('rotating')) {
2708                    this.pause();
2709                }
2710            }, this),
2711            'touchend.owl.core': $.proxy(function() {
2712                if (this._core.settings.autoplayHoverPause) {
2713                    this.play();
2714                }
2715            }, this)
2716        };
2717
2718        // register event handlers
2719        this._core.$element.on(this._handlers);
2720
2721        // set default options
2722        this._core.options = $.extend({}, Autoplay.Defaults, this._core.options);
2723    };
2724
2725    /**
2726     * Default options.
2727     * @public
2728     */
2729    Autoplay.Defaults = {
2730        autoplay: false,
2731        autoplayTimeout: 5000,
2732        autoplayHoverPause: false,
2733        autoplaySpeed: false
2734    };
2735
2736    /**
2737     * Transition to the next slide and set a timeout for the next transition.
2738     * @private
2739     * @param {Number} [speed] - The animation speed for the animations.
2740     */
2741    Autoplay.prototype._next = function(speed) {
2742        this._call = window.setTimeout(
2743            $.proxy(this._next, this, speed),
2744            this._timeout * (Math.round(this.read() / this._timeout) + 1) - this.read()
2745        );
2746
2747        if (this._core.is('interacting') || document.hidden) {
2748            return;
2749        }
2750        this._core.next(speed || this._core.settings.autoplaySpeed);
2751    }
2752
2753    /**
2754     * Reads the current timer value when the timer is playing.
2755     * @public
2756     */
2757    Autoplay.prototype.read = function() {
2758        return new Date().getTime() - this._time;
2759    };
2760
2761    /**
2762     * Starts the autoplay.
2763     * @public
2764     * @param {Number} [timeout] - The interval before the next animation starts.
2765     * @param {Number} [speed] - The animation speed for the animations.
2766     */
2767    Autoplay.prototype.play = function(timeout, speed) {
2768        var elapsed;
2769
2770        if (!this._core.is('rotating')) {
2771            this._core.enter('rotating');
2772        }
2773
2774        timeout = timeout || this._core.settings.autoplayTimeout;
2775
2776        // Calculate the elapsed time since the last transition. If the carousel
2777        // wasn't playing this calculation will yield zero.
2778        elapsed = Math.min(this._time % (this._timeout || timeout), timeout);
2779
2780        if (this._paused) {
2781            // Start the clock.
2782            this._time = this.read();
2783            this._paused = false;
2784        } else {
2785            // Clear the active timeout to allow replacement.
2786            window.clearTimeout(this._call);
2787        }
2788
2789        // Adjust the origin of the timer to match the new timeout value.
2790        this._time += this.read() % timeout - elapsed;
2791
2792        this._timeout = timeout;
2793        this._call = window.setTimeout($.proxy(this._next, this, speed), timeout - elapsed);
2794    };
2795
2796    /**
2797     * Stops the autoplay.
2798     * @public
2799     */
2800    Autoplay.prototype.stop = function() {
2801        if (this._core.is('rotating')) {
2802            // Reset the clock.
2803            this._time = 0;
2804            this._paused = true;
2805
2806            window.clearTimeout(this._call);
2807            this._core.leave('rotating');
2808        }
2809    };
2810
2811    /**
2812     * Pauses the autoplay.
2813     * @public
2814     */
2815    Autoplay.prototype.pause = function() {
2816        if (this._core.is('rotating') && !this._paused) {
2817            // Pause the clock.
2818            this._time = this.read();
2819            this._paused = true;
2820
2821            window.clearTimeout(this._call);
2822        }
2823    };
2824
2825    /**
2826     * Destroys the plugin.
2827     */
2828    Autoplay.prototype.destroy = function() {
2829        var handler, property;
2830
2831        this.stop();
2832
2833        for (handler in this._handlers) {
2834            this._core.$element.off(handler, this._handlers[handler]);
2835        }
2836        for (property in Object.getOwnPropertyNames(this)) {
2837            typeof this[property] != 'function' && (this[property] = null);
2838        }
2839    };
2840
2841    $.fn.owlCarousel.Constructor.Plugins.autoplay = Autoplay;
2842
2843})(window.Zepto || window.jQuery, window, document);
2844
2845/**
2846 * Navigation Plugin
2847 * @version 2.3.4
2848 * @author Artus Kolanowski
2849 * @author David Deutsch
2850 * @license The MIT License (MIT)
2851 */
2852;
2853(function($, window, document, undefined) {
2854    'use strict';
2855
2856    /**
2857     * Creates the navigation plugin.
2858     * @class The Navigation Plugin
2859     * @param {Owl} carousel - The Owl Carousel.
2860     */
2861    var Navigation = function(carousel) {
2862        /**
2863         * Reference to the core.
2864         * @protected
2865         * @type {Owl}
2866         */
2867        this._core = carousel;
2868
2869        /**
2870         * Indicates whether the plugin is initialized or not.
2871         * @protected
2872         * @type {Boolean}
2873         */
2874        this._initialized = false;
2875
2876        /**
2877         * The current paging indexes.
2878         * @protected
2879         * @type {Array}
2880         */
2881        this._pages = [];
2882
2883        /**
2884         * All DOM elements of the user interface.
2885         * @protected
2886         * @type {Object}
2887         */
2888        this._controls = {};
2889
2890        /**
2891         * Markup for an indicator.
2892         * @protected
2893         * @type {Array.<String>}
2894         */
2895        this._templates = [];
2896
2897        /**
2898         * The carousel element.
2899         * @type {jQuery}
2900         */
2901        this.$element = this._core.$element;
2902
2903        /**
2904         * Overridden methods of the carousel.
2905         * @protected
2906         * @type {Object}
2907         */
2908        this._overrides = {
2909            next: this._core.next,
2910            prev: this._core.prev,
2911            to: this._core.to
2912        };
2913
2914        /**
2915         * All event handlers.
2916         * @protected
2917         * @type {Object}
2918         */
2919        this._handlers = {
2920            'prepared.owl.carousel': $.proxy(function(e) {
2921                if (e.namespace && this._core.settings.dotsData) {
2922                    this._templates.push('<div class="' + this._core.settings.dotClass + '">' +
2923                        $(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>');
2924                }
2925            }, this),
2926            'added.owl.carousel': $.proxy(function(e) {
2927                if (e.namespace && this._core.settings.dotsData) {
2928                    this._templates.splice(e.position, 0, this._templates.pop());
2929                }
2930            }, this),
2931            'remove.owl.carousel': $.proxy(function(e) {
2932                if (e.namespace && this._core.settings.dotsData) {
2933                    this._templates.splice(e.position, 1);
2934                }
2935            }, this),
2936            'changed.owl.carousel': $.proxy(function(e) {
2937                if (e.namespace && e.property.name == 'position') {
2938                    this.draw();
2939                }
2940            }, this),
2941            'initialized.owl.carousel': $.proxy(function(e) {
2942                if (e.namespace && !this._initialized) {
2943                    this._core.trigger('initialize', null, 'navigation');
2944                    this.initialize();
2945                    this.update();
2946                    this.draw();
2947                    this._initialized = true;
2948                    this._core.trigger('initialized', null, 'navigation');
2949                }
2950            }, this),
2951            'refreshed.owl.carousel': $.proxy(function(e) {
2952                if (e.namespace && this._initialized) {
2953                    this._core.trigger('refresh', null, 'navigation');
2954                    this.update();
2955                    this.draw();
2956                    this._core.trigger('refreshed', null, 'navigation');
2957                }
2958            }, this)
2959        };
2960
2961        // set default options
2962        this._core.options = $.extend({}, Navigation.Defaults, this._core.options);
2963
2964        // register event handlers
2965        this.$element.on(this._handlers);
2966    };
2967
2968    /**
2969     * Default options.
2970     * @public
2971     * @todo Rename `slideBy` to `navBy`
2972     */
2973    Navigation.Defaults = {
2974        nav: false,
2975        navText: [
2976            '<span aria-label="' + 'Previous' + '">&#x2039;</span>',
2977            '<span aria-label="' + 'Next' + '">&#x203a;</span>'
2978        ],
2979        navSpeed: false,
2980        navElement: 'button type="button" role="presentation"',
2981        navContainer: false,
2982        navContainerClass: 'owl-nav',
2983        navClass: [
2984            'owl-prev',
2985            'owl-next'
2986        ],
2987        slideBy: 1,
2988        dotClass: 'owl-dot',
2989        dotsClass: 'owl-dots',
2990        dots: true,
2991        dotsEach: false,
2992        dotsData: false,
2993        dotsSpeed: false,
2994        dotsContainer: false
2995    };
2996
2997    /**
2998     * Initializes the layout of the plugin and extends the carousel.
2999     * @protected
3000     */
3001    Navigation.prototype.initialize = function() {
3002        var override,
3003            settings = this._core.settings;
3004
3005        // create DOM structure for relative navigation
3006        this._controls.$relative = (settings.navContainer ? $(settings.navContainer) :
3007            $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled');
3008
3009        this._controls.$previous = $('<' + settings.navElement + '>')
3010            .addClass(settings.navClass[0])
3011            .html(settings.navText[0])
3012            .prependTo(this._controls.$relative)
3013            .on('click', $.proxy(function(e) {
3014                this.prev(settings.navSpeed);
3015            }, this));
3016        this._controls.$next = $('<' + settings.navElement + '>')
3017            .addClass(settings.navClass[1])
3018            .html(settings.navText[1])
3019            .appendTo(this._controls.$relative)
3020            .on('click', $.proxy(function(e) {
3021                this.next(settings.navSpeed);
3022            }, this));
3023
3024        // create DOM structure for absolute navigation
3025        if (!settings.dotsData) {
3026            this._templates = [$('<button role="button">')
3027                .addClass(settings.dotClass)
3028                .append($('<span>'))
3029                .prop('outerHTML')
3030            ];
3031        }
3032
3033        this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer) :
3034            $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled');
3035
3036        this._controls.$absolute.on('click', 'button', $.proxy(function(e) {
3037            var index = $(e.target).parent().is(this._controls.$absolute) ?
3038                $(e.target).index() : $(e.target).parent().index();
3039
3040            e.preventDefault();
3041
3042            this.to(index, settings.dotsSpeed);
3043        }, this));
3044
3045        /*$el.on('focusin', function() {
3046        	$(document).off(".carousel");
3047
3048        	$(document).on('keydown.carousel', function(e) {
3049        		if(e.keyCode == 37) {
3050        			$el.trigger('prev.owl')
3051        		}
3052        		if(e.keyCode == 39) {
3053        			$el.trigger('next.owl')
3054        		}
3055        	});
3056        });*/
3057
3058        // override public methods of the carousel
3059        for (override in this._overrides) {
3060            this._core[override] = $.proxy(this[override], this);
3061        }
3062    };
3063
3064    /**
3065     * Destroys the plugin.
3066     * @protected
3067     */
3068    Navigation.prototype.destroy = function() {
3069        var handler, control, property, override, settings;
3070        settings = this._core.settings;
3071
3072        for (handler in this._handlers) {
3073            this.$element.off(handler, this._handlers[handler]);
3074        }
3075        for (control in this._controls) {
3076            if (control === '$relative' && settings.navContainer) {
3077                this._controls[control].html('');
3078            } else {
3079                this._controls[control].remove();
3080            }
3081        }
3082        for (override in this.overides) {
3083            this._core[override] = this._overrides[override];
3084        }
3085        for (property in Object.getOwnPropertyNames(this)) {
3086            typeof this[property] != 'function' && (this[property] = null);
3087        }
3088    };
3089
3090    /**
3091     * Updates the internal state.
3092     * @protected
3093     */
3094    Navigation.prototype.update = function() {
3095        var i, j, k,
3096            lower = this._core.clones().length / 2,
3097            upper = lower + this._core.items().length,
3098            maximum = this._core.maximum(true),
3099            settings = this._core.settings,
3100            size = settings.center || settings.autoWidth || settings.dotsData ?
3101            1 : settings.dotsEach || settings.items;
3102
3103        if (settings.slideBy !== 'page') {
3104            settings.slideBy = Math.min(settings.slideBy, settings.items);
3105        }
3106
3107        if (settings.dots || settings.slideBy == 'page') {
3108            this._pages = [];
3109
3110            for (i = lower, j = 0, k = 0; i < upper; i++) {
3111                if (j >= size || j === 0) {
3112                    this._pages.push({
3113                        start: Math.min(maximum, i - lower),
3114                        end: i - lower + size - 1
3115                    });
3116                    if (Math.min(maximum, i - lower) === maximum) {
3117                        break;
3118                    }
3119                    j = 0, ++k;
3120                }
3121                j += this._core.mergers(this._core.relative(i));
3122            }
3123        }
3124    };
3125
3126    /**
3127     * Draws the user interface.
3128     * @todo The option `dotsData` wont work.
3129     * @protected
3130     */
3131    Navigation.prototype.draw = function() {
3132        var difference,
3133            settings = this._core.settings,
3134            disabled = this._core.items().length <= settings.items,
3135            index = this._core.relative(this._core.current()),
3136            loop = settings.loop || settings.rewind;
3137
3138        this._controls.$relative.toggleClass('disabled', !settings.nav || disabled);
3139
3140        if (settings.nav) {
3141            this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true));
3142            this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true));
3143        }
3144
3145        this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled);
3146
3147        if (settings.dots) {
3148            difference = this._pages.length - this._controls.$absolute.children().length;
3149
3150            if (settings.dotsData && difference !== 0) {
3151                this._controls.$absolute.html(this._templates.join(''));
3152            } else if (difference > 0) {
3153                this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0]));
3154            } else if (difference < 0) {
3155                this._controls.$absolute.children().slice(difference).remove();
3156            }
3157
3158            this._controls.$absolute.find('.active').removeClass('active');
3159            this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active');
3160        }
3161    };
3162
3163    /**
3164     * Extends event data.
3165     * @protected
3166     * @param {Event} event - The event object which gets thrown.
3167     */
3168    Navigation.prototype.onTrigger = function(event) {
3169        var settings = this._core.settings;
3170
3171        event.page = {
3172            index: $.inArray(this.current(), this._pages),
3173            count: this._pages.length,
3174            size: settings && (settings.center || settings.autoWidth || settings.dotsData ?
3175                1 : settings.dotsEach || settings.items)
3176        };
3177    };
3178
3179    /**
3180     * Gets the current page position of the carousel.
3181     * @protected
3182     * @returns {Number}
3183     */
3184    Navigation.prototype.current = function() {
3185        var current = this._core.relative(this._core.current());
3186        return $.grep(this._pages, $.proxy(function(page, index) {
3187            return page.start <= current && page.end >= current;
3188        }, this)).pop();
3189    };
3190
3191    /**
3192     * Gets the current succesor/predecessor position.
3193     * @protected
3194     * @returns {Number}
3195     */
3196    Navigation.prototype.getPosition = function(successor) {
3197        var position, length,
3198            settings = this._core.settings;
3199
3200        if (settings.slideBy == 'page') {
3201            position = $.inArray(this.current(), this._pages);
3202            length = this._pages.length;
3203            successor ? ++position : --position;
3204            position = this._pages[((position % length) + length) % length].start;
3205        } else {
3206            position = this._core.relative(this._core.current());
3207            length = this._core.items().length;
3208            successor ? position += settings.slideBy : position -= settings.slideBy;
3209        }
3210
3211        return position;
3212    };
3213
3214    /**
3215     * Slides to the next item or page.
3216     * @public
3217     * @param {Number} [speed=false] - The time in milliseconds for the transition.
3218     */
3219    Navigation.prototype.next = function(speed) {
3220        $.proxy(this._overrides.to, this._core)(this.getPosition(true), speed);
3221    };
3222
3223    /**
3224     * Slides to the previous item or page.
3225     * @public
3226     * @param {Number} [speed=false] - The time in milliseconds for the transition.
3227     */
3228    Navigation.prototype.prev = function(speed) {
3229        $.proxy(this._overrides.to, this._core)(this.getPosition(false), speed);
3230    };
3231
3232    /**
3233     * Slides to the specified item or page.
3234     * @public
3235     * @param {Number} position - The position of the item or page.
3236     * @param {Number} [speed] - The time in milliseconds for the transition.
3237     * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not.
3238     */
3239    Navigation.prototype.to = function(position, speed, standard) {
3240        var length;
3241
3242        if (!standard && this._pages.length) {
3243            length = this._pages.length;
3244            $.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed);
3245        } else {
3246            $.proxy(this._overrides.to, this._core)(position, speed);
3247        }
3248    };
3249
3250    $.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation;
3251
3252})(window.Zepto || window.jQuery, window, document);
3253
3254/**
3255 * Hash Plugin
3256 * @version 2.3.4
3257 * @author Artus Kolanowski
3258 * @author David Deutsch
3259 * @license The MIT License (MIT)
3260 */
3261;
3262(function($, window, document, undefined) {
3263    'use strict';
3264
3265    /**
3266     * Creates the hash plugin.
3267     * @class The Hash Plugin
3268     * @param {Owl} carousel - The Owl Carousel
3269     */
3270    var Hash = function(carousel) {
3271        /**
3272         * Reference to the core.
3273         * @protected
3274         * @type {Owl}
3275         */
3276        this._core = carousel;
3277
3278        /**
3279         * Hash index for the items.
3280         * @protected
3281         * @type {Object}
3282         */
3283        this._hashes = {};
3284
3285        /**
3286         * The carousel element.
3287         * @type {jQuery}
3288         */
3289        this.$element = this._core.$element;
3290
3291        /**
3292         * All event handlers.
3293         * @protected
3294         * @type {Object}
3295         */
3296        this._handlers = {
3297            'initialized.owl.carousel': $.proxy(function(e) {
3298                if (e.namespace && this._core.settings.startPosition === 'URLHash') {
3299                    $(window).trigger('hashchange.owl.navigation');
3300                }
3301            }, this),
3302            'prepared.owl.carousel': $.proxy(function(e) {
3303                if (e.namespace) {
3304                    var hash = $(e.content).find('[data-hash]').addBack('[data-hash]').attr('data-hash');
3305
3306                    if (!hash) {
3307                        return;
3308                    }
3309
3310                    this._hashes[hash] = e.content;
3311                }
3312            }, this),
3313            'changed.owl.carousel': $.proxy(function(e) {
3314                if (e.namespace && e.property.name === 'position') {
3315                    var current = this._core.items(this._core.relative(this._core.current())),
3316                        hash = $.map(this._hashes, function(item, hash) {
3317                            return item === current ? hash : null;
3318                        }).join();
3319
3320                    if (!hash || window.location.hash.slice(1) === hash) {
3321                        return;
3322                    }
3323
3324                    window.location.hash = hash;
3325                }
3326            }, this)
3327        };
3328
3329        // set default options
3330        this._core.options = $.extend({}, Hash.Defaults, this._core.options);
3331
3332        // register the event handlers
3333        this.$element.on(this._handlers);
3334
3335        // register event listener for hash navigation
3336        $(window).on('hashchange.owl.navigation', $.proxy(function(e) {
3337            var hash = window.location.hash.substring(1),
3338                items = this._core.$stage.children(),
3339                position = this._hashes[hash] && items.index(this._hashes[hash]);
3340
3341            if (position === undefined || position === this._core.current()) {
3342                return;
3343            }
3344
3345            this._core.to(this._core.relative(position), false, true);
3346        }, this));
3347    };
3348
3349    /**
3350     * Default options.
3351     * @public
3352     */
3353    Hash.Defaults = {
3354        URLhashListener: false
3355    };
3356
3357    /**
3358     * Destroys the plugin.
3359     * @public
3360     */
3361    Hash.prototype.destroy = function() {
3362        var handler, property;
3363
3364        $(window).off('hashchange.owl.navigation');
3365
3366        for (handler in this._handlers) {
3367            this._core.$element.off(handler, this._handlers[handler]);
3368        }
3369        for (property in Object.getOwnPropertyNames(this)) {
3370            typeof this[property] != 'function' && (this[property] = null);
3371        }
3372    };
3373
3374    $.fn.owlCarousel.Constructor.Plugins.Hash = Hash;
3375
3376})(window.Zepto || window.jQuery, window, document);
3377
3378/**
3379 * Support Plugin
3380 *
3381 * @version 2.3.4
3382 * @author Vivid Planet Software GmbH
3383 * @author Artus Kolanowski
3384 * @author David Deutsch
3385 * @license The MIT License (MIT)
3386 */
3387;
3388(function($, window, document, undefined) {
3389
3390    var style = $('<support>').get(0).style,
3391        prefixes = 'Webkit Moz O ms'.split(' '),
3392        events = {
3393            transition: {
3394                end: {
3395                    WebkitTransition: 'webkitTransitionEnd',
3396                    MozTransition: 'transitionend',
3397                    OTransition: 'oTransitionEnd',
3398                    transition: 'transitionend'
3399                }
3400            },
3401            animation: {
3402                end: {
3403                    WebkitAnimation: 'webkitAnimationEnd',
3404                    MozAnimation: 'animationend',
3405                    OAnimation: 'oAnimationEnd',
3406                    animation: 'animationend'
3407                }
3408            }
3409        },
3410        tests = {
3411            csstransforms: function() {
3412                return !!test('transform');
3413            },
3414            csstransforms3d: function() {
3415                return !!test('perspective');
3416            },
3417            csstransitions: function() {
3418                return !!test('transition');
3419            },
3420            cssanimations: function() {
3421                return !!test('animation');
3422            }
3423        };
3424
3425    function test(property, prefixed) {
3426        var result = false,
3427            upper = property.charAt(0).toUpperCase() + property.slice(1);
3428
3429        $.each((property + ' ' + prefixes.join(upper + ' ') + upper).split(' '), function(i, property) {
3430            if (style[property] !== undefined) {
3431                result = prefixed ? property : true;
3432                return false;
3433            }
3434        });
3435
3436        return result;
3437    }
3438
3439    function prefixed(property) {
3440        return test(property, true);
3441    }
3442
3443    if (tests.csstransitions()) {
3444        /* jshint -W053 */
3445        $.support.transition = new String(prefixed('transition'))
3446        $.support.transition.end = events.transition.end[$.support.transition];
3447    }
3448
3449    if (tests.cssanimations()) {
3450        /* jshint -W053 */
3451        $.support.animation = new String(prefixed('animation'))
3452        $.support.animation.end = events.animation.end[$.support.animation];
3453    }
3454
3455    if (tests.csstransforms()) {
3456        /* jshint -W053 */
3457        $.support.transform = new String(prefixed('transform'));
3458        $.support.transform3d = tests.csstransforms3d();
3459    }
3460
3461})(window.Zepto || window.jQuery, window, document);

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.