Replicate active pane item

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-06-26 12:18:55 -06:00
committed by Nathan Sobo
parent f340828506
commit a62cd0f16a
2 changed files with 13 additions and 4 deletions

View File

@@ -32,3 +32,9 @@ describe "Pane replication", ->
it "replicates the movement of pane items", ->
pane1.moveItem(editSession1a, 1)
expect(pane2.items).toEqual(pane1.items)
it "replicates which pane item is active", ->
pane1.showNextItem()
expect(pane2.activeItem).toEqual pane1.activeItem
pane1.showNextItem()
expect(pane2.activeItem).toEqual pane1.activeItem

View File

@@ -32,6 +32,7 @@ class Pane extends View
else
@items = args
@state = telepath.Document.fromObject
deserializer: 'Pane'
items: @items.map (item) -> item.getState?() ? item.serialize()
@state.get('items').observe ({index, value, type, site}) =>
@@ -42,7 +43,9 @@ class Pane extends View
when 'remove'
@removeItemAtIndex(index, updateState: false)
@state.set(deserializer: 'Pane')
@state.observe ({key, value, site}) =>
return if site is @state.site.id
@showItemForUri(value) if key is 'activeItemUri'
@viewsByClassName = {}
@showItem(@items[0]) if @items.length > 0
@@ -149,6 +152,8 @@ class Pane extends View
@activeView = view
@trigger 'pane:active-item-changed', [item]
@state.set('activeItemUri', item.getUri?())
activeItemTitleChanged: =>
@trigger 'pane:active-item-title-changed'
@@ -296,9 +301,7 @@ class Pane extends View
serialize: ->
@state.get('items').set(index, item.serialize()) for item, index in @items
@state.set
focused: @is(':has(:focus)')
activeItemUri: @activeItem.getUri?()
@state.set focused: @is(':has(:focus)')
@state
getState: -> @state