Move collapse result command to PathView

This commit is contained in:
Kevin Sawicki
2013-02-13 18:47:15 -08:00
parent 9dcb124ff7
commit 5b1acb5188
2 changed files with 21 additions and 15 deletions

View File

@@ -17,17 +17,30 @@ class PathView extends View
initialize: ->
@on 'mousedown', @onPathSelected
rootView.command 'command-panel:collapse-result', (e) =>
@collapse(true) if @find('.selected').length
onPathSelected: (event) =>
e = $(event.target)
e = e.parent() if e.parent().hasClass 'path'
if e.hasClass 'path'
@matches.toggle 100, => @toggleClass 'is-collapsed'
@toggle(true) if e.hasClass 'path'
expand: ->
@matches.show()
@removeClass 'is-collapsed'
toggle: (animate) ->
if @hasClass('is-collapsed')
@expand(animate)
else
@collapse(animate)
collapse: ->
@matches.hide()
@addClass 'is-collapsed'
expand: (animate=false) ->
if animate
@matches.show 100, => @removeClass 'is-collapsed'
else
@matches.show()
@removeClass 'is-collapsed'
collapse: (animate=false) ->
if animate
@matches.hide 100, => @addClass 'is-collapsed'
else
@matches.hide()
@addClass 'is-collapsed'

View File

@@ -25,13 +25,6 @@ class PreviewList extends ScrollView
@command 'command-panel:collapse-all', => @collapseAllPaths()
@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').addClass 'is-collapsed'
expandAllPaths: ->
@children().each (index, element) -> $(element).view().expand()