Sha256: fbea2568b171c5ed4261503123533cf305be13a30396ba2129997ff7280c3672
Contents?: true
Size: 1.5 KB
Versions: 24
Compression:
Stored size: 1.5 KB
Contents
(function( $ ){ $.fn.browseGroupCategories = function( options ) { // Create some defaults, extending them with any options that were provided var settings = $.extend( { }, options); var $container, slider; function init() { var data = $container.data(); var sidebar = $container.data().sidebar; var items = data.browseGroupCategoriesCount; var dir = $('html').attr('dir'); var controls = $container.parent().find('.browse-group-categories-controls')[0]; slider = tns({ container: $container[0], controlsContainer: controls, loop: false, nav: false, items: 1, slideBy: 'page', textDirection: dir, responsive: { 576: { items: itemCount(items, sidebar) } } }); } // Destroy the slider instance, as tns will change the dom elements, causing some issues with turbolinks function setupDestroy() { document.addEventListener('turbolinks:before-cache', function() { if (slider && slider.destroy) { slider.destroy(); } }); } function itemCount(items, sidebar) { if (items < 3) { return items; } return sidebar ? 3 : 4; } return this.each(function() { $container = $(this); init(); setupDestroy(); }); } })( jQuery ); Spotlight.onLoad(function() { $('[data-browse-group-categories-carousel]').each(function(i, el) { $(el).browseGroupCategories(); }); });
Version data entries
24 entries across 24 versions & 1 rubygems