mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Construct Pane w/ multiple items. Show first item on construction.
This commit is contained in:
committed by
probablycorey
parent
68b05a5d8d
commit
2bdc077d2a
17
spec/app/pane-spec.coffee
Normal file
17
spec/app/pane-spec.coffee
Normal file
@@ -0,0 +1,17 @@
|
||||
Editor = require 'editor'
|
||||
Pane = require 'pane'
|
||||
{$$} = require 'space-pen'
|
||||
|
||||
describe "Pane", ->
|
||||
[view1, view2, editSession1, editSession2, pane] = []
|
||||
|
||||
beforeEach ->
|
||||
view1 = $$ -> @div id: 'view-1', 'View 1'
|
||||
view2 = $$ -> @div id: 'view-1', 'View 1'
|
||||
editSession1 = project.buildEditSession('sample.js')
|
||||
editSession2 = project.buildEditSession('sample.txt')
|
||||
pane = new Pane(view1, editSession1, view2, editSession2)
|
||||
|
||||
describe ".initialize(items...)", ->
|
||||
it "displays the first item in the pane", ->
|
||||
expect(pane.itemViews.find(view1)).toExist()
|
||||
@@ -6,11 +6,20 @@ module.exports =
|
||||
class Pane extends View
|
||||
@content: (wrappedView) ->
|
||||
@div class: 'pane', =>
|
||||
@subview 'wrappedView', wrappedView if wrappedView
|
||||
@div class: 'item-views', outlet: 'itemViews'
|
||||
|
||||
@deserialize: ({wrappedView}) ->
|
||||
new Pane(deserialize(wrappedView))
|
||||
|
||||
initialize: (@items...) ->
|
||||
@viewsByItem = new WeakMap
|
||||
@showItem(@items[0])
|
||||
|
||||
showItem: (item) ->
|
||||
@itemViews.children().hide()
|
||||
@itemViews.append(item) unless @itemViews.children(item).length
|
||||
item.show()
|
||||
|
||||
serialize: ->
|
||||
deserializer: "Pane"
|
||||
wrappedView: @wrappedView?.serialize()
|
||||
|
||||
Reference in New Issue
Block a user