Blame view

frontend/web/js/owl.carousel.js 51.7 KB
ae432de6   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  /*
   *  jQuery OwlCarousel v1.3.3
   *
   *  Copyright (c) 2013 Bartosz Wojciechowski
   *  http://www.owlgraphic.com/owlcarousel/
   *
   *  Licensed under MIT
   *
   */
  
  /*JS Lint helpers: */
  /*global dragMove: false, dragEnd: false, $, jQuery, alert, window, document */
  /*jslint nomen: true, continue:true */
  
  if (typeof Object.create !== "function") {
9870b2b4   Alexey Boroda   -In process
16
17
      Object.create = function (obj) {
          function F() {}
ae432de6   Alexey Boroda   first commit
18
19
20
21
          F.prototype = obj;
          return new F();
      };
  }
9870b2b4   Alexey Boroda   -In process
22
  (function ($, window, document) {
ae432de6   Alexey Boroda   first commit
23
24
  
      var Carousel = {
9870b2b4   Alexey Boroda   -In process
25
          init : function (options, el) {
ae432de6   Alexey Boroda   first commit
26
27
28
29
30
31
32
33
34
              var base = this;
  
              base.$elem = $(el);
              base.options = $.extend({}, $.fn.owlCarousel.options, base.$elem.data(), options);
  
              base.userOptions = options;
              base.loadContent();
          },
  
9870b2b4   Alexey Boroda   -In process
35
          loadContent : function () {
ae432de6   Alexey Boroda   first commit
36
37
38
39
40
              var base = this, url;
  
              function getData(data) {
                  var i, content = "";
                  if (typeof base.options.jsonSuccess === "function") {
9870b2b4   Alexey Boroda   -In process
41
                      base.options.jsonSuccess.apply(this, [data]);
ae432de6   Alexey Boroda   first commit
42
43
44
                  } else {
                      for (i in data.owl) {
                          if (data.owl.hasOwnProperty(i)) {
9870b2b4   Alexey Boroda   -In process
45
                              content += data.owl[i].item;
ae432de6   Alexey Boroda   first commit
46
47
48
49
50
51
52
53
                          }
                      }
                      base.$elem.html(content);
                  }
                  base.logIn();
              }
  
              if (typeof base.options.beforeInit === "function") {
9870b2b4   Alexey Boroda   -In process
54
                  base.options.beforeInit.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
55
56
57
58
59
60
61
62
63
64
              }
  
              if (typeof base.options.jsonPath === "string") {
                  url = base.options.jsonPath;
                  $.getJSON(url, getData);
              } else {
                  base.logIn();
              }
          },
  
9870b2b4   Alexey Boroda   -In process
65
          logIn : function () {
ae432de6   Alexey Boroda   first commit
66
67
              var base = this;
  
9870b2b4   Alexey Boroda   -In process
68
69
70
71
              base.$elem.data({
                  "owl-originalStyles": base.$elem.attr("style"),
                  "owl-originalClasses": base.$elem.attr("class")
              });
ae432de6   Alexey Boroda   first commit
72
73
74
75
76
77
78
79
80
  
              base.$elem.css({opacity: 0});
              base.orignalItems = base.options.items;
              base.checkBrowser();
              base.wrapperWidth = 0;
              base.checkVisible = null;
              base.setVars();
          },
  
9870b2b4   Alexey Boroda   -In process
81
          setVars : function () {
ae432de6   Alexey Boroda   first commit
82
              var base = this;
9870b2b4   Alexey Boroda   -In process
83
              if (base.$elem.children().length === 0) {return false; }
ae432de6   Alexey Boroda   first commit
84
85
86
87
88
89
90
91
92
              base.baseClass();
              base.eventTypes();
              base.$userItems = base.$elem.children();
              base.itemsAmount = base.$userItems.length;
              base.wrapItems();
              base.$owlItems = base.$elem.find(".owl-item");
              base.$owlWrapper = base.$elem.find(".owl-wrapper");
              base.playDirection = "next";
              base.prevItem = 0;
9870b2b4   Alexey Boroda   -In process
93
              base.prevArr = [0];
ae432de6   Alexey Boroda   first commit
94
95
96
97
98
              base.currentItem = 0;
              base.customEvents();
              base.onStartup();
          },
  
9870b2b4   Alexey Boroda   -In process
99
          onStartup : function () {
ae432de6   Alexey Boroda   first commit
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
              var base = this;
              base.updateItems();
              base.calculateAll();
              base.buildControls();
              base.updateControls();
              base.response();
              base.moveEvents();
              base.stopOnHover();
              base.owlStatus();
  
              if (base.options.transitionStyle !== false) {
                  base.transitionTypes(base.options.transitionStyle);
              }
              if (base.options.autoPlay === true) {
                  base.options.autoPlay = 5000;
              }
              base.play();
  
9870b2b4   Alexey Boroda   -In process
118
              base.$elem.find(".owl-wrapper").css("display", "block");
ae432de6   Alexey Boroda   first commit
119
120
121
122
123
124
125
126
127
  
              if (!base.$elem.is(":visible")) {
                  base.watchVisibility();
              } else {
                  base.$elem.css("opacity", 1);
              }
              base.onstartup = false;
              base.eachMoveUpdate();
              if (typeof base.options.afterInit === "function") {
9870b2b4   Alexey Boroda   -In process
128
                  base.options.afterInit.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
129
130
131
              }
          },
  
9870b2b4   Alexey Boroda   -In process
132
          eachMoveUpdate : function () {
ae432de6   Alexey Boroda   first commit
133
134
135
136
137
138
139
140
141
142
143
              var base = this;
  
              if (base.options.lazyLoad === true) {
                  base.lazyLoad();
              }
              if (base.options.autoHeight === true) {
                  base.autoHeight();
              }
              base.onVisibleItems();
  
              if (typeof base.options.afterAction === "function") {
9870b2b4   Alexey Boroda   -In process
144
                  base.options.afterAction.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
145
146
147
              }
          },
  
9870b2b4   Alexey Boroda   -In process
148
          updateVars : function () {
ae432de6   Alexey Boroda   first commit
149
150
              var base = this;
              if (typeof base.options.beforeUpdate === "function") {
9870b2b4   Alexey Boroda   -In process
151
                  base.options.beforeUpdate.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
152
153
154
155
156
157
158
159
              }
              base.watchVisibility();
              base.updateItems();
              base.calculateAll();
              base.updatePosition();
              base.updateControls();
              base.eachMoveUpdate();
              if (typeof base.options.afterUpdate === "function") {
9870b2b4   Alexey Boroda   -In process
160
                  base.options.afterUpdate.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
161
162
163
              }
          },
  
9870b2b4   Alexey Boroda   -In process
164
          reload : function () {
ae432de6   Alexey Boroda   first commit
165
              var base = this;
9870b2b4   Alexey Boroda   -In process
166
167
168
              window.setTimeout(function () {
                  base.updateVars();
              }, 0);
ae432de6   Alexey Boroda   first commit
169
170
          },
  
9870b2b4   Alexey Boroda   -In process
171
          watchVisibility : function () {
ae432de6   Alexey Boroda   first commit
172
173
174
175
176
177
178
179
180
              var base = this;
  
              if (base.$elem.is(":visible") === false) {
                  base.$elem.css({opacity: 0});
                  window.clearInterval(base.autoPlayInterval);
                  window.clearInterval(base.checkVisible);
              } else {
                  return false;
              }
9870b2b4   Alexey Boroda   -In process
181
182
183
184
185
186
187
              base.checkVisible = window.setInterval(function () {
                  if (base.$elem.is(":visible")) {
                      base.reload();
                      base.$elem.animate({opacity: 1}, 200);
                      window.clearInterval(base.checkVisible);
                  }
              }, 500);
ae432de6   Alexey Boroda   first commit
188
189
          },
  
9870b2b4   Alexey Boroda   -In process
190
          wrapItems : function () {
ae432de6   Alexey Boroda   first commit
191
              var base = this;
9870b2b4   Alexey Boroda   -In process
192
193
              base.$userItems.wrapAll("<div class=\"owl-wrapper\">").wrap("<div class=\"owl-item\"></div>");
              base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\">");
ae432de6   Alexey Boroda   first commit
194
195
196
197
              base.wrapperOuter = base.$elem.find(".owl-wrapper-outer");
              base.$elem.css("display", "block");
          },
  
9870b2b4   Alexey Boroda   -In process
198
199
200
201
          baseClass : function () {
              var base = this,
                  hasBaseClass = base.$elem.hasClass(base.options.baseClass),
                  hasThemeClass = base.$elem.hasClass(base.options.theme);
ae432de6   Alexey Boroda   first commit
202
203
204
205
206
207
208
209
210
211
  
              if (!hasBaseClass) {
                  base.$elem.addClass(base.options.baseClass);
              }
  
              if (!hasThemeClass) {
                  base.$elem.addClass(base.options.theme);
              }
          },
  
9870b2b4   Alexey Boroda   -In process
212
          updateItems : function () {
ae432de6   Alexey Boroda   first commit
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
              var base = this, width, i;
  
              if (base.options.responsive === false) {
                  return false;
              }
              if (base.options.singleItem === true) {
                  base.options.items = base.orignalItems = 1;
                  base.options.itemsCustom = false;
                  base.options.itemsDesktop = false;
                  base.options.itemsDesktopSmall = false;
                  base.options.itemsTablet = false;
                  base.options.itemsTabletSmall = false;
                  base.options.itemsMobile = false;
                  return false;
              }
  
9870b2b4   Alexey Boroda   -In process
229
              width = $(base.options.responsiveBaseWidth).width();
ae432de6   Alexey Boroda   first commit
230
  
9870b2b4   Alexey Boroda   -In process
231
              if (width > (base.options.itemsDesktop[0] || base.orignalItems)) {
ae432de6   Alexey Boroda   first commit
232
233
234
235
                  base.options.items = base.orignalItems;
              }
              if (base.options.itemsCustom !== false) {
                  //Reorder array by screen size
9870b2b4   Alexey Boroda   -In process
236
                  base.options.itemsCustom.sort(function (a, b) {return a[0] - b[0]; });
ae432de6   Alexey Boroda   first commit
237
238
  
                  for (i = 0; i < base.options.itemsCustom.length; i += 1) {
9870b2b4   Alexey Boroda   -In process
239
240
                      if (base.options.itemsCustom[i][0] <= width) {
                          base.options.items = base.options.itemsCustom[i][1];
ae432de6   Alexey Boroda   first commit
241
242
243
244
245
                      }
                  }
  
              } else {
  
9870b2b4   Alexey Boroda   -In process
246
247
                  if (width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false) {
                      base.options.items = base.options.itemsDesktop[1];
ae432de6   Alexey Boroda   first commit
248
249
                  }
  
9870b2b4   Alexey Boroda   -In process
250
251
                  if (width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false) {
                      base.options.items = base.options.itemsDesktopSmall[1];
ae432de6   Alexey Boroda   first commit
252
253
                  }
  
9870b2b4   Alexey Boroda   -In process
254
255
                  if (width <= base.options.itemsTablet[0] && base.options.itemsTablet !== false) {
                      base.options.items = base.options.itemsTablet[1];
ae432de6   Alexey Boroda   first commit
256
257
                  }
  
9870b2b4   Alexey Boroda   -In process
258
259
                  if (width <= base.options.itemsTabletSmall[0] && base.options.itemsTabletSmall !== false) {
                      base.options.items = base.options.itemsTabletSmall[1];
ae432de6   Alexey Boroda   first commit
260
261
                  }
  
9870b2b4   Alexey Boroda   -In process
262
263
                  if (width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false) {
                      base.options.items = base.options.itemsMobile[1];
ae432de6   Alexey Boroda   first commit
264
265
266
267
268
269
270
271
272
                  }
              }
  
              //if number of items is less than declared
              if (base.options.items > base.itemsAmount && base.options.itemsScaleUp === true) {
                  base.options.items = base.itemsAmount;
              }
          },
  
9870b2b4   Alexey Boroda   -In process
273
274
275
276
          response : function () {
              var base = this,
                  smallDelay,
                  lastWindowWidth;
ae432de6   Alexey Boroda   first commit
277
278
279
280
  
              if (base.options.responsive !== true) {
                  return false;
              }
9870b2b4   Alexey Boroda   -In process
281
              lastWindowWidth = $(window).width();
ae432de6   Alexey Boroda   first commit
282
  
9870b2b4   Alexey Boroda   -In process
283
284
              base.resizer = function () {
                  if ($(window).width() !== lastWindowWidth) {
ae432de6   Alexey Boroda   first commit
285
286
287
288
                      if (base.options.autoPlay !== false) {
                          window.clearInterval(base.autoPlayInterval);
                      }
                      window.clearTimeout(smallDelay);
9870b2b4   Alexey Boroda   -In process
289
290
291
292
                      smallDelay = window.setTimeout(function () {
                          lastWindowWidth = $(window).width();
                          base.updateVars();
                      }, base.options.responsiveRefreshRate);
ae432de6   Alexey Boroda   first commit
293
294
                  }
              };
9870b2b4   Alexey Boroda   -In process
295
              $(window).resize(base.resizer);
ae432de6   Alexey Boroda   first commit
296
297
          },
  
9870b2b4   Alexey Boroda   -In process
298
          updatePosition : function () {
ae432de6   Alexey Boroda   first commit
299
300
301
302
303
304
305
              var base = this;
              base.jumpTo(base.currentItem);
              if (base.options.autoPlay !== false) {
                  base.checkAp();
              }
          },
  
9870b2b4   Alexey Boroda   -In process
306
307
308
309
          appendItemsSizes : function () {
              var base = this,
                  roundPages = 0,
                  lastItem = base.itemsAmount - base.options.items;
ae432de6   Alexey Boroda   first commit
310
  
9870b2b4   Alexey Boroda   -In process
311
312
313
314
315
              base.$owlItems.each(function (index) {
                  var $this = $(this);
                  $this
                      .css({"width": base.itemWidth})
                      .data("owl-item", Number(index));
ae432de6   Alexey Boroda   first commit
316
  
9870b2b4   Alexey Boroda   -In process
317
318
319
                  if (index % base.options.items === 0 || index === lastItem) {
                      if (!(index > lastItem)) {
                          roundPages += 1;
ae432de6   Alexey Boroda   first commit
320
                      }
ae432de6   Alexey Boroda   first commit
321
                  }
9870b2b4   Alexey Boroda   -In process
322
323
                  $this.data("owl-roundPages", roundPages);
              });
ae432de6   Alexey Boroda   first commit
324
325
          },
  
9870b2b4   Alexey Boroda   -In process
326
327
328
          appendWrapperSizes : function () {
              var base = this,
                  width = base.$owlItems.length * base.itemWidth;
ae432de6   Alexey Boroda   first commit
329
  
9870b2b4   Alexey Boroda   -In process
330
331
332
333
              base.$owlWrapper.css({
                  "width": width * 2,
                  "left": 0
              });
ae432de6   Alexey Boroda   first commit
334
335
336
              base.appendItemsSizes();
          },
  
9870b2b4   Alexey Boroda   -In process
337
          calculateAll : function () {
ae432de6   Alexey Boroda   first commit
338
339
340
341
342
343
344
              var base = this;
              base.calculateWidth();
              base.appendWrapperSizes();
              base.loops();
              base.max();
          },
  
9870b2b4   Alexey Boroda   -In process
345
          calculateWidth : function () {
ae432de6   Alexey Boroda   first commit
346
347
348
349
              var base = this;
              base.itemWidth = Math.round(base.$elem.width() / base.options.items);
          },
  
9870b2b4   Alexey Boroda   -In process
350
351
352
          max : function () {
              var base = this,
                  maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1;
ae432de6   Alexey Boroda   first commit
353
354
355
356
357
358
359
360
361
362
363
              if (base.options.items > base.itemsAmount) {
                  base.maximumItem = 0;
                  maximum = 0;
                  base.maximumPixels = 0;
              } else {
                  base.maximumItem = base.itemsAmount - base.options.items;
                  base.maximumPixels = maximum;
              }
              return maximum;
          },
  
9870b2b4   Alexey Boroda   -In process
364
          min : function () {
ae432de6   Alexey Boroda   first commit
365
366
367
              return 0;
          },
  
9870b2b4   Alexey Boroda   -In process
368
369
370
371
372
373
374
          loops : function () {
              var base = this,
                  prev = 0,
                  elWidth = 0,
                  i,
                  item,
                  roundPageNum;
ae432de6   Alexey Boroda   first commit
375
  
9870b2b4   Alexey Boroda   -In process
376
              base.positionsInArray = [0];
ae432de6   Alexey Boroda   first commit
377
378
379
380
381
382
383
              base.pagesInArray = [];
  
              for (i = 0; i < base.itemsAmount; i += 1) {
                  elWidth += base.itemWidth;
                  base.positionsInArray.push(-elWidth);
  
                  if (base.options.scrollPerPage === true) {
9870b2b4   Alexey Boroda   -In process
384
                      item = $(base.$owlItems[i]);
ae432de6   Alexey Boroda   first commit
385
386
                      roundPageNum = item.data("owl-roundPages");
                      if (roundPageNum !== prev) {
9870b2b4   Alexey Boroda   -In process
387
                          base.pagesInArray[prev] = base.positionsInArray[i];
ae432de6   Alexey Boroda   first commit
388
389
390
391
392
393
                          prev = roundPageNum;
                      }
                  }
              }
          },
  
9870b2b4   Alexey Boroda   -In process
394
          buildControls : function () {
ae432de6   Alexey Boroda   first commit
395
396
              var base = this;
              if (base.options.navigation === true || base.options.pagination === true) {
9870b2b4   Alexey Boroda   -In process
397
                  base.owlControls = $("<div class=\"owl-controls\"/>").toggleClass("clickable", !base.browser.isTouch).appendTo(base.$elem);
ae432de6   Alexey Boroda   first commit
398
399
400
401
402
403
404
405
406
              }
              if (base.options.pagination === true) {
                  base.buildPagination();
              }
              if (base.options.navigation === true) {
                  base.buildButtons();
              }
          },
  
9870b2b4   Alexey Boroda   -In process
407
408
409
          buildButtons : function () {
              var base = this,
                  buttonsWrapper = $("<div class=\"owl-buttons\"/>");
ae432de6   Alexey Boroda   first commit
410
411
              base.owlControls.append(buttonsWrapper);
  
9870b2b4   Alexey Boroda   -In process
412
413
414
415
              base.buttonPrev = $("<div/>", {
                  "class" : "owl-prev",
                  "html" : base.options.navigationText[0] || ""
              });
ae432de6   Alexey Boroda   first commit
416
  
9870b2b4   Alexey Boroda   -In process
417
418
419
420
              base.buttonNext = $("<div/>", {
                  "class" : "owl-next",
                  "html" : base.options.navigationText[1] || ""
              });
ae432de6   Alexey Boroda   first commit
421
422
423
424
425
  
              buttonsWrapper
                  .append(base.buttonPrev)
                  .append(base.buttonNext);
  
9870b2b4   Alexey Boroda   -In process
426
427
428
429
430
431
432
433
434
435
              buttonsWrapper.on("touchstart.owlControls mousedown.owlControls", "div[class^=\"owl\"]", function (event) {
                  event.preventDefault();
              });
  
              buttonsWrapper.on("touchend.owlControls mouseup.owlControls", "div[class^=\"owl\"]", function (event) {
                  event.preventDefault();
                  if ($(this).hasClass("owl-next")) {
                      base.next();
                  } else {
                      base.prev();
ae432de6   Alexey Boroda   first commit
436
                  }
9870b2b4   Alexey Boroda   -In process
437
              });
ae432de6   Alexey Boroda   first commit
438
439
          },
  
9870b2b4   Alexey Boroda   -In process
440
          buildPagination : function () {
ae432de6   Alexey Boroda   first commit
441
442
443
444
445
              var base = this;
  
              base.paginationWrapper = $("<div class=\"owl-pagination\"/>");
              base.owlControls.append(base.paginationWrapper);
  
9870b2b4   Alexey Boroda   -In process
446
447
448
449
              base.paginationWrapper.on("touchend.owlControls mouseup.owlControls", ".owl-page", function (event) {
                  event.preventDefault();
                  if (Number($(this).data("owl-page")) !== base.currentItem) {
                      base.goTo(Number($(this).data("owl-page")), true);
ae432de6   Alexey Boroda   first commit
450
                  }
9870b2b4   Alexey Boroda   -In process
451
              });
ae432de6   Alexey Boroda   first commit
452
453
          },
  
9870b2b4   Alexey Boroda   -In process
454
455
456
457
458
459
460
461
          updatePagination : function () {
              var base = this,
                  counter,
                  lastPage,
                  lastItem,
                  i,
                  paginationButton,
                  paginationButtonInner;
ae432de6   Alexey Boroda   first commit
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
  
              if (base.options.pagination === false) {
                  return false;
              }
  
              base.paginationWrapper.html("");
  
              counter = 0;
              lastPage = base.itemsAmount - base.itemsAmount % base.options.items;
  
              for (i = 0; i < base.itemsAmount; i += 1) {
                  if (i % base.options.items === 0) {
                      counter += 1;
                      if (lastPage === i) {
                          lastItem = base.itemsAmount - base.options.items;
                      }
9870b2b4   Alexey Boroda   -In process
478
479
480
481
482
483
484
                      paginationButton = $("<div/>", {
                          "class" : "owl-page"
                      });
                      paginationButtonInner = $("<span></span>", {
                          "text": base.options.paginationNumbers === true ? counter : "",
                          "class": base.options.paginationNumbers === true ? "owl-numbers" : ""
                      });
ae432de6   Alexey Boroda   first commit
485
486
487
488
489
490
491
492
493
494
                      paginationButton.append(paginationButtonInner);
  
                      paginationButton.data("owl-page", lastPage === i ? lastItem : i);
                      paginationButton.data("owl-roundPages", counter);
  
                      base.paginationWrapper.append(paginationButton);
                  }
              }
              base.checkPagination();
          },
9870b2b4   Alexey Boroda   -In process
495
          checkPagination : function () {
ae432de6   Alexey Boroda   first commit
496
497
498
499
              var base = this;
              if (base.options.pagination === false) {
                  return false;
              }
9870b2b4   Alexey Boroda   -In process
500
501
502
503
504
505
506
507
              base.paginationWrapper.find(".owl-page").each(function () {
                  if ($(this).data("owl-roundPages") === $(base.$owlItems[base.currentItem]).data("owl-roundPages")) {
                      base.paginationWrapper
                          .find(".owl-page")
                          .removeClass("active");
                      $(this).addClass("active");
                  }
              });
ae432de6   Alexey Boroda   first commit
508
509
          },
  
9870b2b4   Alexey Boroda   -In process
510
          checkNavigation : function () {
ae432de6   Alexey Boroda   first commit
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
              var base = this;
  
              if (base.options.navigation === false) {
                  return false;
              }
              if (base.options.rewindNav === false) {
                  if (base.currentItem === 0 && base.maximumItem === 0) {
                      base.buttonPrev.addClass("disabled");
                      base.buttonNext.addClass("disabled");
                  } else if (base.currentItem === 0 && base.maximumItem !== 0) {
                      base.buttonPrev.addClass("disabled");
                      base.buttonNext.removeClass("disabled");
                  } else if (base.currentItem === base.maximumItem) {
                      base.buttonPrev.removeClass("disabled");
                      base.buttonNext.addClass("disabled");
                  } else if (base.currentItem !== 0 && base.currentItem !== base.maximumItem) {
                      base.buttonPrev.removeClass("disabled");
                      base.buttonNext.removeClass("disabled");
                  }
              }
          },
  
9870b2b4   Alexey Boroda   -In process
533
          updateControls : function () {
ae432de6   Alexey Boroda   first commit
534
535
536
537
538
539
540
541
542
543
544
545
              var base = this;
              base.updatePagination();
              base.checkNavigation();
              if (base.owlControls) {
                  if (base.options.items >= base.itemsAmount) {
                      base.owlControls.hide();
                  } else {
                      base.owlControls.show();
                  }
              }
          },
  
9870b2b4   Alexey Boroda   -In process
546
          destroyControls : function () {
ae432de6   Alexey Boroda   first commit
547
548
549
550
551
552
              var base = this;
              if (base.owlControls) {
                  base.owlControls.remove();
              }
          },
  
9870b2b4   Alexey Boroda   -In process
553
          next : function (speed) {
ae432de6   Alexey Boroda   first commit
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
              var base = this;
  
              if (base.isTransition) {
                  return false;
              }
  
              base.currentItem += base.options.scrollPerPage === true ? base.options.items : 1;
              if (base.currentItem > base.maximumItem + (base.options.scrollPerPage === true ? (base.options.items - 1) : 0)) {
                  if (base.options.rewindNav === true) {
                      base.currentItem = 0;
                      speed = "rewind";
                  } else {
                      base.currentItem = base.maximumItem;
                      return false;
                  }
              }
              base.goTo(base.currentItem, speed);
          },
  
9870b2b4   Alexey Boroda   -In process
573
          prev : function (speed) {
ae432de6   Alexey Boroda   first commit
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
              var base = this;
  
              if (base.isTransition) {
                  return false;
              }
  
              if (base.options.scrollPerPage === true && base.currentItem > 0 && base.currentItem < base.options.items) {
                  base.currentItem = 0;
              } else {
                  base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 1;
              }
              if (base.currentItem < 0) {
                  if (base.options.rewindNav === true) {
                      base.currentItem = base.maximumItem;
                      speed = "rewind";
                  } else {
                      base.currentItem = 0;
                      return false;
                  }
              }
              base.goTo(base.currentItem, speed);
          },
  
9870b2b4   Alexey Boroda   -In process
597
598
599
          goTo : function (position, speed, drag) {
              var base = this,
                  goToPixel;
ae432de6   Alexey Boroda   first commit
600
601
602
603
604
  
              if (base.isTransition) {
                  return false;
              }
              if (typeof base.options.beforeMove === "function") {
9870b2b4   Alexey Boroda   -In process
605
                  base.options.beforeMove.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
606
607
608
609
610
611
612
613
614
615
616
              }
              if (position >= base.maximumItem) {
                  position = base.maximumItem;
              } else if (position <= 0) {
                  position = 0;
              }
  
              base.currentItem = base.owl.currentItem = position;
              if (base.options.transitionStyle !== false && drag !== "drag" && base.options.items === 1 && base.browser.support3d === true) {
                  base.swapSpeed(0);
                  if (base.browser.support3d === true) {
9870b2b4   Alexey Boroda   -In process
617
                      base.transition3d(base.positionsInArray[position]);
ae432de6   Alexey Boroda   first commit
618
                  } else {
9870b2b4   Alexey Boroda   -In process
619
                      base.css2slide(base.positionsInArray[position], 1);
ae432de6   Alexey Boroda   first commit
620
621
622
623
624
                  }
                  base.afterGo();
                  base.singleItemTransition();
                  return false;
              }
9870b2b4   Alexey Boroda   -In process
625
              goToPixel = base.positionsInArray[position];
ae432de6   Alexey Boroda   first commit
626
627
628
629
630
631
  
              if (base.browser.support3d === true) {
                  base.isCss3Finish = false;
  
                  if (speed === true) {
                      base.swapSpeed("paginationSpeed");
9870b2b4   Alexey Boroda   -In process
632
633
634
                      window.setTimeout(function () {
                          base.isCss3Finish = true;
                      }, base.options.paginationSpeed);
ae432de6   Alexey Boroda   first commit
635
636
637
  
                  } else if (speed === "rewind") {
                      base.swapSpeed(base.options.rewindSpeed);
9870b2b4   Alexey Boroda   -In process
638
639
640
                      window.setTimeout(function () {
                          base.isCss3Finish = true;
                      }, base.options.rewindSpeed);
ae432de6   Alexey Boroda   first commit
641
642
643
  
                  } else {
                      base.swapSpeed("slideSpeed");
9870b2b4   Alexey Boroda   -In process
644
645
646
                      window.setTimeout(function () {
                          base.isCss3Finish = true;
                      }, base.options.slideSpeed);
ae432de6   Alexey Boroda   first commit
647
648
649
650
651
652
653
654
655
656
657
658
659
660
                  }
                  base.transition3d(goToPixel);
              } else {
                  if (speed === true) {
                      base.css2slide(goToPixel, base.options.paginationSpeed);
                  } else if (speed === "rewind") {
                      base.css2slide(goToPixel, base.options.rewindSpeed);
                  } else {
                      base.css2slide(goToPixel, base.options.slideSpeed);
                  }
              }
              base.afterGo();
          },
  
9870b2b4   Alexey Boroda   -In process
661
          jumpTo : function (position) {
ae432de6   Alexey Boroda   first commit
662
663
              var base = this;
              if (typeof base.options.beforeMove === "function") {
9870b2b4   Alexey Boroda   -In process
664
                  base.options.beforeMove.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
665
666
667
668
669
670
671
672
              }
              if (position >= base.maximumItem || position === -1) {
                  position = base.maximumItem;
              } else if (position <= 0) {
                  position = 0;
              }
              base.swapSpeed(0);
              if (base.browser.support3d === true) {
9870b2b4   Alexey Boroda   -In process
673
                  base.transition3d(base.positionsInArray[position]);
ae432de6   Alexey Boroda   first commit
674
              } else {
9870b2b4   Alexey Boroda   -In process
675
                  base.css2slide(base.positionsInArray[position], 1);
ae432de6   Alexey Boroda   first commit
676
677
678
679
680
              }
              base.currentItem = base.owl.currentItem = position;
              base.afterGo();
          },
  
9870b2b4   Alexey Boroda   -In process
681
          afterGo : function () {
ae432de6   Alexey Boroda   first commit
682
683
684
              var base = this;
  
              base.prevArr.push(base.currentItem);
9870b2b4   Alexey Boroda   -In process
685
              base.prevItem = base.owl.prevItem = base.prevArr[base.prevArr.length - 2];
ae432de6   Alexey Boroda   first commit
686
687
688
689
690
691
692
693
694
695
696
697
              base.prevArr.shift(0);
  
              if (base.prevItem !== base.currentItem) {
                  base.checkPagination();
                  base.checkNavigation();
                  base.eachMoveUpdate();
  
                  if (base.options.autoPlay !== false) {
                      base.checkAp();
                  }
              }
              if (typeof base.options.afterMove === "function" && base.prevItem !== base.currentItem) {
9870b2b4   Alexey Boroda   -In process
698
                  base.options.afterMove.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
699
700
701
              }
          },
  
9870b2b4   Alexey Boroda   -In process
702
          stop : function () {
ae432de6   Alexey Boroda   first commit
703
704
705
706
707
              var base = this;
              base.apStatus = "stop";
              window.clearInterval(base.autoPlayInterval);
          },
  
9870b2b4   Alexey Boroda   -In process
708
          checkAp : function () {
ae432de6   Alexey Boroda   first commit
709
710
711
712
713
714
              var base = this;
              if (base.apStatus !== "stop") {
                  base.play();
              }
          },
  
9870b2b4   Alexey Boroda   -In process
715
          play : function () {
ae432de6   Alexey Boroda   first commit
716
717
718
719
720
721
              var base = this;
              base.apStatus = "play";
              if (base.options.autoPlay === false) {
                  return false;
              }
              window.clearInterval(base.autoPlayInterval);
9870b2b4   Alexey Boroda   -In process
722
723
724
              base.autoPlayInterval = window.setInterval(function () {
                  base.next(true);
              }, base.options.autoPlay);
ae432de6   Alexey Boroda   first commit
725
726
          },
  
9870b2b4   Alexey Boroda   -In process
727
          swapSpeed : function (action) {
ae432de6   Alexey Boroda   first commit
728
729
730
731
732
733
734
735
736
737
              var base = this;
              if (action === "slideSpeed") {
                  base.$owlWrapper.css(base.addCssSpeed(base.options.slideSpeed));
              } else if (action === "paginationSpeed") {
                  base.$owlWrapper.css(base.addCssSpeed(base.options.paginationSpeed));
              } else if (typeof action !== "string") {
                  base.$owlWrapper.css(base.addCssSpeed(action));
              }
          },
  
9870b2b4   Alexey Boroda   -In process
738
          addCssSpeed : function (speed) {
ae432de6   Alexey Boroda   first commit
739
740
741
742
743
744
745
746
              return {
                  "-webkit-transition": "all " + speed + "ms ease",
                  "-moz-transition": "all " + speed + "ms ease",
                  "-o-transition": "all " + speed + "ms ease",
                  "transition": "all " + speed + "ms ease"
              };
          },
  
9870b2b4   Alexey Boroda   -In process
747
          removeTransition : function () {
ae432de6   Alexey Boroda   first commit
748
749
750
751
752
753
754
755
              return {
                  "-webkit-transition": "",
                  "-moz-transition": "",
                  "-o-transition": "",
                  "transition": ""
              };
          },
  
9870b2b4   Alexey Boroda   -In process
756
          doTranslate : function (pixels) {
ae432de6   Alexey Boroda   first commit
757
758
759
760
761
762
763
764
765
              return {
                  "-webkit-transform": "translate3d(" + pixels + "px, 0px, 0px)",
                  "-moz-transform": "translate3d(" + pixels + "px, 0px, 0px)",
                  "-o-transform": "translate3d(" + pixels + "px, 0px, 0px)",
                  "-ms-transform": "translate3d(" + pixels + "px, 0px, 0px)",
                  "transform": "translate3d(" + pixels + "px, 0px,0px)"
              };
          },
  
9870b2b4   Alexey Boroda   -In process
766
          transition3d : function (value) {
ae432de6   Alexey Boroda   first commit
767
768
769
770
              var base = this;
              base.$owlWrapper.css(base.doTranslate(value));
          },
  
9870b2b4   Alexey Boroda   -In process
771
          css2move : function (value) {
ae432de6   Alexey Boroda   first commit
772
              var base = this;
9870b2b4   Alexey Boroda   -In process
773
              base.$owlWrapper.css({"left" : value});
ae432de6   Alexey Boroda   first commit
774
775
          },
  
9870b2b4   Alexey Boroda   -In process
776
          css2slide : function (value, speed) {
ae432de6   Alexey Boroda   first commit
777
778
779
              var base = this;
  
              base.isCssFinish = false;
9870b2b4   Alexey Boroda   -In process
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
              base.$owlWrapper.stop(true, true).animate({
                  "left" : value
              }, {
                  duration : speed || base.options.slideSpeed,
                  complete : function () {
                      base.isCssFinish = true;
                  }
              });
          },
  
          checkBrowser : function () {
              var base = this,
                  translate3D = "translate3d(0px, 0px, 0px)",
                  tempElem = document.createElement("div"),
                  regex,
                  asSupport,
                  support3d,
                  isTouch;
  
              tempElem.style.cssText = "  -moz-transform:" + translate3D +
                                    "; -ms-transform:"     + translate3D +
                                    "; -o-transform:"      + translate3D +
                                    "; -webkit-transform:" + translate3D +
                                    "; transform:"         + translate3D;
ae432de6   Alexey Boroda   first commit
804
805
806
807
808
809
810
              regex = /translate3d\(0px, 0px, 0px\)/g;
              asSupport = tempElem.style.cssText.match(regex);
              support3d = (asSupport !== null && asSupport.length === 1);
  
              isTouch = "ontouchstart" in window || window.navigator.msMaxTouchPoints;
  
              base.browser = {
9870b2b4   Alexey Boroda   -In process
811
812
                  "support3d" : support3d,
                  "isTouch" : isTouch
ae432de6   Alexey Boroda   first commit
813
814
815
              };
          },
  
9870b2b4   Alexey Boroda   -In process
816
          moveEvents : function () {
ae432de6   Alexey Boroda   first commit
817
818
819
820
821
822
823
              var base = this;
              if (base.options.mouseDrag !== false || base.options.touchDrag !== false) {
                  base.gestures();
                  base.disabledEvents();
              }
          },
  
9870b2b4   Alexey Boroda   -In process
824
825
826
          eventTypes : function () {
              var base = this,
                  types = ["s", "e", "x"];
ae432de6   Alexey Boroda   first commit
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
  
              base.ev_types = {};
  
              if (base.options.mouseDrag === true && base.options.touchDrag === true) {
                  types = [
                      "touchstart.owl mousedown.owl",
                      "touchmove.owl mousemove.owl",
                      "touchend.owl touchcancel.owl mouseup.owl"
                  ];
              } else if (base.options.mouseDrag === false && base.options.touchDrag === true) {
                  types = [
                      "touchstart.owl",
                      "touchmove.owl",
                      "touchend.owl touchcancel.owl"
                  ];
              } else if (base.options.mouseDrag === true && base.options.touchDrag === false) {
                  types = [
                      "mousedown.owl",
                      "mousemove.owl",
                      "mouseup.owl"
                  ];
              }
  
9870b2b4   Alexey Boroda   -In process
850
851
852
              base.ev_types.start = types[0];
              base.ev_types.move = types[1];
              base.ev_types.end = types[2];
ae432de6   Alexey Boroda   first commit
853
854
          },
  
9870b2b4   Alexey Boroda   -In process
855
          disabledEvents :  function () {
ae432de6   Alexey Boroda   first commit
856
              var base = this;
9870b2b4   Alexey Boroda   -In process
857
858
859
860
              base.$elem.on("dragstart.owl", function (event) { event.preventDefault(); });
              base.$elem.on("mousedown.disableTextSelect", function (e) {
                  return $(e.target).is('input, textarea, select, option');
              });
ae432de6   Alexey Boroda   first commit
861
862
          },
  
9870b2b4   Alexey Boroda   -In process
863
          gestures : function () {
ae432de6   Alexey Boroda   first commit
864
              /*jslint unparam: true*/
9870b2b4   Alexey Boroda   -In process
865
866
867
868
869
870
871
872
873
874
875
876
877
              var base = this,
                  locals = {
                      offsetX : 0,
                      offsetY : 0,
                      baseElWidth : 0,
                      relativePos : 0,
                      position: null,
                      minSwipe : null,
                      maxSwipe: null,
                      sliding : null,
                      dargging: null,
                      targetElement : null
                  };
ae432de6   Alexey Boroda   first commit
878
879
880
881
882
883
  
              base.isCssFinish = true;
  
              function getTouches(event) {
                  if (event.touches !== undefined) {
                      return {
9870b2b4   Alexey Boroda   -In process
884
885
                          x : event.touches[0].pageX,
                          y : event.touches[0].pageY
ae432de6   Alexey Boroda   first commit
886
887
888
889
890
891
                      };
                  }
  
                  if (event.touches === undefined) {
                      if (event.pageX !== undefined) {
                          return {
9870b2b4   Alexey Boroda   -In process
892
893
                              x : event.pageX,
                              y : event.pageY
ae432de6   Alexey Boroda   first commit
894
895
896
897
                          };
                      }
                      if (event.pageX === undefined) {
                          return {
9870b2b4   Alexey Boroda   -In process
898
899
                              x : event.clientX,
                              y : event.clientY
ae432de6   Alexey Boroda   first commit
900
901
902
903
904
905
906
                          };
                      }
                  }
              }
  
              function swapEvents(type) {
                  if (type === "on") {
9870b2b4   Alexey Boroda   -In process
907
908
                      $(document).on(base.ev_types.move, dragMove);
                      $(document).on(base.ev_types.end, dragEnd);
ae432de6   Alexey Boroda   first commit
909
                  } else if (type === "off") {
9870b2b4   Alexey Boroda   -In process
910
911
                      $(document).off(base.ev_types.move);
                      $(document).off(base.ev_types.end);
ae432de6   Alexey Boroda   first commit
912
913
914
915
                  }
              }
  
              function dragStart(event) {
9870b2b4   Alexey Boroda   -In process
916
917
                  var ev = event.originalEvent || event || window.event,
                      position;
ae432de6   Alexey Boroda   first commit
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
  
                  if (ev.which === 3) {
                      return false;
                  }
                  if (base.itemsAmount <= base.options.items) {
                      return;
                  }
                  if (base.isCssFinish === false && !base.options.dragBeforeAnimFinish) {
                      return false;
                  }
                  if (base.isCss3Finish === false && !base.options.dragBeforeAnimFinish) {
                      return false;
                  }
  
                  if (base.options.autoPlay !== false) {
                      window.clearInterval(base.autoPlayInterval);
                  }
  
                  if (base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")) {
                      base.$owlWrapper.addClass("grabbing");
                  }
  
                  base.newPosX = 0;
                  base.newRelativeX = 0;
  
9870b2b4   Alexey Boroda   -In process
943
                  $(this).css(base.removeTransition());
ae432de6   Alexey Boroda   first commit
944
  
9870b2b4   Alexey Boroda   -In process
945
                  position = $(this).position();
ae432de6   Alexey Boroda   first commit
946
947
948
949
950
951
952
953
954
955
956
957
                  locals.relativePos = position.left;
  
                  locals.offsetX = getTouches(ev).x - position.left;
                  locals.offsetY = getTouches(ev).y - position.top;
  
                  swapEvents("on");
  
                  locals.sliding = false;
                  locals.targetElement = ev.target || ev.srcElement;
              }
  
              function dragMove(event) {
9870b2b4   Alexey Boroda   -In process
958
959
960
                  var ev = event.originalEvent || event || window.event,
                      minSwipe,
                      maxSwipe;
ae432de6   Alexey Boroda   first commit
961
962
963
964
965
966
967
  
                  base.newPosX = getTouches(ev).x - locals.offsetX;
                  base.newPosY = getTouches(ev).y - locals.offsetY;
                  base.newRelativeX = base.newPosX - locals.relativePos;
  
                  if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) {
                      locals.dragging = true;
9870b2b4   Alexey Boroda   -In process
968
                      base.options.startDragging.apply(base, [base.$elem]);
ae432de6   Alexey Boroda   first commit
969
970
971
972
973
974
975
976
977
978
979
980
                  }
  
                  if ((base.newRelativeX > 8 || base.newRelativeX < -8) && (base.browser.isTouch === true)) {
                      if (ev.preventDefault !== undefined) {
                          ev.preventDefault();
                      } else {
                          ev.returnValue = false;
                      }
                      locals.sliding = true;
                  }
  
                  if ((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false) {
9870b2b4   Alexey Boroda   -In process
981
                      $(document).off("touchmove.owl");
ae432de6   Alexey Boroda   first commit
982
983
                  }
  
9870b2b4   Alexey Boroda   -In process
984
                  minSwipe = function () {
ae432de6   Alexey Boroda   first commit
985
986
987
                      return base.newRelativeX / 5;
                  };
  
9870b2b4   Alexey Boroda   -In process
988
                  maxSwipe = function () {
ae432de6   Alexey Boroda   first commit
989
990
991
992
993
994
995
996
997
998
999
1000
                      return base.maximumPixels + base.newRelativeX / 5;
                  };
  
                  base.newPosX = Math.max(Math.min(base.newPosX, minSwipe()), maxSwipe());
                  if (base.browser.support3d === true) {
                      base.transition3d(base.newPosX);
                  } else {
                      base.css2move(base.newPosX);
                  }
              }
  
              function dragEnd(event) {
9870b2b4   Alexey Boroda   -In process
1001
1002
1003
1004
                  var ev = event.originalEvent || event || window.event,
                      newPosition,
                      handlers,
                      owlStopEvent;
ae432de6   Alexey Boroda   first commit
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
  
                  ev.target = ev.target || ev.srcElement;
  
                  locals.dragging = false;
  
                  if (base.browser.isTouch !== true) {
                      base.$owlWrapper.removeClass("grabbing");
                  }
  
                  if (base.newRelativeX < 0) {
                      base.dragDirection = base.owl.dragDirection = "left";
                  } else {
                      base.dragDirection = base.owl.dragDirection = "right";
                  }
  
                  if (base.newRelativeX !== 0) {
                      newPosition = base.getNewPosition();
                      base.goTo(newPosition, false, "drag");
                      if (locals.targetElement === ev.target && base.browser.isTouch !== true) {
9870b2b4   Alexey Boroda   -In process
1024
1025
1026
1027
1028
1029
                          $(ev.target).on("click.disable", function (ev) {
                              ev.stopImmediatePropagation();
                              ev.stopPropagation();
                              ev.preventDefault();
                              $(ev.target).off("click.disable");
                          });
ae432de6   Alexey Boroda   first commit
1030
1031
1032
1033
1034
1035
1036
                          handlers = $._data(ev.target, "events").click;
                          owlStopEvent = handlers.pop();
                          handlers.splice(0, 0, owlStopEvent);
                      }
                  }
                  swapEvents("off");
              }
ae432de6   Alexey Boroda   first commit
1037
1038
1039
              base.$elem.on(base.ev_types.start, ".owl-wrapper", dragStart);
          },
  
9870b2b4   Alexey Boroda   -In process
1040
1041
1042
          getNewPosition : function () {
              var base = this,
                  newPosition = base.closestItem();
ae432de6   Alexey Boroda   first commit
1043
1044
1045
  
              if (newPosition > base.maximumItem) {
                  base.currentItem = base.maximumItem;
9870b2b4   Alexey Boroda   -In process
1046
                  newPosition  = base.maximumItem;
ae432de6   Alexey Boroda   first commit
1047
1048
1049
1050
1051
1052
              } else if (base.newPosX >= 0) {
                  newPosition = 0;
                  base.currentItem = 0;
              }
              return newPosition;
          },
9870b2b4   Alexey Boroda   -In process
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
          closestItem : function () {
              var base = this,
                  array = base.options.scrollPerPage === true ? base.pagesInArray : base.positionsInArray,
                  goal = base.newPosX,
                  closest = null;
  
              $.each(array, function (i, v) {
                  if (goal - (base.itemWidth / 20) > array[i + 1] && goal - (base.itemWidth / 20) < v && base.moveDirection() === "left") {
                      closest = v;
                      if (base.options.scrollPerPage === true) {
                          base.currentItem = $.inArray(closest, base.positionsInArray);
                      } else {
                          base.currentItem = i;
                      }
                  } else if (goal + (base.itemWidth / 20) < v && goal + (base.itemWidth / 20) > (array[i + 1] || array[i] - base.itemWidth) && base.moveDirection() === "right") {
                      if (base.options.scrollPerPage === true) {
                          closest = array[i + 1] || array[array.length - 1];
                          base.currentItem = $.inArray(closest, base.positionsInArray);
                      } else {
                          closest = array[i + 1];
                          base.currentItem = i + 1;
ae432de6   Alexey Boroda   first commit
1074
1075
                      }
                  }
9870b2b4   Alexey Boroda   -In process
1076
              });
ae432de6   Alexey Boroda   first commit
1077
1078
1079
              return base.currentItem;
          },
  
9870b2b4   Alexey Boroda   -In process
1080
1081
1082
          moveDirection : function () {
              var base = this,
                  direction;
ae432de6   Alexey Boroda   first commit
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
              if (base.newRelativeX < 0) {
                  direction = "right";
                  base.playDirection = "next";
              } else {
                  direction = "left";
                  base.playDirection = "prev";
              }
              return direction;
          },
  
9870b2b4   Alexey Boroda   -In process
1093
          customEvents : function () {
ae432de6   Alexey Boroda   first commit
1094
1095
              /*jslint unparam: true*/
              var base = this;
9870b2b4   Alexey Boroda   -In process
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
              base.$elem.on("owl.next", function () {
                  base.next();
              });
              base.$elem.on("owl.prev", function () {
                  base.prev();
              });
              base.$elem.on("owl.play", function (event, speed) {
                  base.options.autoPlay = speed;
                  base.play();
                  base.hoverStatus = "play";
              });
              base.$elem.on("owl.stop", function () {
                  base.stop();
                  base.hoverStatus = "stop";
              });
              base.$elem.on("owl.goTo", function (event, item) {
                  base.goTo(item);
              });
              base.$elem.on("owl.jumpTo", function (event, item) {
                  base.jumpTo(item);
              });
          },
  
          stopOnHover : function () {
ae432de6   Alexey Boroda   first commit
1120
1121
              var base = this;
              if (base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false) {
9870b2b4   Alexey Boroda   -In process
1122
1123
1124
1125
1126
1127
                  base.$elem.on("mouseover", function () {
                      base.stop();
                  });
                  base.$elem.on("mouseout", function () {
                      if (base.hoverStatus !== "stop") {
                          base.play();
ae432de6   Alexey Boroda   first commit
1128
                      }
9870b2b4   Alexey Boroda   -In process
1129
                  });
ae432de6   Alexey Boroda   first commit
1130
1131
1132
              }
          },
  
9870b2b4   Alexey Boroda   -In process
1133
1134
1135
1136
1137
1138
1139
          lazyLoad : function () {
              var base = this,
                  i,
                  $item,
                  itemNumber,
                  $lazyImg,
                  follow;
ae432de6   Alexey Boroda   first commit
1140
1141
1142
1143
1144
  
              if (base.options.lazyLoad === false) {
                  return false;
              }
              for (i = 0; i < base.itemsAmount; i += 1) {
9870b2b4   Alexey Boroda   -In process
1145
                  $item = $(base.$owlItems[i]);
ae432de6   Alexey Boroda   first commit
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
  
                  if ($item.data("owl-loaded") === "loaded") {
                      continue;
                  }
  
                  itemNumber = $item.data("owl-item");
                  $lazyImg = $item.find(".lazyOwl");
  
                  if (typeof $lazyImg.data("src") !== "string") {
                      $item.data("owl-loaded", "loaded");
                      continue;
                  }
                  if ($item.data("owl-loaded") === undefined) {
                      $lazyImg.hide();
9870b2b4   Alexey Boroda   -In process
1160
                      $item.addClass("loading").data("owl-loaded", "checked");
ae432de6   Alexey Boroda   first commit
1161
1162
1163
1164
1165
1166
1167
                  }
                  if (base.options.lazyFollow === true) {
                      follow = itemNumber >= base.currentItem;
                  } else {
                      follow = true;
                  }
                  if (follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length) {
9870b2b4   Alexey Boroda   -In process
1168
1169
1170
                      $lazyImg.each(function() {
                          base.lazyPreload($item, $(this));
                      });
ae432de6   Alexey Boroda   first commit
1171
1172
1173
1174
                  }
              }
          },
  
9870b2b4   Alexey Boroda   -In process
1175
1176
1177
1178
          lazyPreload : function ($item, $lazyImg) {
              var base = this,
                  iterations = 0,
                  isBackgroundImg;
ae432de6   Alexey Boroda   first commit
1179
1180
1181
1182
1183
  
              if ($lazyImg.prop("tagName") === "DIV") {
                  $lazyImg.css("background-image", "url(" + $lazyImg.data("src") + ")");
                  isBackgroundImg = true;
              } else {
9870b2b4   Alexey Boroda   -In process
1184
                  $lazyImg[0].src = $lazyImg.data("src");
ae432de6   Alexey Boroda   first commit
1185
1186
1187
              }
  
              function showImage() {
9870b2b4   Alexey Boroda   -In process
1188
                  $item.data("owl-loaded", "loaded").removeClass("loading");
ae432de6   Alexey Boroda   first commit
1189
1190
1191
1192
1193
1194
1195
                  $lazyImg.removeAttr("data-src");
                  if (base.options.lazyEffect === "fade") {
                      $lazyImg.fadeIn(400);
                  } else {
                      $lazyImg.show();
                  }
                  if (typeof base.options.afterLazyLoad === "function") {
9870b2b4   Alexey Boroda   -In process
1196
                      base.options.afterLazyLoad.apply(this, [base.$elem]);
ae432de6   Alexey Boroda   first commit
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
                  }
              }
  
              function checkLazyImage() {
                  iterations += 1;
                  if (base.completeImg($lazyImg.get(0)) || isBackgroundImg === true) {
                      showImage();
                  } else if (iterations <= 100) {//if image loads in less than 10 seconds 
                      window.setTimeout(checkLazyImage, 100);
                  } else {
                      showImage();
                  }
              }
  
              checkLazyImage();
          },
  
9870b2b4   Alexey Boroda   -In process
1214
1215
1216
1217
          autoHeight : function () {
              var base = this,
                  $currentimg = $(base.$owlItems[base.currentItem]).find("img"),
                  iterations;
ae432de6   Alexey Boroda   first commit
1218
1219
  
              function addHeight() {
9870b2b4   Alexey Boroda   -In process
1220
                  var $currentItem = $(base.$owlItems[base.currentItem]).height();
ae432de6   Alexey Boroda   first commit
1221
1222
                  base.wrapperOuter.css("height", $currentItem + "px");
                  if (!base.wrapperOuter.hasClass("autoHeight")) {
9870b2b4   Alexey Boroda   -In process
1223
1224
1225
                      window.setTimeout(function () {
                          base.wrapperOuter.addClass("autoHeight");
                      }, 0);
ae432de6   Alexey Boroda   first commit
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
                  }
              }
  
              function checkImage() {
                  iterations += 1;
                  if (base.completeImg($currentimg.get(0))) {
                      addHeight();
                  } else if (iterations <= 100) { //if image loads in less than 10 seconds 
                      window.setTimeout(checkImage, 100);
                  } else {
                      base.wrapperOuter.css("height", ""); //Else remove height attribute
                  }
              }
  
              if ($currentimg.get(0) !== undefined) {
                  iterations = 0;
                  checkImage();
              } else {
                  addHeight();
              }
          },
  
9870b2b4   Alexey Boroda   -In process
1248
          completeImg : function (img) {
ae432de6   Alexey Boroda   first commit
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
              var naturalWidthType;
  
              if (!img.complete) {
                  return false;
              }
              naturalWidthType = typeof img.naturalWidth;
              if (naturalWidthType !== "undefined" && img.naturalWidth === 0) {
                  return false;
              }
              return true;
          },
  
9870b2b4   Alexey Boroda   -In process
1261
1262
1263
          onVisibleItems : function () {
              var base = this,
                  i;
ae432de6   Alexey Boroda   first commit
1264
1265
1266
1267
1268
1269
1270
1271
1272
  
              if (base.options.addClassActive === true) {
                  base.$owlItems.removeClass("active");
              }
              base.visibleItems = [];
              for (i = base.currentItem; i < base.currentItem + base.options.items; i += 1) {
                  base.visibleItems.push(i);
  
                  if (base.options.addClassActive === true) {
9870b2b4   Alexey Boroda   -In process
1273
                      $(base.$owlItems[i]).addClass("active");
ae432de6   Alexey Boroda   first commit
1274
1275
1276
1277
1278
                  }
              }
              base.owl.visibleItems = base.visibleItems;
          },
  
9870b2b4   Alexey Boroda   -In process
1279
          transitionTypes : function (className) {
ae432de6   Alexey Boroda   first commit
1280
1281
1282
1283
1284
1285
              var base = this;
              //Currently available: "fade", "backSlide", "goDown", "fadeUp"
              base.outClass = "owl-" + className + "-out";
              base.inClass = "owl-" + className + "-in";
          },
  
9870b2b4   Alexey Boroda   -In process
1286
1287
1288
1289
1290
1291
1292
1293
1294
          singleItemTransition : function () {
              var base = this,
                  outClass = base.outClass,
                  inClass = base.inClass,
                  $currentItem = base.$owlItems.eq(base.currentItem),
                  $prevItem = base.$owlItems.eq(base.prevItem),
                  prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem],
                  origin = Math.abs(base.positionsInArray[base.currentItem]) + base.itemWidth / 2,
                  animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend';
ae432de6   Alexey Boroda   first commit
1295
1296
1297
1298
1299
  
              base.isTransition = true;
  
              base.$owlWrapper
                  .addClass('owl-origin')
9870b2b4   Alexey Boroda   -In process
1300
1301
1302
1303
1304
                  .css({
                      "-webkit-transform-origin" : origin + "px",
                      "-moz-perspective-origin" : origin + "px",
                      "perspective-origin" : origin + "px"
                  });
ae432de6   Alexey Boroda   first commit
1305
1306
              function transStyles(prevPos) {
                  return {
9870b2b4   Alexey Boroda   -In process
1307
1308
                      "position" : "relative",
                      "left" : prevPos + "px"
ae432de6   Alexey Boroda   first commit
1309
1310
1311
1312
1313
1314
                  };
              }
  
              $prevItem
                  .css(transStyles(prevPos, 10))
                  .addClass(outClass)
9870b2b4   Alexey Boroda   -In process
1315
1316
1317
1318
1319
                  .on(animEnd, function () {
                      base.endPrev = true;
                      $prevItem.off(animEnd);
                      base.clearTransStyle($prevItem, outClass);
                  });
ae432de6   Alexey Boroda   first commit
1320
1321
1322
  
              $currentItem
                  .addClass(inClass)
9870b2b4   Alexey Boroda   -In process
1323
1324
1325
1326
1327
                  .on(animEnd, function () {
                      base.endCurrent = true;
                      $currentItem.off(animEnd);
                      base.clearTransStyle($currentItem, inClass);
                  });
ae432de6   Alexey Boroda   first commit
1328
1329
          },
  
9870b2b4   Alexey Boroda   -In process
1330
          clearTransStyle : function (item, classToRemove) {
ae432de6   Alexey Boroda   first commit
1331
              var base = this;
9870b2b4   Alexey Boroda   -In process
1332
1333
1334
1335
              item.css({
                  "position" : "",
                  "left" : ""
              }).removeClass(classToRemove);
ae432de6   Alexey Boroda   first commit
1336
1337
1338
1339
1340
1341
1342
1343
1344
  
              if (base.endPrev && base.endCurrent) {
                  base.$owlWrapper.removeClass('owl-origin');
                  base.endPrev = false;
                  base.endCurrent = false;
                  base.isTransition = false;
              }
          },
  
9870b2b4   Alexey Boroda   -In process
1345
          owlStatus : function () {
ae432de6   Alexey Boroda   first commit
1346
1347
              var base = this;
              base.owl = {
9870b2b4   Alexey Boroda   -In process
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
                  "userOptions"   : base.userOptions,
                  "baseElement"   : base.$elem,
                  "userItems"     : base.$userItems,
                  "owlItems"      : base.$owlItems,
                  "currentItem"   : base.currentItem,
                  "prevItem"      : base.prevItem,
                  "visibleItems"  : base.visibleItems,
                  "isTouch"       : base.browser.isTouch,
                  "browser"       : base.browser,
                  "dragDirection" : base.dragDirection
ae432de6   Alexey Boroda   first commit
1358
1359
1360
              };
          },
  
9870b2b4   Alexey Boroda   -In process
1361
          clearEvents : function () {
ae432de6   Alexey Boroda   first commit
1362
1363
              var base = this;
              base.$elem.off(".owl owl mousedown.disableTextSelect");
9870b2b4   Alexey Boroda   -In process
1364
1365
              $(document).off(".owl owl");
              $(window).off("resize", base.resizer);
ae432de6   Alexey Boroda   first commit
1366
1367
          },
  
9870b2b4   Alexey Boroda   -In process
1368
          unWrap : function () {
ae432de6   Alexey Boroda   first commit
1369
1370
1371
              var base = this;
              if (base.$elem.children().length !== 0) {
                  base.$owlWrapper.unwrap();
9870b2b4   Alexey Boroda   -In process
1372
                  base.$userItems.unwrap().unwrap();
ae432de6   Alexey Boroda   first commit
1373
1374
1375
1376
1377
                  if (base.owlControls) {
                      base.owlControls.remove();
                  }
              }
              base.clearEvents();
9870b2b4   Alexey Boroda   -In process
1378
1379
1380
1381
              base.$elem.attr({
                  style: base.$elem.data("owl-originalStyles") || "",
                  class: base.$elem.data("owl-originalClasses")
              });
ae432de6   Alexey Boroda   first commit
1382
1383
          },
  
9870b2b4   Alexey Boroda   -In process
1384
          destroy : function () {
ae432de6   Alexey Boroda   first commit
1385
1386
1387
1388
1389
1390
1391
              var base = this;
              base.stop();
              window.clearInterval(base.checkVisible);
              base.unWrap();
              base.$elem.removeData();
          },
  
9870b2b4   Alexey Boroda   -In process
1392
1393
1394
          reinit : function (newOptions) {
              var base = this,
                  options = $.extend({}, base.userOptions, newOptions);
ae432de6   Alexey Boroda   first commit
1395
1396
1397
1398
              base.unWrap();
              base.init(options, base.$elem);
          },
  
9870b2b4   Alexey Boroda   -In process
1399
1400
1401
          addItem : function (htmlString, targetPosition) {
              var base = this,
                  position;
ae432de6   Alexey Boroda   first commit
1402
  
9870b2b4   Alexey Boroda   -In process
1403
              if (!htmlString) {return false; }
ae432de6   Alexey Boroda   first commit
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
  
              if (base.$elem.children().length === 0) {
                  base.$elem.append(htmlString);
                  base.setVars();
                  return false;
              }
              base.unWrap();
              if (targetPosition === undefined || targetPosition === -1) {
                  position = -1;
              } else {
                  position = targetPosition;
              }
              if (position >= base.$userItems.length || position === -1) {
9870b2b4   Alexey Boroda   -In process
1417
                  base.$userItems.eq(-1).after(htmlString);
ae432de6   Alexey Boroda   first commit
1418
              } else {
9870b2b4   Alexey Boroda   -In process
1419
                  base.$userItems.eq(position).before(htmlString);
ae432de6   Alexey Boroda   first commit
1420
1421
1422
1423
1424
              }
  
              base.setVars();
          },
  
9870b2b4   Alexey Boroda   -In process
1425
1426
1427
          removeItem : function (targetPosition) {
              var base = this,
                  position;
ae432de6   Alexey Boroda   first commit
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
  
              if (base.$elem.children().length === 0) {
                  return false;
              }
              if (targetPosition === undefined || targetPosition === -1) {
                  position = -1;
              } else {
                  position = targetPosition;
              }
  
              base.unWrap();
9870b2b4   Alexey Boroda   -In process
1439
              base.$userItems.eq(position).remove();
ae432de6   Alexey Boroda   first commit
1440
1441
1442
1443
1444
              base.setVars();
          }
  
      };
  
9870b2b4   Alexey Boroda   -In process
1445
1446
1447
1448
      $.fn.owlCarousel = function (options) {
          return this.each(function () {
              if ($(this).data("owl-init") === true) {
                  return false;
ae432de6   Alexey Boroda   first commit
1449
              }
9870b2b4   Alexey Boroda   -In process
1450
1451
1452
1453
1454
              $(this).data("owl-init", true);
              var carousel = Object.create(Carousel);
              carousel.init(options, this);
              $.data(this, "owlCarousel", carousel);
          });
ae432de6   Alexey Boroda   first commit
1455
1456
1457
1458
      };
  
      $.fn.owlCarousel.options = {
  
9870b2b4   Alexey Boroda   -In process
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
          items : 5,
          itemsCustom : false,
          itemsDesktop : [1199, 4],
          itemsDesktopSmall : [979, 3],
          itemsTablet : [768, 2],
          itemsTabletSmall : false,
          itemsMobile : [479, 1],
          singleItem : false,
          itemsScaleUp : false,
  
          slideSpeed : 200,
          paginationSpeed : 800,
          rewindSpeed : 1000,
  
          autoPlay : false,
          stopOnHover : false,
  
          navigation : false,
          navigationText : ["prev", "next"],
          rewindNav : true,
          scrollPerPage : false,
  
          pagination : true,
          paginationNumbers : false,
  
          responsive : true,
          responsiveRefreshRate : 200,
          responsiveBaseWidth : window,
  
          baseClass : "owl-carousel",
          theme : "owl-theme",
  
          lazyLoad : false,
          lazyFollow : true,
          lazyEffect : "fade",
  
          autoHeight : false,
  
          jsonPath : false,
          jsonSuccess : false,
  
          dragBeforeAnimFinish : true,
          mouseDrag : true,
          touchDrag : true,
  
          addClassActive : false,
          transitionStyle : false,
  
          beforeUpdate : false,
          afterUpdate : false,
          beforeInit : false,
          afterInit : false,
          beforeMove : false,
          afterMove : false,
          afterAction : false,
          startDragging : false,
ae432de6   Alexey Boroda   first commit
1515
1516
1517
          afterLazyLoad: false
      };
  }(jQuery, window, document));