1(function ($){ 2 $('#tiles').imagesLoaded(function() { 3 function comparatorName(a, b) { 4 return $(a).data('name') < $(b).data('name') ? -1 : 1; 5 } 6 function comparatorPrice(a, b) { 7 return $(a).data('price') < $(b).data('price') ? -1 : 1; 8 } 9 function comparatorAleatorio(a, b) { 10 return $(a).data('aleatorio') > $(b).data('aleatorio') ? -1 : 1; 11 } 12 // Prepare layout options. 13 var options = { 14 autoResize: true, // This will auto-update the layout when the browser window is resized. 15 container: $('#main'), // Optional, used for some extra CSS styling 16 offset: 2, // Optional, the distance between grid items 17 itemWidth: 210, // Optional, the width of a grid item 18 comparator: comparatorAleatorio, 19 fillEmptySpace: false // Optional, fill the bottom of each column with widths of flexible height 20 }; 21 22 // Get a reference to your grid items. 23 var handler = $('#tiles li'), 24 filters = $('#filters li'); 25 26 // Get a reference to your grid items. 27 var handler2 = $('#tiles li'), 28 filters2 = $('#filtersp li'); 29 30 // Call the layout function. 31 handler.wookmark(options); 32 33 /** 34 * When a filter is clicked, toggle it's active state and refresh. 35 */ 36 var onClickFilter = function(event) { 37 var item = $(event.currentTarget), 38 activeFilters = []; 39 if(onlyFilter != 1) item.toggleClass('active'); 40 else { 41 filters.removeClass('active'); 42 item.addClass('active'); 43 }; 44 if(onlyFilter != 1){ 45 // Collect active filter strings 46 filters.filter('.active').each(function() { 47 activeFilters.push($(this).data('filter')); 48 }); 49 if(onlyFilter == 2){ 50 filters2.filter('.active').each(function() { 51 activeFilters.push($(this).data('filter')); 52 }); 53 }; 54 }else{ 55 // Filter by the currently selected filter 56 if (item.hasClass('active')) { 57 activeFilters.push(item.data('filter')); 58 } 59 }; 60 if(onlyFilter != 1) handler.wookmarkInstance.filter(activeFilters, 'and'); 61 else handler.wookmarkInstance.filter(activeFilters); 62 } 63 64 // Capture filter click events. 65 filters.click(onClickFilter); 66 if(onlyFilter == 1) $(filters[0]).trigger('click'); 67 68 // Get a reference to your grid items. 69 var $handler1 = $('#tiles li'), 70 $sortbys = $('#sortbys li'); 71 72 // Call the layout function. 73 $handler1.wookmark(options); 74 75 /** 76 * When a filter is clicked, toggle it's active state and refresh. 77 */ 78 var onClickSortBy = function(e) { 79 e.preventDefault(); 80 $currentSortby = $(this); 81 switch ($currentSortby.data('sortby')) { 82 case 'price': 83 options.comparator = comparatorPrice; 84 break; 85 case 'aleatorio': 86 options.comparator = comparatorAleatorio; 87 break; 88 case 'name': 89 default: 90 options.comparator = comparatorName; 91 break; 92 } 93 94 $sortbys.removeClass('active'); 95 $currentSortby.addClass('active'); 96 97 $handler1.wookmark(options); 98 } 99 100 // Capture filter click events. 101 $sortbys.click(onClickSortBy); 102 103 // Call the layout function. 104 handler2.wookmark(options); 105 106 /** 107 * When a filter is clicked, toggle it's active state and refresh. 108 */ 109 var onClickFilter1 = function(event) { 110 var item1 = $(event.currentTarget), 111 activefiltersP = []; 112 filters2.removeClass('active'); 113 item1.addClass('active'); 114 // Filter by the currently selected filter 115 if (item1.hasClass('active')) { 116 activefiltersP.push(item1.data('filter')); 117 }; 118 filters.filter('.active').each(function() { 119 activefiltersP.push($(this).data('filter')); 120 }); 121 handler2.wookmarkInstance.filter(activefiltersP,'and'); 122 } 123 124 // Capture filter click events. 125 filters2.click(onClickFilter1); 126 $(filters2[0]).trigger('click'); 127 128 }); 129})(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.