-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (36 loc) · 1.23 KB
/
index.js
File metadata and controls
46 lines (36 loc) · 1.23 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
var BaseElement = require('base-element')
var inherits = require('inherits')
var rowsView = require('./rows')
module.exports = DataList
inherits(DataList, BaseElement)
function DataList (options) {
if (!(this instanceof DataList)) return new DataList(options)
options = options || {}
BaseElement.call(this, options.el)
var self = this
this.rows = rowsView(options)
this.properties = propertiesView(options)
this.rows.addEventListener('load', function (el) {
el.style.height = (window.innerHeight - (options.offsetX || 35)) + 'px'
})
this.rows.addEventListener('click', function (e, row, key, value) {
self.send('click', e, row, key, value)
})
this.rows.addEventListener('focus', function (e, row, key, value) {
self.send('focus', e, row, key, value)
})
this.rows.addEventListener('blur', function (e, row, key, value) {
self.send('blur', e, row, key, value)
})
this.rows.addEventListener('input', function (e, row, key, value) {
self.send('input', e, row, key, value)
})
this.on = this.addEventListener
}
DataList.prototype.render = function (state) {
var vtree = this.html('div#data-list', [
this.properties.render(state),
this.rows.render(state)
])
return this.afterRender(vtree)
}