File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change
1
+ import $ from 'jquery' ;
2
+
1
3
// Count tag elements
2
4
function countTag ( tag ) {
3
5
return $ ( ".visible[data-tags*='" + tag + "']" ) . length ;
@@ -18,23 +20,28 @@ function getFilterCounts($labels) {
18
20
} ) ;
19
21
}
20
22
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 */
21
27
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' ) ;
24
31
25
32
getFilterCounts ( $labels ) ;
26
33
27
34
$inputs . click ( function ( ) {
28
35
// List of tags to hide
29
- var tagArray = $ ( component )
36
+ var tagArray = $component
30
37
. find ( 'input:checkbox:checked' )
31
38
. map ( function ( ) {
32
39
return $ ( this ) . attr ( 'name' ) . replace ( / [ \W ] + / , '-' ) ;
33
40
} )
34
41
. get ( ) ;
35
42
36
43
// List of tags to restore
37
- var restoreArray = $ ( component )
44
+ var restoreArray = $component
38
45
. find ( 'input:checkbox:not(:checked)' )
39
46
. map ( function ( ) {
40
47
return $ ( this ) . attr ( 'name' ) . replace ( / [ \W ] + / , '-' ) ;
You can’t perform that action at this time.
0 commit comments