Skip to content

Commit 377a157

Browse files
committed
chore(js): Cleanup and add note about list-filters
1 parent 8193057 commit 377a157

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

assets/js/list-filters.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import $ from 'jquery';
2+
13
// Count tag elements
24
function countTag(tag) {
35
return $(".visible[data-tags*='" + tag + "']").length;
@@ -18,23 +20,28 @@ function getFilterCounts($labels) {
1820
});
1921
}
2022

23+
/** TODO: Include the data source value in the as an additional attribute
24+
* in the HTML and pass it into the component, which would let us use selectors
25+
* for only the source items and let us have more than one
26+
* list filter component per page without conflicts */
2127
export default function ListFilters({ component }) {
22-
const $labels = $(component).find('label');
23-
const $inputs = $(component).find('input');
28+
const $component = $(component);
29+
const $labels = $component.find('label');
30+
const $inputs = $component.find('input');
2431

2532
getFilterCounts($labels);
2633

2734
$inputs.click(function () {
2835
// List of tags to hide
29-
var tagArray = $(component)
36+
var tagArray = $component
3037
.find('input:checkbox:checked')
3138
.map(function () {
3239
return $(this).attr('name').replace(/[\W]+/, '-');
3340
})
3441
.get();
3542

3643
// List of tags to restore
37-
var restoreArray = $(component)
44+
var restoreArray = $component
3845
.find('input:checkbox:not(:checked)')
3946
.map(function () {
4047
return $(this).attr('name').replace(/[\W]+/, '-');

0 commit comments

Comments
 (0)