Added toggle to Pane. Makes more sense there.

Also made pane be more jquery'y
This commit is contained in:
Corey Johnson
2011-09-12 17:50:17 -07:00
parent 5ae4975e98
commit 4f55f4d4a0
3 changed files with 21 additions and 18 deletions

View File

@@ -10,7 +10,9 @@ class Project extends Pane
showing: false
position: 'left'
html: require "project/project.html"
html:
$ require "project/project.html"
keymap:
'Command-Ctrl-N': 'toggle'
@@ -36,19 +38,9 @@ class Project extends Pane
false # Don't bubble!
toggle: ->
if @showing
$('#project').parent().remove()
else
activeWindow.addPane this
@reload()
@showing = not @showing
reload: ->
$('#project .cwd').text _.last dir.split '/'
$('#project li').remove()
$('#project .files').append @createList dir
@html.children('#project .cwd').text _.last @dir.split '/'
@html.children('#project li').remove()
@html.children('#project .files').append @createList @dir
createList: (dir) ->
files = File.list dir

View File

@@ -26,4 +26,15 @@ class Pane
@initialize options
# Override in your subclass
initialize: ->
initialize: ->
toggle: ->
if @showing
@html.parent().detach()
else
# This require should be at the top of the file, BUT it doesn't work.
# Would like to figure out why.
{activeWindow} = require 'app'
activeWindow.addPane this
@showing = not @showing

View File

@@ -24,9 +24,9 @@ class Window extends Pane
verticalDiv = $('#app-vertical')
horizontalDiv = $('#app-horizontal')
el = document.createElement "div"
el.setAttribute 'class', "pane " + position
el.innerHTML = html
el = $ "<div>"
el.addClass "pane " + position
el.append html
switch position
when 'top', 'main'