Merge pull request #4478 from atom/mb-panel-markup

Allow PanelElements to be instantiated with markup
This commit is contained in:
Max Brunsfeld 2014-12-09 13:05:35 -08:00
commit caf6fdd5ac
2 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,6 @@
{CompositeDisposable} = require 'event-kit'
{callAttachHooks} = require './space-pen-extensions'
Panel = require './panel'
class PanelElement extends HTMLElement
createdCallback: ->
@ -13,14 +14,15 @@ class PanelElement extends HTMLElement
@subscriptions.add @model.onDidDestroy(@destroyed.bind(this))
this
getModel: -> @model
getModel: ->
@model ?= new Panel
getItemView: ->
atom.views.getView(@model.getItem())
atom.views.getView(@getModel().getItem())
attachedCallback: ->
callAttachHooks(@getItemView()) # for backward compatibility with SpacePen views
@visibleChanged(@model.isVisible())
@visibleChanged(@getModel().isVisible())
visibleChanged: (visible) ->
if visible

View File

@ -14,7 +14,7 @@ class Panel
Section: Construction and Destruction
###
constructor: ({@item, @visible, @priority, @className}) ->
constructor: ({@item, @visible, @priority, @className}={}) ->
@emitter = new Emitter
@visible ?= true
@priority ?= 100