From 377a157faac0fba281c914c5bdff51a48a184fb8 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Mon, 9 Jun 2025 17:44:11 -0500 Subject: [PATCH] chore(js): Cleanup and add note about list-filters --- assets/js/list-filters.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/js/list-filters.js b/assets/js/list-filters.js index c71e145a2..28c818507 100644 --- a/assets/js/list-filters.js +++ b/assets/js/list-filters.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + // Count tag elements function countTag(tag) { return $(".visible[data-tags*='" + tag + "']").length; @@ -18,15 +20,20 @@ function getFilterCounts($labels) { }); } +/** TODO: Include the data source value in the as an additional attribute + * in the HTML and pass it into the component, which would let us use selectors + * for only the source items and let us have more than one + * list filter component per page without conflicts */ export default function ListFilters({ component }) { - const $labels = $(component).find('label'); - const $inputs = $(component).find('input'); + const $component = $(component); + const $labels = $component.find('label'); + const $inputs = $component.find('input'); getFilterCounts($labels); $inputs.click(function () { // List of tags to hide - var tagArray = $(component) + var tagArray = $component .find('input:checkbox:checked') .map(function () { return $(this).attr('name').replace(/[\W]+/, '-'); @@ -34,7 +41,7 @@ export default function ListFilters({ component }) { .get(); // List of tags to restore - var restoreArray = $(component) + var restoreArray = $component .find('input:checkbox:not(:checked)') .map(function () { return $(this).attr('name').replace(/[\W]+/, '-');