mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Move collapse result command to PathView
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user