added the posibility to show image alt next to next/prev buttons
added the posibility to show image alt next to next/prev buttons

/* /*
* jQuery OwlCarousel v1.3.2 * jQuery OwlCarousel v1.3.2
* *
* Copyright (c) 2013 Bartosz Wojciechowski * Copyright (c) 2013 Bartosz Wojciechowski
* http://www.owlgraphic.com/owlcarousel/ * http://www.owlgraphic.com/owlcarousel/
* *
* Licensed under MIT * Licensed under MIT
* *
*/ */
   
/*JS Lint helpers: */ /*JS Lint helpers: */
/*global dragMove: false, dragEnd: false, $, jQuery, alert, window, document */ /*global dragMove: false, dragEnd: false, $, jQuery, alert, window, document */
/*jslint nomen: true, continue:true */ /*jslint nomen: true, continue:true */
   
if (typeof Object.create !== "function") { if (typeof Object.create !== "function") {
Object.create = function (obj) { Object.create = function (obj) {
function F() {} function F() {}
F.prototype = obj; F.prototype = obj;
return new F(); return new F();
}; };
} }
(function ($, window, document) { (function ($, window, document) {
   
var Carousel = { var Carousel = {
init : function (options, el) { init : function (options, el) {
var base = this; var base = this;
   
base.$elem = $(el); base.$elem = $(el);
base.options = $.extend({}, $.fn.owlCarousel.options, base.$elem.data(), options); base.options = $.extend({}, $.fn.owlCarousel.options, base.$elem.data(), options);
   
base.userOptions = options; base.userOptions = options;
base.loadContent(); base.loadContent();
}, },
   
loadContent : function () { loadContent : function () {
var base = this, url; var base = this, url;
   
function getData(data) { function getData(data) {
var i, content = ""; var i, content = "";
if (typeof base.options.jsonSuccess === "function") { if (typeof base.options.jsonSuccess === "function") {
base.options.jsonSuccess.apply(this, [data]); base.options.jsonSuccess.apply(this, [data]);
} else { } else {
for (i in data.owl) { for (i in data.owl) {
if (data.owl.hasOwnProperty(i)) { if (data.owl.hasOwnProperty(i)) {
content += data.owl[i].item; content += data.owl[i].item;
} }
} }
base.$elem.html(content); base.$elem.html(content);
} }
base.logIn(); base.logIn();
} }
   
if (typeof base.options.beforeInit === "function") { if (typeof base.options.beforeInit === "function") {
base.options.beforeInit.apply(this, [base.$elem]); base.options.beforeInit.apply(this, [base.$elem]);
} }
   
if (typeof base.options.jsonPath === "string") { if (typeof base.options.jsonPath === "string") {
url = base.options.jsonPath; url = base.options.jsonPath;
$.getJSON(url, getData); $.getJSON(url, getData);
} else { } else {
base.logIn(); base.logIn();
} }
}, },
   
logIn : function () { logIn : function () {
var base = this; var base = this;
   
base.$elem.data("owl-originalStyles", base.$elem.attr("style")) base.$elem.data("owl-originalStyles", base.$elem.attr("style"))
.data("owl-originalClasses", base.$elem.attr("class")); .data("owl-originalClasses", base.$elem.attr("class"));
   
base.$elem.css({opacity: 0}); base.$elem.css({opacity: 0});
base.orignalItems = base.options.items; base.orignalItems = base.options.items;
base.checkBrowser(); base.checkBrowser();
base.wrapperWidth = 0; base.wrapperWidth = 0;
base.checkVisible = null; base.checkVisible = null;
base.setVars(); base.setVars();
}, },
   
setVars : function () { setVars : function () {
var base = this; var base = this;
if (base.$elem.children().length === 0) {return false; } if (base.$elem.children().length === 0) {return false; }
base.baseClass(); base.baseClass();
base.eventTypes(); base.eventTypes();
base.$userItems = base.$elem.children(); base.$userItems = base.$elem.children();
base.itemsAmount = base.$userItems.length; base.itemsAmount = base.$userItems.length;
base.wrapItems(); base.wrapItems();
base.$owlItems = base.$elem.find(".owl-item"); base.$owlItems = base.$elem.find(".owl-item");
  base.titles = {};
base.$owlWrapper = base.$elem.find(".owl-wrapper"); base.$owlWrapper = base.$elem.find(".owl-wrapper");
base.playDirection = "next"; base.playDirection = "next";
base.prevItem = 0; base.prevItem = 0;
base.prevArr = [0]; base.prevArr = [0];
base.currentItem = 0; base.currentItem = 0;
base.customEvents(); base.customEvents();
base.onStartup(); base.onStartup();
}, },
   
onStartup : function () { onStartup : function () {
var base = this; var base = this;
base.updateItems(); base.updateItems();
base.calculateAll(); base.calculateAll();
base.buildControls(); base.buildControls();
base.updateControls(); base.updateControls();
base.response(); base.response();
base.moveEvents(); base.moveEvents();
base.stopOnHover(); base.stopOnHover();
base.owlStatus(); base.owlStatus();
   
if (base.options.transitionStyle !== false) { if (base.options.transitionStyle !== false) {
base.transitionTypes(base.options.transitionStyle); base.transitionTypes(base.options.transitionStyle);
} }
if (base.options.autoPlay === true) { if (base.options.autoPlay === true) {
base.options.autoPlay = 5000; base.options.autoPlay = 5000;
} }
base.play(); base.play();
   
base.$elem.find(".owl-wrapper").css("display", "block"); base.$elem.find(".owl-wrapper").css("display", "block");
   
if (!base.$elem.is(":visible")) { if (!base.$elem.is(":visible")) {
base.watchVisibility(); base.watchVisibility();
} else { } else {
base.$elem.css("opacity", 1); base.$elem.css("opacity", 1);
} }
base.onstartup = false; base.onstartup = false;
base.eachMoveUpdate(); base.eachMoveUpdate();
if (typeof base.options.afterInit === "function") { if (typeof base.options.afterInit === "function") {
base.options.afterInit.apply(this, [base.$elem]); base.options.afterInit.apply(this, [base.$elem]);
} }
}, },
   
eachMoveUpdate : function () { eachMoveUpdate : function () {
var base = this; var base = this;
   
if (base.options.lazyLoad === true) { if (base.options.lazyLoad === true) {
base.lazyLoad(); base.lazyLoad();
} }
if (base.options.autoHeight === true) { if (base.options.autoHeight === true) {
base.autoHeight(); base.autoHeight();
} }
base.onVisibleItems(); base.onVisibleItems();
   
if (typeof base.options.afterAction === "function") { if (typeof base.options.afterAction === "function") {
base.options.afterAction.apply(this, [base.$elem]); base.options.afterAction.apply(this, [base.$elem]);
} }
}, },
   
updateVars : function () { updateVars : function () {
var base = this; var base = this;
if (typeof base.options.beforeUpdate === "function") { if (typeof base.options.beforeUpdate === "function") {
base.options.beforeUpdate.apply(this, [base.$elem]); base.options.beforeUpdate.apply(this, [base.$elem]);
} }
base.watchVisibility(); base.watchVisibility();
base.updateItems(); base.updateItems();
base.calculateAll(); base.calculateAll();
base.updatePosition(); base.updatePosition();
base.updateControls(); base.updateControls();
base.eachMoveUpdate(); base.eachMoveUpdate();
if (typeof base.options.afterUpdate === "function") { if (typeof base.options.afterUpdate === "function") {
base.options.afterUpdate.apply(this, [base.$elem]); base.options.afterUpdate.apply(this, [base.$elem]);
} }
}, },
   
reload : function () { reload : function () {
var base = this; var base = this;
window.setTimeout(function () { window.setTimeout(function () {
base.updateVars(); base.updateVars();
}, 0); }, 0);
}, },
   
watchVisibility : function () { watchVisibility : function () {
var base = this; var base = this;
   
if (base.$elem.is(":visible") === false) { if (base.$elem.is(":visible") === false) {
base.$elem.css({opacity: 0}); base.$elem.css({opacity: 0});
window.clearInterval(base.autoPlayInterval); window.clearInterval(base.autoPlayInterval);
window.clearInterval(base.checkVisible); window.clearInterval(base.checkVisible);
} else { } else {
return false; return false;
} }
base.checkVisible = window.setInterval(function () { base.checkVisible = window.setInterval(function () {
if (base.$elem.is(":visible")) { if (base.$elem.is(":visible")) {
base.reload(); base.reload();
base.$elem.animate({opacity: 1}, 200); base.$elem.animate({opacity: 1}, 200);
window.clearInterval(base.checkVisible); window.clearInterval(base.checkVisible);
} }
}, 500); }, 500);
}, },
   
wrapItems : function () { wrapItems : function () {
var base = this; var base = this;
base.$userItems.wrapAll("<div class=\"owl-wrapper\">").wrap("<div class=\"owl-item\"></div>"); base.$userItems.wrapAll("<div class=\"owl-wrapper\">").wrap("<div class=\"owl-item\"></div>");
base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\">"); base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\">");
base.wrapperOuter = base.$elem.find(".owl-wrapper-outer"); base.wrapperOuter = base.$elem.find(".owl-wrapper-outer");
base.$elem.css("display", "block"); base.$elem.css("display", "block");
}, },
   
baseClass : function () { baseClass : function () {
var base = this, var base = this,
hasBaseClass = base.$elem.hasClass(base.options.baseClass), hasBaseClass = base.$elem.hasClass(base.options.baseClass),
hasThemeClass = base.$elem.hasClass(base.options.theme); hasThemeClass = base.$elem.hasClass(base.options.theme);
   
if (!hasBaseClass) { if (!hasBaseClass) {
base.$elem.addClass(base.options.baseClass); base.$elem.addClass(base.options.baseClass);
} }
   
if (!hasThemeClass) { if (!hasThemeClass) {
base.$elem.addClass(base.options.theme); base.$elem.addClass(base.options.theme);
} }
}, },
   
updateItems : function () { updateItems : function () {
var base = this, width, i; var base = this, width, i;
   
if (base.options.responsive === false) { if (base.options.responsive === false) {
return false; return false;
} }
if (base.options.singleItem === true) { if (base.options.singleItem === true) {
base.options.items = base.orignalItems = 1; base.options.items = base.orignalItems = 1;
base.options.itemsCustom = false; base.options.itemsCustom = false;
base.options.itemsDesktop = false; base.options.itemsDesktop = false;
base.options.itemsDesktopSmall = false; base.options.itemsDesktopSmall = false;
base.options.itemsTablet = false; base.options.itemsTablet = false;
base.options.itemsTabletSmall = false; base.options.itemsTabletSmall = false;
base.options.itemsMobile = false; base.options.itemsMobile = false;
return false; return false;
} }
   
width = $(base.options.responsiveBaseWidth).width(); width = $(base.options.responsiveBaseWidth).width();
   
if (width > (base.options.itemsDesktop[0] || base.orignalItems)) { if (width > (base.options.itemsDesktop[0] || base.orignalItems)) {
base.options.items = base.orignalItems; base.options.items = base.orignalItems;
} }
if (base.options.itemsCustom !== false) { if (base.options.itemsCustom !== false) {
//Reorder array by screen size //Reorder array by screen size
base.options.itemsCustom.sort(function (a, b) {return a[0] - b[0]; }); base.options.itemsCustom.sort(function (a, b) {return a[0] - b[0]; });
   
for (i = 0; i < base.options.itemsCustom.length; i += 1) { for (i = 0; i < base.options.itemsCustom.length; i += 1) {
if (base.options.itemsCustom[i][0] <= width) { if (base.options.itemsCustom[i][0] <= width) {
base.options.items = base.options.itemsCustom[i][1]; base.options.items = base.options.itemsCustom[i][1];
} }
} }
   
} else { } else {
   
if (width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false) { if (width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false) {
base.options.items = base.options.itemsDesktop[1]; base.options.items = base.options.itemsDesktop[1];
} }
   
if (width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false) { if (width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false) {
base.options.items = base.options.itemsDesktopSmall[1]; base.options.items = base.options.itemsDesktopSmall[1];
} }
   
if (width <= base.options.itemsTablet[0] && base.options.itemsTablet !== false) { if (width <= base.options.itemsTablet[0] && base.options.itemsTablet !== false) {
base.options.items = base.options.itemsTablet[1]; base.options.items = base.options.itemsTablet[1];
} }
   
if (width <= base.options.itemsTabletSmall[0] && base.options.itemsTabletSmall !== false) { if (width <= base.options.itemsTabletSmall[0] && base.options.itemsTabletSmall !== false) {
base.options.items = base.options.itemsTabletSmall[1]; base.options.items = base.options.itemsTabletSmall[1];
} }
   
if (width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false) { if (width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false) {
base.options.items = base.options.itemsMobile[1]; base.options.items = base.options.itemsMobile[1];
} }
} }
   
//if number of items is less than declared //if number of items is less than declared
if (base.options.items > base.itemsAmount && base.options.itemsScaleUp === true) { if (base.options.items > base.itemsAmount && base.options.itemsScaleUp === true) {
base.options.items = base.itemsAmount; base.options.items = base.itemsAmount;
} }
}, },
   
response : function () { response : function () {
var base = this, var base = this,
smallDelay, smallDelay,
lastWindowWidth; lastWindowWidth;
   
if (base.options.responsive !== true) { if (base.options.responsive !== true) {
return false; return false;
} }
lastWindowWidth = $(window).width(); lastWindowWidth = $(window).width();
   
base.resizer = function () { base.resizer = function () {
if ($(window).width() !== lastWindowWidth) { if ($(window).width() !== lastWindowWidth) {
if (base.options.autoPlay !== false) { if (base.options.autoPlay !== false) {
window.clearInterval(base.autoPlayInterval); window.clearInterval(base.autoPlayInterval);
} }
window.clearTimeout(smallDelay); window.clearTimeout(smallDelay);
smallDelay = window.setTimeout(function () { smallDelay = window.setTimeout(function () {
lastWindowWidth = $(window).width(); lastWindowWidth = $(window).width();
base.updateVars(); base.updateVars();
}, base.options.responsiveRefreshRate); }, base.options.responsiveRefreshRate);
} }
}; };
$(window).resize(base.resizer); $(window).resize(base.resizer);
}, },
   
updatePosition : function () { updatePosition : function () {
var base = this; var base = this;
base.jumpTo(base.currentItem); base.jumpTo(base.currentItem);
if (base.options.autoPlay !== false) { if (base.options.autoPlay !== false) {
base.checkAp(); base.checkAp();
} }
}, },
   
appendItemsSizes : function () { appendItemsSizes : function () {
var base = this, var base = this,
roundPages = 0, roundPages = 0,
lastItem = base.itemsAmount - base.options.items; lastItem = base.itemsAmount - base.options.items;
   
base.$owlItems.each(function (index) { base.$owlItems.each(function (index) {
  base.titles[index] = $(this).find('img').attr ('alt');
var $this = $(this); var $this = $(this);
$this $this
.css({"width": base.itemWidth}) .css({"width": base.itemWidth})
.data("owl-item", Number(index)); .data("owl-item", Number(index));
   
if (index % base.options.items === 0 || index === lastItem) { if (index % base.options.items === 0 || index === lastItem) {
if (!(index > lastItem)) { if (!(index > lastItem)) {
roundPages += 1; roundPages += 1;
} }
} }
$this.data("owl-roundPages", roundPages); $this.data("owl-roundPages", roundPages);
}); });
}, },
   
appendWrapperSizes : function () { appendWrapperSizes : function () {
var base = this, var base = this,
width = base.$owlItems.length * base.itemWidth; width = base.$owlItems.length * base.itemWidth;
   
base.$owlWrapper.css({ base.$owlWrapper.css({
"width": width * 2, "width": width * 2,
"left": 0 "left": 0
}); });
base.appendItemsSizes(); base.appendItemsSizes();
}, },
   
calculateAll : function () { calculateAll : function () {
var base = this; var base = this;
base.calculateWidth(); base.calculateWidth();
base.appendWrapperSizes(); base.appendWrapperSizes();
base.loops(); base.loops();
base.max(); base.max();
}, },
   
calculateWidth : function () { calculateWidth : function () {
var base = this; var base = this;
base.itemWidth = Math.round(base.$elem.width() / base.options.items); base.itemWidth = Math.round(base.$elem.width() / base.options.items);
}, },
   
max : function () { max : function () {
var base = this, var base = this,
maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1; maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1;
if (base.options.items > base.itemsAmount) { if (base.options.items > base.itemsAmount) {
base.maximumItem = 0; base.maximumItem = 0;
maximum = 0; maximum = 0;
base.maximumPixels = 0; base.maximumPixels = 0;
} else { } else {
base.maximumItem = base.itemsAmount - base.options.items; base.maximumItem = base.itemsAmount - base.options.items;
base.maximumPixels = maximum; base.maximumPixels = maximum;
} }
return maximum; return maximum;
}, },
   
min : function () { min : function () {
return 0; return 0;
}, },
   
loops : function () { loops : function () {
var base = this, var base = this,
prev = 0, prev = 0,
elWidth = 0, elWidth = 0,
i, i,
item, item,
roundPageNum; roundPageNum;
   
base.positionsInArray = [0]; base.positionsInArray = [0];
base.pagesInArray = []; base.pagesInArray = [];
   
for (i = 0; i < base.itemsAmount; i += 1) { for (i = 0; i < base.itemsAmount; i += 1) {
elWidth += base.itemWidth; elWidth += base.itemWidth;
base.positionsInArray.push(-elWidth); base.positionsInArray.push(-elWidth);
   
if (base.options.scrollPerPage === true) { if (base.options.scrollPerPage === true) {
item = $(base.$owlItems[i]); item = $(base.$owlItems[i]);
roundPageNum = item.data("owl-roundPages"); roundPageNum = item.data("owl-roundPages");
if (roundPageNum !== prev) { if (roundPageNum !== prev) {
base.pagesInArray[prev] = base.positionsInArray[i]; base.pagesInArray[prev] = base.positionsInArray[i];
prev = roundPageNum; prev = roundPageNum;
} }
} }
} }
}, },
   
buildControls : function () { buildControls : function () {
var base = this; var base = this;
if (base.options.navigation === true || base.options.pagination === true) { if (base.options.navigation === true || base.options.pagination === true) {
base.owlControls = $("<div class=\"owl-controls\"/>").toggleClass("clickable", !base.browser.isTouch).appendTo(base.$elem); base.owlControls = $("<div class=\"owl-controls\"/>").toggleClass("clickable", !base.browser.isTouch).appendTo(base.$elem);
} }
if (base.options.pagination === true) { if (base.options.pagination === true) {
base.buildPagination(); base.buildPagination();
} }
if (base.options.navigation === true) { if (base.options.navigation === true) {
base.buildButtons(); base.buildButtons();
} }
}, },
   
buildButtons : function () { buildButtons : function () {
var base = this, var base = this,
buttonsWrapper = $("<div class=\"owl-buttons\"/>"); buttonsWrapper = $("<div class=\"owl-buttons\"/>");
base.owlControls.append(buttonsWrapper); base.owlControls.append(buttonsWrapper);
   
base.buttonPrev = $("<div/>", { base.buttonPrev = $("<div/>", {
"class" : "owl-prev", "class" : "owl-prev",
"html" : base.options.navigationText[0] || "" "html" : base.options.navigationText[0] || ""
}); });
   
base.buttonNext = $("<div/>", { base.buttonNext = $("<div/>", {
"class" : "owl-next", "class" : "owl-next",
"html" : base.options.navigationText[1] || "" "html" : base.options.navigationText[1] || ""
}); });
   
buttonsWrapper buttonsWrapper
.append(base.buttonPrev) .append(base.buttonPrev)
  .append( base.userOptions.showTitles ? '<span id="currTitle">'+base.titles[ base.currentItem ]+'</span>' : '' )
.append(base.buttonNext); .append(base.buttonNext);
   
  if ( base.userOptions.showTitles ) {
  buttonsWrapper.prepend ( '<span id="prevTitle">'+((base.currentItem > 0) ? base.titles[ (base.currentItem-1) ] : base.titles[(base.itemsAmount-1)])+'</span>' );
  buttonsWrapper.append ( '<span id="nextTitle">'+((base.currentItem < base.itemsAmount) ? base.titles[ (base.currentItem+1) ] : '')+'</span>' );
  $('#prevTitle').click (function(){base.prev()});
  $('#nextTitle').click (function(){base.next()});
  }
   
buttonsWrapper.on("touchstart.owlControls mousedown.owlControls", "div[class^=\"owl\"]", function (event) { buttonsWrapper.on("touchstart.owlControls mousedown.owlControls", "div[class^=\"owl\"]", function (event) {
event.preventDefault(); event.preventDefault();
}); });
   
buttonsWrapper.on("touchend.owlControls mouseup.owlControls", "div[class^=\"owl\"]", function (event) { buttonsWrapper.on("touchend.owlControls mouseup.owlControls", "div[class^=\"owl\"]", function (event) {
event.preventDefault(); event.preventDefault();
if ($(this).hasClass("owl-next")) { if ($(this).hasClass("owl-next")) {
base.next(); base.next();
} else { } else {
base.prev(); base.prev();
} }
}); });
}, },
   
buildPagination : function () { buildPagination : function () {
var base = this; var base = this;
   
base.paginationWrapper = $("<div class=\"owl-pagination\"/>"); base.paginationWrapper = $("<div class=\"owl-pagination\"/>");
base.owlControls.append(base.paginationWrapper); base.owlControls.append(base.paginationWrapper);
   
base.paginationWrapper.on("touchend.owlControls mouseup.owlControls", ".owl-page", function (event) { base.paginationWrapper.on("touchend.owlControls mouseup.owlControls", ".owl-page", function (event) {
event.preventDefault(); event.preventDefault();
if (Number($(this).data("owl-page")) !== base.currentItem) { if (Number($(this).data("owl-page")) !== base.currentItem) {
base.goTo(Number($(this).data("owl-page")), true); base.goTo(Number($(this).data("owl-page")), true);
} }
}); });
}, },
   
updatePagination : function () { updatePagination : function () {
var base = this, var base = this,
counter, counter,
lastPage, lastPage,
lastItem, lastItem,
i, i,
paginationButton, paginationButton,
paginationButtonInner; paginationButtonInner;
   
if (base.options.pagination === false) { if (base.options.pagination === false) {
return false; return false;
} }
   
base.paginationWrapper.html(""); base.paginationWrapper.html("");
   
counter = 0; counter = 0;
lastPage = base.itemsAmount - base.itemsAmount % base.options.items; lastPage = base.itemsAmount - base.itemsAmount % base.options.items;
   
for (i = 0; i < base.itemsAmount; i += 1) { for (i = 0; i < base.itemsAmount; i += 1) {
if (i % base.options.items === 0) { if (i % base.options.items === 0) {
counter += 1; counter += 1;
if (lastPage === i) { if (lastPage === i) {
lastItem = base.itemsAmount - base.options.items; lastItem = base.itemsAmount - base.options.items;
} }
paginationButton = $("<div/>", { paginationButton = $("<div/>", {
"class" : "owl-page" "class" : "owl-page"
}); });
paginationButtonInner = $("<span></span>", { paginationButtonInner = $("<span></span>", {
"text": base.options.paginationNumbers === true ? counter : "", "text": base.options.paginationNumbers === true ? counter : "",
"class": base.options.paginationNumbers === true ? "owl-numbers" : "" "class": base.options.paginationNumbers === true ? "owl-numbers" : ""
}); });
paginationButton.append(paginationButtonInner); paginationButton.append(paginationButtonInner);
   
paginationButton.data("owl-page", lastPage === i ? lastItem : i); paginationButton.data("owl-page", lastPage === i ? lastItem : i);
paginationButton.data("owl-roundPages", counter); paginationButton.data("owl-roundPages", counter);
   
base.paginationWrapper.append(paginationButton); base.paginationWrapper.append(paginationButton);
} }
} }
base.checkPagination(); base.checkPagination();
}, },
checkPagination : function () { checkPagination : function () {
var base = this; var base = this;
if (base.options.pagination === false) { if (base.options.pagination === false) {
return false; return false;
} }
base.paginationWrapper.find(".owl-page").each(function () { base.paginationWrapper.find(".owl-page").each(function () {
  console.log ( base.currentItem );
if ($(this).data("owl-roundPages") === $(base.$owlItems[base.currentItem]).data("owl-roundPages")) { if ($(this).data("owl-roundPages") === $(base.$owlItems[base.currentItem]).data("owl-roundPages")) {
base.paginationWrapper base.paginationWrapper
.find(".owl-page") .find(".owl-page")
.removeClass("active"); .removeClass("active");
$(this).addClass("active"); $(this).addClass("active");
} }
}); });
}, },
   
checkNavigation : function () { checkNavigation : function () {
var base = this; var base = this;
   
if (base.options.navigation === false) { if (base.options.navigation === false) {
return false; return false;
} }
if (base.options.rewindNav === false) { if (base.options.rewindNav === false) {
if (base.currentItem === 0 && base.maximumItem === 0) { if (base.currentItem === 0 && base.maximumItem === 0) {
base.buttonPrev.addClass("disabled"); base.buttonPrev.addClass("disabled");
base.buttonNext.addClass("disabled"); base.buttonNext.addClass("disabled");
} else if (base.currentItem === 0 && base.maximumItem !== 0) { } else if (base.currentItem === 0 && base.maximumItem !== 0) {
base.buttonPrev.addClass("disabled"); base.buttonPrev.addClass("disabled");
base.buttonNext.removeClass("disabled"); base.buttonNext.removeClass("disabled");
} else if (base.currentItem === base.maximumItem) { } else if (base.currentItem === base.maximumItem) {
base.buttonPrev.removeClass("disabled"); base.buttonPrev.removeClass("disabled");
base.buttonNext.addClass("disabled"); base.buttonNext.addClass("disabled");
} else if (base.currentItem !== 0 && base.currentItem !== base.maximumItem) { } else if (base.currentItem !== 0 && base.currentItem !== base.maximumItem) {
base.buttonPrev.removeClass("disabled"); base.buttonPrev.removeClass("disabled");
base.buttonNext.removeClass("disabled"); base.buttonNext.removeClass("disabled");
} }
} }
}, },
   
updateControls : function () { updateControls : function () {
var base = this; var base = this;
base.updatePagination(); base.updatePagination();
base.checkNavigation(); base.checkNavigation();
if (base.owlControls) { if (base.owlControls) {
if (base.options.items >= base.itemsAmount) { if (base.options.items >= base.itemsAmount) {
base.owlControls.hide(); base.owlControls.hide();
} else { } else {
base.owlControls.show(); base.owlControls.show();
} }
} }
}, },
   
destroyControls : function () { destroyControls : function () {
var base = this; var base = this;
if (base.owlControls) { if (base.owlControls) {
base.owlControls.remove(); base.owlControls.remove();
} }
}, },
   
  displayTitles : function () {
  var base = this;
  $('#prevTitle').html( ( (base.currentItem > 0) ? base.titles[ (base.currentItem-1) ] : base.titles[(base.itemsAmount-1)] ) );
  $('#currTitle').html( base.titles[ base.currentItem ] );
  $('#nextTitle').html( ( (base.currentItem < (base.itemsAmount-1)) ? base.titles[ (base.currentItem+1) ] : base.titles[0]) );
  },
   
next : function (speed) { next : function (speed) {
var base = this; var base = this;
   
if (base.isTransition) { if (base.isTransition) {
return false; return false;
} }
   
base.currentItem += base.options.scrollPerPage === true ? base.options.items : 1; 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.currentItem > base.maximumItem + (base.options.scrollPerPage === true ? (base.options.items - 1) : 0)) {
if (base.options.rewindNav === true) { if (base.options.rewindNav === true) {
base.currentItem = 0; base.currentItem = 0;
speed = "rewind"; speed = "rewind";
} else { } else {
base.currentItem = base.maximumItem; base.currentItem = base.maximumItem;
return false; return false;
} }
} }
base.goTo(base.currentItem, speed); base.goTo(base.currentItem, speed);
}, },
   
prev : function (speed) { prev : function (speed) {
var base = this; var base = this;
   
if (base.isTransition) { if (base.isTransition) {
return false; return false;
} }
   
if (base.options.scrollPerPage === true && base.currentItem > 0 && base.currentItem < base.options.items) { if (base.options.scrollPerPage === true && base.currentItem > 0 && base.currentItem < base.options.items) {
base.currentItem = 0; base.currentItem = 0;
} else { } else {
base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 1; base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 1;
} }
if (base.currentItem < 0) { if (base.currentItem < 0) {
if (base.options.rewindNav === true) { if (base.options.rewindNav === true) {
base.currentItem = base.maximumItem; base.currentItem = base.maximumItem;
speed = "rewind"; speed = "rewind";
} else { } else {
base.currentItem = 0; base.currentItem = 0;
return false; return false;
} }
} }
base.goTo(base.currentItem, speed); base.goTo(base.currentItem, speed);
}, },
   
goTo : function (position, speed, drag) { goTo : function (position, speed, drag) {
var base = this, var base = this,
goToPixel; goToPixel;
   
if (base.isTransition) { if (base.isTransition) {
return false; return false;
} }
if (typeof base.options.beforeMove === "function") { if (typeof base.options.beforeMove === "function") {
base.options.beforeMove.apply(this, [base.$elem]); base.options.beforeMove.apply(this, [base.$elem]);
} }
if (position >= base.maximumItem) { if (position >= base.maximumItem) {
position = base.maximumItem; position = base.maximumItem;
} else if (position <= 0) { } else if (position <= 0) {
position = 0; position = 0;
} }
   
base.currentItem = base.owl.currentItem = position; base.currentItem = base.owl.currentItem = position;
if (base.options.transitionStyle !== false && drag !== "drag" && base.options.items === 1 && base.browser.support3d === true) { if (base.options.transitionStyle !== false && drag !== "drag" && base.options.items === 1 && base.browser.support3d === true) {
base.swapSpeed(0); base.swapSpeed(0);
if (base.browser.support3d === true) { if (base.browser.support3d === true) {
base.transition3d(base.positionsInArray[position]); base.transition3d(base.positionsInArray[position]);
} else { } else {
base.css2slide(base.positionsInArray[position], 1); base.css2slide(base.positionsInArray[position], 1);
} }
base.afterGo(); base.afterGo();
base.singleItemTransition(); base.singleItemTransition();
return false; return false;
} }
goToPixel = base.positionsInArray[position]; goToPixel = base.positionsInArray[position];
   
if (base.browser.support3d === true) { if (base.browser.support3d === true) {
base.isCss3Finish = false; base.isCss3Finish = false;
   
if (speed === true) { if (speed === true) {
base.swapSpeed("paginationSpeed"); base.swapSpeed("paginationSpeed");
window.setTimeout(function () { window.setTimeout(function () {
base.isCss3Finish = true; base.isCss3Finish = true;
}, base.options.paginationSpeed); }, base.options.paginationSpeed);
   
} else if (speed === "rewind") { } else if (speed === "rewind") {
base.swapSpeed(base.options.rewindSpeed); base.swapSpeed(base.options.rewindSpeed);
window.setTimeout(function () { window.setTimeout(function () {
base.isCss3Finish = true; base.isCss3Finish = true;
}, base.options.rewindSpeed); }, base.options.rewindSpeed);
   
} else { } else {
base.swapSpeed("slideSpeed"); base.swapSpeed("slideSpeed");
window.setTimeout(function () { window.setTimeout(function () {
base.isCss3Finish = true; base.isCss3Finish = true;
}, base.options.slideSpeed); }, base.options.slideSpeed);
} }
base.transition3d(goToPixel); base.transition3d(goToPixel);
} else { } else {
if (speed === true) { if (speed === true) {
base.css2slide(goToPixel, base.options.paginationSpeed); base.css2slide(goToPixel, base.options.paginationSpeed);
} else if (speed === "rewind") { } else if (speed === "rewind") {
base.css2slide(goToPixel, base.options.rewindSpeed); base.css2slide(goToPixel, base.options.rewindSpeed);
} else { } else {
base.css2slide(goToPixel, base.options.slideSpeed); base.css2slide(goToPixel, base.options.slideSpeed);
} }
} }
base.afterGo(); base.afterGo();
}, },
   
jumpTo : function (position) { jumpTo : function (position) {
var base = this; var base = this;
if (typeof base.options.beforeMove === "function") { if (typeof base.options.beforeMove === "function") {
base.options.beforeMove.apply(this, [base.$elem]); base.options.beforeMove.apply(this, [base.$elem]);
} }
if (position >= base.maximumItem || position === -1) { if (position >= base.maximumItem || position === -1) {
position = base.maximumItem; position = base.maximumItem;
} else if (position <= 0) { } else if (position <= 0) {
position = 0; position = 0;
} }
base.swapSpeed(0); base.swapSpeed(0);
if (base.browser.support3d === true) { if (base.browser.support3d === true) {
base.transition3d(base.positionsInArray[position]); base.transition3d(base.positionsInArray[position]);
} else { } else {
base.css2slide(base.positionsInArray[position], 1); base.css2slide(base.positionsInArray[position], 1);
} }
base.currentItem = base.owl.currentItem = position; base.currentItem = base.owl.currentItem = position;
base.afterGo(); base.afterGo();
}, },
   
afterGo : function () { afterGo : function () {
var base = this; var base = this;
   
base.prevArr.push(base.currentItem); base.prevArr.push(base.currentItem);
base.prevItem = base.owl.prevItem = base.prevArr[base.prevArr.length - 2]; base.prevItem = base.owl.prevItem = base.prevArr[base.prevArr.length - 2];
base.prevArr.shift(0); base.prevArr.shift(0);
   
if (base.prevItem !== base.currentItem) { if (base.prevItem !== base.currentItem) {
base.checkPagination(); base.checkPagination();
base.checkNavigation(); base.checkNavigation();
base.eachMoveUpdate(); base.eachMoveUpdate();
   
if (base.options.autoPlay !== false) { if (base.options.autoPlay !== false) {
base.checkAp(); base.checkAp();
} }
} }
if (typeof base.options.afterMove === "function" && base.prevItem !== base.currentItem) { if (typeof base.options.afterMove === "function" && base.prevItem !== base.currentItem) {
base.options.afterMove.apply(this, [base.$elem]); base.options.afterMove.apply(this, [base.$elem]);
} }
  base.displayTitles ();
}, },
   
stop : function () { stop : function () {
var base = this; var base = this;
base.apStatus = "stop"; base.apStatus = "stop";
window.clearInterval(base.autoPlayInterval); window.clearInterval(base.autoPlayInterval);
}, },
   
checkAp : function () { checkAp : function () {
var base = this; var base = this;
if (base.apStatus !== "stop") { if (base.apStatus !== "stop") {
base.play(); base.play();
} }
}, },
   
play : function () { play : function () {
var base = this; var base = this;
base.apStatus = "play"; base.apStatus = "play";
if (base.options.autoPlay === false) { if (base.options.autoPlay === false) {
return false; return false;
} }
window.clearInterval(base.autoPlayInterval); window.clearInterval(base.autoPlayInterval);
base.autoPlayInterval = window.setInterval(function () { base.autoPlayInterval = window.setInterval(function () {
base.next(true); base.next(true);
}, base.options.autoPlay); }, base.options.autoPlay);
}, },
   
swapSpeed : function (action) { swapSpeed : function (action) {
var base = this; var base = this;
if (action === "slideSpeed") { if (action === "slideSpeed") {
base.$owlWrapper.css(base.addCssSpeed(base.options.slideSpeed)); base.$owlWrapper.css(base.addCssSpeed(base.options.slideSpeed));
} else if (action === "paginationSpeed") { } else if (action === "paginationSpeed") {
base.$owlWrapper.css(base.addCssSpeed(base.options.paginationSpeed)); base.$owlWrapper.css(base.addCssSpeed(base.options.paginationSpeed));
} else if (typeof action !== "string") { } else if (typeof action !== "string") {
base.$owlWrapper.css(base.addCssSpeed(action)); base.$owlWrapper.css(base.addCssSpeed(action));
} }
}, },
   
addCssSpeed : function (speed) { addCssSpeed : function (speed) {
return { return {
"-webkit-transition": "all " + speed + "ms ease", "-webkit-transition": "all " + speed + "ms ease",
"-moz-transition": "all " + speed + "ms ease", "-moz-transition": "all " + speed + "ms ease",
"-o-transition": "all " + speed + "ms ease", "-o-transition": "all " + speed + "ms ease",
"transition": "all " + speed + "ms ease" "transition": "all " + speed + "ms ease"
}; };
}, },
   
removeTransition : function () { removeTransition : function () {
return { return {
"-webkit-transition": "", "-webkit-transition": "",
"-moz-transition": "", "-moz-transition": "",
"-o-transition": "", "-o-transition": "",
"transition": "" "transition": ""
}; };
}, },
   
doTranslate : function (pixels) { doTranslate : function (pixels) {
return { return {
"-webkit-transform": "translate3d(" + pixels + "px, 0px, 0px)", "-webkit-transform": "translate3d(" + pixels + "px, 0px, 0px)",
"-moz-transform": "translate3d(" + pixels + "px, 0px, 0px)", "-moz-transform": "translate3d(" + pixels + "px, 0px, 0px)",
"-o-transform": "translate3d(" + pixels + "px, 0px, 0px)", "-o-transform": "translate3d(" + pixels + "px, 0px, 0px)",
"-ms-transform": "translate3d(" + pixels + "px, 0px, 0px)", "-ms-transform": "translate3d(" + pixels + "px, 0px, 0px)",
"transform": "translate3d(" + pixels + "px, 0px,0px)" "transform": "translate3d(" + pixels + "px, 0px,0px)"
}; };
}, },
   
transition3d : function (value) { transition3d : function (value) {
var base = this; var base = this;
base.$owlWrapper.css(base.doTranslate(value)); base.$owlWrapper.css(base.doTranslate(value));
}, },
   
css2move : function (value) { css2move : function (value) {
var base = this; var base = this;
base.$owlWrapper.css({"left" : value}); base.$owlWrapper.css({"left" : value});
}, },
   
css2slide : function (value, speed) { css2slide : function (value, speed) {
var base = this; var base = this;
   
base.isCssFinish = false; base.isCssFinish = false;
base.$owlWrapper.stop(true, true).animate({ base.$owlWrapper.stop(true, true).animate({
"left" : value "left" : value
}, { }, {
duration : speed || base.options.slideSpeed, duration : speed || base.options.slideSpeed,
complete : function () { complete : function () {
base.isCssFinish = true; base.isCssFinish = true;
} }
}); });
}, },
   
checkBrowser : function () { checkBrowser : function () {
var base = this, var base = this,
translate3D = "translate3d(0px, 0px, 0px)", translate3D = "translate3d(0px, 0px, 0px)",
tempElem = document.createElement("div"), tempElem = document.createElement("div"),
regex, regex,
asSupport, asSupport,
support3d, support3d,
isTouch; isTouch;
   
tempElem.style.cssText = " -moz-transform:" + translate3D + tempElem.style.cssText = " -moz-transform:" + translate3D +
"; -ms-transform:" + translate3D + "; -ms-transform:" + translate3D +
"; -o-transform:" + translate3D + "; -o-transform:" + translate3D +
"; -webkit-transform:" + translate3D + "; -webkit-transform:" + translate3D +
"; transform:" + translate3D; "; transform:" + translate3D;
regex = /translate3d\(0px, 0px, 0px\)/g; regex = /translate3d\(0px, 0px, 0px\)/g;
asSupport = tempElem.style.cssText.match(regex); asSupport = tempElem.style.cssText.match(regex);
support3d = (asSupport !== null && asSupport.length === 1); support3d = (asSupport !== null && asSupport.length === 1);
   
isTouch = "ontouchstart" in window || window.navigator.msMaxTouchPoints; isTouch = "ontouchstart" in window || window.navigator.msMaxTouchPoints;
   
base.browser = { base.browser = {
"support3d" : support3d, "support3d" : support3d,
"isTouch" : isTouch "isTouch" : isTouch
}; };
}, },
   
moveEvents : function () { moveEvents : function () {
var base = this; var base = this;
if (base.options.mouseDrag !== false || base.options.touchDrag !== false) { if (base.options.mouseDrag !== false || base.options.touchDrag !== false) {
base.gestures(); base.gestures();
base.disabledEvents(); base.disabledEvents();
} }
}, },
   
eventTypes : function () { eventTypes : function () {
var base = this, var base = this,
types = ["s", "e", "x"]; types = ["s", "e", "x"];
   
base.ev_types = {}; base.ev_types = {};
   
if (base.options.mouseDrag === true && base.options.touchDrag === true) { if (base.options.mouseDrag === true && base.options.touchDrag === true) {
types = [ types = [
"touchstart.owl mousedown.owl", "touchstart.owl mousedown.owl",
"touchmove.owl mousemove.owl", "touchmove.owl mousemove.owl",
"touchend.owl touchcancel.owl mouseup.owl" "touchend.owl touchcancel.owl mouseup.owl"
]; ];
} else if (base.options.mouseDrag === false && base.options.touchDrag === true) { } else if (base.options.mouseDrag === false && base.options.touchDrag === true) {
types = [ types = [
"touchstart.owl", "touchstart.owl",
"touchmove.owl", "touchmove.owl",
"touchend.owl touchcancel.owl" "touchend.owl touchcancel.owl"
]; ];
} else if (base.options.mouseDrag === true && base.options.touchDrag === false) { } else if (base.options.mouseDrag === true && base.options.touchDrag === false) {
types = [ types = [
"mousedown.owl", "mousedown.owl",
"mousemove.owl", "mousemove.owl",
"mouseup.owl" "mouseup.owl"
]; ];
} }
   
base.ev_types.start = types[0]; base.ev_types.start = types[0];
base.ev_types.move = types[1]; base.ev_types.move = types[1];
base.ev_types.end = types[2]; base.ev_types.end = types[2];
}, },
   
disabledEvents : function () { disabledEvents : function () {
var base = this; var base = this;
base.$elem.on("dragstart.owl", function (event) { event.preventDefault(); }); base.$elem.on("dragstart.owl", function (event) { event.preventDefault(); });
base.$elem.on("mousedown.disableTextSelect", function (e) { base.$elem.on("mousedown.disableTextSelect", function (e) {
return $(e.target).is('input, textarea, select, option'); return $(e.target).is('input, textarea, select, option');
}); });
}, },
   
gestures : function () { gestures : function () {
/*jslint unparam: true*/ /*jslint unparam: true*/
var base = this, var base = this,
locals = { locals = {
offsetX : 0, offsetX : 0,
offsetY : 0, offsetY : 0,
baseElWidth : 0, baseElWidth : 0,
relativePos : 0, relativePos : 0,
position: null, position: null,
minSwipe : null, minSwipe : null,
maxSwipe: null, maxSwipe: null,
sliding : null, sliding : null,
dargging: null, dargging: null,
targetElement : null targetElement : null
}; };
   
base.isCssFinish = true; base.isCssFinish = true;
   
function getTouches(event) { function getTouches(event) {
if (event.touches !== undefined) { if (event.touches !== undefined) {
return { return {
x : event.touches[0].pageX, x : event.touches[0].pageX,
y : event.touches[0].pageY y : event.touches[0].pageY
}; };
} }
   
if (event.touches === undefined) { if (event.touches === undefined) {
if (event.pageX !== undefined) { if (event.pageX !== undefined) {
return { return {
x : event.pageX, x : event.pageX,
y : event.pageY y : event.pageY
}; };
} }
if (event.pageX === undefined) { if (event.pageX === undefined) {
return { return {
x : event.clientX, x : event.clientX,
y : event.clientY y : event.clientY
}; };
} }
} }
} }
   
function swapEvents(type) { function swapEvents(type) {
if (type === "on") { if (type === "on") {
$(document).on(base.ev_types.move, dragMove); $(document).on(base.ev_types.move, dragMove);
$(document).on(base.ev_types.end, dragEnd); $(document).on(base.ev_types.end, dragEnd);
} else if (type === "off") { } else if (type === "off") {
$(document).off(base.ev_types.move); $(document).off(base.ev_types.move);
$(document).off(base.ev_types.end); $(document).off(base.ev_types.end);
} }
} }
   
function dragStart(event) { function dragStart(event) {
var ev = event.originalEvent || event || window.event, var ev = event.originalEvent || event || window.event,
position; position;
   
if (ev.which === 3) { if (ev.which === 3) {
return false; return false;
} }
if (base.itemsAmount <= base.options.items) { if (base.itemsAmount <= base.options.items) {
return; return;
} }
if (base.isCssFinish === false && !base.options.dragBeforeAnimFinish) { if (base.isCssFinish === false && !base.options.dragBeforeAnimFinish) {
return false; return false;
} }
if (base.isCss3Finish === false && !base.options.dragBeforeAnimFinish) { if (base.isCss3Finish === false && !base.options.dragBeforeAnimFinish) {
return false; return false;
} }
   
if (base.options.autoPlay !== false) { if (base.options.autoPlay !== false) {
window.clearInterval(base.autoPlayInterval); window.clearInterval(base.autoPlayInterval);
} }
   
if (base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")) { if (base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")) {
base.$owlWrapper.addClass("grabbing"); base.$owlWrapper.addClass("grabbing");
} }
   
base.newPosX = 0; base.newPosX = 0;
base.newRelativeX = 0; base.newRelativeX = 0;
   
$(this).css(base.removeTransition()); $(this).css(base.removeTransition());
   
position = $(this).position(); position = $(this).position();
locals.relativePos = position.left; locals.relativePos = position.left;
   
locals.offsetX = getTouches(ev).x - position.left; locals.offsetX = getTouches(ev).x - position.left;
locals.offsetY = getTouches(ev).y - position.top; locals.offsetY = getTouches(ev).y - position.top;
   
swapEvents("on"); swapEvents("on");
   
locals.sliding = false; locals.sliding = false;
locals.targetElement = ev.target || ev.srcElement; locals.targetElement = ev.target || ev.srcElement;
} }
   
function dragMove(event) { function dragMove(event) {
var ev = event.originalEvent || event || window.event, var ev = event.originalEvent || event || window.event,
minSwipe, minSwipe,
maxSwipe; maxSwipe;
   
base.newPosX = getTouches(ev).x - locals.offsetX; base.newPosX = getTouches(ev).x - locals.offsetX;
base.newPosY = getTouches(ev).y - locals.offsetY; base.newPosY = getTouches(ev).y - locals.offsetY;
base.newRelativeX = base.newPosX - locals.relativePos; base.newRelativeX = base.newPosX - locals.relativePos;
   
if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) { if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) {
locals.dragging = true; locals.dragging = true;
base.options.startDragging.apply(base, [base.$elem]); base.options.startDragging.apply(base, [base.$elem]);
} }
   
if ((base.newRelativeX > 8 || base.newRelativeX < -8) && (base.browser.isTouch === true)) { if ((base.newRelativeX > 8 || base.newRelativeX < -8) && (base.browser.isTouch === true)) {
if (ev.preventDefault !== undefined) { if (ev.preventDefault !== undefined) {
ev.preventDefault(); ev.preventDefault();
} else { } else {
ev.returnValue = false; ev.returnValue = false;
} }
locals.sliding = true; locals.sliding = true;
} }
   
if ((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false) { if ((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false) {
$(document).off("touchmove.owl"); $(document).off("touchmove.owl");
} }
   
minSwipe = function () { minSwipe = function () {
return base.newRelativeX / 5; return base.newRelativeX / 5;
}; };
   
maxSwipe = function () { maxSwipe = function () {
return base.maximumPixels + base.newRelativeX / 5; return base.maximumPixels + base.newRelativeX / 5;
}; };
   
base.newPosX = Math.max(Math.min(base.newPosX, minSwipe()), maxSwipe()); base.newPosX = Math.max(Math.min(base.newPosX, minSwipe()), maxSwipe());
if (base.browser.support3d === true) { if (base.browser.support3d === true) {
base.transition3d(base.newPosX); base.transition3d(base.newPosX);
} else { } else {
base.css2move(base.newPosX); base.css2move(base.newPosX);
} }
} }
   
function dragEnd(event) { function dragEnd(event) {
var ev = event.originalEvent || event || window.event, var ev = event.originalEvent || event || window.event,
newPosition, newPosition,
handlers, handlers,
owlStopEvent; owlStopEvent;
   
ev.target = ev.target || ev.srcElement; ev.target = ev.target || ev.srcElement;
   
locals.dragging = false; locals.dragging = false;
   
if (base.browser.isTouch !== true) { if (base.browser.isTouch !== true) {
base.$owlWrapper.removeClass("grabbing"); base.$owlWrapper.removeClass("grabbing");
} }
   
if (base.newRelativeX < 0) { if (base.newRelativeX < 0) {
base.dragDirection = base.owl.dragDirection = "left"; base.dragDirection = base.owl.dragDirection = "left";
} else { } else {
base.dragDirection = base.owl.dragDirection = "right"; base.dragDirection = base.owl.dragDirection = "right";
} }
   
if (base.newRelativeX !== 0) { if (base.newRelativeX !== 0) {
newPosition = base.getNewPosition(); newPosition = base.getNewPosition();
base.goTo(newPosition, false, "drag"); base.goTo(newPosition, false, "drag");
if (locals.targetElement === ev.target && base.browser.isTouch !== true) { if (locals.targetElement === ev.target && base.browser.isTouch !== true) {
$(ev.target).on("click.disable", function (ev) { $(ev.target).on("click.disable", function (ev) {
ev.stopImmediatePropagation(); ev.stopImmediatePropagation();
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
$(ev.target).off("click.disable"); $(ev.target).off("click.disable");
}); });
handlers = $._data(ev.target, "events").click; handlers = $._data(ev.target, "events").click;
owlStopEvent = handlers.pop(); owlStopEvent = handlers.pop();
handlers.splice(0, 0, owlStopEvent); handlers.splice(0, 0, owlStopEvent);
} }
} }
swapEvents("off"); swapEvents("off");
} }
base.$elem.on(base.ev_types.start, ".owl-wrapper", dragStart); base.$elem.on(base.ev_types.start, ".owl-wrapper", dragStart);
}, },
   
getNewPosition : function () { getNewPosition : function () {
var base = this, var base = this,
newPosition = base.closestItem(); newPosition = base.closestItem();
   
if (newPosition > base.maximumItem) { if (newPosition > base.maximumItem) {
base.currentItem = base.maximumItem; base.currentItem = base.maximumItem;
newPosition = base.maximumItem; newPosition = base.maximumItem;
} else if (base.newPosX >= 0) { } else if (base.newPosX >= 0) {
newPosition = 0; newPosition = 0;
base.currentItem = 0; base.currentItem = 0;
} }
return newPosition; return newPosition;
}, },
closestItem : function () { closestItem : function () {
var base = this, var base = this,
array = base.options.scrollPerPage === true ? base.pagesInArray : base.positionsInArray, array = base.options.scrollPerPage === true ? base.pagesInArray : base.positionsInArray,
goal = base.newPosX, goal = base.newPosX,
closest = null; closest = null;
   
$.each(array, function (i, v) { $.each(array, function (i, v) {
if (goal - (base.itemWidth / 20) > array[i + 1] && goal - (base.itemWidth / 20) < v && base.moveDirection() === "left") { if (goal - (base.itemWidth / 20) > array[i + 1] && goal - (base.itemWidth / 20) < v && base.moveDirection() === "left") {
closest = v; closest = v;
if (base.options.scrollPerPage === true) { if (base.options.scrollPerPage === true) {
base.currentItem = $.inArray(closest, base.positionsInArray); base.currentItem = $.inArray(closest, base.positionsInArray);
} else { } else {
base.currentItem = i; base.currentItem = i;
} }
} else if (goal + (base.itemWidth / 20) < v && goal + (base.itemWidth / 20) > (array[i + 1] || array[i] - base.itemWidth) && base.moveDirection() === "right") { } 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) { if (base.options.scrollPerPage === true) {
closest = array[i + 1] || array[array.length - 1]; closest = array[i + 1] || array[array.length - 1];
base.currentItem = $.inArray(closest, base.positionsInArray); base.currentItem = $.inArray(closest, base.positionsInArray);
} else { } else {
closest = array[i + 1]; closest = array[i + 1];
base.currentItem = i + 1; base.currentItem = i + 1;
} }
} }
}); });
return base.currentItem; return base.currentItem;
}, },
   
moveDirection : function () { moveDirection : function () {
var base = this, var base = this,
direction; direction;
if (base.newRelativeX < 0) { if (base.newRelativeX < 0) {
direction = "right"; direction = "right";
base.playDirection = "next"; base.playDirection = "next";
} else { } else {
direction = "left"; direction = "left";
base.playDirection = "prev"; base.playDirection = "prev";
} }
return direction; return direction;
}, },
   
customEvents : function () { customEvents : function () {
/*jslint unparam: true*/ /*jslint unparam: true*/
var base = this; var base = this;
base.$elem.on("owl.next", function () { base.$elem.on("owl.next", function () {
base.next(); base.next();
}); });
base.$elem.on("owl.prev", function () { base.$elem.on("owl.prev", function () {
base.prev(); base.prev();
}); });
base.$elem.on("owl.play", function (event, speed) { base.$elem.on("owl.play", function (event, speed) {
base.options.autoPlay = speed; base.options.autoPlay = speed;
base.play(); base.play();
base.hoverStatus = "play"; base.hoverStatus = "play";
}); });
base.$elem.on("owl.stop", function () { base.$elem.on("owl.stop", function () {
base.stop(); base.stop();
base.hoverStatus = "stop"; base.hoverStatus = "stop";
}); });
base.$elem.on("owl.goTo", function (event, item) { base.$elem.on("owl.goTo", function (event, item) {
base.goTo(item); base.goTo(item);
}); });
base.$elem.on("owl.jumpTo", function (event, item) { base.$elem.on("owl.jumpTo", function (event, item) {
base.jumpTo(item); base.jumpTo(item);
}); });
}, },
   
stopOnHover : function () { stopOnHover : function () {
var base = this; var base = this;
if (base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false) { if (base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false) {
base.$elem.on("mouseover", function () { base.$elem.on("mouseover", function () {
base.stop(); base.stop();
}); });
base.$elem.on("mouseout", function () { base.$elem.on("mouseout", function () {
if (base.hoverStatus !== "stop") { if (base.hoverStatus !== "stop") {
base.play(); base.play();
} }
}); });
} }
}, },
   
lazyLoad : function () { lazyLoad : function () {
var base = this, var base = this,
i, i,
$item, $item,
itemNumber, itemNumber,
$lazyImg, $lazyImg,
follow; follow;
   
if (base.options.lazyLoad === false) { if (base.options.lazyLoad === false) {
return false; return false;
} }
for (i = 0; i < base.itemsAmount; i += 1) { for (i = 0; i < base.itemsAmount; i += 1) {
$item = $(base.$owlItems[i]); $item = $(base.$owlItems[i]);
   
if ($item.data("owl-loaded") === "loaded") { if ($item.data("owl-loaded") === "loaded") {
continue; continue;
} }
   
itemNumber = $item.data("owl-item"); itemNumber = $item.data("owl-item");
$lazyImg = $item.find(".lazyOwl"); $lazyImg = $item.find(".lazyOwl");
   
if (typeof $lazyImg.data("src") !== "string") { if (typeof $lazyImg.data("src") !== "string") {
$item.data("owl-loaded", "loaded"); $item.data("owl-loaded", "loaded");
continue; continue;
} }
if ($item.data("owl-loaded") === undefined) { if ($item.data("owl-loaded") === undefined) {
$lazyImg.hide(); $lazyImg.hide();
$item.addClass("loading").data("owl-loaded", "checked"); $item.addClass("loading").data("owl-loaded", "checked");
} }
if (base.options.lazyFollow === true) { if (base.options.lazyFollow === true) {
follow = itemNumber >= base.currentItem; follow = itemNumber >= base.currentItem;
} else { } else {
follow = true; follow = true;
} }
if (follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length) { if (follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length) {
base.lazyPreload($item, $lazyImg); base.lazyPreload($item, $lazyImg);
} }
} }
}, },
   
lazyPreload : function ($item, $lazyImg) { lazyPreload : function ($item, $lazyImg) {
var base = this, var base = this,
iterations = 0, iterations = 0,
isBackgroundImg; isBackgroundImg;
   
if ($lazyImg.prop("tagName") === "DIV") { if ($lazyImg.prop("tagName") === "DIV") {
$lazyImg.css("background-image", "url(" + $lazyImg.data("src") + ")"); $lazyImg.css("background-image", "url(" + $lazyImg.data("src") + ")");
isBackgroundImg = true; isBackgroundImg = true;
} else { } else {
$lazyImg[0].src = $lazyImg.data("src"); $lazyImg[0].src = $lazyImg.data("src");
} }
   
function showImage() { function showImage() {
$item.data("owl-loaded", "loaded").removeClass("loading"); $item.data("owl-loaded", "loaded").removeClass("loading");
$lazyImg.removeAttr("data-src"); $lazyImg.removeAttr("data-src");
if (base.options.lazyEffect === "fade") { if (base.options.lazyEffect === "fade") {
$lazyImg.fadeIn(400); $lazyImg.fadeIn(400);
} else { } else {
$lazyImg.show(); $lazyImg.show();
} }
if (typeof base.options.afterLazyLoad === "function") { if (typeof base.options.afterLazyLoad === "function") {
base.options.afterLazyLoad.apply(this, [base.$elem]); base.options.afterLazyLoad.apply(this, [base.$elem]);
} }
} }
   
function checkLazyImage() { function checkLazyImage() {
iterations += 1; iterations += 1;
if (base.completeImg($lazyImg.get(0)) || isBackgroundImg === true) { if (base.completeImg($lazyImg.get(0)) || isBackgroundImg === true) {
showImage(); showImage();
} else if (iterations <= 100) {//if image loads in less than 10 seconds } else if (iterations <= 100) {//if image loads in less than 10 seconds
window.setTimeout(checkLazyImage, 100); window.setTimeout(checkLazyImage, 100);
} else { } else {
showImage(); showImage();
} }
} }
   
checkLazyImage(); checkLazyImage();
}, },
   
autoHeight : function () { autoHeight : function () {
var base = this, var base = this,
$currentimg = $(base.$owlItems[base.currentItem]).find("img"), $currentimg = $(base.$owlItems[base.currentItem]).find("img"),
iterations; iterations;
   
function addHeight() { function addHeight() {
var $currentItem = $(base.$owlItems[base.currentItem]).height(); var $currentItem = $(base.$owlItems[base.currentItem]).height();
base.wrapperOuter.css("height", $currentItem + "px"); base.wrapperOuter.css("height", $currentItem + "px");
if (!base.wrapperOuter.hasClass("autoHeight")) { if (!base.wrapperOuter.hasClass("autoHeight")) {
window.setTimeout(function () { window.setTimeout(function () {
base.wrapperOuter.addClass("autoHeight"); base.wrapperOuter.addClass("autoHeight");
}, 0); }, 0);
} }
} }
   
function checkImage() { function checkImage() {
iterations += 1; iterations += 1;
if (base.completeImg($currentimg.get(0))) { if (base.completeImg($currentimg.get(0))) {
addHeight(); addHeight();
} else if (iterations <= 100) { //if image loads in less than 10 seconds } else if (iterations <= 100) { //if image loads in less than 10 seconds
window.setTimeout(checkImage, 100); window.setTimeout(checkImage, 100);
} else { } else {
base.wrapperOuter.css("height", ""); //Else remove height attribute base.wrapperOuter.css("height", ""); //Else remove height attribute
} }
} }
   
if ($currentimg.get(0) !== undefined) { if ($currentimg.get(0) !== undefined) {
iterations = 0; iterations = 0;
checkImage(); checkImage();
} else { } else {
addHeight(); addHeight();
} }
}, },
   
completeImg : function (img) { completeImg : function (img) {
var naturalWidthType; var naturalWidthType;
   
if (!img.complete) { if (!img.complete) {
return false; return false;
} }
naturalWidthType = typeof img.naturalWidth; naturalWidthType = typeof img.naturalWidth;
if (naturalWidthType !== "undefined" && img.naturalWidth === 0) { if (naturalWidthType !== "undefined" && img.naturalWidth === 0) {
return false; return false;
} }
return true; return true;
}, },
   
onVisibleItems : function () { onVisibleItems : function () {
var base = this, var base = this,
i; i;
   
if (base.options.addClassActive === true) { if (base.options.addClassActive === true) {
base.$owlItems.removeClass("active"); base.$owlItems.removeClass("active");
} }
base.visibleItems = []; base.visibleItems = [];
for (i = base.currentItem; i < base.currentItem + base.options.items; i += 1) { for (i = base.currentItem; i < base.currentItem + base.options.items; i += 1) {
base.visibleItems.push(i); base.visibleItems.push(i);
   
if (base.options.addClassActive === true) { if (base.options.addClassActive === true) {
$(base.$owlItems[i]).addClass("active"); $(base.$owlItems[i]).addClass("active");
} }
} }
base.owl.visibleItems = base.visibleItems; base.owl.visibleItems = base.visibleItems;
}, },
   
transitionTypes : function (className) { transitionTypes : function (className) {
var base = this; var base = this;
//Currently available: "fade", "backSlide", "goDown", "fadeUp" //Currently available: "fade", "backSlide", "goDown", "fadeUp"
base.outClass = "owl-" + className + "-out"; base.outClass = "owl-" + className + "-out";
base.inClass = "owl-" + className + "-in"; base.inClass = "owl-" + className + "-in";
}, },
   
singleItemTransition : function () { singleItemTransition : function () {
var base = this, var base = this,
outClass = base.outClass, outClass = base.outClass,
inClass = base.inClass, inClass = base.inClass,
$currentItem = base.$owlItems.eq(base.currentItem), $currentItem = base.$owlItems.eq(base.currentItem),
$prevItem = base.$owlItems.eq(base.prevItem), $prevItem = base.$owlItems.eq(base.prevItem),
prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem], prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem],
origin = Math.abs(base.positionsInArray[base.currentItem]) + base.itemWidth / 2, origin = Math.abs(base.positionsInArray[base.currentItem]) + base.itemWidth / 2,
animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend'; animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend';
   
base.isTransition = true; base.isTransition = true;
   
base.$owlWrapper base.$owlWrapper
.addClass('owl-origin') .addClass('owl-origin')
.css({ .css({
"-webkit-transform-origin" : origin + "px", "-webkit-transform-origin" : origin + "px",
"-moz-perspective-origin" : origin + "px", "-moz-perspective-origin" : origin + "px",
"perspective-origin" : origin + "px" "perspective-origin" : origin + "px"
}); });
function transStyles(prevPos) { function transStyles(prevPos) {
return { return {
"position" : "relative", "position" : "relative",
"left" : prevPos + "px" "left" : prevPos + "px"
}; };
} }
   
$prevItem $prevItem
.css(transStyles(prevPos, 10)) .css(transStyles(prevPos, 10))
.addClass(outClass) .addClass(outClass)
.on(animEnd, function () { .on(animEnd, function () {
base.endPrev = true; base.endPrev = true;
$prevItem.off(animEnd); $prevItem.off(animEnd);
base.clearTransStyle($prevItem, outClass); base.clearTransStyle($prevItem, outClass);
}); });
   
$currentItem $currentItem
.addClass(inClass) .addClass(inClass)
.on(animEnd, function () { .on(animEnd, function () {
base.endCurrent = true; base.endCurrent = true;
$currentItem.off(animEnd); $currentItem.off(animEnd);
base.clearTransStyle($currentItem, inClass); base.clearTransStyle($currentItem, inClass);
}); });
}, },
   
clearTransStyle : function (item, classToRemove) { clearTransStyle : function (item, classToRemove) {
var base = this; var base = this;
item.css({ item.css({
"position" : "", "position" : "",
"left" : "" "left" : ""
}).removeClass(classToRemove); }).removeClass(classToRemove);
   
if (base.endPrev && base.endCurrent) { if (base.endPrev && base.endCurrent) {
base.$owlWrapper.removeClass('owl-origin'); base.$owlWrapper.removeClass('owl-origin');
base.endPrev = false; base.endPrev = false;
base.endCurrent = false; base.endCurrent = false;
base.isTransition = false; base.isTransition = false;
} }
}, },
   
owlStatus : function () { owlStatus : function () {
var base = this; var base = this;
base.owl = { base.owl = {
"userOptions" : base.userOptions, "userOptions" : base.userOptions,
"baseElement" : base.$elem, "baseElement" : base.$elem,
"userItems" : base.$userItems, "userItems" : base.$userItems,
"owlItems" : base.$owlItems, "owlItems" : base.$owlItems,
"currentItem" : base.currentItem, "currentItem" : base.currentItem,
"prevItem" : base.prevItem, "prevItem" : base.prevItem,
"visibleItems" : base.visibleItems, "visibleItems" : base.visibleItems,
"isTouch" : base.browser.isTouch, "isTouch" : base.browser.isTouch,
"browser" : base.browser, "browser" : base.browser,
"dragDirection" : base.dragDirection "dragDirection" : base.dragDirection
}; };
}, },
   
clearEvents : function () { clearEvents : function () {
var base = this; var base = this;
base.$elem.off(".owl owl mousedown.disableTextSelect"); base.$elem.off(".owl owl mousedown.disableTextSelect");
$(document).off(".owl owl"); $(document).off(".owl owl");
$(window).off("resize", base.resizer); $(window).off("resize", base.resizer);
}, },
   
unWrap : function () { unWrap : function () {
var base = this; var base = this;
if (base.$elem.children().length !== 0) { if (base.$elem.children().length !== 0) {
base.$owlWrapper.unwrap(); base.$owlWrapper.unwrap();
base.$userItems.unwrap().unwrap(); base.$userItems.unwrap().unwrap();
if (base.owlControls) { if (base.owlControls) {
base.owlControls.remove(); base.owlControls.remove();
} }
} }
base.clearEvents(); base.clearEvents();
base.$elem base.$elem
.attr("style", base.$elem.data("owl-originalStyles") || "") .attr("style", base.$elem.data("owl-originalStyles") || "")
.attr("class", base.$elem.data("owl-originalClasses")); .attr("class", base.$elem.data("owl-originalClasses"));
}, },
   
destroy : function () { destroy : function () {
var base = this; var base = this;
base.stop(); base.stop();
window.clearInterval(base.checkVisible); window.clearInterval(base.checkVisible);
base.unWrap(); base.unWrap();
base.$elem.removeData(); base.$elem.removeData();
}, },
   
reinit : function (newOptions) { reinit : function (newOptions) {
var base = this, var base = this,
options = $.extend({}, base.userOptions, newOptions); options = $.extend({}, base.userOptions, newOptions);
base.unWrap(); base.unWrap();
base.init(options, base.$elem); base.init(options, base.$elem);
}, },
   
addItem : function (htmlString, targetPosition) { addItem : function (htmlString, targetPosition) {
var base = this, var base = this,
position; position;
   
if (!htmlString) {return false; } if (!htmlString) {return false; }
   
if (base.$elem.children().length === 0) { if (base.$elem.children().length === 0) {
base.$elem.append(htmlString); base.$elem.append(htmlString);
base.setVars(); base.setVars();
return false; return false;
} }
base.unWrap(); base.unWrap();
if (targetPosition === undefined || targetPosition === -1) { if (targetPosition === undefined || targetPosition === -1) {
position = -1; position = -1;
} else { } else {
position = targetPosition; position = targetPosition;
} }
if (position >= base.$userItems.length || position === -1) { if (position >= base.$userItems.length || position === -1) {
base.$userItems.eq(-1).after(htmlString); base.$userItems.eq(-1).after(htmlString);
} else { } else {
base.$userItems.eq(position).before(htmlString); base.$userItems.eq(position).before(htmlString);
} }
   
base.setVars(); base.setVars();
}, },
   
removeItem : function (targetPosition) { removeItem : function (targetPosition) {
var base = this, var base = this,
position; position;
   
if (base.$elem.children().length === 0) { if (base.$elem.children().length === 0) {
return false; return false;
} }
if (targetPosition === undefined || targetPosition === -1) { if (targetPosition === undefined || targetPosition === -1) {
position = -1; position = -1;
} else { } else {
position = targetPosition; position = targetPosition;
} }
   
base.unWrap(); base.unWrap();
base.$userItems.eq(position).remove(); base.$userItems.eq(position).remove();
base.setVars(); base.setVars();
} }
   
}; };
   
$.fn.owlCarousel = function (options) { $.fn.owlCarousel = function (options) {
return this.each(function () { return this.each(function () {
if ($(this).data("owl-init") === true) { if ($(this).data("owl-init") === true) {
return false; return false;
} }
$(this).data("owl-init", true); $(this).data("owl-init", true);
var carousel = Object.create(Carousel); var carousel = Object.create(Carousel);
carousel.init(options, this); carousel.init(options, this);
$.data(this, "owlCarousel", carousel); $.data(this, "owlCarousel", carousel);
}); });
}; };
   
$.fn.owlCarousel.options = { $.fn.owlCarousel.options = {
   
items : 5, items : 5,
itemsCustom : false, itemsCustom : false,
itemsDesktop : [1199, 4], itemsDesktop : [1199, 4],
itemsDesktopSmall : [979, 3], itemsDesktopSmall : [979, 3],
itemsTablet : [768, 2], itemsTablet : [768, 2],
itemsTabletSmall : false, itemsTabletSmall : false,
itemsMobile : [479, 1], itemsMobile : [479, 1],
singleItem : false, singleItem : false,
itemsScaleUp : false, itemsScaleUp : false,
   
slideSpeed : 200, slideSpeed : 200,
paginationSpeed : 800, paginationSpeed : 800,
rewindSpeed : 1000, rewindSpeed : 1000,
   
autoPlay : false, autoPlay : false,
stopOnHover : false, stopOnHover : false,
   
navigation : false, navigation : false,
navigationText : ["prev", "next"], navigationText : ["prev", "next"],
rewindNav : true, rewindNav : true,
scrollPerPage : false, scrollPerPage : false,
   
pagination : true, pagination : true,
paginationNumbers : false, paginationNumbers : false,
   
responsive : true, responsive : true,
responsiveRefreshRate : 200, responsiveRefreshRate : 200,
responsiveBaseWidth : window, responsiveBaseWidth : window,
   
baseClass : "owl-carousel", baseClass : "owl-carousel",
theme : "owl-theme", theme : "owl-theme",
   
lazyLoad : false, lazyLoad : false,
lazyFollow : true, lazyFollow : true,
lazyEffect : "fade", lazyEffect : "fade",
   
autoHeight : false, autoHeight : false,
   
jsonPath : false, jsonPath : false,
jsonSuccess : false, jsonSuccess : false,
   
dragBeforeAnimFinish : true, dragBeforeAnimFinish : true,
mouseDrag : true, mouseDrag : true,
touchDrag : true, touchDrag : true,
   
addClassActive : false, addClassActive : false,
transitionStyle : false, transitionStyle : false,
   
beforeUpdate : false, beforeUpdate : false,
afterUpdate : false, afterUpdate : false,
beforeInit : false, beforeInit : false,
afterInit : false, afterInit : false,
beforeMove : false, beforeMove : false,
afterMove : false, afterMove : false,
afterAction : false, afterAction : false,
startDragging : false, startDragging : false,
afterLazyLoad: false afterLazyLoad: false,
   
  showTitles : false
}; };
}(jQuery, window, document)); }(jQuery, window, document));
comments