“use strict”;
P.when(“jQuery”, “jQuery-owl”,“ready”).execute(function($) {
var owls = $("#in-page-carousel"); var prevButton = $(".car-prev"); var nextButton = $(".car-next"); /* * Event details documented here: * http://www.owlcarousel.owlgraphic.com/docs/api-events.html */ owls.on("translated.owl.carousel initialized.owl.carousel", function(event){ /* * Hide the left button if we are at the carousel * starting position. */ if(event.page.index === 0) { prevButton.addClass('disabled'); } else { prevButton.removeClass('disabled'); } /* * Hide the next button if the last item is completely visible within * the owl carousel */ var lastItem = owls.find(".owl-item").last(); if(lastItem.offset().left + lastItem.width() < owls.offset().left + owls.width()) { nextButton.addClass('disabled'); } else { nextButton.removeClass('disabled'); } }); /* * Initialize the carousel. Documentation: * http://www.owlcarousel.owlgraphic.com/docs/api-options.html */ owls.owlCarousel({ pagination : false, margin : 30, autoWidth:true, loop:false, responsive:{ 0:{ items:1 }, 490:{ items:2 }, 768:{ items:3 }, 1280:{ items:4 } } }); nextButton.click(function() { if(!nextButton.hasClass('disabled')){ owls.trigger('next.owl.carousel'); } }); prevButton.click(function() { if(!prevButton.hasClass('disabled')) { owls.trigger('prev.owl.carousel'); } });
});