##// END OF EJS Templates
Merge pull request #5896 from ellisonbg/widget-fixes...
Min RK -
r16833:3c6f9298 merge
parent child Browse files
Show More
@@ -120,7 +120,6 b''
120 var parameters = {model: model, options: options};
120 var parameters = {model: model, options: options};
121 view = new ViewType(parameters);
121 view = new ViewType(parameters);
122 view.render();
122 view.render();
123 model.views.push(view);
124 model.on('destroy', view.remove, view);
123 model.on('destroy', view.remove, view);
125 return view;
124 return view;
126 }
125 }
@@ -198,9 +197,13 b''
198
197
199 WidgetManager.prototype._handle_comm_open = function (comm, msg) {
198 WidgetManager.prototype._handle_comm_open = function (comm, msg) {
200 // Handle when a comm is opened.
199 // Handle when a comm is opened.
200 var that = this;
201 var model_id = comm.comm_id;
201 var model_id = comm.comm_id;
202 var widget_type_name = msg.content.target_name;
202 var widget_type_name = msg.content.target_name;
203 var widget_model = new WidgetManager._model_types[widget_type_name](this, model_id, comm);
203 var widget_model = new WidgetManager._model_types[widget_type_name](this, model_id, comm);
204 widget_model.on('comm:close', function () {
205 delete that._models[model_id];
206 });
204 this._models[model_id] = widget_model;
207 this._models[model_id] = widget_model;
205 };
208 };
206
209
@@ -313,6 +313,7 b' function(WidgetManager, _, Backbone){'
313 if (view !== undefined) {
313 if (view !== undefined) {
314 delete this.child_views[child_model.id];
314 delete this.child_views[child_model.id];
315 view.remove();
315 view.remove();
316 child_model.views.pop(view);
316 }
317 }
317 },
318 },
318
319
@@ -27,6 +27,18 b' define(["widgets/js/widget"], function(WidgetManager) {'
27 this.update_children(model.previous('_children'), value);
27 this.update_children(model.previous('_children'), value);
28 }, this);
28 }, this);
29 this.update();
29 this.update();
30
31 // Trigger model displayed events for any models that are child to
32 // this model when this model is displayed.
33 var that = this;
34 this.model.on('displayed', function(){
35 that.is_displayed = true;
36 for (var property in that.child_views) {
37 if (that.child_views.hasOwnProperty(property)) {
38 that.child_views[property].model.trigger('displayed');
39 }
40 }
41 });
30 },
42 },
31
43
32 update_children: function(old_list, new_list) {
44 update_children: function(old_list, new_list) {
@@ -47,6 +59,11 b' define(["widgets/js/widget"], function(WidgetManager) {'
47 // Called when a model is added to the children list.
59 // Called when a model is added to the children list.
48 var view = this.create_child_view(model);
60 var view = this.create_child_view(model);
49 this.$el.append(view.$el);
61 this.$el.append(view.$el);
62
63 // Trigger the displayed event if this model is displayed.
64 if (this.is_displayed) {
65 model.trigger('displayed');
66 }
50 },
67 },
51
68
52 update: function(){
69 update: function(){
@@ -81,7 +98,7 b' define(["widgets/js/widget"], function(WidgetManager) {'
81 // need to know about all of the top-level widgets. The IPython
98 // need to know about all of the top-level widgets. The IPython
82 // widget manager uses this to register the elements with the
99 // widget manager uses this to register the elements with the
83 // keyboard manager.
100 // keyboard manager.
84 this.additional_elements = [this.$window]
101 this.additional_elements = [this.$window];
85
102
86 this.$title_bar = $('<div />')
103 this.$title_bar = $('<div />')
87 .addClass('popover-title')
104 .addClass('popover-title')
@@ -169,6 +186,17 b' define(["widgets/js/widget"], function(WidgetManager) {'
169 this.update_children(model.previous('_children'), value);
186 this.update_children(model.previous('_children'), value);
170 }, this);
187 }, this);
171 this.update();
188 this.update();
189
190 // Trigger model displayed events for any models that are child to
191 // this model when this model is displayed.
192 this.model.on('displayed', function(){
193 that.is_displayed = true;
194 for (var property in that.child_views) {
195 if (that.child_views.hasOwnProperty(property)) {
196 that.child_views[property].model.trigger('displayed');
197 }
198 }
199 });
172 },
200 },
173
201
174 hide: function() {
202 hide: function() {
@@ -228,6 +256,11 b' define(["widgets/js/widget"], function(WidgetManager) {'
228 // Called when a child is added to children list.
256 // Called when a child is added to children list.
229 var view = this.create_child_view(model);
257 var view = this.create_child_view(model);
230 this.$body.append(view.$el);
258 this.$body.append(view.$el);
259
260 // Trigger the displayed event if this model is displayed.
261 if (this.is_displayed) {
262 model.trigger('displayed');
263 }
231 },
264 },
232
265
233 update: function(){
266 update: function(){
@@ -35,8 +35,17 b' define(["widgets/js/widget"], function(WidgetManager){'
35 this.model.on('change:_titles', function(model, value, options) {
35 this.model.on('change:_titles', function(model, value, options) {
36 this.update_titles(value);
36 this.update_titles(value);
37 }, this);
37 }, this);
38 var that = this;
38 this.model.on('displayed', function() {
39 this.model.on('displayed', function() {
39 this.update_titles();
40 this.update_titles();
41 // Trigger model displayed events for any models that are child to
42 // this model when this model is displayed.
43 that.is_displayed = true;
44 for (var property in that.child_views) {
45 if (that.child_views.hasOwnProperty(property)) {
46 that.child_views[property].model.trigger('displayed');
47 }
48 }
40 }, this);
49 }, this);
41 },
50 },
42
51
@@ -125,6 +134,11 b' define(["widgets/js/widget"], function(WidgetManager){'
125
134
126 this.update();
135 this.update();
127 this.update_titles();
136 this.update_titles();
137
138 // Trigger the displayed event if this model is displayed.
139 if (this.is_displayed) {
140 model.trigger('displayed');
141 }
128 },
142 },
129 });
143 });
130 WidgetManager.register_widget_view('AccordionView', AccordionView);
144 WidgetManager.register_widget_view('AccordionView', AccordionView);
@@ -153,6 +167,17 b' define(["widgets/js/widget"], function(WidgetManager){'
153 this.model.on('change:_children', function(model, value, options) {
167 this.model.on('change:_children', function(model, value, options) {
154 this.update_children(model.previous('_children'), value);
168 this.update_children(model.previous('_children'), value);
155 }, this);
169 }, this);
170
171 // Trigger model displayed events for any models that are child to
172 // this model when this model is displayed.
173 this.model.on('displayed', function(){
174 that.is_displayed = true;
175 for (var property in that.child_views) {
176 if (that.child_views.hasOwnProperty(property)) {
177 that.child_views[property].model.trigger('displayed');
178 }
179 }
180 });
156 },
181 },
157
182
158 update_children: function(old_list, new_list) {
183 update_children: function(old_list, new_list) {
@@ -206,6 +231,11 b' define(["widgets/js/widget"], function(WidgetManager){'
206 .append(view.$el)
231 .append(view.$el)
207 .appendTo(this.$tab_contents);
232 .appendTo(this.$tab_contents);
208 view.parent_container = contents_div;
233 view.parent_container = contents_div;
234
235 // Trigger the displayed event if this model is displayed.
236 if (this.is_displayed) {
237 model.trigger('displayed');
238 }
209 },
239 },
210
240
211 update: function(options) {
241 update: function(options) {
General Comments 0
You need to be logged in to leave comments. Login now