(function (ns) { /** * @alias app.partner.View */ ns.View = function () { this.construct.apply(this, arguments); }; ns.View.prototype.construct = function () { this.SlideWidth = 150; this.SlidesCount = 4; this.Slides = null; this.resizeTimeout = null; this.initPartnersCarousel(); }; ns.View.prototype.initPartnersCarousel = function () { $('#partnerCarouselHolder').show(); this.Slides = new Swiper( '#partnerCarousel', { direction:'horizontal', autoplay: 7000, autoplayDisableOnInteraction: false, loop: true, //spaceBetween: "5", centeredSlides: false, //lazyLoading: true, //preloadImages: false, //pagination: '.swiper-pagination', nextButton: '.swiper-button-next', prevButton: '.swiper-button-prev', //centeredSlides: true, paginationClickable: true, slidesPerView: this.getSlidesCount(), preloadImages:true } ); $(window).on('resize.partners', _.bind(function () { if (null != this.resizeTimeout) { clearTimeout(this.resizeTimeout); } this.resizeTimeout = setTimeout(_.bind(this.onPartnerCarouselResize, this), 300); }, this)); }; ns.View.prototype.onPartnerCarouselResize = function () { var slidesCount = this.getSlidesCount(); if (slidesCount != this.Slides.params.slidesPerView) { this.Slides.params.slidesPerView = slidesCount; this.Slides.onResize(); } this.resizeTimeout = null; }; ns.View.prototype.getSlidesCount = function () { var slidesCount = Math.floor($(window).width() / this.SlideWidth); if (slidesCount > this.SlidesCount) { slidesCount = this.SlidesCount; } return slidesCount; }; })(qs.defineNS('app.Partner'));