list.forEach(current => { if (context) { if (current.type == 'item') current.parentCollection = context; else current.parentCommunity = context; } directory.enhance(current); if (current.type != 'item') { current.expanded = false; current.toggle = function () { this.expanded = !this.expanded; if (this.expanded) { if (this.type == 'collection') directory.loadNav('item', this); else { directory.loadNav('community', this); directory.loadNav('collection', this); } } } } });