$(function() { var _slider = null; var _sliderMargin = 30; /** BOOTSTRAP WIDTHS **/ var BOOTSTRAP_LG_MIN = 1200; var BOOTSTRAP_MD_MIN = 992; var BOOTSTRAP_SM_MIN = 768; function reloadSliderWithBaseMinWidth(__minWidth) { if(_slider == null) return; // Par précaution var containerWidth = ($('.slider').parents('.mod-selection.col-sm-12').length > 0) ? $('.slider').parents('.mod-selection.col-sm-12').width() : $('.slider').parents('.bx-viewport').width(); // Je remonte au-dessus de ".bx-viewport" qui semblait plus propre mais ce div ne reprend pas toujours bien la "max-width" possible... var numSlides; if(__minWidth == 0) numSlides = 1; else if(__minWidth == BOOTSTRAP_SM_MIN) numSlides = 2; else numSlides = 3; var slideWidth = Math.round((containerWidth - (_sliderMargin * (numSlides - 1))) / numSlides); _slider.reloadSlider({ minSlides: numSlides, maxSlides: numSlides, slideWidth: slideWidth, adaptiveHeight : true, slideMargin: _sliderMargin, controls: false }); } if($('.slider').length > 0) { var sliderBaseMinWidth = BOOTSTRAP_LG_MIN; var sliderBaseMaxWidth = (BOOTSTRAP_LG_MIN * 9999); _slider = $('.slider').bxSlider({ minSlides: 3, maxSlides: 3, slideWidth: 370, adaptiveHeight : true, slideMargin: _sliderMargin, controls: false }); $(window).resize(function() { var currentWidth = $(this).innerWidth(); if((currentWidth < sliderBaseMinWidth) || (currentWidth > sliderBaseMaxWidth)) { if(currentWidth < BOOTSTRAP_SM_MIN) { sliderBaseMinWidth = 0; sliderBaseMaxWidth = BOOTSTRAP_SM_MIN; } else if((currentWidth >= BOOTSTRAP_SM_MIN) && (currentWidth < BOOTSTRAP_MD_MIN)) { sliderBaseMinWidth = BOOTSTRAP_SM_MIN; sliderBaseMaxWidth = BOOTSTRAP_MD_MIN; } else if((currentWidth >= BOOTSTRAP_MD_MIN) && (currentWidth < BOOTSTRAP_LG_MIN)) { sliderBaseMinWidth = BOOTSTRAP_MD_MIN; sliderBaseMaxWidth = BOOTSTRAP_LG_MIN; } else { sliderBaseMinWidth = BOOTSTRAP_LG_MIN; sliderBaseMaxWidth = (BOOTSTRAP_LG_MIN * 9999); } setTimeout(function() {reloadSliderWithBaseMinWidth(sliderBaseMinWidth);}, 100); // Léger timeout pour être sûr que le div ait repris sa taille } }); $(window).resize(); } RESPONSIVEUI.responsiveTabs(); });