/*
* jQuery OwlCarousel v1.3.2
*
* 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") {
Object.create = function (obj) {
function F() {}
F.prototype = obj;
return new F();
};
}
(function ($, window, document) {
var Carousel = {
init : function (options, el) {
var base = this;
base.$elem = $(el);
base.options = $.extend({}, $.fn.owlCarousel.options, base.$elem.data(), options);
base.userOptions = options;
base.loadContent();
},
loadContent : function () {
var base = this, url;
function getData(data) {
var i, content = "";
if (typeof base.options.jsonSuccess === "function") {
base.options.jsonSuccess.apply(this, [data]);
} else {
for (i in data.owl) {
if (data.owl.hasOwnProperty(i)) {
content += data.owl[i].item;
}
}
base.$elem.html(content);
}
base.logIn();
}
if (typeof base.options.beforeInit === "function") {
base.options.beforeInit.apply(this, [base.$elem]);
}
if (typeof base.options.jsonPath === "string") {
url = base.options.jsonPath;
$.getJSON(url, getData);
} else {
base.logIn();
}
},
logIn : function () {
var base = this;
base.$elem.data("owl-originalStyles", base.$elem.attr("style"))
.data("owl-originalClasses", base.$elem.attr("class"));
base.$elem.css({opacity: 0});
base.orignalItems = base.options.items;
base.checkBrowser();
base.wrapperWidth = 0;
base.checkVisible = null;
base.setVars();
},
setVars : function () {
var base = this;
if (base.$elem.children().length === 0) {return false; }
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;
base.prevArr = [0];
base.currentItem = 0;
base.customEvents();
base.onStartup();
},
onStartup : function () {
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();
base.$elem.find(".owl-wrapper").css("display", "block");
if (!base.$elem.is(":visible")) {
base.watchVisibility();
} else {
base.$elem.css("opacity", 1);
}
base.onstartup = false;
base.eachMoveUpdate();
if (typeof base.options.afterInit === "function") {
base.options.afterInit.apply(this, [base.$elem]);
}
},
eachMoveUpdate : function () {
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") {
base.options.afterAction.apply(this, [base.$elem]);
}
},
updateVars : function () {
var base = this;
if (typeof base.options.beforeUpdate === "function") {
base.options.beforeUpdate.apply(this, [base.$elem]);
}
base.watchVisibility();
base.updateItems();
base.calculateAll();
base.updatePosition();
base.updateControls();
base.eachMoveUpdate();
if (typeof base.options.afterUpdate === "function") {
base.options.afterUpdate.apply(this, [base.$elem]);
}
},
reload : function () {
var base = this;
window.setTimeout(function () {
base.updateVars();
}, 0);
},
watchVisibility : function () {
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;
}
base.checkVisible = window.setInterval(function () {
if (base.$elem.is(":visible")) {
base.reload();
base.$elem.animate({opacity: 1}, 200);
window.clearInterval(base.checkVisible);
}
}, 500);
},
wrapItems : function () {
var base = this;
base.$userItems.wrapAll("
").wrap("
");
base.$elem.find(".owl-wrapper").wrap("
");
base.wrapperOuter = base.$elem.find(".owl-wrapper-outer");
base.$elem.css("display", "block");
},
baseClass : function () {
var base = this,
hasBaseClass = base.$elem.hasClass(base.options.baseClass),
hasThemeClass = base.$elem.hasClass(base.options.theme);
if (!hasBaseClass) {
base.$elem.addClass(base.options.baseClass);
}
if (!hasThemeClass) {
base.$elem.addClass(base.options.theme);
}
},
updateItems : function () {
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;
}
width = $(base.options.responsiveBaseWidth).width();
if (width > (base.options.itemsDesktop[0] || base.orignalItems)) {
base.options.items = base.orignalItems;
}
if (base.options.itemsCustom !== false) {
//Reorder array by screen size
base.options.itemsCustom.sort(function (a, b) {return a[0] - b[0]; });
for (i = 0; i < base.options.itemsCustom.length; i += 1) {
if (base.options.itemsCustom[i][0] <= width) {
base.options.items = base.options.itemsCustom[i][1];
}
}
} else {
if (width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false) {
base.options.items = base.options.itemsDesktop[1];
}
if (width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false) {
base.options.items = base.options.itemsDesktopSmall[1];
}
if (width <= base.options.itemsTablet[0] && base.options.itemsTablet !== false) {
base.options.items = base.options.itemsTablet[1];
}
if (width <= base.options.itemsTabletSmall[0] && base.options.itemsTabletSmall !== false) {
base.options.items = base.options.itemsTabletSmall[1];
}
if (width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false) {
base.options.items = base.options.itemsMobile[1];
}
}
//if number of items is less than declared
if (base.options.items > base.itemsAmount && base.options.itemsScaleUp === true) {
base.options.items = base.itemsAmount;
}
},
response : function () {
var base = this,
smallDelay,
lastWindowWidth;
if (base.options.responsive !== true) {
return false;
}
lastWindowWidth = $(window).width();
base.resizer = function () {
if ($(window).width() !== lastWindowWidth) {
if (base.options.autoPlay !== false) {
window.clearInterval(base.autoPlayInterval);
}
window.clearTimeout(smallDelay);
smallDelay = window.setTimeout(function () {
lastWindowWidth = $(window).width();
base.updateVars();
}, base.options.responsiveRefreshRate);
}
};
$(window).resize(base.resizer);
},
updatePosition : function () {
var base = this;
base.jumpTo(base.currentItem);
if (base.options.autoPlay !== false) {
base.checkAp();
}
},
appendItemsSizes : function () {
var base = this,
roundPages = 0,
lastItem = base.itemsAmount - base.options.items;
base.$owlItems.each(function (index) {
var $this = $(this);
$this
.css({"width": base.itemWidth})
.data("owl-item", Number(index));
if (index % base.options.items === 0 || index === lastItem) {
if (!(index > lastItem)) {
roundPages += 1;
}
}
$this.data("owl-roundPages", roundPages);
});
},
appendWrapperSizes : function () {
var base = this,
width = base.$owlItems.length * base.itemWidth;
base.$owlWrapper.css({
"width": width * 2,
"left": 0
});
base.appendItemsSizes();
},
calculateAll : function () {
var base = this;
base.calculateWidth();
base.appendWrapperSizes();
base.loops();
base.max();
},
calculateWidth : function () {
var base = this;
base.itemWidth = Math.round(base.$elem.width() / base.options.items);
},
max : function () {
var base = this,
maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1;
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;
},
min : function () {
return 0;
},
loops : function () {
var base = this,
prev = 0,
elWidth = 0,
i,
item,
roundPageNum;
base.positionsInArray = [0];
base.pagesInArray = [];
for (i = 0; i < base.itemsAmount; i += 1) {
elWidth += base.itemWidth;
base.positionsInArray.push(-elWidth);
if (base.options.scrollPerPage === true) {
item = $(base.$owlItems[i]);
roundPageNum = item.data("owl-roundPages");
if (roundPageNum !== prev) {
base.pagesInArray[prev] = base.positionsInArray[i];
prev = roundPageNum;
}
}
}
},
buildControls : function () {
var base = this;
if (base.options.navigation === true || base.options.pagination === true) {
base.owlControls = $("
").toggleClass("clickable", !base.browser.isTouch).appendTo(base.$elem);
}
if (base.options.pagination === true) {
base.buildPagination();
}
if (base.options.navigation === true) {
base.buildButtons();
}
},
buildButtons : function () {
var base = this,
buttonsWrapper = $("