Add Pane.moveItem(item, index)

This is the precursor to supporting drag/drop of tabs within and
between panes.
This commit is contained in:
Nathan Sobo
2013-02-25 19:03:06 -07:00
committed by probablycorey
parent 21990cf986
commit 887b5ea007
2 changed files with 29 additions and 0 deletions

View File

@@ -104,6 +104,12 @@ class Pane extends View
@trigger 'pane:item-removed', [item, index]
@remove() unless @items.length
moveItem: (item, newIndex) ->
oldIndex = @items.indexOf(item)
@items.splice(oldIndex, 1)
@items.splice(newIndex, 0, item)
@trigger 'pane:item-moved', [item, newIndex]
itemForPath: (path) ->
_.detect @items, (item) -> item.getPath?() is path