Completed
Push — master ( d66b80...474a37 )
by Konrad
05:52
created

search.js ➔ ... ➔ Filter.init.afterApplyFilter   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 13
rs 10
c 1
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A search.js ➔ ... ➔ $(ꞌ#depmon-list ul:not(.header)ꞌ).each 0 7 2
1
$(function() {
2
    var filter = Filter.init({
0 ignored issues
show
Bug introduced by
The variable Filter seems to be never declared. If this is a global, consider adding a /** global: Filter */ comment.

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.

Loading history...
3
        filterForms: [
4
            '#depmon-filter'
5
        ],
6
        list: '#depmon-list',
7
        storage: true,
8
        afterApplyFilter: function () {
9
            // hide list header with no more entries in the list
10
            $('.list-header').removeClass('hidden');
11
            if (!$('#depmon-filter input[name="overview"]:checked').length) {
12
                $('#depmon-list ul:not(.header)').each(function () {
13
                    var list = $(this);
14
                    if (list.find('li:not(.hidden):not(.list-header)').length === 0) {
15
                        var listHeader = $(list.find('li.list-header'))[0];
16
                        $(listHeader).addClass('hidden');
17
                    }
18
                });
19
            }
20
        },
21
        debug: true
22
    });
23
24
    $('.filter-reset').click(function () {
25
        filter.reset();
26
        filter.applyFilter(null);
27
        $('.collapse').collapse('hide');
28
    });
29
30
    // ToDo: Combine these event listener to a more generic one
31
    // Quick filter for project
32
    $('.filter-project').click(function() {
33
        var project = $(this).attr('data-project');
34
        var object = {
35
            'project': [
36
                project
37
            ]
38
        };
39
        filter.applyFilter(object);
40
        $('#filter-project-collapse').collapse('show');
41
    });
42
43
    // Quick filter for dependency
44
    $('.filter-dependency').click(function() {
45
        var dependency = $(this).attr('data-dependency');
46
        var object = {
47
            'name': [
48
                dependency
49
            ]
50
        };
51
        filter.applyFilter(object);
52
    });
53
54
    // Quick filter for type
55
    $('.filter-type').click(function() {
56
        var type = $(this).attr('data-type');
57
        var object = {
58
            'project-type': [
59
                type
60
            ]
61
        };
62
        filter.applyFilter(object);
63
        $('#filter-type-collapse').collapse('show');
64
    });
65
66
    // Quick filter for state and the project
67
    $('.filter-state-project').click(function() {
68
        var project = $(this).attr('data-project');
69
        var state = $(this).attr('data-state');
70
        var object = {
71
            'project': [
72
                project
73
            ],
74
            'state': [
75
                state
76
            ]
77
        };
78
        filter.applyFilter(object);
79
        $('#filter-project-collapse').collapse('show');
80
        $('#filter-state-collapse').collapse('show');
81
    });
82
83
    // Quick filter for type
84
    $('.filter-required-project').click(function() {
85
        var project = $(this).attr('data-project');
86
        var required = $(this).attr('data-required');
87
        var object = {
88
            'project': [
89
                project
90
            ],
91
            'required': [
92
                required
93
            ]
94
        };
95
        filter.applyFilter(object);
96
        $('#filter-project-collapse').collapse('show');
97
    });
98
});