mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
33 lines
989 B
CoffeeScript
33 lines
989 B
CoffeeScript
{CompositeDisposable} = require 'event-kit'
|
|
{callAttachHooks} = require './space-pen-extensions'
|
|
|
|
class PanelElement extends HTMLElement
|
|
createdCallback: ->
|
|
@subscriptions = new CompositeDisposable
|
|
|
|
getModel: -> @model
|
|
|
|
setModel: (@model) ->
|
|
view = @model.getItemView()
|
|
@appendChild(view)
|
|
|
|
@classList.add(@model.getClassName().split(' ')...) if @model.getClassName()?
|
|
@subscriptions.add @model.onDidChangeVisible(@visibleChanged.bind(this))
|
|
@subscriptions.add @model.onDidDestroy(@destroyed.bind(this))
|
|
|
|
attachedCallback: ->
|
|
callAttachHooks(@model.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
|