diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee new file mode 100644 index 000000000..8693d67fc --- /dev/null +++ b/spec/app/pane-spec.coffee @@ -0,0 +1,17 @@ +Editor = require 'editor' +Pane = require 'pane' +{$$} = require 'space-pen' + +describe "Pane", -> + [view1, view2, editSession1, editSession2, pane] = [] + + beforeEach -> + view1 = $$ -> @div id: 'view-1', 'View 1' + view2 = $$ -> @div id: 'view-1', 'View 1' + editSession1 = project.buildEditSession('sample.js') + editSession2 = project.buildEditSession('sample.txt') + pane = new Pane(view1, editSession1, view2, editSession2) + + describe ".initialize(items...)", -> + it "displays the first item in the pane", -> + expect(pane.itemViews.find(view1)).toExist() diff --git a/src/app/pane.coffee b/src/app/pane.coffee index df096af7b..7ed290cd7 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -6,11 +6,20 @@ module.exports = class Pane extends View @content: (wrappedView) -> @div class: 'pane', => - @subview 'wrappedView', wrappedView if wrappedView + @div class: 'item-views', outlet: 'itemViews' @deserialize: ({wrappedView}) -> new Pane(deserialize(wrappedView)) + initialize: (@items...) -> + @viewsByItem = new WeakMap + @showItem(@items[0]) + + showItem: (item) -> + @itemViews.children().hide() + @itemViews.append(item) unless @itemViews.children(item).length + item.show() + serialize: -> deserializer: "Pane" wrappedView: @wrappedView?.serialize()