PageSourceSearch

https://www.stewardship.org.uk/themes/custom/stewardship/assets/js/vendors/owl.carousel.js?v=3.750.676

js stewardship.org.uk collected 2026-10-01 11:55:00 UTC 79,182 bytes, 3,072 lines download raw bytes

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