-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathfilter-group.js
65 lines (55 loc) · 1.37 KB
/
filter-group.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* jshint node: true */
/* jshint jquery: true */
/* jshint esversion: 6 */
"use strict";
/**
* FilterGroup class
*
* Holds a group of filters
* @params Nothing
* @return Filter Group object
*/
var mu = require( "mu2" );
mu.root = __dirname + '/templates';
var Misc = require( "./misc.js" );
class FilterGroup {
constructor( obj ) {
this.clipboard = obj.clipboard;
this.name = obj.name;
this.checked = obj.checked ? "checked" : "";
this.color = obj.color;
this.filters = {};
this.id = obj.id;
this.folded = obj.folded;
}
add( filter ) {
this.filters[filter.id] = filter;
}
remove( filter ) {
delete this.filters[filter.id];
}
getFilter( filterId ) {
if ( this.filters[filterId]) {
return this.filters[filterId];
} else {
return null;
}
}
/**
* Render the filter group to html using a template
*
* @params Callback
* @return Generated HTML through callback
*/
render( callback ) {
var generated = "";
mu.compileAndRender( "filter-group.html", this )
.on( "data", function ( data ) {
generated += data.toString();
})
.on( "end", function() {
callback( generated );
});
}
}
module.exports = FilterGroup;