Move path selection to view class

This commit is contained in:
Kevin Sawicki
2013-02-13 18:30:08 -08:00
parent e03a669413
commit 9dcb124ff7
2 changed files with 10 additions and 8 deletions

View File

@@ -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'

View File

@@ -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()