1(function ($) { 2 "use strict"; 3 4 $( document ).ready(function() { 5 6 // store filter for each group 7 var buttonFilters = {}; 8 var buttonFilter; 9 // quick search regex 10 var qsRegex; 11 12 // init Isotope 13 var $grid = $('.people-filter-wrap').isotope({ 14 itemSelector: '.people-list', 15 filter: function() { 16 var $this = $(this); 17 var searchResult = qsRegex ? $this.text().match( qsRegex ) : true; 18 var buttonResult = buttonFilter ? $this.is( buttonFilter ) : true; 19 return searchResult && buttonResult; 20 }, 21 }); 22 23 $('.filters').on( 'click', '.button', function() { 24 var $this = $(this); 25 // get group key 26 var $buttonGroup = $this.parents('.filter-button-group'); 27 var filterGroup = $buttonGroup.attr('data-filter-group'); 28 // set filter for group 29 buttonFilters[ filterGroup ] = $this.attr('data-filter'); 30 // combine filters 31 buttonFilter = concatValues( buttonFilters ); 32 // Isotope arrange 33 $grid.isotope(); 34 }); 35 36 // use value of search field to filter 37 var $quicksearch = $('#attsearch').keyup( debounce( function() { 38 qsRegex = new RegExp( $quicksearch.val(), 'gi' ); 39 $grid.isotope(); 40 }) ); 41 42 // change is-checked class on buttons 43 $('.filter-button-group').each( function( i, buttonGroup ) { 44 var $buttonGroup = $( buttonGroup ); 45 $buttonGroup.on( 'click', 'button', function() { 46 $buttonGroup.find('.is-checked').removeClass('is-checked'); 47 $( this ).addClass('is-checked'); 48 }); 49 }); 50 51 // flatten object by concatting values 52 function concatValues( obj ) { 53 var value = ''; 54 for ( var prop in obj ) { 55 value += obj[ prop ]; 56 } 57 return value; 58 } 59 60 // debounce so filtering doesn't happen every millisecond 61 function debounce( fn, threshold ) { 62 var timeout; 63 threshold = threshold || 100; 64 return function debounced() { 65 clearTimeout( timeout ); 66 var args = arguments; 67 var _this = this; 68 function delayed() { 69 fn.apply( _this, args ); 70 } 71 timeout = setTimeout( delayed, threshold ); 72 }; 73 } 74 75 }); 76})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.