Add indexOfPane and paneAtIndex to PaneContainer

This commit is contained in:
Nathan Sobo
2013-02-26 11:41:41 -07:00
committed by probablycorey
parent 4a7e5b74c6
commit 61fa393e03
2 changed files with 13 additions and 8 deletions

View File

@@ -37,7 +37,13 @@ class PaneContainer extends View
@children().first().view()
getPanes: ->
@find('.pane').toArray().map (node)-> $(node).view()
@find('.pane').views()
indexOfPane: (pane) ->
@getPanes().indexOf(pane.view())
paneAtIndex: (index) ->
@getPanes()[index]
eachPane: (callback) ->
callback(pane) for pane in @getPanes()

View File

@@ -171,6 +171,12 @@ class RootView extends View
eachPane: (callback) ->
@panes.eachPane(callback)
getPanes: ->
@panes.getPanes()
indexOfPane: (pane) ->
@panes.indexOfPane(pane)
eachEditor: (callback) ->
callback(editor) for editor in @getEditors()
@on 'editor:attached', (e, editor) -> callback(editor)
@@ -181,10 +187,3 @@ class RootView extends View
eachBuffer: (callback) ->
project.eachBuffer(callback)
indexOfPane: (pane) ->
index = -1
for p, idx in @panes.find('.pane')
if pane.is(p)
index = idx
break
index