Remove focusNext/PreviousPane methods from PaneContainer view

This commit is contained in:
Nathan Sobo 2014-01-09 18:34:50 -07:00
parent 60daa483e6
commit e87b8dc463
2 changed files with 6 additions and 27 deletions

View File

@ -42,6 +42,8 @@ describe "PaneContainer", ->
describe ".focusPreviousPane()", ->
it "focuses the pane preceding the focused pane or the last pane if no pane has focus", ->
container.attachToDom()
pane3.focusout()
container.focusPreviousPane()
expect(pane3.activeItem).toMatchSelector ':focus'
container.focusPreviousPane()

View File

@ -1,4 +1,5 @@
Serializable = require 'serializable'
Delegator = require 'delegato'
{$, View} = require './space-pen-extensions'
Pane = require './pane'
PaneContainerModel = require './pane-container-model'
@ -7,6 +8,7 @@ PaneContainerModel = require './pane-container-model'
module.exports =
class PaneContainer extends View
Serializable.includeInto(this)
Delegator.includeInto(this)
@deserialize: (state) ->
new this(PaneContainerModel.deserialize(state.model))
@ -14,6 +16,8 @@ class PaneContainer extends View
@content: ->
@div class: 'panes'
@delegatesMethods 'focusNextPane', 'focusPreviousPane', toProperty: 'model'
initialize: (params) ->
if params instanceof PaneContainerModel
@model = params
@ -47,33 +51,6 @@ class PaneContainer extends View
### Public ###
focusNextPane: ->
panes = @getPanes()
if panes.length > 1
currentIndex = panes.indexOf(@getFocusedPane())
nextIndex = (currentIndex + 1) % panes.length
panes[nextIndex].focus()
true
else
false
focusPreviousPane: ->
panes = @getPanes()
if panes.length > 1
currentIndex = panes.indexOf(@getFocusedPane())
previousIndex = currentIndex - 1
previousIndex = panes.length - 1 if previousIndex < 0
panes[previousIndex].focus()
true
else
false
makeNextPaneActive: ->
panes = @getPanes()
currentIndex = panes.indexOf(@getActivePane())
nextIndex = (currentIndex + 1) % panes.length
panes[nextIndex].makeActive()
itemDestroyed: (item) ->
@trigger 'item-destroyed', item