1jQuery(document).ready(function($) { 2 'use strict'; 3 4 $('.bt-iso-grid').each(function(){ 5 var filter = $(this).find( '.bt-filters' ), 6 grid = $(this).find( '.bt-isotope' ), 7 container = grid.isotope( $(this).data( 'iso' ) ), 8 loadmore = $(this).find( '.bt-load-more-wrap .bt-load-more' ), 9 obj_loadMore = $(this).data( 'loadmore' ), 10 showLoadMore = typeof obj_loadMore !== 'undefined' ? obj_loadMore.show_loadmore : 0, //number of items loaded on init 11 initShow = typeof obj_loadMore !== 'undefined' ? parseInt(obj_loadMore.initShow): 6, //number of items loaded on init 12 initLoad = typeof obj_loadMore !== 'undefined' ? parseInt(obj_loadMore.initLoad) : 3, //number of items onclick load more button 13 counter = initShow, //counter for load more button 14 iso = container.data('isotope'); // get Isotope instance 15 16 // bind filter button click 17 filter.on('click', '.bt-btn-filter', function(e) { 18 e.preventDefault(); 19 var filterValue = $(this).attr('data-filter'); 20 container.isotope({ 21 filter: filterValue 22 }); 23 24 updateFilterCounts(); 25 }); 26 27 // change is-checked class on buttons 28 filter.each(function(i, buttonGroup) { 29 var buttonGroup = $(buttonGroup); 30 buttonGroup.on('click', '.bt-btn-filter', function() { 31 buttonGroup.find('.is-checked').removeClass('is-checked'); 32 $(this).addClass('is-checked'); 33 }); 34 }); 35 36 updateFilterCounts(); 37 38 // flatten object by concatting values 39 function concatValues( obj ) { 40 var value = ''; 41 for ( var prop in obj ) { 42 value += obj[ prop ]; 43 } 44 return value; 45 } 46 47 function updateFilterCounts() { 48 // get filtered item elements 49 var itemElems = grid.isotope('getFilteredItemElements'); 50 var contElems = $( itemElems ); 51 52 filter.find('.bt-btn-filter').each( function( i, button ) { 53 var button = $(this), 54 filterValue = $(this).attr('data-filter'); 55 56 if ( !filterValue ) { 57 // do not update 'any' buttons 58 return; 59 } 60 61 var count = contElems.filter( filterValue ).length; 62 button.find('.bt-count').text( count ); 63 }); 64 65 } 66 67 68 loadMore(initShow); //execute function onload 69 70 function loadMore(toShow) { 71 72 if ( showLoadMore == 0 ) { 73 // do not show load more button 74 return; 75 } 76 77 container.find('.iso-hidden').removeClass('iso-hidden'); 78 79 var hiddenElems = iso.filteredItems.slice(toShow, iso.filteredItems.length).map(function(item) { 80 return item.element; 81 }); 82 $(hiddenElems).addClass('iso-hidden'); 83 container.isotope('layout'); 84 85 var count = hiddenElems.length; 86 loadmore.find('.bt-count').text( count ); 87 88 //when no more to load, hide show more button 89 if (hiddenElems.length == 0) { 90 loadmore.parent().hide(); 91 } else { 92 loadmore.parent().show(); 93 }; 94 } 95 96 //when load more button clicked 97 loadmore.click(function(e) { 98 e.preventDefault(); 99 if (filter.data('clicked')) { 100 //when filter button clicked, set initial value for counter 101 counter = initShow; 102 filter.data('clicked', false); 103 } else { 104 counter = counter; 105 }; 106 counter = counter + initLoad; 107 108 loadMore(counter); 109 }); 110 111 //when filter button clicked 112 filter.click(function() { 113 $(this).data('clicked', true); 114 loadMore(initShow); 115 }); 116 }); 117});
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.