##// END OF EJS Templates
Dont err if view name isn't registered.
Jonathan Frederic -
Show More
@@ -212,9 +212,11 b' define(["components/underscore/underscore-min",'
212 var parent_view = parent_views[parent_view_index];
212 var parent_view = parent_views[parent_view_index];
213 if (parent_view.display_child != undefined) {
213 if (parent_view.display_child != undefined) {
214 var view = this._create_view(view_name, cell);
214 var view = this._create_view(view_name, cell);
215 new_views.push(view);
215 if (view != null) {
216 parent_view.display_child(view);
216 new_views.push(view);
217 displayed = true;
217 parent_view.display_child(view);
218 displayed = true;
219 }
218 }
220 }
219 }
221 }
220 }
222 }
@@ -223,11 +225,13 b' define(["components/underscore/underscore-min",'
223 // No parent view is defined or exists. Add the view's
225 // No parent view is defined or exists. Add the view's
224 // element to cell's widget div.
226 // element to cell's widget div.
225 var view = this._create_view(view_name, cell);
227 var view = this._create_view(view_name, cell);
226 new_views.push(view);
228 if (view != null) {
229 new_views.push(view);
227
230
228 if (cell.widget_subarea != undefined && cell.widget_subarea != null) {
231 if (cell.widget_subarea != undefined && cell.widget_subarea != null) {
229 cell.widget_area.show();
232 cell.widget_area.show();
230 cell.widget_subarea.append(view.$el);
233 cell.widget_subarea.append(view.$el);
234 }
231 }
235 }
232 }
236 }
233
237
@@ -240,32 +244,36 b' define(["components/underscore/underscore-min",'
240
244
241 // Create a view
245 // Create a view
242 _create_view: function (view_name, cell) {
246 _create_view: function (view_name, cell) {
243 var view = new this.widget_manager.widget_view_types[view_name]({model: this});
247 var view_type = this.widget_manager.widget_view_types[view_name];
244 view.render();
248 if (view_type != undefined && view_type != null) {
245 if (this.views[cell]==undefined) {
249 var view = new view_type({model: this});
246 this.views[cell] = []
250 view.render();
247 }
251 if (this.views[cell]==undefined) {
248 this.views[cell].push(view);
252 this.views[cell] = []
249 view.cell = cell;
250
251 // Handle when the view element is remove from the page.
252 var that = this;
253 view.$el.on("remove", function(){
254 var index = that.views[cell].indexOf(view);
255 if (index > -1) {
256 that.views[cell].splice(index, 1);
257 }
258 view.remove(); // Clean-up view
259 if (that.views[cell].length()==0) {
260 delete that.views[cell];
261 }
253 }
254 this.views[cell].push(view);
255 view.cell = cell;
262
256
263 // Close the comm if there are no views left.
257 // Handle when the view element is remove from the page.
264 if (that.views.length()==0) {
258 var that = this;
265 that.comm.close();
259 view.$el.on("remove", function(){
266 }
260 var index = that.views[cell].indexOf(view);
267 });
261 if (index > -1) {
268 return view;
262 that.views[cell].splice(index, 1);
263 }
264 view.remove(); // Clean-up view
265 if (that.views[cell].length()==0) {
266 delete that.views[cell];
267 }
268
269 // Close the comm if there are no views left.
270 if (that.views.length()==0) {
271 that.comm.close();
272 }
273 });
274 return view;
275 }
276 return null;
269 },
277 },
270
278
271
279
General Comments 0
You need to be logged in to leave comments. Login now