Start on TreeView. It renders the entries in the current project's root directory.

This commit is contained in:
Nathan Sobo
2012-04-23 14:20:17 -06:00
parent d204c6f5a8
commit 55c78e9550
9 changed files with 114 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
{View, $$} = require 'space-pen'
Directory = require 'directory'
module.exports =
class TreeView extends View
@activate: (rootView) ->
requireStylesheet 'tree-view.css'
rootView.prepend(new TreeView(rootView.project.getRootDirectory()))
@content: (directory) ->
@div class: 'tree-view', =>
@subview 'root', new DirectoryView(directory: directory, isExpanded: true)
initialize: (@project) ->
class DirectoryView extends View
@content: ({directory, isExpanded}) ->
@li class: 'directory', =>
@disclosureArrow(isExpanded)
@span directory.getName() + '/', class: 'name'
@disclosureArrow: (isExpanded) ->
arrowCharacter = if isExpanded then '' else ''
@span arrowCharacter, class: 'disclosure'
initialize: ({@directory, @isExpanded}) ->
@buildEntries() if @isExpanded
buildEntries: ->
contents = $$ -> @ol class: 'entries'
for entry in @directory.getEntries()
if entry instanceof Directory
contents.append(new DirectoryView(directory: entry, isExpanded: false))
else
contents.append $$ -> @li entry.getName(), class: 'file'
@append(contents)