PageSourceSearch

https://brandcitations.com/wp-content/plugins/referr-reviews/public/js/multipleFilterMasonry.js

js brandcitations.com collected 2026-09-30 14:48:56 UTC 2,955 bytes, 101 lines download raw bytes

1jQuery(document).ready(function($){
2  'use strict';
3  $.fn.multipleFilterMasonry = function(options){
4    var cache=[];
5    var filters = [];
6
7    if(options.selectorType === "list") {
8      $(options.filtersGroupSelector).children().each(function() {
9        filters.push($(this).data("filter"));
10      });
11    }
12
13    //the main job of the function is to cache the item,because we are going to filter the items later
14    var init = function($container){
15      $container.find(options.itemSelector).each(function(){
16        cache.push($(this));
17      });
18      $container.masonry(options);
19    };
20
21    //filter items in cache
22    var filterItems = function(selector){
23      var result=[];
24      $(cache).each(function(item){
25        $(selector).each(function(index,sel) {
26          if(cache[item].is(sel)){
27            if($.inArray(cache[item], result) === -1) result.push(cache[item]);
28          }
29        });
30      });
31      return result;
32    };
33
34    //reload masonry
35    var reload = function($container,items){
36      $container.empty();
37      $(items).each(function(){
38        $($container).append($(this));
39      });
40      $container.masonry("reloadItems");
41      $container.masonry();
42    };
43
44    // Hash filter
45    var hashFilter = function($container) {
46      var hash = window.location.hash.replace("#", "");
47      if($.inArray(hash, filters) !== -1) {
48        reload($container, $("." + hash));
49      }
50    };
51
52    var proc = function($container){
53      var btns = $(options.filtersGroupSelector).find('input[type="checkbox"]');
54      btns.each(function(){
55        $(this).change(function(){
56          var selector = [];
57          btns.removeClass('selected');
58          btns.each( function() {
59            if ( $(this).is(':checked') ) {
60              $(this).addClass("selected");
61              selector.push( "." + $(this).val() );
62            }
63          });
64          var items = cache;
65          if (selector.length > 0) {
66            items = filterItems(selector);
67          }
68          reload($container,items);
69        });
70      });
71    };
72
73    var procUL = function($container){
74      var btns = $(options.filtersGroupSelector).children();
75      btns.each(function(){
76        $(this).click(function(){
77          btns.removeClass('selected');
78          window.location.hash = $(this).data("filter");
79          var selector = [];
80          selector.push( "." + $(this).data("filter") );
81          $(this).addClass("selected");
82          var items = cache;
83          if (selector.length > 0) {
84            items = filterItems(selector);
85          }
86          reload($container,items);
87        });
88      });
89
90      hashFilter($container);
91      btns.removeClass('selected');
92      $('.filters li[data-filter="'+window.location.hash.replace("#", "")+'"]').addClass("selected");
93    };
94
95    return this.each(function() {
96      var $$ = $(this);
97      init($$);
98      options.selectorType === "list" ? procUL($$) : proc($$);
99    });
100  };
101});

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.