/*! flexible bootstrap carousel v0.4 copyright (c) 2017 dan dev released under the mit license https://github.com/dandevg/flexible-bootstrap-carousel/master/license.md */ /* global $ */ /* global customevent */ $(window).load(function() { $(".carousel").on("acarouselhasbeenadjusted", function() { // do something }); adjustallcarousels(); $(window).resize(function() { adjustallcarousels(); }); }); function adjustallcarousels() { $(".carousel.flexible").each(function() { var items = 0; $(this).find(".items .flex-item").each(function() { items++; }); var item_width = ($(window).width() > 991 && $(window).width() < 1200) ? 300 : 319; adjustcarousel($(this), items, item_width); }); } function adjustcarousel(carousel, num_of_items, item_width) { var carousel_width = $(carousel).width(); var columns_in_item = math.floor(carousel_width / item_width); if (columns_in_item > 3) { columns_in_item = 3; } else if (columns_in_item < 1) { columns_in_item = 1; } var number_of_items = math.ceil(num_of_items / columns_in_item); var $items = $(carousel).find(".items .flex-item"); var length_of_$items = $items.length; $(carousel).find(".carousel-inner").html(""); var current_item = 0; var number_of_columns = string(math.round(12 / columns_in_item)); for (var i = 0; i < number_of_items; i++) { var item = "
").parent().html() : ""; item += "