mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Meta-/ (tree-view:toggle) attaches / detaches the TreeView
This commit is contained in:
parent
79315b0ef6
commit
897f505e4f
@ -96,6 +96,19 @@ describe "TreeView", ->
|
||||
newTreeView = newRootView.find(".tree-view").view()
|
||||
expect(newTreeView).toMatchSelector ':focus'
|
||||
|
||||
describe "when tree-view:toggle is triggered on the root view", ->
|
||||
it "shows/hides the tree view", ->
|
||||
rootView.attachToDom()
|
||||
treeView.focus()
|
||||
expect(treeView.hasParent()).toBeTruthy()
|
||||
rootView.trigger 'tree-view:toggle'
|
||||
expect(treeView.hasParent()).toBeFalsy()
|
||||
expect(rootView).toMatchSelector(':focus')
|
||||
|
||||
rootView.trigger 'tree-view:toggle'
|
||||
expect(treeView.hasParent()).toBeTruthy()
|
||||
expect(treeView).toMatchSelector(':focus')
|
||||
|
||||
describe "when a directory's disclosure arrow is clicked", ->
|
||||
it "expands / collapses the associated directory", ->
|
||||
subdir = treeView.root.find('.entries > li:contains(dir/)').view()
|
||||
|
@ -1,5 +1,6 @@
|
||||
window.keymap.bindKeys '#root-view'
|
||||
'alt-tab': 'tree-view:focus'
|
||||
'meta-/': 'tree-view:toggle'
|
||||
|
||||
window.keymap.bindKeys '.tree-view'
|
||||
'right': 'tree-view:expand-directory'
|
||||
|
@ -18,7 +18,7 @@ class TreeView extends View
|
||||
else
|
||||
@instance = new TreeView(rootView)
|
||||
|
||||
rootView.horizontal.prepend(@instance)
|
||||
@instance.attach()
|
||||
|
||||
@serialize: ->
|
||||
@instance.serialize()
|
||||
@ -49,6 +49,7 @@ class TreeView extends View
|
||||
@on 'tree-view:add', => @add()
|
||||
@on 'tree-view:remove', => @removeSelectedEntry()
|
||||
@on 'tree-view:directory-modified', => @selectActiveFile()
|
||||
@rootView.on 'tree-view:toggle', => @toggle()
|
||||
@rootView.on 'active-editor-path-change', => @selectActiveFile()
|
||||
@rootView.project.on 'path-change', => @updateRoot()
|
||||
|
||||
@ -66,6 +67,17 @@ class TreeView extends View
|
||||
deactivate: ->
|
||||
@root?.unwatchEntries()
|
||||
|
||||
toggle: ->
|
||||
if @hasParent()
|
||||
@detach()
|
||||
@rootView.focus()
|
||||
else
|
||||
@attach()
|
||||
@focus()
|
||||
|
||||
attach: ->
|
||||
@rootView.horizontal.prepend(this)
|
||||
|
||||
entryClicked: (e) ->
|
||||
entry = $(e.currentTarget).view()
|
||||
switch e.originalEvent?.detail ? 1
|
||||
|
Loading…
Reference in New Issue
Block a user