Files
atom/src/panel-element.coffee
Nathan Sobo 4591f00a65 Remove view registry references from the workspace model layer
Removed various ::getView methods from the model. Using the atom.views
global in the views for now, but going to switch them over to using a
locally assigned view registry instead in a subsequent commit.
2014-12-01 16:28:33 -08:00

35 lines
1021 B
CoffeeScript

{CompositeDisposable} = require 'event-kit'
{callAttachHooks} = require './space-pen-extensions'
class PanelElement extends HTMLElement
createdCallback: ->
@subscriptions = new CompositeDisposable
getModel: -> @model
setModel: (@model) ->
@appendChild(@getItemView())
@classList.add(@model.getClassName().split(' ')...) if @model.getClassName()?
@subscriptions.add @model.onDidChangeVisible(@visibleChanged.bind(this))
@subscriptions.add @model.onDidDestroy(@destroyed.bind(this))
getItemView: ->
atom.views.getView(@model.getItem())
attachedCallback: ->
callAttachHooks(@getItemView()) # for backward compatibility with SpacePen views
@visibleChanged(@model.isVisible())
visibleChanged: (visible) ->
if visible
@style.display = null
else
@style.display = 'none'
destroyed: ->
@subscriptions.dispose()
@parentNode?.removeChild(this)
module.exports = PanelElement = document.registerElement 'atom-panel', prototype: PanelElement.prototype