Add Pane.destroyItem and rename removeActiveItem -> destroyActiveItem

Pane.removeItem removes an item, but no longer tries to call destroy
on it. This will facilitate moving items between panes.
This commit is contained in:
Nathan Sobo
2013-02-26 14:19:33 -07:00
committed by probablycorey
parent 61fa393e03
commit 2e2ff3a1d0
2 changed files with 17 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ class Pane extends View
@viewsByClassName = {}
@showItem(@items[0])
@command 'core:close', @removeActiveItem
@command 'core:close', @destroyActiveItem
@command 'pane:show-next-item', @showNextItem
@command 'pane:show-previous-item', @showPreviousItem
@command 'pane:split-left', => @splitLeft()
@@ -89,17 +89,21 @@ class Pane extends View
@trigger 'pane:item-added', [item, index]
item
removeActiveItem: =>
@removeItem(@activeItem)
destroyActiveItem: =>
@destroyItem(@activeItem)
false
destroyItem: (item) ->
@removeItem(item)
item.destroy?()
removeItem: (item) ->
index = @items.indexOf(item)
return if index == -1
@showNextItem() if item is @activeItem and @items.length > 1
_.remove(@items, item)
item.destroy?()
@cleanupItemView(item)
@trigger 'pane:item-removed', [item, index]
@remove() unless @items.length