-
Notifications
You must be signed in to change notification settings - Fork 896
/
Copy pathitem.js
60 lines (51 loc) · 1.56 KB
/
item.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
module.exports = function (list) {
return function (initValues, element, notCreate) {
var item = this
this._values = {}
this.found = false // Show if list.searched == true and this.found == true
this.filtered = false // Show if list.filtered == true and this.filtered == true
var init = function (initValues, element, notCreate) {
if (element === undefined) {
if (notCreate) {
item.values(initValues, notCreate)
} else {
item.values(initValues)
}
} else {
item.elm = element
var values = list.templater.get(item, initValues)
item.values(values)
}
}
this.values = function (newValues, notCreate) {
if (newValues !== undefined) {
for (var name in newValues) {
item._values[name] = newValues[name]
}
if (notCreate !== true) {
list.templater.set(item, item.values())
}
} else {
return item._values
}
}
this.show = function () {
list.templater.show(item)
}
this.hide = function () {
list.templater.hide(item)
}
this.matching = function () {
return (
(list.filtered && list.searched && item.found && item.filtered) ||
(list.filtered && !list.searched && item.filtered) ||
(!list.filtered && list.searched && item.found) ||
(!list.filtered && !list.searched)
)
}
this.visible = function () {
return item.elm && item.elm.parentNode == list.list ? true : false
}
init(initValues, element, notCreate)
}
}