class NfusionTestimonialsHandler extends elementorModules.frontend.handlers.Base {
getDefaultSettings(){
return {
selectors: {
wrap: '.nft-2eadfe97-wrap',
listItem: '.nft-2eadfe97-list-item',
slide: '.nft-2eadfe97-slide',
prevBtn: '.nft-2eadfe97-prev',
nextBtn: '.nft-2eadfe97-next',
counterCurrent: '.nft-2eadfe97-counter-current',
attrName: '.nft-2eadfe97-attr-name',
attrCat: '.nft-2eadfe97-attr-cat',
dot: '.nft-2eadfe97-dot',
right: '.nft-2eadfe97-right',
chip: '.nft-2eadfe97-chip',
strip: '.nft-2eadfe97-strip',
},
activeClass: 'is-active',
autoplayDelay: 5000,
};}
getDefaultElements(){
var selectors=this.getSettings('selectors');
return {
$wrap: this.$element.find(selectors.wrap),
$listItems: this.$element.find(selectors.listItem),
$slides: this.$element.find(selectors.slide),
$prevBtn: this.$element.find(selectors.prevBtn),
$nextBtn: this.$element.find(selectors.nextBtn),
$counterCurrent: this.$element.find(selectors.counterCurrent),
$attrName: this.$element.find(selectors.attrName),
$attrCat: this.$element.find(selectors.attrCat),
$dots: this.$element.find(selectors.dot),
$right: this.$element.find(selectors.right),
$chips: this.$element.find(selectors.chip),
$strip: this.$element.find(selectors.strip),
};}
bindEvents(){
this.currentIndex=0;
this.autoplayTimer=null;
var self=this;
this.elements.$listItems.each(function(){
jQuery(this).on('click', function(){
var idx=parseInt(jQuery(this).attr('data-index'), 10);
self.goTo(idx);
self.resetAutoplay();
});
});
this.elements.$chips.each(function(){
jQuery(this).on('click', function(e){
e.stopPropagation();
var idx=parseInt(jQuery(this).attr('data-chip-index'), 10);
self.goTo(idx);
self.resetAutoplay();
});
});
this.elements.$prevBtn.on('click', function(e){
e.stopPropagation();
self.prev();
self.resetAutoplay();
});
this.elements.$nextBtn.on('click', function(e){
e.stopPropagation();
self.next();
self.resetAutoplay();
});
this.elements.$right.on('click', function(){
self.next();
self.resetAutoplay();
});
this.elements.$wrap.on('mouseenter', function(){
self.stopAutoplay();
});
this.elements.$wrap.on('mouseleave', function(){
self.startAutoplay();
});
this.visibilityHandler=function(){
if(document.hidden){
self.stopAutoplay();
}else if(!self.elements.$wrap.is(':hover')){
self.startAutoplay();
}};
document.addEventListener('visibilitychange', this.visibilityHandler);
this.startAutoplay();
}
goTo(index){
var total=this.elements.$slides.length;
if(index < 0) index=total - 1;
if(index >=total) index=0;
var activeClass=this.getSettings('activeClass');
this.elements.$listItems.removeClass(activeClass);
this.elements.$slides.removeClass(activeClass);
this.elements.$dots.removeClass(activeClass);
this.elements.$chips.removeClass(activeClass);
jQuery(this.elements.$listItems[index]).addClass(activeClass);
jQuery(this.elements.$slides[index]).addClass(activeClass);
jQuery(this.elements.$dots[index]).addClass(activeClass);
jQuery(this.elements.$chips[index]).addClass(activeClass);
this.elements.$chips.attr('aria-selected', 'false');
jQuery(this.elements.$chips[index]).attr('aria-selected', 'true');
var display=('0' + (index + 1)).slice(-2);
this.elements.$counterCurrent.text(display);
var $activeListItem=jQuery(this.elements.$listItems[index]);
var clientName=$activeListItem.find('.nft-2eadfe97-client-name').text();
var clientCat=$activeListItem.find('.nft-2eadfe97-client-cat').text();
this.elements.$attrName.text(clientName);
this.elements.$attrCat.text(clientCat);
this.centerActiveChip(index);
this.currentIndex=index;
}
centerActiveChip(index){
var $strip=this.elements.$strip;
if(!$strip||!$strip.length) return;
var strip=$strip[0];
if(strip.offsetParent===null) return;
var chip=this.elements.$chips[index];
if(!chip) return;
var target=chip.offsetLeft - (strip.clientWidth - chip.clientWidth) / 2;
var maxScroll=strip.scrollWidth - strip.clientWidth;
target=Math.max(0, Math.min(target, maxScroll));
if(typeof strip.scrollTo==='function'){
strip.scrollTo({ left: target, behavior: 'smooth' });
}else{
strip.scrollLeft=target;
}}
prev(){
this.goTo(this.currentIndex - 1);
}
next(){
this.goTo(this.currentIndex + 1);
}
startAutoplay(){
var self=this;
this.stopAutoplay();
this.autoplayTimer=setInterval(function(){
self.next();
}, this.getSettings('autoplayDelay'));
}
stopAutoplay(){
if(this.autoplayTimer){
clearInterval(this.autoplayTimer);
this.autoplayTimer=null;
}}
resetAutoplay(){
this.startAutoplay();
}}
jQuery(window).on('elementor/frontend/init', function(){
var addHandler=function($element){
elementorFrontend.elementsHandler.addHandler(NfusionTestimonialsHandler, { $element: $element });
};
elementorFrontend.hooks.addAction('frontend/element_ready/nfusion_testimonials_2eadfe97.default', addHandler);
});