When a file is clicked in the tree view, it is opened in the active editor

This commit is contained in:
Nathan Sobo
2012-04-23 17:13:05 -06:00
parent ea6930af54
commit dc8a9f090a
3 changed files with 34 additions and 12 deletions

View File

@@ -6,13 +6,18 @@ module.exports =
class TreeView extends View
@activate: (rootView) ->
requireStylesheet 'tree-view.css'
rootView.prepend(new TreeView(rootView.project.getRootDirectory()))
rootView.prepend(new TreeView(rootView))
@content: (directory) ->
@content: (rootView) ->
@div class: 'tree-view', =>
@subview 'root', new DirectoryView(directory: directory, isExpanded: true)
@subview 'root', new DirectoryView(directory: rootView.project.getRootDirectory(), isExpanded: true)
initialize: (@project) ->
initialize: (@rootView) ->
@on 'click', '.file', (e) =>
clickedLi = $(e.target)
@rootView.open(clickedLi.attr('path'))
@find('.selected').removeClass('selected')
clickedLi.addClass('selected')
class DirectoryView extends View
@content: ({directory, isExpanded}) ->
@@ -31,7 +36,7 @@ class DirectoryView extends View
if entry instanceof Directory
@entries.append(new DirectoryView(directory: entry, isExpanded: false))
else
@entries.append $$ -> @li entry.getName(), class: 'file'
@entries.append $$ -> @li entry.getName(), class: 'file', path: entry.path
@append(@entries)
toggleExpansion: ->
@@ -66,7 +71,3 @@ class DirectoryView extends View
view = $(this).view()
view.entryStates = childEntryStates
view.expand()