Panel containers have the orientation

This commit is contained in:
Ben Ogle 2014-10-16 16:16:49 -07:00
parent 5c2e55861c
commit 83e5873f3b
3 changed files with 9 additions and 2 deletions

View File

@ -30,10 +30,13 @@ describe "PanelContainerElement", ->
modelConstructor: TestPanelItem
viewConstructor: TestPanelItemElement
container = new PanelContainer({viewRegistry})
container = new PanelContainer({viewRegistry, orientation: 'left'})
element = container.getView()
jasmineContent.appendChild(element)
it 'has an oritation attribute with value from the model', ->
expect(element.getAttribute('orientation')).toBe 'left'
it 'removes the element when the container is destroyed', ->
expect(element.parentNode).toBe jasmineContent
container.destroy()

View File

@ -11,6 +11,8 @@ class PanelContainerElement extends HTMLElement
@subscriptions.add @model.onDidRemovePanel(@panelRemoved.bind(this))
@subscriptions.add @model.onDidDestroy(@destroyed.bind(this))
@setAttribute('orientation', @model.getOrientation())
panelAdded: ({panel, index}) ->
if index >= @childNodes.length
@appendChild(panel.getView())

View File

@ -3,7 +3,7 @@
# Public:
module.exports =
class PanelContainer
constructor: ({@viewRegistry}) ->
constructor: ({@viewRegistry, @orientation}) ->
@emitter = new Emitter
@subscriptions = new CompositeDisposable
@panels = []
@ -33,6 +33,8 @@ class PanelContainer
getView: -> @viewRegistry.getView(this)
getOrientation: -> @orientation
getPanels: -> @panels
addPanel: (panel) ->