When showing an item on a pane, add it to the items list if needed

This commit is contained in:
Nathan Sobo
2013-02-18 15:38:43 -07:00
committed by probablycorey
parent 41f18ee6a2
commit d89a7eb522
2 changed files with 16 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ class Pane extends View
@showItem(@items[index])
showItem: (item) ->
@addItem(item)
@itemViews.children().hide()
view = @viewForItem(item)
unless view.parent().is(@itemViews)
@@ -54,6 +55,11 @@ class Pane extends View
@currentItem = item
view.show()
addItem: (item) ->
return if _.include(@items, item)
@items.splice(@getCurrentItemIndex() + 1, 0, item)
item
removeItem: (item) ->
@showNextItem() if item is @currentItem and @items.length > 1
_.remove(@items, item)