From d84614866a35e4f463142e09fe8af53de7b3f0cd Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Thu, 7 Mar 2013 12:21:20 -0800 Subject: [PATCH] Add Pane.getNextPane --- spec/app/pane-spec.coffee | 8 ++++++++ src/app/pane.coffee | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index 3c62fc797..96f379acd 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -450,6 +450,14 @@ describe "Pane", -> pane.remove() expect(rootView.focus).not.toHaveBeenCalled() + describe ".getNextPane()", -> + it "returns the next pane if one exists, wrapping around from the last pane to the first", -> + pane.showItem(editSession1) + expect(pane.getNextPane()).toBeUndefined + pane2 = pane.splitRight() + expect(pane.getNextPane()).toBe pane2 + expect(pane2.getNextPane()).toBe pane + describe "when the pane is focused", -> it "focuses the active item view", -> focusHandler = jasmine.createSpy("focusHandler") diff --git a/src/app/pane.coffee b/src/app/pane.coffee index ef29ce72f..b0134f552 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -72,6 +72,12 @@ class Pane extends View isActive: -> @hasClass('active') + getNextPane: -> + panes = @getContainer()?.getPanes() + return unless panes.length > 1 + nextIndex = (panes.indexOf(this) + 1) % panes.length + panes[nextIndex] + getItems: -> new Array(@items...)