From c99e211144be9fc5c56e33b04c6f9669c015510e Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Tue, 7 Jan 2014 15:42:23 -0700 Subject: [PATCH] Store Pane items in PaneModel --- package.json | 3 ++- src/pane-model.coffee | 5 +++++ src/pane.coffee | 14 ++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 src/pane-model.coffee diff --git a/package.json b/package.json index f9cca4db8..d438072a5 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ "temp": "0.5.0", "text-buffer": "0.9.0", "underscore-plus": "0.6.1", - "theorist": "~0.7.0" + "theorist": "~0.7.0", + "delegato": "~0.4.0" }, "packageDependencies": { "atom-dark-syntax": "0.10.0", diff --git a/src/pane-model.coffee b/src/pane-model.coffee new file mode 100644 index 000000000..fd0c1e6ce --- /dev/null +++ b/src/pane-model.coffee @@ -0,0 +1,5 @@ +{Model} = require 'theorist' + +module.exports = +class PaneModel extends Model + constructor: ({@items}) -> diff --git a/src/pane.coffee b/src/pane.coffee index d976a95f0..234a50048 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -2,7 +2,9 @@ {$, View} = require './space-pen-extensions' _ = require 'underscore-plus' Serializable = require 'serializable' +Delegator = require 'delegato' +PaneModel = require './pane-model' PaneRow = require './pane-row' PaneColumn = require './pane-column' @@ -15,6 +17,7 @@ PaneColumn = require './pane-column' module.exports = class Pane extends View Serializable.includeInto(this) + Delegator.includeInto(this) @version: 1 @@ -22,18 +25,17 @@ class Pane extends View @div class: 'pane', tabindex: -1, => @div class: 'item-views', outlet: 'itemViews' + @delegatesProperty 'items', toProperty: 'model' + activeItem: null - items: null - viewsByItem: null # Views without a setModel() method are stored here # Private: initialize: (args...) -> if args[0]?.items # deserializing - {@items, activeItemUri, @focusOnAttach} = args[0] + {items, activeItemUri, @focusOnAttach} = args[0] + @model = new PaneModel({items}) else - @items = args - - @items ?= [] + @model = new PaneModel(items: args) @handleItemEvents(item) for item in @items