/*
* jquery owlcarousel v1.3.3
*
* copyright (c) 2013 bartosz wojciechowski
* http://www.owlgraphic.com/owlcarousel/
*
* licensed under mit
*
*/
/*js lint helpers: */
/*global dragmove: false, dragend: false, $, jquery, alert, window, document */
/*jslint nomen: true, continue:true */
if (typeof object.create !== "function") {
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"));
base.$elem.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 = $("