$(window).load(function(){
var INTERVAL_TIME = 4000,
activeSlideIndex = 0,
slidesNbr = $("#zoom-widget-container .zoom-slide").length;
// Generate dots list
$("#zoom-widget-container .zoom-slide").each(function(){
var currentSlideIndex = $(this).index();
var list = $("
");
for(var i = 0; i < slidesNbr; i++){
var element = $("
");
if(i == currentSlideIndex){element.addClass("zoom-active");} else {element.addClass("zoom-inactive");}
list.append(element);
}
$(this).find("#zoom-buttons-container").append(list);
});
// Add listeners
$("#zoom-widget-container .zoom-slide #zoom-buttons-container ul li").each(function(){
if($(this).hasClass("zoom-inactive")){
var currentDotIndex = $(this).index();
$(this).click(function(){
$("#zoom-widget-container .zoom-slide").each(function(){
var slideIndex = $(this).index();
if(slideIndex == currentDotIndex){
activeSlideIndex = slideIndex;
$(this).removeClass("zoom-slide-inactive");
if($("#zoom-text-container").length > 0){
$(this).find("#zoom-text-container").dotdotdot();
};
}
});
$(this).parent().parent().parent().parent().addClass("zoom-slide-inactive");
if($("#zoom-text-container").length > 0){
// .ellipsis deja effectuer dans js global
//$(".ellipsis").dotdotdot({ellipsis:'...'});
};
});
}
});
// Auto change
var timerHandle = setInterval(function(){myTimer()}, INTERVAL_TIME);
function myTimer(){
if(activeSlideIndex + 1>= slidesNbr) {activeSlideIndex = 0;} else {activeSlideIndex += 1;}
$("#zoom-widget-container .zoom-slide").each(function(){
var slideIndex = $(this).index();
if(slideIndex == activeSlideIndex){
$(this).removeClass("zoom-slide-inactive");
if($("#zoom-text-container").length > 0){
$(this).find("#zoom-text-container").dotdotdot();
};
} else {
$(this).addClass("zoom-slide-inactive");
}
});
//.ellipsis deja chargé dans js global
//$(".ellipsis").dotdotdot({ellipsis:'...'});
}
$("#zoom-widget-container").hover(function(){
clearInterval(timerHandle); // Hover in
}, function(){
timerHandle = setInterval(function(){myTimer()}, INTERVAL_TIME); // Hover out
});
});