Support clicking on entries in file finder

Add a hover color and register a mousedown listener
that opens the selected path.
This commit is contained in:
Kevin Sawicki
2012-06-07 18:29:47 -07:00
parent e2b9e74e19
commit 7b15e18c98
2 changed files with 15 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
{View, $$} = require 'space-pen'
stringScore = require 'stringscore'
fuzzyFilter = require 'fuzzy-filter'
$ = require 'jquery'
Editor = require 'editor'
module.exports =
@@ -26,6 +27,7 @@ class FileFinder extends View
@on 'move-up', => @moveUp()
@on 'move-down', => @moveDown()
@on 'file-finder:select-file', => @select()
@on 'mousedown', 'li', (e) => @entryClicked(e)
@miniEditor.buffer.on 'change', => @populatePathList() if @hasParent()
@miniEditor.off 'move-up move-down'
@@ -58,12 +60,14 @@ class FileFinder extends View
findSelectedLi: ->
@pathList.children('li.selected')
select: ->
selectedLi = @findSelectedLi()
return unless selectedLi.length
@rootView.open(selectedLi.text())
open : (text) ->
return unless text.length
@rootView.open(text)
@detach()
select: ->
@open(@findSelectedLi().text())
moveUp: ->
@findSelectedLi()
.filter(':not(:first-child)')
@@ -80,3 +84,6 @@ class FileFinder extends View
findMatches: (query) ->
fuzzyFilter(@paths, query, maxResults: @maxResults)
entryClicked: (e) ->
@open($(e.currentTarget).text())