Sha256: e4f8a1054101c6ef2029dd0582a8e94667ecfb9914f72a36cdba66006c179e70

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

// store filter for each group
var filters = {};

// init Isotope
var $grid = $('[data-layout="grid"] .grid').isotope({
  itemSelector: '[data-component="product-cards/progressive"]',
  filter: function() {

    var isMatched = true;
    var $this = $(this);

    for ( var prop in filters ) {
      var filter = filters[ prop ];
      // use function if it matches
      filter = filterFns[ filter ] || filter;
      // test each filter
      if ( filter ) {
        isMatched = isMatched && $(this).is( filter );
      }
      // break if not matched
      if ( !isMatched ) {
        break;
      }
    }
    return isMatched;
  }
});

$('#filters').on( 'click', '.btn', function() {
  var $this = $(this);
  // get group key
  var $buttonGroup = $this.parents('.btn-group-vertical');
  var filterGroup = $buttonGroup.attr('data-filter-group');
  // set filter for group
  filters[ filterGroup ] = $this.attr('data-filter');
  // arrange, and use filter fn
  $grid.isotope();
});

// change is-checked class on buttons
$('.btn-group-vertical').each( function( i, buttonGroup ) {
  var $buttonGroup = $( buttonGroup );
  $buttonGroup.on( 'click', 'button', function() {
    $buttonGroup.find('.active').removeClass('active');
    $( this ).addClass('active');
  });
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-theme-marketing-1.0.1 _includes/components/filters/isotope.js
jekyll-theme-marketing-1.0.0 _includes/components/filters/isotope.js