1/* -- Filter Plugin -- */ 2(function ($) { 3 'use strict'; 4 $.fn.masonryFilter = function (options) { 5 //reload masonry 6 var reload = function ($container) { 7 setTimeout(function () { 8 $container.masonry("layout"); 9 }, 100); 10 }; 11 12 var process = function ($container) { 13 var items = $container.masonry("getAllItems"), 14 revealItems = [], 15 hideItems = []; 16 17 $.each(items, function(i) { 18 var item = items[i]; 19 var elm = $(item.element), 20 shouldShow = options.filter && options.filter.call(elm); 21 22 if (shouldShow) { 23 if (item.isHidden) { 24 // -- Have to set this property so masonry does 25 // not include hidden items when calling "layout" 26 item.isIgnored = false; 27 revealItems.push(item); 28 } 29 } else { 30 if (!item.isHidden) { 31 // -- Easier to set this property directy rather than 32 // using the "ignore" method, as it takes in a DOM 33 // element rather than the masonry item object. 34 item.isIgnored = true; 35 hideItems.push(item); 36 } 37 } 38 }); 39 40 $container.masonry('hide', hideItems); 41 $container.masonry('reveal', revealItems); 42 43 reload($container); 44 }; 45 46 return this.each(function () { 47 var self = $(this); 48 process(self); 49 }); 50 }; 51}(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.