diff --git a/extensions/blank-extension/pane.coffee b/extensions/blank-extension/pane.coffee
index 2a532c9ec..2533dc5f9 100644
--- a/extensions/blank-extension/pane.coffee
+++ b/extensions/blank-extension/pane.coffee
@@ -11,3 +11,4 @@ class BlankExtension extends Pane
html: null
constructor: ->
+ super
diff --git a/extensions/tabs/tabs-pane.coffee b/extensions/tabs/tabs-pane.coffee
index c5f3cfb17..de2e62dcf 100644
--- a/extensions/tabs/tabs-pane.coffee
+++ b/extensions/tabs/tabs-pane.coffee
@@ -7,11 +7,11 @@ module.exports =
class TabsPane extends Pane
position: 'top'
- html: $ require 'tabs/tabs.html'
-
constructor: ->
+ html = require 'tabs/tabs.html'
+ super html
+
# Style html
- @html.parents('.pane').css height: 'inherit'
css = $('').html require 'tabs/tabs.css'
$('head').append css
diff --git a/extensions/tree/tree-pane.coffee b/extensions/tree/tree-pane.coffee
index ba787aee4..827e1ee3b 100644
--- a/extensions/tree/tree-pane.coffee
+++ b/extensions/tree/tree-pane.coffee
@@ -8,12 +8,11 @@ Pane = require 'pane'
module.exports =
class TreePane extends Pane
position: 'left'
-
tree: null
- html: $ require "tree/tree.html"
-
constructor: (@tree) ->
+ super require "tree/tree.html"
+
@render()
$('#tree li').live 'click', (event) =>
@@ -37,10 +36,10 @@ class TreePane extends Pane
false
render: ->
- @html.children('#tree .cwd').text _.last window.url.split '/'
+ @el.find('.cwd').text _.last window.url.split '/'
fileList = @createList @tree.urls()
fileList.addClass 'files'
- @html.children('#tree .files').replaceWith fileList
+ @el.find('.files').replaceWith fileList
createList: (urls) ->
list = $('
')
diff --git a/src/atom/editor-pane.coffee b/src/atom/editor-pane.coffee
index c5b9fe8a2..d791c9928 100644
--- a/src/atom/editor-pane.coffee
+++ b/src/atom/editor-pane.coffee
@@ -7,20 +7,14 @@ ace = require 'ace/ace'
module.exports =
class EditorPane extends Pane
- id: null
- html: null
position: 'main'
editor: null
- constructor: ->
- @id = _.uniqueId 'editor-'
- @html = $ ""
-
show: ->
super
return if @ace
- @ace = ace.edit @id
+ @ace = ace.edit @paneID
# Resize editor when panes are added/removed
el = document.body
diff --git a/src/atom/pane.coffee b/src/atom/pane.coffee
index a8e19ca4a..86b9fb72e 100644
--- a/src/atom/pane.coffee
+++ b/src/atom/pane.coffee
@@ -1,46 +1,53 @@
$ = require 'jquery'
+_ = require 'underscore'
module.exports =
class Pane
+ paneID: null
position: null
- html: null
+ constructor: (html) ->
+ @paneID = _.uniqueId 'pane-'
+ @el = $ ""
+ @el.addClass "pane " + @position
+ @el.append html
add: ->
verticalDiv = $('#app-vertical')
horizontalDiv = $('#app-horizontal')
- @pane = $ "
"
- @pane.addClass "pane " + @position
- @pane.append @html
-
switch @position
when 'main'
+ # Only one main pane can be visiable.
$('#main > div').addClass 'hidden'
- $('#main').append @pane
+ $('#main').append @el
when 'top'
- verticalDiv.prepend @pane
+ verticalDiv.prepend @el
when 'left'
- horizontalDiv.prepend @pane
+ horizontalDiv.prepend @el
when 'bottom'
- verticalDiv.append @pane
+ verticalDiv.append @el
when 'right'
- horizontalDiv.append @pane
+ horizontalDiv.append @el
else
throw "pane position of #{this} can't be `#{@position}`"
+ el: ->
+ el = $ "##{@paneID}"
+ el[0] and el # Return null if doesn't exist, jquery object if it does
+
showing: ->
- @pane and not @pane.hasClass 'hidden'
+ @el and not @el.hasClass 'hidden'
show: ->
- if not @pane
+ if not @el.parent()[0]
@add()
else
$('#main > div').addClass 'hidden' if @position == 'main'
- @pane.removeClass 'hidden'
+ @el.removeClass 'hidden'
hide: ->
- @pane.addClass 'hidden'
+ @el.addClass 'hidden'
toggle: ->
if @showing()