Collapse selected path with left arrow

This commit is contained in:
Kevin Sawicki 2013-02-13 17:27:53 -08:00
parent 1a8bba4d70
commit a42a82c8c0
3 changed files with 17 additions and 0 deletions

View File

@ -16,3 +16,6 @@
'.command-panel': '.command-panel':
'ctrl-{': 'command-panel:collapse-all' 'ctrl-{': 'command-panel:collapse-all'
'ctrl-}': 'command-panel:expand-all' 'ctrl-}': 'command-panel:expand-all'
'.command-panel .preview-list':
'left': 'command-panel:collapse-result'

View File

@ -25,6 +25,13 @@ class PreviewList extends ScrollView
@on 'mousedown', 'li.path', @onPathSelected @on 'mousedown', 'li.path', @onPathSelected
@command 'command-panel:collapse-all', => @collapseAllPaths() @command 'command-panel:collapse-all', => @collapseAllPaths()
@command 'command-panel:expand-all', => @expandAllPaths() @command 'command-panel:expand-all', => @expandAllPaths()
@command 'command-panel:collapse-result', @collapseSelectedPath
collapseSelectedPath: (event) =>
e = $('.selected').closest('.path')
return if e.hasClass 'is-collapsed'
e.children('ul.matches').hide 100, (e) ->
$(this).closest('li.path').add 'is-collapsed'
onPathSelected: (event) => onPathSelected: (event) =>
e = $(event.target) e = $(event.target)

View File

@ -478,3 +478,10 @@ describe "CommandPanel", ->
previewList.find('li.path:first-child').mousedown() previewList.find('li.path:first-child').mousedown()
expect(previewList.find('li.path:first-child ul.matches')).toBeVisible() expect(previewList.find('li.path:first-child ul.matches')).toBeVisible()
describe "when command-panel:collapse-result is triggered", ->
it "collapses the path of the selected operation", ->
rootView.attachToDom()
expect(previewList.find('li.path:first-child ul.matches')).toBeVisible()
previewList.trigger 'command-panel:collapse-result'
expect(previewList.find('li.path:first-child ul.matches')).toBeHidden()