Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
21627 kshitij.so 1
/*
2
 *	jQuery OwlCarousel v1.21
3
 *
4
 *	Copyright (c) 2013 Bartosz Wojciechowski
5
 *	http://www.owlgraphic.com/owlcarousel
6
 *
7
 *	Licensed under MIT
8
 *
9
 */
10
 
11
 
12
// Object.create function
13
if ( typeof Object.create !== "function" ) {
14
	Object.create = function( obj ) {
15
		function F() {};
16
		F.prototype = obj;
17
		return new F();
18
	};
19
}
20
(function( $, window, document, undefined ) {
21
 
22
	var Carousel = {
23
		init :function(options, el){
24
			var base = this;
25
			base.options = $.extend({}, $.fn.owlCarousel.options, options);
26
			var elem = el;
27
			var $elem = $(el);
28
			base.$elem = $elem;
29
			base.loadContent()
30
		},
31
 
32
		loadContent : function(){
33
			var base = this;
34
 
35
			if (typeof base.options.beforeInit === "function") {
36
				base.options.beforeInit.apply(this,[base.$elem]);
37
			}
38
 
39
			if (typeof base.options.jsonPath === "string") {
40
				var url = base.options.jsonPath;
41
 
42
				function getData(data) {
43
					if (typeof base.options.jsonSuccess === "function") {
44
						base.options.jsonSuccess.apply(this,[data]);
45
					} else {
46
						var content = "";
47
						for(var i in data["owl"]){
48
							content += data["owl"][i]["item"];
49
						}
50
						base.$elem.html(content);
51
					}
52
					base.logIn();
53
				}
54
				$.getJSON(url,getData);
55
			} else {
56
				base.logIn();
57
			}
58
		},
59
 
60
		logIn : function(){
61
			var base = this;
62
 
63
			base.baseClass();
64
 
65
			base.$elem
66
			.css({opacity: 0})
67
 
68
			base.checkTouch();
69
			base.support3d();
70
 
71
			base.wrapperWidth = 0;
72
			base.currentSlide = 0; //Starting Position
73
 
74
			base.userItems = base.$elem.children();
75
			base.itemsAmount = base.userItems.length;
76
			base.wrapItems();
77
 
78
			base.owlItems = base.$elem.find(".owl-item");
79
			base.owlWrapper = base.$elem.find(".owl-wrapper");
80
 
81
			base.orignalItems = base.options.items;
82
			base.playDirection = "next";
83
 
84
			base.checkVisible;
85
 
86
			//setTimeout(function(){
87
			base.onStartup();
88
			//},0);
89
			base.customEvents();
90
 
91
		},
92
 
93
		onStartup : function(){
94
			var base = this;
95
			base.updateItems();
96
			base.calculateAll();
97
			base.buildControls();
98
			base.updateControls();
99
			base.response();
100
			base.moveEvents();
101
			base.stopOnHover();
102
			if(base.options.autoPlay === true){
103
				base.options.autoPlay = 5000;
104
			}
105
			base.play();
106
			base.$elem.find(".owl-wrapper").css("display","block")
107
 
108
			if(!base.$elem.is(":visible")){
109
				base.watchVisibility();
110
			} else {
111
				setTimeout(function(){
112
					base.$elem.animate({opacity: 1},200);
113
				},10);
114
			}
115
			base.onstartup = false;
116
			base.eachMoveUpdate();
117
			if (typeof base.options.afterInit === "function") {
118
				base.options.afterInit.apply(this,[base.$elem]);
119
			}
120
		},
121
 
122
		eachMoveUpdate : function(){
123
			var base = this;
124
			base.lazyLoad();
125
			base.autoHeight();
126
			if(base.options.singleItem === true){
127
				base.addActiveClass();
128
			}
129
			if (typeof base.options.afterAction === "function") {
130
				base.options.afterAction.apply(this);
131
			}
132
		},
133
 
134
		updateVars : function(){
135
			var base = this;
136
			base.watchVisibility();
137
			base.updateItems();
138
			base.calculateAll();
139
			base.updatePosition();
140
			base.updateControls();
141
			base.eachMoveUpdate();
142
		},
143
 
144
		reload : function(elements){
145
			var base = this;
146
			setTimeout(function(){
147
				base.updateVars();
148
			},0)
149
		},
150
 
151
		watchVisibility : function(){
152
			var base = this;
153
			clearInterval(base.checkVisible);
154
			if(!base.$elem.is(":visible")){
155
				base.$elem.css({opacity: 0});
156
				clearInterval(base.autoPlaySpeed);
157
			} else {
158
				return false;
159
			}
160
			base.checkVisible = setInterval(function(){
161
				if (base.$elem.is(":visible")) {
162
					base.reload();
163
					base.$elem.animate({opacity: 1},200);
164
					clearInterval(base.checkVisible);
165
				}
166
			}, 500);
167
		},
168
 
169
		wrapItems : function(){
170
			var base = this;
171
			base.userItems.wrapAll("<div class=\"owl-wrapper\">").wrap("<div class=\"owl-item\"></div>");
172
			base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\">");
173
			base.wrapperOuter = base.$elem.find(".owl-wrapper-outer");
174
			base.$elem.css("display","block");
175
		},
176
 
177
		baseClass : function(){
178
			var base = this;
179
			var hasBaseClass = base.$elem.hasClass(base.options.baseClass);
180
			var hasThemeClass = base.$elem.hasClass(base.options.theme);
181
 
182
			if(!hasBaseClass){
183
				base.$elem.addClass(base.options.baseClass);
184
			}
185
 
186
			if(!hasThemeClass){
187
				base.$elem.addClass(base.options.theme);
188
			}
189
		},
190
 
191
		updateItems : function(){
192
			var base = this;
193
 
194
			if(base.options.responsive === false){
195
				return false;
196
			}
197
 
198
			if(base.options.singleItem === true){
199
				base.options.items = base.orignalItems = 1;
200
				base.options.itemsDesktop = false;
201
				base.options.itemsDesktopSmall = false;
202
				base.options.itemsTablet = false;
203
				base.options.itemsMobile = false;
204
				return false;
205
			}
206
 
207
			var width = $(window).width();
208
 
209
			if(width > (base.options.itemsDesktop[0] || base.orignalItems) ){
210
				 base.options.items = base.orignalItems
211
			}
212
 
213
			if(width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false){
214
				base.options.items = base.options.itemsDesktop[1];
215
			}
216
 
217
			if(width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false){
218
				base.options.items = base.options.itemsDesktopSmall[1];
219
			}
220
 
221
			if(width <= base.options.itemsTablet[0]  && base.options.itemsTablet !== false){
222
				base.options.items = base.options.itemsTablet[1];
223
			}
224
 
225
			if(width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false){
226
				base.options.items = base.options.itemsMobile[1];
227
			}
228
 
229
			//if number of items is less than declared
230
			if(base.options.items > base.itemsAmount){
231
				base.options.items = base.itemsAmount;
232
			}
233
		},
234
 
235
		response : function(){
236
			var base = this,
237
				smallDelay;
238
			if(base.options.responsive !== true){
239
				return false
240
			}
241
			$(window).resize(function(){
242
				if(base.options.autoPlay !== false){
243
					clearInterval(base.autoPlaySpeed);
244
				}
245
				clearTimeout(smallDelay)
246
				smallDelay = setTimeout(function(){
247
					base.updateVars();
248
				},base.options.responsiveRefreshRate);
249
			})
250
		},
251
 
252
		updatePosition : function(){
253
			var base = this;
254
 
255
			if(base.support3d === true){
256
				if(base.positionsInArray[base.currentSlide] > base.maximumPixels){
257
					base.transition3d(base.positionsInArray[base.currentSlide]);
258
				} else {
259
					base.transition3d(0);
260
					base.currentSlide = 0;
261
				}
262
			} else{
263
				if(base.positionsInArray[base.currentSlide] > base.maximumPixels){
264
					base.css2slide(base.positionsInArray[base.currentSlide]);
265
				} else {
266
					base.css2slide(0);
267
					base.currentSlide = 0;
268
				}
269
			}
270
			if(base.options.autoPlay !== false){
271
				base.checkAp();
272
			}
273
		},
274
 
275
		appendItemsSizes : function(){
276
			var base = this;
277
 
278
			var roundPages = 0;
279
			var lastItem = base.itemsAmount - base.options.items;
280
 
281
			base.owlItems.each(function(index){
282
				$(this)
283
				.css({"width": base.itemWidth})
284
				.data("owl-item",Number(index));
285
 
286
				if(index % base.options.items === 0 || index === lastItem){
287
					if(!(index > lastItem)){
288
						roundPages +=1;
289
					}
290
				}
291
				$(this).data("owl-roundPages",roundPages);
292
			});
293
		},
294
 
295
		appendWrapperSizes : function(){
296
			var base = this;
297
			var width = 0;
298
 
299
			var width = base.owlItems.length * base.itemWidth;
300
 
301
			base.owlWrapper.css({
302
				"width": width*2,
303
				"left": 0
304
			});
305
			base.appendItemsSizes();
306
		},
307
 
308
		calculateAll : function(){
309
			var base = this;
310
			base.calculateWidth();
311
			base.appendWrapperSizes();
312
			base.loops();
313
			base.max();
314
		},
315
 
316
		calculateWidth : function(){
317
			var base = this;
318
			base.itemWidth = Math.round(base.$elem.width()/base.options.items)
319
		},
320
 
321
		max : function(){
322
			var base = this;
323
			base.maximumSlide = base.itemsAmount - base.options.items;
324
			var maximum = (base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth;
325
				maximum = maximum * -1
326
			base.maximumPixels = maximum;
327
			return maximum;
328
		},
329
 
330
		min : function(){
331
			return 0;
332
		},
333
 
334
		loops : function(){
335
			var base = this;
336
 
337
			base.positionsInArray = [0];
338
			var elWidth = 0;
339
 
340
			for(var i = 0; i<base.itemsAmount; i++){
341
				elWidth += base.itemWidth;
342
				base.positionsInArray.push(-elWidth)
343
			}
344
		},
345
 
346
		buildControls : function(){
347
			var base = this;
348
			if(base.options.navigation === true || base.options.pagination === true){
349
				base.owlControls = $("<div class=\"owl-controls\"/>").toggleClass("clickable", !base.isTouch).appendTo(base.$elem);
350
			}
351
			if(base.options.pagination === true){
352
				base.buildPagination();
353
			}
354
			if(base.options.navigation === true){
355
				base.buildButtons();
356
			}
357
		},
358
 
359
		buildButtons : function(){
360
			var base = this;
361
			var buttonsWrapper = $("<div class=\"owl-buttons\"/>")
362
			base.owlControls.append(buttonsWrapper);
363
 
364
			base.buttonPrev = $("<div/>",{
365
				"class" : "owl-prev",
366
				"html" : base.options.navigationText[0] || ""
367
				});
368
 
369
			base.buttonNext = $("<div/>",{
370
				"class" : "owl-next",
371
				"html" : base.options.navigationText[1] || ""
372
				});
373
 
374
			buttonsWrapper
375
			.append(base.buttonPrev)
376
			.append(base.buttonNext);
377
 
378
			buttonsWrapper.on(base.getEvent(), "div[class^=\"owl\"]", function(event){
379
				event.preventDefault();
380
				if($(this).hasClass("owl-next")){
381
					base.next();
382
				} else{
383
					base.prev();
384
				}
385
			})
386
		},
387
 
388
		getEvent : function(){
389
			var base = this;
390
			if (base.isTouch === true){
391
				return "touchend.owlControls";
392
			} else {
393
				return "click.owlControls";
394
			}
395
		},
396
 
397
		buildPagination : function(){
398
			var base = this;
399
 
400
			base.paginationWrapper = $("<div class=\"owl-pagination\"/>");
401
			base.owlControls.append(base.paginationWrapper);
402
 
403
			base.paginationWrapper.on(base.getEvent(), ".owl-page", function(event){
404
				event.preventDefault();
405
				if(Number($(this).data("owl-page")) !== base.currentSlide){
406
					base.goTo( Number($(this).data("owl-page")), true);
407
				}
408
			});
409
		},
410
 
411
		updatePagination : function(){
412
			var base = this;
413
			if(base.options.pagination === false){
414
				return false;
415
			}
416
 
417
			base.paginationWrapper.html("");
418
 
419
			var counter = 0;
420
			var lastPage = base.itemsAmount - base.itemsAmount % base.options.items;
421
 
422
			for(var i = 0; i<base.itemsAmount; i++){
423
				if(i % base.options.items === 0){
424
					counter +=1;
425
					if(lastPage === i){
426
						var lastItem = base.itemsAmount - base.options.items;
427
					}
428
					var paginationButton = $("<div/>",{
429
						"class" : "owl-page"
430
						});
431
					var paginationButtonInner = $("<span></span>",{
432
						"text": base.options.paginationNumbers === true ? counter : "",
433
						"class": base.options.paginationNumbers === true ? "owl-numbers" : ""
434
					});
435
					paginationButton.append(paginationButtonInner);
436
 
437
					paginationButton.data("owl-page",lastPage === i ? lastItem : i);
438
					paginationButton.data("owl-roundPages",counter);
439
 
440
					base.paginationWrapper.append(paginationButton);
441
				}
442
			}
443
			base.checkPagination();
444
		},
445
		checkPagination : function(){
446
			var base = this;
447
 
448
			base.paginationWrapper.find(".owl-page").each(function(i,v){
449
				if($(this).data("owl-roundPages") === $(base.owlItems[base.currentSlide]).data("owl-roundPages") ){
450
					base.paginationWrapper
451
						.find(".owl-page")
452
						.removeClass("active");
453
					$(this).addClass("active");
454
				}
455
			});
456
		},
457
 
458
		checkNavigation : function(){
459
			var base = this;
460
 
461
			if(base.options.navigation === false){
462
				return false;
463
			}
464
			if(base.options.goToFirstNav === false){
465
				if(base.currentSlide === 0 && base.maximumSlide === 0){
466
					base.buttonPrev.addClass("disabled");
467
					base.buttonNext.addClass("disabled");
468
				} else if(base.currentSlide === 0 && base.maximumSlide !== 0){
469
					base.buttonPrev.addClass("disabled");
470
					base.buttonNext.removeClass("disabled");
471
				} else if (base.currentSlide === base.maximumSlide){
472
					base.buttonPrev.removeClass("disabled");
473
					base.buttonNext.addClass("disabled");
474
				} else if(base.currentSlide !== 0 && base.currentSlide !== base.maximumSlide){
475
					base.buttonPrev.removeClass("disabled");
476
					base.buttonNext.removeClass("disabled");
477
				}
478
			}
479
		},
480
 
481
		updateControls : function(){
482
			var base = this;
483
			base.updatePagination();
484
			base.checkNavigation();
485
			if(base.owlControls){
486
				if(base.options.items === base.itemsAmount){
487
					base.owlControls.hide();
488
				} else {
489
					base.owlControls.show();
490
				}
491
			}
492
		},
493
 
494
		destroyControls : function(){
495
			var base = this;
496
			if(base.owlControls){
497
				base.owlControls.remove();
498
			}
499
		},
500
 
501
		next : function(speed){
502
			var base = this;
503
			base.currentSlide += base.options.scrollPerPage === true ? base.options.items : 1;
504
			if(base.currentSlide > base.maximumSlide + (base.options.scrollPerPage == true ? (base.options.items - 1) : 0)){
505
				if(base.options.goToFirstNav === true){
506
					base.currentSlide = 0;
507
					speed = "goToFirst";
508
				} else {
509
					base.currentSlide = base.maximumSlide;
510
					return false;
511
				}
512
			}
513
			base.goTo(base.currentSlide,speed);
514
		},
515
 
516
		prev : function(speed){
517
			var base = this;
518
			if(base.options.scrollPerPage === true && base.currentSlide > 0 && base.currentSlide < base.options.items){
519
				base.currentSlide = 0
520
			} else {
521
			base.currentSlide -= base.options.scrollPerPage === true ? base.options.items : 1;
522
			}
523
			if(base.currentSlide < 0){
524
				if(base.options.goToFirstNav === true){
525
					base.currentSlide = base.maximumSlide;
526
					speed = "goToFirst"
527
				} else {
528
					base.currentSlide =0;
529
					return false;
530
				}
531
			}
532
			base.goTo(base.currentSlide,speed);
533
		},
534
 
535
		goTo : function(position,pagination){
536
			var base = this;
537
 
538
			if(typeof base.options.beforeMove === "function") {
539
				base.options.beforeMove.apply(this);
540
			}
541
			if(position >= base.maximumSlide){
542
				position = base.maximumSlide;
543
			}
544
			else if( position <= 0 ){
545
				position = 0;
546
			}
547
			base.currentSlide = position;
548
 
549
			var goToPixel = base.positionsInArray[position];
550
 
551
			if(base.support3d === true){
552
				base.isCss3Finish = false;
553
 
554
				if(pagination === true){
555
					base.swapTransitionSpeed("paginationSpeed");
556
					setTimeout(function() {
557
						base.isCss3Finish = true;
558
					}, base.options.paginationSpeed);
559
 
560
				} else if(pagination === "goToFirst" ){
561
					base.swapTransitionSpeed(base.options.goToFirstSpeed);
562
					setTimeout(function() {
563
						base.isCss3Finish = true;
564
					}, base.options.goToFirstSpeed);
565
 
566
				} else {
567
					base.swapTransitionSpeed("slideSpeed");
568
					setTimeout(function() {
569
						base.isCss3Finish = true;
570
					}, base.options.slideSpeed);
571
				}
572
				base.transition3d(goToPixel);
573
			} else {
574
				if(pagination === true){
575
					base.css2slide(goToPixel, base.options.paginationSpeed);
576
				} else if(pagination === "goToFirst" ){
577
					base.css2slide(goToPixel, base.options.goToFirstSpeed);
578
				} else {
579
					base.css2slide(goToPixel, base.options.slideSpeed);
580
				}
581
			}
582
			if(base.options.pagination === true){
583
				base.checkPagination();
584
			}
585
			if(base.options.navigation === true){
586
				base.checkNavigation();
587
			}
588
			if(base.options.autoPlay !== false){
589
				base.checkAp();
590
			}
591
			base.eachMoveUpdate();
592
			if(typeof base.options.afterMove === "function") {
593
				base.options.afterMove.apply(this);
594
			}
595
		},
596
 
597
		stop: function(){
598
			var base = this;
599
			base.apStatus = "stop";
600
			clearInterval(base.autoPlaySpeed);
601
		},
602
 
603
		checkAp : function(){
604
			var base = this;
605
			if(base.apStatus !== "stop"){
606
				base.play();
607
			}
608
		},
609
 
610
		play : function(){
611
			var base = this;
612
			base.apStatus = "play";
613
			if(base.options.autoPlay === false){
614
				return false;
615
			}
616
			clearInterval(base.autoPlaySpeed);
617
			base.autoPlaySpeed = setInterval(function(){
618
				if(base.currentSlide < base.maximumSlide && base.playDirection === "next"){
619
					base.next(true);
620
				} else if(base.currentSlide === base.maximumSlide){
621
					if(base.options.goToFirst === true){
622
						base.goTo(0,"goToFirst");
623
					} else{
624
						base.playDirection = "prev";
625
						base.prev(true);
626
					}
627
				} else if(base.playDirection === "prev" && base.currentSlide > 0){
628
					base.prev(true);
629
				} else if(base.playDirection === "prev" && base.currentSlide === 0){
630
					base.playDirection = "next";
631
					base.next(true);
632
				}
633
			},base.options.autoPlay);
634
		},
635
 
636
		swapTransitionSpeed : function(action){
637
			var base = this;
638
			if(action === "slideSpeed"){
639
				base.owlWrapper.css(base.addTransition(base.options.slideSpeed));
640
			} else if(action === "paginationSpeed" ){
641
				base.owlWrapper.css(base.addTransition(base.options.paginationSpeed));
642
			} else if(typeof action !== "string"){
643
				base.owlWrapper.css(base.addTransition(action));
644
			}
645
		},
646
 
647
		addTransition : function(speed){
648
			var base = this;
649
			return {
650
				"-webkit-transition": "all "+ speed +"ms ease",
651
				"-moz-transition": "all "+ speed +"ms ease",
652
				"-o-transition": "all "+ speed +"ms ease",
653
				"transition": "all "+ speed +"ms ease"
654
			};
655
		},
656
 
657
		removeTransition : function(){
658
			return {
659
				"-webkit-transition": "",
660
				"-moz-transition": "",
661
				"-o-transition": "",
662
				"transition": ""
663
			};
664
		},
665
 
666
		doTranslate : function(pixels){
667
			return {
668
				"-webkit-transform": "translate3d("+pixels+"px, 0px, 0px)",
669
				"-moz-transform": "translate3d("+pixels+"px, 0px, 0px)",
670
				"-o-transform": "translate3d("+pixels+"px, 0px, 0px)",
671
				"-ms-transform": "translate3d("+pixels+"px, 0px, 0px)",
672
				"transform": "translate3d("+pixels+"px, 0px,0px)"
673
			};
674
		},
675
 
676
		transition3d : function(value){
677
			var base = this;
678
			base.owlWrapper.css(base.doTranslate(value));
679
		},
680
 
681
		css2move : function(value){
682
			var base = this;
683
			base.owlWrapper.css({"left" : value})
684
		},
685
 
686
		css2slide : function(value,speed){
687
			var base = this;
688
 
689
			base.isCssFinish = false;
690
			base.owlWrapper.stop(true,true).animate({
691
				"left" : value
692
			}, {
693
				duration : speed || base.options.slideSpeed ,
694
				complete : function(){
695
					base.isCssFinish = true;
696
				}
697
			});
698
		},
699
 
700
		support3d : function(){
701
				var base = this;
702
 
703
				var sTranslate3D = "translate3d(0px, 0px, 0px)";
704
				 var eTemp = document.createElement("div");
705
				eTemp.style.cssText = "  -moz-transform:"    + sTranslate3D +
706
									  "; -ms-transform:"     + sTranslate3D +
707
									  "; -o-transform:"      + sTranslate3D +
708
									  "; -webkit-transform:" + sTranslate3D +
709
									  "; transform:"         + sTranslate3D;
710
				var rxTranslate = /translate3d\(0px, 0px, 0px\)/g;
711
				var asSupport = eTemp.style.cssText.match(rxTranslate);
712
				var bHasSupport = (asSupport !== null && asSupport.length === 1);
713
				base.support3d = bHasSupport
714
				return bHasSupport;
715
		},
716
 
717
		checkTouch : function(){
718
			var base = this;
719
			base.isTouch = ("ontouchstart" in document.documentElement);
720
		},
721
 
722
		moveEvents : function(){
723
			var base = this;
724
			if(base.options.mouseDraggable || base.isTouch === true){
725
				base.eventTypes();
726
				base.gestures();
727
				base.disabledEvents();
728
			}
729
		},
730
 
731
		eventTypes : function(){
732
		var base = this;
733
		var types;
734
 
735
		base.ev_types = {};
736
 
737
		if(base.isTouch) {
738
		types = [
739
			"touchstart.owl",
740
			"touchmove.owl",
741
			"touchend.owl"
742
			];
743
		} else{
744
		types = [
745
			"mousedown.owl",
746
			"mousemove.owl",
747
			"mouseup.owl"
748
			];
749
		}
750
		base.ev_types["start"] = types[0];
751
		base.ev_types["move"] = types[1];
752
		base.ev_types["end"] = types[2];
753
		},
754
 
755
		disabledEvents :  function(){
756
			var base = this;
757
			if(base.isTouch !== true){
758
				base.$elem.on("dragstart.owl","img", function(event) { event.preventDefault();});
759
				base.$elem.bind("mousedown.disableTextSelect", function() {return false;});
760
			}
761
		},
762
 
763
		gestures : function(){
764
			var base = this;
765
 
766
			var locals = {
767
				offsetX : 0,
768
				offsetY : 0,
769
				baseElWidth : 0,
770
				relativePos : 0,
771
				position: null,
772
				minSwipe : null,
773
				maxSwipe: null,
774
				sliding : null,
775
				targetElement : null
776
			}
777
 
778
			base.isCssFinish = true;
779
 
780
			function getTouches(event){
781
				if(base.isTouch === true){
782
					return {
783
						x : event.touches[0].pageX,
784
						y : event.touches[0].pageY
785
					}
786
				} else {
787
					if(event.pageX !== undefined){
788
						return {
789
							x : event.pageX,
790
							y : event.pageY
791
						}
792
					} else {
793
						return {
794
							x : event.clientX,
795
							y : event.clientY
796
						}
797
					}
798
				}
799
			}
800
 
801
			function swapEvents(type){
802
				if(type === "on"){
803
					$(document).on(base.ev_types["move"], dragMove);
804
					$(document).on(base.ev_types["end"], dragEnd);
805
				} else if(type === "off"){
806
					$(document).off(base.ev_types["move"]);
807
					$(document).off(base.ev_types["end"]);
808
				}
809
			}
810
			function dragStart(event) {
811
				var event = event.originalEvent || event || window.event;
812
 
813
				if(base.isCssFinish === false){
814
					return false;
815
				}
816
				if(base.isCss3Finish === false){
817
					return false;
818
				}
819
 
820
				if(base.options.autoPlay !== false){
821
					clearInterval(base.autoPlaySpeed);
822
				}
823
 
824
				if(base.isTouch !== true && !base.owlWrapper.hasClass("grabbing")){
825
					base.owlWrapper.addClass("grabbing")
826
				}
827
 
828
				base.newPosX = 0;
829
				base.newRelativeX = 0;
830
 
831
				$(this).css(base.removeTransition());
832
 
833
				var position = $(this).position();
834
				locals.relativePos = position.left;
835
 
836
				locals.offsetX = getTouches(event).x - position.left;
837
				locals.offsetY = getTouches(event).y - position.top;
838
 
839
				swapEvents("on");
840
 
841
				locals.sliding = false;
842
				locals.targetElement = event.target || event.srcElement;
843
			}
844
 
845
			function dragMove(event){
846
				var event = event.originalEvent || event || window.event;
847
 
848
				base.newPosX = getTouches(event).x- locals.offsetX;
849
				base.newPosY = getTouches(event).y - locals.offsetY;
850
				base.newRelativeX = base.newPosX - locals.relativePos;
851
 
852
				if(base.newRelativeX > 8 || base.newRelativeX < -8 && base.isTouch === true){
853
					event.preventDefault ? event.preventDefault() : event.returnValue = false;
854
					locals.sliding = true;
855
				}
856
 
857
				if((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false){
858
					 $(document).off("touchmove.owl");
859
				}
860
 
861
				var minSwipe = function(){
862
					return  base.newRelativeX / 5;
863
				}
864
				var maxSwipe = function(){
865
					return  base.maximumPixels + base.newRelativeX / 5;
866
				}
867
 
868
				base.newPosX = Math.max(Math.min( base.newPosX, minSwipe() ), maxSwipe() );
869
				if(base.support3d === true){
870
					base.transition3d(base.newPosX);
871
				} else {
872
					base.css2move(base.newPosX);
873
				}
874
			}
875
 
876
			var dragEnd = function(event){
877
				var event = event.originalEvent || event || window.event;
878
				event.target = event.target || event.srcElement;
879
 
880
				if(base.isTouch !== true){
881
					base.owlWrapper.removeClass("grabbing");
882
				}
883
 
884
				swapEvents("off");
885
 
886
				if(base.newPosX !== 0){
887
					var newPosition = base.getNewPosition();
888
					base.goTo(newPosition);
889
					if(locals.targetElement === event.target && base.isTouch !== true){
890
						$(event.target).on("click.disable", function(ev){
891
							ev.stopImmediatePropagation()
892
							ev.stopPropagation();
893
							ev.preventDefault();
894
							$(event.target).off("click.disable");
895
						});
896
					var handlers = $._data(event.target, "events")["click"];
897
					var owlStopEvent = handlers.pop();
898
					handlers.splice(0, 0, owlStopEvent);
899
					}
900
				}
901
			}
902
			base.$elem.on(base.ev_types["start"], ".owl-wrapper", dragStart); 
903
		},
904
 
905
		clearEvents : function(){
906
			var base = this;
907
			base.$elem.off(".owl");
908
			$(document).off(".owl");
909
		},
910
 
911
		getNewPosition : function(){
912
			var base = this,
913
				newPosition;
914
 
915
			var newPosition = base.improveClosest();
916
 
917
			if(newPosition>base.maximumSlide){
918
				base.currentSlide = base.maximumSlide;
919
				newPosition  = base.maximumSlide;
920
			} else if( base.newPosX >=0 ){
921
				newPosition = 0;
922
				base.currentSlide = 0;
923
			}
924
			return newPosition;
925
		},
926
 
927
		improveClosest : function(){
928
			var base = this;
929
			var array = base.positionsInArray;
930
			var goal = base.newPosX;
931
			var closest = null;
932
			$.each(array, function(i,v){
933
				if( goal - (base.itemWidth/20) > array[i+1] && goal - (base.itemWidth/20)< v && base.moveDirection() === "left") {
934
					closest = v;
935
					base.currentSlide = i;
936
				} 
937
				else if (goal + (base.itemWidth/20) < v && goal + (base.itemWidth/20) > array[i+1] && base.moveDirection() === "right"){
938
					closest = array[i+1];
939
					base.currentSlide = i+1;
940
				}
941
			});
942
			return base.currentSlide;
943
		},
944
 
945
		moveDirection : function(){
946
			var base = this,
947
				direction;
948
			if(base.newRelativeX < 0 ){
949
				direction = "right"
950
				base.playDirection = "next"
951
			} else {
952
				direction = "left"
953
				base.playDirection = "prev"
954
			}
955
			return direction
956
		},
957
 
958
		customEvents : function(){
959
			var base = this;
960
			base.$elem.on("owl.next",function(){
961
				base.next();
962
			});
963
			base.$elem.on("owl.prev",function(){
964
				base.prev();
965
			});
966
			base.$elem.on("owl.play",function(event,speed){
967
				base.options.autoPlay = speed;
968
				base.play();
969
				base.hoverStatus = "play";
970
			});
971
			base.$elem.on("owl.stop",function(){
972
				base.stop();
973
				base.hoverStatus = "stop";
974
			});
975
		},
976
 
977
		stopOnHover : function(){
978
			var base = this;
979
			if(base.options.stopOnHover === true && base.isTouch === false && base.options.autoPlay !== false){
980
				base.$elem.on("mouseover", function(){
981
					base.stop();
982
				});
983
				base.$elem.on("mouseout", function(){
984
					if(base.hoverStatus !== "stop"){
985
						base.play();
986
					}
987
				});
988
			}
989
		},
990
 
991
		lazyLoad : function(){
992
			var base = this;
993
 
994
			if(base.options.lazyLoad === false){
995
				return false;
996
			}
997
 
998
			for(var i=0; i<base.itemsAmount; i++){
999
				var item = $(base.owlItems[i]),
1000
					itemNumber = item.data("owl-item"),
1001
					lazyImg = item.find(".lazyOwl"),
1002
					follow;
1003
 
1004
				if(item.data("owl-loaded") === undefined){
1005
					lazyImg.hide();
1006
					item.addClass("loading").data("owl-loaded","checked");
1007
				} else if(item.data("owl-loaded") === "loaded"){
1008
					continue;
1009
				}
1010
 
1011
				if(base.options.lazyFollow === true){
1012
					follow = itemNumber >= base.currentSlide;
1013
				}else {
1014
					follow = true;
1015
				}
1016
 
1017
				if(follow && itemNumber < base.currentSlide + base.options.items){
1018
					item.data("owl-loaded", "loaded");
1019
 
1020
					var link = lazyImg.data("src");
1021
					if(link){
1022
						lazyImg[0].src = link;
1023
						lazyImg.removeAttr("data-src");
1024
					}
1025
 
1026
					lazyImg.fadeIn(200);
1027
					item.removeClass("loading");
1028
				}
1029
			}
1030
		},
1031
 
1032
		autoHeight : function(){
1033
			var base = this;
1034
			if(base.options.autoHeight === true){
1035
				var itemHeight = $(base.owlItems[base.currentSlide]).css("height");
1036
				base.wrapperOuter.css("height",itemHeight);
1037
 
1038
				setTimeout(function(){
1039
					if(itemHeight !== $(base.owlItems[base.currentSlide]).css("height")){
1040
						base.wrapperOuter.css("height",itemHeight);
1041
					}
1042
				},400);
1043
 
1044
				setTimeout(function(){
1045
					if(!base.wrapperOuter.hasClass("autoHeight")){
1046
						base.wrapperOuter.addClass("autoHeight");
1047
					}
1048
				},0);
1049
			}
1050
		},
1051
		addActiveClass : function(){
1052
			var base = this;
1053
			$(base.owlItems).removeClass('active');
1054
			$(base.owlItems[base.currentSlide]).addClass('active');
1055
		}
1056
 
1057
	};
1058
 
1059
 
1060
	$.fn.owlCarousel = function( options ){
1061
		return this.each(function() {
1062
			var carousel = Object.create( Carousel );
1063
			carousel.init( options, this );
1064
			$.data( this, "owlCarousel", carousel );
1065
		});
1066
	};
1067
 
1068
	$.fn.owlCarousel.options = {
1069
 
1070
		items : 5,
1071
		itemsDesktop : [1199,4],
1072
		itemsDesktopSmall : [979,3],
1073
		itemsTablet: [768,2],
1074
		itemsMobile : [479,1],
1075
		singleItem:false,
1076
 
1077
		slideSpeed : 200,
1078
		paginationSpeed : 800,
1079
 
1080
		autoPlay : false,
1081
		stopOnHover : false,
1082
		goToFirst : true,
1083
		goToFirstSpeed : 1000,
1084
 
1085
		navigation : false,
1086
		navigationText : ["prev","next"],
1087
		goToFirstNav : true,
1088
		scrollPerPage : false,
1089
 
1090
		pagination : true,
1091
		paginationNumbers: false,
1092
 
1093
		responsive: true,
1094
		responsiveRefreshRate : 200,
1095
 
1096
		baseClass : "owl-carousel",
1097
		theme : "owl-theme",
1098
 
1099
		lazyLoad : false,
1100
		lazyFollow : true,
1101
 
1102
		autoHeight : false,
1103
 
1104
		jsonPath : false,
1105
		jsonSuccess : false,
1106
 
1107
		mouseDraggable : true,
1108
 
1109
		beforeInit : false,
1110
		afterInit : false,
1111
		beforeMove: false,
1112
		afterMove: false,
1113
		afterAction : false
1114
	};
1115
})( jQuery, window, document );