pane adds itself.

This commit is contained in:
Corey Johnson
2011-09-23 16:16:27 -07:00
parent d8d98ca7e3
commit 5c54dd77c9
2 changed files with 25 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
{bindKey} = require 'keybinder'
$ = require 'jquery'
module.exports =
class Pane
@@ -9,12 +9,35 @@ class Pane
showing: false
constructor: (@window) ->
$('.pane').live 'click', (event) =>
console.log @.constructor.name
true
add: ->
verticalDiv = $('#app-vertical')
horizontalDiv = $('#app-horizontal')
el = $ "<div>"
el.addClass "pane " + @position
el.append @html
switch @position
when 'top', 'main'
verticalDiv.prepend el
when 'left'
horizontalDiv.prepend el
when 'bottom'
verticalDiv.append el
when 'right'
horizontalDiv.append el
else
throw "I DON'T KNOW HOW TO DEAL WITH #{@position}"
toggle: ->
if @showing
@html.parent().detach()
else
@window.addPane this
@add this
@showing = not @showing

View File

@@ -55,26 +55,6 @@ class Window
console.warn "Plugin Loading Failed: #{plugin.constructor.name}"
console.warn error
addPane: ({position, html}) ->
verticalDiv = $('#app-vertical')
horizontalDiv = $('#app-horizontal')
el = $ "<div>"
el.addClass "pane " + position
el.append html
switch position
when 'top', 'main'
verticalDiv.prepend el
when 'left'
horizontalDiv.prepend el
when 'bottom'
verticalDiv.append el
when 'right'
horizontalDiv.append el
else
throw "I DON'T KNOW HOW TO DEAL WITH #{position}"
close: ->
@controller.close()