Total Complexity | 8 |
Complexity/F | 1.6 |
Lines of Code | 29 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | var targets = Object.keys(document.querySelectorAll('[data-vanillatrigger]')).map(function(index) { |
||
2 | return document.querySelectorAll('[data-vanillatrigger]')[index]; |
||
3 | }); |
||
4 | |||
5 | targets.filter(function(item) { |
||
6 | item.addEventListener('click', function() { |
||
7 | |||
8 | // Uncheck all triggers |
||
9 | if(typeof item.value === 'undefined' || item.value === "") { |
||
10 | resetFilters(targets); |
||
|
|||
11 | } else { |
||
12 | if(VF.options.vanillaSingleFilter) { |
||
13 | resetFilters(targets); |
||
14 | } |
||
15 | |||
16 | item.checked = true; |
||
17 | |||
18 | return item.classList.toggle('is-active'); |
||
19 | } |
||
20 | }); |
||
21 | }); |
||
22 | |||
23 | function resetFilters(targets) { |
||
24 | targets.filter(function(item) { |
||
25 | item.checked = false; |
||
26 | |||
27 | return item.classList.remove('is-active'); |
||
28 | }); |
||
29 | } |
||
30 |