1/* 2 * Multiple Filter Masonry 3 * 4 * Copyright (c) 2013 Dynamick (http://dynamick.github.io/multiple-filter-masonry/) 5* MIT License 6 */ 7!function($){ 8 $.fn.multipleFilterMasonry = function(options){ 9 var cache=[]; 10 //the main job of the function is to cache the item,because we are going to filter the items later 11 var init = function($container){ 12 $container.find(options.itemSelector).each(function(){ 13 cache.push($(this)); 14 }); 15 $container.masonry(options); 16 } 17 //filter items in cache 18 var filterItems = function(selector){ 19 var result=[]; 20 $(cache).each(function(item){ 21 $(selector).each(function(index,sel) { 22 if(cache[item].is(sel)){ 23 if($.inArray(cache[item], result) === -1) result.push(cache[item]); 24 } 25 }); 26 }) 27 return result; 28 } 29 30 //reload masonry 31 var reload = function($container,items){ 32 $container.empty(); 33 $(items).each(function(){ 34 $($container).append($(this)); 35 }); 36 $container.masonry('reloadItems'); 37 $container.masonry(); 38 } 39 40 var proc = function($container){ 41 $(options.filtersGroupSelector).find('input[type=radio]').each(function(){ 42 $(this).change(function(){ 43 var selector = []; 44 $(options.filtersGroupSelector).find('input[type=radio]').each( function() { 45 if ( $(this).is(':checked') ) { 46 selector.push( '.' + $(this).val() ); 47 } 48 }); 49 var items = cache; 50 if (selector.length > 0) { 51 items = filterItems(selector); 52 } 53 reload($container,items); 54 }) 55 }) 56 } 57 58 return this.each(function() { 59 var $$ = $(this); 60 init($$); 61 proc($$); 62 }); 63 } 64}(window.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.