Show More
@@ -30,9 +30,10 b'' | |||||
30 | //-------------------------------------------------------------------- |
|
30 | //-------------------------------------------------------------------- | |
31 | var WidgetManager = function () { |
|
31 | var WidgetManager = function () { | |
32 | this.comm_manager = null; |
|
32 | this.comm_manager = null; | |
33 |
this. |
|
33 | this._model_types = {}; /* Dictionary of model type names | |
34 | this.widget_view_types = {}; |
|
34 | (target_name) and model types. */ | |
35 | this._model_instances = {}; |
|
35 | this._view_types = {}; /* Dictionary of view names and view types. */ | |
|
36 | this._models = {}; /* Dictionary of model ids and model instances */ | |||
36 |
|
37 | |||
37 | Backbone.sync = function (method, model, options, error) { |
|
38 | Backbone.sync = function (method, model, options, error) { | |
38 | var result = model._handle_sync(method, options); |
|
39 | var result = model._handle_sync(method, options); | |
@@ -47,7 +48,7 b'' | |||||
47 | this.comm_manager = comm_manager; |
|
48 | this.comm_manager = comm_manager; | |
48 |
|
49 | |||
49 | // Register already-registered widget model types with the comm manager. |
|
50 | // Register already-registered widget model types with the comm manager. | |
50 |
for (var widget_model_name in this. |
|
51 | for (var widget_model_name in this._model_types) { | |
51 | this.comm_manager.register_target(widget_model_name, $.proxy(this._handle_comm_open, this)); |
|
52 | this.comm_manager.register_target(widget_model_name, $.proxy(this._handle_comm_open, this)); | |
52 | } |
|
53 | } | |
53 | }; |
|
54 | }; | |
@@ -59,12 +60,12 b'' | |||||
59 | if (this.comm_manager !== null) { |
|
60 | if (this.comm_manager !== null) { | |
60 | this.comm_manager.register_target(widget_model_name, $.proxy(this._handle_comm_open, this)); |
|
61 | this.comm_manager.register_target(widget_model_name, $.proxy(this._handle_comm_open, this)); | |
61 | } |
|
62 | } | |
62 |
this. |
|
63 | this._model_types[widget_model_name] = widget_model_type; | |
63 | }; |
|
64 | }; | |
64 |
|
65 | |||
65 |
|
66 | |||
66 | WidgetManager.prototype.register_widget_view = function (widget_view_name, widget_view_type) { |
|
67 | WidgetManager.prototype.register_widget_view = function (widget_view_name, widget_view_type) { | |
67 |
this. |
|
68 | this._view_types[widget_view_name] = widget_view_type; | |
68 | }; |
|
69 | }; | |
69 |
|
70 | |||
70 |
|
71 | |||
@@ -98,11 +99,15 b'' | |||||
98 | WidgetManager.prototype.create_view = function(model, view_name, options) { |
|
99 | WidgetManager.prototype.create_view = function(model, view_name, options) { | |
99 | >>>>>>> Completely remove cell from model and view. |
|
100 | >>>>>>> Completely remove cell from model and view. | |
100 | view_name = view_name || model.get('default_view_name'); |
|
101 | view_name = view_name || model.get('default_view_name'); | |
|
102 | <<<<<<< HEAD | |||
101 | ======= |
|
103 | ======= | |
102 | WidgetManager.prototype.create_view = function(model, view_name, cell, options) { |
|
104 | WidgetManager.prototype.create_view = function(model, view_name, cell, options) { | |
103 | view_name = view_name || model.get('default_view_name'); |
|
105 | view_name = view_name || model.get('default_view_name'); | |
104 | >>>>>>> Add widget view options in creating child views |
|
106 | >>>>>>> Add widget view options in creating child views | |
105 | var ViewType = this.widget_view_types[view_name]; |
|
107 | var ViewType = this.widget_view_types[view_name]; | |
|
108 | ======= | |||
|
109 | var ViewType = this._view_types[view_name]; | |||
|
110 | >>>>>>> _model_types, _view_types, _models - and document what keys and values are | |||
106 | if (ViewType !== undefined && ViewType !== null) { |
|
111 | if (ViewType !== undefined && ViewType !== null) { | |
107 | var view = new ViewType({model: model, widget_manager: this, options: options}); |
|
112 | var view = new ViewType({model: model, widget_manager: this, options: options}); | |
108 | view.render(); |
|
113 | view.render(); | |
@@ -226,7 +231,7 b'' | |||||
226 |
|
231 | |||
227 |
|
232 | |||
228 | WidgetManager.prototype.get_model = function (model_id) { |
|
233 | WidgetManager.prototype.get_model = function (model_id) { | |
229 |
var model = this._model |
|
234 | var model = this._models[model_id]; | |
230 | if (model !== undefined && model.id == model_id) { |
|
235 | if (model !== undefined && model.id == model_id) { | |
231 | return model; |
|
236 | return model; | |
232 | } |
|
237 | } | |
@@ -261,8 +266,8 b'' | |||||
261 |
|
266 | |||
262 | WidgetManager.prototype._handle_comm_open = function (comm, msg) { |
|
267 | WidgetManager.prototype._handle_comm_open = function (comm, msg) { | |
263 | var widget_type_name = msg.content.target_name; |
|
268 | var widget_type_name = msg.content.target_name; | |
264 |
var widget_model = new this. |
|
269 | var widget_model = new this._model_types[widget_type_name](this, comm.comm_id, comm); | |
265 |
this._model |
|
270 | this._models[comm.comm_id] = widget_model; // comm_id == model_id | |
266 | this._handle_create_widget(widget_model); |
|
271 | this._handle_create_widget(widget_model); | |
267 | }; |
|
272 | }; | |
268 |
|
273 |
General Comments 0
You need to be logged in to leave comments.
Login now