Hi there,
I found an old thread with some JS modifications to randomize testimonials upon page load, but it doesn’t seem to be working. The testimonials continue to display in the same order that they were loaded.
Can you see if this code is still valid and diagnose what I may be doing wrong, please?
This is my JS code, which I modified enfold/config-templatebuilder/avia-shortcodes/testimonials/testimonials.js:
(function($)
{
"use strict";
// -------------------------------------------------------------------------------------------
// testimonial shortcode javascript
// -------------------------------------------------------------------------------------------
$.fn.shuffle = function() {
var allElems = this.get(),
getRandom = function(max) {
return Math.floor(Math.random() * max);
},
shuffled = $.map(allElems, function(){
var random = getRandom(allElems.length),
randEl = $(allElems[random]).clone(true)[0];
allElems.splice(random, 1);
return randEl;
});
this.each(function(i){
$(this).replaceWith($(shuffled[i]));
});
return $(shuffled);
};
$.fn.avia_sc_testimonial = function(options)
{
return this.each(function()
{
var container = $(this), elements = container.find('.avia-testimonial');
$('.avia-testimonial').shuffle();
//trigger displaying of thumbnails
container.on('avia_start_animation', function()
{
elements.each(function(i)
{
var element = $(this);
setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 150));
});
});
});
}
}(jQuery));
Hi all,
Looks like this is working now. Feel free to close the thread. Thank you!
Hi,
If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon