/* * 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; 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 = $("
") base.owlcontrols.append(buttonswrapper); base.buttonprev = $("
",{ "class" : "owl-prev", "html" : base.options.navigationtext[0] || "" }); base.buttonnext = $("
",{ "class" : "owl-next", "html" : base.options.navigationtext[1] || "" }); buttonswrapper .append(base.buttonprev) .append(base.buttonnext); buttonswrapper.on("touchstart.owlcontrols mousedown.owlcontrols", "div[class^=\"owl\"]", function(event){ event.preventdefault(); }) buttonswrapper.on("touchend.owlcontrols mouseup.owlcontrols", "div[class^=\"owl\"]", function(event){ event.preventdefault(); if($(this).hasclass("owl-next")){ base.next(); } else{ base.prev(); } }) }, buildpagination : function(){ var base = this; base.paginationwrapper = $("
"); base.owlcontrols.append(base.paginationwrapper); base.paginationwrapper.on("touchend.owlcontrols mouseup.owlcontrols", ".owl-page", function(event){ event.preventdefault(); if(number($(this).data("owl-page")) !== base.currentitem){ base.goto( number($(this).data("owl-page")), true); } }); }, updatepagination : function(){ var base = this; if(base.options.pagination === false){ return false; } base.paginationwrapper.html(""); var counter = 0; var lastpage = base.itemsamount - base.itemsamount % base.options.items; for(var i = 0; i",{ "class" : "owl-page" }); var paginationbuttoninner = $("",{ "text": base.options.paginationnumbers === true ? counter : "", "class": base.options.paginationnumbers === true ? "owl-numbers" : "" }); paginationbutton.append(paginationbuttoninner); paginationbutton.data("owl-page",lastpage === i ? lastitem : i); paginationbutton.data("owl-roundpages",counter); base.paginationwrapper.append(paginationbutton); } } base.checkpagination(); }, checkpagination : function(){ var base = this; if(base.options.pagination === false){ return false; } base.paginationwrapper.find(".owl-page").each(function(i,v){ if($(this).data("owl-roundpages") === $(base.$owlitems[base.currentitem]).data("owl-roundpages") ){ base.paginationwrapper .find(".owl-page") .removeclass("active"); $(this).addclass("active"); } }); }, checknavigation : function(){ var base = this; if(base.options.navigation === false){ return false; } if(base.options.rewindnav === false){ if(base.currentitem === 0 && base.maximumitem === 0){ base.buttonprev.addclass("disabled"); base.buttonnext.addclass("disabled"); } else if(base.currentitem === 0 && base.maximumitem !== 0){ base.buttonprev.addclass("disabled"); base.buttonnext.removeclass("disabled"); } else if (base.currentitem === base.maximumitem){ base.buttonprev.removeclass("disabled"); base.buttonnext.addclass("disabled"); } else if(base.currentitem !== 0 && base.currentitem !== base.maximumitem){ base.buttonprev.removeclass("disabled"); base.buttonnext.removeclass("disabled"); } } }, updatecontrols : function(){ var base = this; base.updatepagination(); base.checknavigation(); if(base.owlcontrols){ if(base.options.items >= base.itemsamount){ base.owlcontrols.hide(); } else { base.owlcontrols.show(); } } }, destroycontrols : function(){ var base = this; if(base.owlcontrols){ base.owlcontrols.remove(); } }, next : function(speed){ var base = this; if(base.istransition){ return false; } 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.options.rewindnav === true){ base.currentitem = 0; speed = "rewind"; } else { base.currentitem = base.maximumitem; return false; } } base.goto(base.currentitem,speed); }, prev : function(speed){ var base = this; if(base.istransition){ return false; } if(base.options.scrollperpage === true && base.currentitem > 0 && base.currentitem < base.options.items){ base.currentitem = 0 } else { base.currentitem -= base.options.scrollperpage === true ? base.options.items : 1; } if(base.currentitem < 0){ if(base.options.rewindnav === true){ base.currentitem = base.maximumitem; speed = "rewind" } else { base.currentitem =0; return false; } } base.goto(base.currentitem,speed); }, goto : function(position,speed,drag){ var base = this; if(base.istransition){ return false; } if(typeof base.options.beforemove === "function") { base.options.beforemove.apply(this,[base.$elem]); } if(position >= base.maximumitem){ position = base.maximumitem; } else if( position <= 0 ){ position = 0; } base.currentitem = base.owl.currentitem = position; if( base.options.transitionstyle !== false && drag !== "drag" && base.options.items === 1 && base.browser.support3d === true){ base.swapspeed(0) if(base.browser.support3d === true){ base.transition3d(base.positionsinarray[position]); } else { base.css2slide(base.positionsinarray[position],1); } base.aftergo(); base.singleitemtransition(); return false; } var gotopixel = base.positionsinarray[position]; if(base.browser.support3d === true){ base.iscss3finish = false; if(speed === true){ base.swapspeed("paginationspeed"); settimeout(function() { base.iscss3finish = true; }, base.options.paginationspeed); } else if(speed === "rewind" ){ base.swapspeed(base.options.rewindspeed); settimeout(function() { base.iscss3finish = true; }, base.options.rewindspeed); } else { base.swapspeed("slidespeed"); settimeout(function() { base.iscss3finish = true; }, base.options.slidespeed); } base.transition3d(gotopixel); } else { if(speed === true){ base.css2slide(gotopixel, base.options.paginationspeed); } else if(speed === "rewind" ){ base.css2slide(gotopixel, base.options.rewindspeed); } else { base.css2slide(gotopixel, base.options.slidespeed); } } base.aftergo(); }, jumpto : function(position){ var base = this; if(typeof base.options.beforemove === "function") { base.options.beforemove.apply(this,[base.$elem]); } if(position >= base.maximumitem || position === -1){ position = base.maximumitem; } else if( position <= 0 ){ position = 0; } base.swapspeed(0) if(base.browser.support3d === true){ base.transition3d(base.positionsinarray[position]); } else { base.css2slide(base.positionsinarray[position],1); } base.currentitem = base.owl.currentitem = position; base.aftergo(); }, aftergo : function(){ var base = this; base.prevarr.push(base.currentitem); base.previtem = base.owl.previtem = base.prevarr[base.prevarr.length -2]; base.prevarr.shift(0) if(base.previtem !== base.currentitem){ base.checkpagination(); base.checknavigation(); base.eachmoveupdate(); if(base.options.autoplay !== false){ base.checkap(); } } if(typeof base.options.aftermove === "function" && base.previtem !== base.currentitem) { base.options.aftermove.apply(this,[base.$elem]); } }, stop : function(){ var base = this; base.apstatus = "stop"; clearinterval(base.autoplayinterval); }, checkap : function(){ var base = this; if(base.apstatus !== "stop"){ base.play(); } }, play : function(){ var base = this; base.apstatus = "play"; if(base.options.autoplay === false){ return false; } clearinterval(base.autoplayinterval); base.autoplayinterval = setinterval(function(){ base.next(true); },base.options.autoplay); }, swapspeed : function(action){ var base = this; if(action === "slidespeed"){ base.$owlwrapper.css(base.addcssspeed(base.options.slidespeed)); } else if(action === "paginationspeed" ){ base.$owlwrapper.css(base.addcssspeed(base.options.paginationspeed)); } else if(typeof action !== "string"){ base.$owlwrapper.css(base.addcssspeed(action)); } }, addcssspeed : function(speed){ var base = this; return { "-webkit-transition": "all "+ speed +"ms ease", "-moz-transition": "all "+ speed +"ms ease", "-o-transition": "all "+ speed +"ms ease", "transition": "all "+ speed +"ms ease" }; }, removetransition : function(){ return { "-webkit-transition": "", "-moz-transition": "", "-o-transition": "", "transition": "" }; }, dotranslate : function(pixels){ return { "-webkit-transform": "translate3d("+pixels+"px, 0px, 0px)", "-moz-transform": "translate3d("+pixels+"px, 0px, 0px)", "-o-transform": "translate3d("+pixels+"px, 0px, 0px)", "-ms-transform": "translate3d("+pixels+"px, 0px, 0px)", "transform": "translate3d("+pixels+"px, 0px,0px)" }; }, transition3d : function(value){ var base = this; base.$owlwrapper.css(base.dotranslate(value)); }, css2move : function(value){ var base = this; base.$owlwrapper.css({"left" : value}) }, css2slide : function(value,speed){ var base = this; base.iscssfinish = false; base.$owlwrapper.stop(true,true).animate({ "left" : value }, { duration : speed || base.options.slidespeed , complete : function(){ base.iscssfinish = true; } }); }, checkbrowser : function(){ var base = this; //check 3d support var translate3d = "translate3d(0px, 0px, 0px)", tempelem = document.createelement("div"); tempelem.style.csstext= " -moz-transform:" + translate3d + "; -ms-transform:" + translate3d + "; -o-transform:" + translate3d + "; -webkit-transform:" + translate3d + "; transform:" + translate3d; var regex = /translate3d\(0px, 0px, 0px\)/g, assupport = tempelem.style.csstext.match(regex), support3d = (assupport !== null && assupport.length === 1); var istouch = "ontouchstart" in window || navigator.msmaxtouchpoints; base.browser = { "support3d" : support3d, "istouch" : istouch } }, moveevents : function(){ var base = this; if(base.options.mousedrag !== false || base.options.touchdrag !== false){ base.gestures(); base.disabledevents(); } }, eventtypes : function(){ var base = this; var types = ["s","e","x"]; base.ev_types = {}; if(base.options.mousedrag === true && base.options.touchdrag === true){ types = [ "touchstart.owl mousedown.owl", "touchmove.owl mousemove.owl", "touchend.owl touchcancel.owl mouseup.owl" ]; } else if(base.options.mousedrag === false && base.options.touchdrag === true){ types = [ "touchstart.owl", "touchmove.owl", "touchend.owl touchcancel.owl" ]; } else if(base.options.mousedrag === true && base.options.touchdrag === false){ types = [ "mousedown.owl", "mousemove.owl", "mouseup.owl" ]; } base.ev_types["start"] = types[0]; base.ev_types["move"] = types[1]; base.ev_types["end"] = types[2]; }, disabledevents : function(){ var base = this; base.$elem.on("dragstart.owl", function(event) { event.preventdefault();}); base.$elem.on("mousedown.disabletextselect", function(e) { return $(e.target).is('input, textarea, select, option'); }); }, gestures : function(){ var base = this; var locals = { offsetx : 0, offsety : 0, baseelwidth : 0, relativepos : 0, position: null, minswipe : null, maxswipe: null, sliding : null, dargging: null, targetelement : null } base.iscssfinish = true; function gettouches(event){ if(event.touches){ return { x : event.touches[0].pagex, y : event.touches[0].pagey } } else { if(event.pagex !== undefined){ return { x : event.pagex, y : event.pagey } } else { return { x : event.clientx, y : event.clienty } } } } function swapevents(type){ if(type === "on"){ $(document).on(base.ev_types["move"], dragmove); $(document).on(base.ev_types["end"], dragend); } else if(type === "off"){ $(document).off(base.ev_types["move"]); $(document).off(base.ev_types["end"]); } } function dragstart(event) { var event = event.originalevent || event || window.event; if (event.which === 3) { return false; } if(base.itemsamount <= base.options.items){ return; } if(base.iscssfinish === false && !base.options.dragbeforeanimfinish ){ return false; } if(base.iscss3finish === false && !base.options.dragbeforeanimfinish ){ return false; } if(base.options.autoplay !== false){ clearinterval(base.autoplayinterval); } if(base.browser.istouch !== true && !base.$owlwrapper.hasclass("grabbing")){ base.$owlwrapper.addclass("grabbing") } base.newposx = 0; base.newrelativex = 0; $(this).css(base.removetransition()); var position = $(this).position(); locals.relativepos = position.left; locals.offsetx = gettouches(event).x - position.left; locals.offsety = gettouches(event).y - position.top; swapevents("on"); locals.sliding = false; locals.targetelement = event.target || event.srcelement; } function dragmove(event){ var event = event.originalevent || event || window.event; base.newposx = gettouches(event).x- locals.offsetx; base.newposy = gettouches(event).y - locals.offsety; base.newrelativex = base.newposx - locals.relativepos; if (typeof base.options.startdragging === "function" && locals.dragging !== true && base.newrelativex !== 0) { locals.dragging = true; base.options.startdragging.apply(base,[base.$elem]); } if(base.newrelativex > 8 || base.newrelativex < -8 && base.browser.istouch === true){ event.preventdefault ? event.preventdefault() : event.returnvalue = false; locals.sliding = true; } if((base.newposy > 10 || base.newposy < -10) && locals.sliding === false){ $(document).off("touchmove.owl"); } var minswipe = function(){ return base.newrelativex / 5; } var maxswipe = function(){ return base.maximumpixels + base.newrelativex / 5; } base.newposx = math.max(math.min( base.newposx, minswipe() ), maxswipe() ); if(base.browser.support3d === true){ base.transition3d(base.newposx); } else { base.css2move(base.newposx); } } function dragend(event){ var event = event.originalevent || event || window.event; event.target = event.target || event.srcelement; locals.dragging = false; if(base.browser.istouch !== true){ base.$owlwrapper.removeclass("grabbing"); } if(base.newrelativex<0){ base.dragdirection = base.owl.dragdirection = "left" } else { base.dragdirection = base.owl.dragdirection = "right" } if(base.newrelativex !== 0){ var newposition = base.getnewposition(); base.goto(newposition,false,"drag"); if(locals.targetelement === event.target && base.browser.istouch !== true){ $(event.target).on("click.disable", function(ev){ ev.stopimmediatepropagation(); ev.stoppropagation(); ev.preventdefault(); $(event.target).off("click.disable"); }); var handlers = $._data(event.target, "events")["click"]; var owlstopevent = handlers.pop(); handlers.splice(0, 0, owlstopevent); } } swapevents("off"); } base.$elem.on(base.ev_types["start"], ".owl-wrapper", dragstart); }, getnewposition : function(){ var base = this, newposition; newposition = base.closestitem(); if(newposition>base.maximumitem){ base.currentitem = base.maximumitem; newposition = base.maximumitem; } else if( base.newposx >=0 ){ newposition = 0; base.currentitem = 0; } return newposition; }, closestitem : function(){ var base = this, array = base.options.scrollperpage === true ? base.pagesinarray : base.positionsinarray, goal = base.newposx, closest = null; $.each(array, function(i,v){ if( goal - (base.itemwidth/20) > array[i+1] && goal - (base.itemwidth/20)< v && base.movedirection() === "left") { closest = v; if(base.options.scrollperpage === true){ base.currentitem = $.inarray(closest, base.positionsinarray); } else { base.currentitem = i; } } 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){ closest = array[i+1] || array[array.length-1]; base.currentitem = $.inarray(closest, base.positionsinarray); } else { closest = array[i+1]; base.currentitem = i+1; } } }); return base.currentitem; }, movedirection : function(){ var base = this, direction; if(base.newrelativex < 0 ){ direction = "right" base.playdirection = "next" } else { direction = "left" base.playdirection = "prev" } return direction }, customevents : function(){ var base = this; base.$elem.on("owl.next",function(){ base.next(); }); base.$elem.on("owl.prev",function(){ base.prev(); }); base.$elem.on("owl.play",function(event,speed){ base.options.autoplay = speed; base.play(); base.hoverstatus = "play"; }); base.$elem.on("owl.stop",function(){ base.stop(); base.hoverstatus = "stop"; }); base.$elem.on("owl.goto",function(event,item){ base.goto(item) }); base.$elem.on("owl.jumpto",function(event,item){ base.jumpto(item) }); }, stoponhover : function(){ var base = this; if(base.options.stoponhover === true && base.browser.istouch !== true && base.options.autoplay !== false){ base.$elem.on("mouseover", function(){ base.stop(); }); base.$elem.on("mouseout", function(){ if(base.hoverstatus !== "stop"){ base.play(); } }); } }, lazyload : function(){ var base = this; if(base.options.lazyload === false){ return false; } for(var i=0; i= base.currentitem; } else { follow = true; } if(follow && itemnumber < base.currentitem + base.options.items && $lazyimg.length){ base.lazypreload($item,$lazyimg); } } }, lazypreload : function($item,$lazyimg){ var base = this, iterations = 0; if ($lazyimg.prop("tagname") === "div") { $lazyimg.css("background-image", "url(" + $lazyimg.data("src")+ ")" ); var isbackgroundimg=true; } else { $lazyimg[0].src = $lazyimg.data("src"); } checklazyimage(); function checklazyimage(){ iterations += 1; if (base.completeimg($lazyimg.get(0)) || isbackgroundimg === true) { showimage(); } else if(iterations <= 100){//if image loads in less than 10 seconds settimeout(checklazyimage,100); } else { showimage(); } } function showimage(){ $item.data("owl-loaded", "loaded").removeclass("loading"); $lazyimg.removeattr("data-src"); base.options.lazyeffect === "fade" ? $lazyimg.fadein(400) : $lazyimg.show(); if(typeof base.options.afterlazyload === "function") { base.options.afterlazyload.apply(this,[base.$elem]); } } }, autoheight : function(){ var base = this; var $currentimg = $(base.$owlitems[base.currentitem]).find("img"); if($currentimg.get(0) !== undefined ){ var iterations = 0; checkimage(); } else { addheight(); } function checkimage(){ iterations += 1; if ( base.completeimg($currentimg.get(0)) ) { addheight(); } else if(iterations <= 100){ //if image loads in less than 10 seconds settimeout(checkimage,100); } else { base.wrapperouter.css("height", ""); //else remove height attribute } } function addheight(){ var $currentitem = $(base.$owlitems[base.currentitem]).height(); base.wrapperouter.css("height",$currentitem+"px"); if(!base.wrapperouter.hasclass("autoheight")){ settimeout(function(){ base.wrapperouter.addclass("autoheight"); },0); } } }, completeimg : function(img) { if (!img.complete) { return false; } if (typeof img.naturalwidth !== "undefined" && img.naturalwidth == 0) { return false; } return true; }, onvisibleitems : function(){ var base = this; if(base.options.addclassactive === true){ base.$owlitems.removeclass("active"); } base.visibleitems = []; for(var i=base.currentitem; i= base.$useritems.length || position === -1){ base.$useritems.eq(-1).after(htmlstring) } else { base.$useritems.eq(position).before(htmlstring) } base.setvars(); }, removeitem : function(targetposition){ var base = this, position; if(base.$elem.children().length === 0){return false} if(targetposition === undefined || targetposition === -1){ position = -1; } else { position = targetposition; } base.unwrap(); base.$useritems.eq(position).remove(); base.setvars(); } }; $.fn.owlcarousel = function( options ){ return this.each(function() { if($(this).data("owl-init") === true){ return false; } $(this).data("owl-init", true); var carousel = object.create( carousel ); carousel.init( options, this ); $.data( this, "owlcarousel", carousel ); }); }; $.fn.owlcarousel.options = { items : 1, itemscustom : false, itemsdesktop : [1199,1], itemsdesktopsmall : [979,1], itemstablet : [768,1], itemstabletsmall : false, itemsmobile : [479,1], singleitem : false, itemsscaleup : false, slidespeed : 200, paginationspeed : 800, rewindspeed : 1000, autoplay : false, stoponhover : false, navigation : false, navigationtext : ["prev","next"], rewindnav : true, scrollperpage : false, pagination : true, paginationnumbers : false, responsive : true, responsiverefreshrate : 200, responsivebasewidth : window, baseclass : "owl-carousel", theme : "owl-theme", lazyload : false, lazyfollow : true, lazyeffect : "fade", autoheight : false, jsonpath : false, jsonsuccess : false, dragbeforeanimfinish : true, mousedrag : true, touchdrag : true, addclassactive : false, transitionstyle : false, beforeupdate : false, afterupdate : false, beforeinit : false, afterinit : false, beforemove : false, aftermove : false, afteraction : false, startdragging : false, afterlazyload: false }; })( jquery, window, document );