##// 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 120 var parameters = {model: model, options: options};
121 121 view = new ViewType(parameters);
122 122 view.render();
123 model.views.push(view);
124 123 model.on('destroy', view.remove, view);
125 124 return view;
126 125 }
@@ -198,9 +197,13 b''
198 197
199 198 WidgetManager.prototype._handle_comm_open = function (comm, msg) {
200 199 // Handle when a comm is opened.
200 var that = this;
201 201 var model_id = comm.comm_id;
202 202 var widget_type_name = msg.content.target_name;
203 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 207 this._models[model_id] = widget_model;
205 208 };
206 209
@@ -313,6 +313,7 b' function(WidgetManager, _, Backbone){'
313 313 if (view !== undefined) {
314 314 delete this.child_views[child_model.id];
315 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 27 this.update_children(model.previous('_children'), value);
28 28 }, this);
29 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 44 update_children: function(old_list, new_list) {
@@ -47,6 +59,11 b' define(["widgets/js/widget"], function(WidgetManager) {'
47 59 // Called when a model is added to the children list.
48 60 var view = this.create_child_view(model);
49 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 69 update: function(){
@@ -81,7 +98,7 b' define(["widgets/js/widget"], function(WidgetManager) {'
81 98 // need to know about all of the top-level widgets. The IPython
82 99 // widget manager uses this to register the elements with the
83 100 // keyboard manager.
84 this.additional_elements = [this.$window]
101 this.additional_elements = [this.$window];
85 102
86 103 this.$title_bar = $('<div />')
87 104 .addClass('popover-title')
@@ -169,6 +186,17 b' define(["widgets/js/widget"], function(WidgetManager) {'
169 186 this.update_children(model.previous('_children'), value);
170 187 }, this);
171 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 202 hide: function() {
@@ -228,6 +256,11 b' define(["widgets/js/widget"], function(WidgetManager) {'
228 256 // Called when a child is added to children list.
229 257 var view = this.create_child_view(model);
230 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 266 update: function(){
@@ -35,8 +35,17 b' define(["widgets/js/widget"], function(WidgetManager){'
35 35 this.model.on('change:_titles', function(model, value, options) {
36 36 this.update_titles(value);
37 37 }, this);
38 var that = this;
38 39 this.model.on('displayed', function() {
39 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 49 }, this);
41 50 },
42 51
@@ -125,6 +134,11 b' define(["widgets/js/widget"], function(WidgetManager){'
125 134
126 135 this.update();
127 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 144 WidgetManager.register_widget_view('AccordionView', AccordionView);
@@ -153,6 +167,17 b' define(["widgets/js/widget"], function(WidgetManager){'
153 167 this.model.on('change:_children', function(model, value, options) {
154 168 this.update_children(model.previous('_children'), value);
155 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 183 update_children: function(old_list, new_list) {
@@ -206,6 +231,11 b' define(["widgets/js/widget"], function(WidgetManager){'
206 231 .append(view.$el)
207 232 .appendTo(this.$tab_contents);
208 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 241 update: function(options) {
General Comments 0
You need to be logged in to leave comments. Login now