1 | /** |
||
2 | * Search |
||
3 | * |
||
4 | * @tableofcontent |
||
5 | * 1. Functions |
||
6 | * 1.1 Init |
||
7 | * 1.2 Event Listener |
||
8 | * |
||
9 | */ |
||
10 | |||
11 | /** |
||
12 | * @section 1. Functions |
||
13 | */ |
||
14 | |||
15 | $(function() { |
||
16 | |||
17 | // @section 1.1 Init |
||
18 | var filter = Filter.init({ |
||
0 ignored issues
–
show
|
|||
19 | filterForms: [ |
||
20 | '#depmon-filter' |
||
21 | ], |
||
22 | list: '#depmon-list', |
||
23 | storage: true, |
||
24 | afterApplyFilter: function () { |
||
25 | // hide list header with no more entries in the list |
||
26 | $('.list-header').removeClass('hidden'); |
||
27 | if (!$('#depmon-filter input[name="overview"]:checked').length) { |
||
28 | $('#depmon-list ul:not(.header)').each(function () { |
||
29 | var list = $(this); |
||
30 | if (list.find('li:not(.hidden):not(.list-header)').length === 0) { |
||
31 | var listHeader = $(list.find('li.list-header'))[0]; |
||
32 | $(listHeader).addClass('hidden'); |
||
33 | } |
||
34 | }); |
||
35 | } |
||
36 | }, |
||
37 | debug: true |
||
38 | }); |
||
39 | |||
40 | // @section 1.2 Event Listener |
||
41 | $('.filter-reset').click(function () { |
||
42 | filter.reset(); |
||
43 | filter.applyFilter(null); |
||
44 | $('.collapse').collapse('hide'); |
||
45 | }); |
||
46 | |||
47 | // ToDo: Combine these event listener to a more generic one |
||
48 | // Quick filter for project |
||
49 | $('.filter-project').click(function() { |
||
50 | var project = $(this).attr('data-project'); |
||
51 | var object = { |
||
52 | 'project': [ |
||
53 | project |
||
54 | ] |
||
55 | }; |
||
56 | filter.applyFilter(object); |
||
57 | $('#filter-project-collapse').collapse('show'); |
||
58 | }); |
||
59 | |||
60 | // Quick filter for dependency |
||
61 | $('.filter-dependency').click(function() { |
||
62 | var dependency = $(this).attr('data-dependency'); |
||
63 | var object = { |
||
64 | 'name': [ |
||
65 | dependency |
||
66 | ] |
||
67 | }; |
||
68 | filter.applyFilter(object); |
||
69 | }); |
||
70 | |||
71 | // Quick filter for type |
||
72 | $('.filter-type').click(function() { |
||
73 | var type = $(this).attr('data-type'); |
||
74 | var object = { |
||
75 | 'project-type': [ |
||
76 | type |
||
77 | ] |
||
78 | }; |
||
79 | filter.applyFilter(object); |
||
80 | $('#filter-type-collapse').collapse('show'); |
||
81 | }); |
||
82 | |||
83 | // Quick filter for state and the project |
||
84 | $('.filter-state-project').click(function() { |
||
85 | var project = $(this).attr('data-project'); |
||
86 | var state = $(this).attr('data-state'); |
||
87 | var object = { |
||
88 | 'project': [ |
||
89 | project |
||
90 | ], |
||
91 | 'state': [ |
||
92 | state |
||
93 | ] |
||
94 | }; |
||
95 | filter.applyFilter(object); |
||
96 | $('#filter-project-collapse').collapse('show'); |
||
97 | $('#filter-state-collapse').collapse('show'); |
||
98 | }); |
||
99 | |||
100 | // Quick filter for type |
||
101 | $('.filter-required-project').click(function() { |
||
102 | var project = $(this).attr('data-project'); |
||
103 | var required = $(this).attr('data-required'); |
||
104 | var object = { |
||
105 | 'project': [ |
||
106 | project |
||
107 | ], |
||
108 | 'required': [ |
||
109 | required |
||
110 | ] |
||
111 | }; |
||
112 | filter.applyFilter(object); |
||
113 | $('#filter-project-collapse').collapse('show'); |
||
114 | }); |
||
115 | }); |
||
116 | |||
117 | // end of _search.js |
||
118 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.