Commit f969a043 authored by yann300's avatar yann300

retrieve node at specific path

parent 97c3429e
......@@ -42,6 +42,7 @@ class TreeView {
this.formatSelf = opts.formatSelf || this.formatSelfDefault
this.view = null
this.nodeIsExpanded = {}
this.nodes = {}
}
render (json) {
......@@ -86,6 +87,7 @@ class TreeView {
if (data.children) {
var isExpanded = self.nodeIsExpanded[keyPath]
var list = yo`<ul class=${css.ul_tv}>${children}</ul>`
this.nodes[keyPath] = list
list.style.display = isExpanded !== undefined ? (isExpanded ? 'block' : 'none') : (expand ? 'block' : 'none')
caret.className = list.style.display === 'none' ? 'fa fa-caret-right' : 'fa fa-caret-down'
label.onclick = function () {
......@@ -101,6 +103,10 @@ class TreeView {
return li
}
nodeAt (path) {
return this.nodes[path]
}
formatSelfDefault (key, data) {
return yo`<label>${key}: ${data.self}</label>`
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment