mirror of
https://github.com/atom/atom.git
synced 2026-01-26 07:19:06 -05:00
Move path selection to view class
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{View} = require 'space-pen'
|
||||
fs = require 'fs'
|
||||
OperationView = require './operation-view'
|
||||
$ = require 'jquery'
|
||||
|
||||
module.exports =
|
||||
class PathView extends View
|
||||
@@ -14,6 +15,15 @@ class PathView extends View
|
||||
for operation in operations
|
||||
@subview "operation#{operation.index}", new OperationView({operation})
|
||||
|
||||
initialize: ->
|
||||
@on 'mousedown', @onPathSelected
|
||||
|
||||
onPathSelected: (event) =>
|
||||
e = $(event.target)
|
||||
e = e.parent() if e.parent().hasClass 'path'
|
||||
if e.hasClass 'path'
|
||||
@matches.toggle 100, => @toggleClass 'is-collapsed'
|
||||
|
||||
expand: ->
|
||||
@matches.show()
|
||||
@removeClass 'is-collapsed'
|
||||
|
||||
@@ -23,7 +23,6 @@ class PreviewList extends ScrollView
|
||||
@setSelectedOperationIndex(parseInt($(e.target).closest('li').data('index')))
|
||||
@executeSelectedOperation()
|
||||
|
||||
@on 'mousedown', 'li.path', @onPathSelected
|
||||
@command 'command-panel:collapse-all', => @collapseAllPaths()
|
||||
@command 'command-panel:expand-all', => @expandAllPaths()
|
||||
@command 'command-panel:collapse-result', @collapseSelectedPath
|
||||
@@ -34,13 +33,6 @@ class PreviewList extends ScrollView
|
||||
e.children('ul.matches').hide 100, (e) ->
|
||||
$(this).closest('li.path').addClass 'is-collapsed'
|
||||
|
||||
onPathSelected: (event) =>
|
||||
e = $(event.target)
|
||||
e = e.parent() if e.parent().hasClass 'path'
|
||||
return unless e.hasClass 'path'
|
||||
e.children('ul.matches').toggle 100, (e) ->
|
||||
$(this).closest('li.path').toggleClass 'is-collapsed'
|
||||
|
||||
expandAllPaths: ->
|
||||
@children().each (index, element) -> $(element).view().expand()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user