-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathListItemModule.js
More file actions
52 lines (46 loc) · 1.69 KB
/
ListItemModule.js
File metadata and controls
52 lines (46 loc) · 1.69 KB
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
/**
* @class ListItemModule
*
* @param parentRoot: HTMLElement
* @param template: Refuel.Template instance
* @author Stefano Sergio
**/
Refuel.define('ListItemModule', {inherits: 'AbstractModule'},
function ListItemModule() {
var config = {};
this.init = function(myConfig) {
config = Refuel.mix(config, myConfig);
delete config['data'];
this.enableAutoUpdate(this.data);
this.isSelected = false;
if (this.dataSource) {
//console.log(Refuel.refuelClass(this),config.dataLabel,'have dataSource and is waiting for data...');
this.dataSource.subscribe('dataAvailable', function(data) {
//console.log(Refuel.refuelClass(this),'got all data (dataAvailable), now he can draw()');
this.notify('loadComplete');
this.draw();
this.notify('drawComplete');
}, this);
this.dataSource.init(config);
}
}
function oa_update(e) {
//console.log('ListItemModule.oa_update', e);
}
this.destroy = function() {
this.template.remove();
delete this;
}
this.draw = function() {
if (!config.template) throw "No template found for ListItemModule";
this.template.create(config.parentRoot, config.template, this.data);
}
this.select = function() {
this.classList.add('selected');
this.isSelected = true;
}
this.deselect = function() {
this.classList.remove('selected');
this.isSelected = false;
}
});