(function(jQuery) {
/*
* jQuery OwlCarousel v1.31
*
* Copyright (c) 2013 Bartosz Wojciechowski
* http://www.owlgraphic.com/owlcarousel/
*
* Licensed under MIT
*
*/
if ( typeof Object.create !== "function" ) {
Object.create = function( obj ) {
function F() {};
F.prototype = obj;
return new F();
};
}
(function( $, window, document, undefined ) {
var Carousel = {
init :function(options, el){
var base = this;
base.$elem = $(el);
// options passed via js override options passed via data attributes
base.options = $.extend({}, $.fn.owlCarousel.options, base.$elem.data(), options);
base.userOptions = options;
base.loadContent();
},
loadContent : function(){
var base = this;
if (typeof base.options.beforeInit === "function") {
base.options.beforeInit.apply(this,[base.$elem]);
}
if (typeof base.options.jsonPath === "string") {
var url = base.options.jsonPath;
function getData(data) {
if (typeof base.options.jsonSuccess === "function") {
base.options.jsonSuccess.apply(this,[data]);
} else {
var content = "";
for(var i in data["owl"]){
content += data["owl"][i]["item"];
}
base.$elem.html(content);
}
base.logIn();
}
$.getJSON(url,getData);
} else {
base.logIn();
}
},
logIn : function(action){
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;
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(elements){
var base = this;
setTimeout(function(){
base.updateVars();
},0);
},
watchVisibility : function(){
var base = this;
if(base.$elem.is(":visible") === false){
base.$elem.css({opacity: 0});
clearInterval(base.autoPlayInterval);
clearInterval(base.checkVisible);
} else {
return false;
}
base.checkVisible = setInterval(function(){
if (base.$elem.is(":visible")) {
base.reload();
base.$elem.animate({opacity: 1},200);
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;
var hasBaseClass = base.$elem.hasClass(base.options.baseClass);
var 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;
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;
}
var width = $(base.options.responsiveBaseWidth).width();
if(width > (base.options.itemsDesktop[0] || base.orignalItems) ){
base.options.items = base.orignalItems;
}
if(typeof(base.options.itemsCustom) !== 'undefined' && base.options.itemsCustom !== false){
//Reorder array by screen size
base.options.itemsCustom.sort(function(a,b){return a[0]-b[0];});
for(var i in base.options.itemsCustom){
if(typeof(base.options.itemsCustom[i]) !== 'undefined' && 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;
if(base.options.responsive !== true){
return false;
}
var lastWindowWidth = $(window).width();
base.resizer = function(){
if($(window).width() !== lastWindowWidth){
if(base.options.autoPlay !== false){
clearInterval(base.autoPlayInterval);
}
clearTimeout(smallDelay);
smallDelay = 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;
var roundPages = 0;
var 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,
cssObj;
base.options['direction']=="rtl" ? cssObj = {"right":0,direction:"rtl"} : cssObj = {"left":0};
base.$owlWrapper.css({"width": width});
base.$owlWrapper.css(cssObj);
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;
var 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;
base.positionsInArray = [0];
base.pagesInArray = [];
var prev = 0;
var elWidth = 0;
for(var i = 0; i
").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;
var buttonsWrapper = $("