Files
atom/plugins/project/project.coffee
Chris Wanstrath 868c0f08c2 hardcore require(). _ and $ are no longer global. ultimate victory.
CoffeeScript is still a global because it's used by require() to
open .coffee files. However, you can also load your own:

cs4 = require('my-coffee-script').CoffeeScript

🚬
2011-08-28 12:30:22 -07:00

32 lines
724 B
CoffeeScript

$ = require 'jquery'
_ = require 'underscore'
{Chrome, Dir, File, Process} = require 'osx'
{bindKey} = require 'editor'
exports.init = ->
@html = File.read(Chrome.appRoot() + "/plugins/project/project.html")
bindKey 'toggleProjectDrawer', 'Command-Ctrl-N', (env) =>
@toggle()
exports.toggle = ->
if @showing
$('#project').parent().remove()
else
Chrome.addPane 'left', @html
@reload()
@showing = not @showing
exports.reload = ->
dir = OSX.NSFileManager.defaultManager.currentDirectoryPath
$('#project .cwd').text(dir)
files = Dir.list(dir)
listItems = _.map files, (file) ->
file = file.replace(dir, "")
"<li>#{file}</li>"
$('#project .files').append(listItems.join('\n'))