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