/*
* 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 = 4000;
}
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;
var width = 0;
var 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;
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 = $("