Show More
@@ -65,6 +65,16 b' define(["components/underscore/underscore-min",' | |||
|
65 | 65 | }, |
|
66 | 66 | |
|
67 | 67 | |
|
68 | on_view_displayed: function (callback) { | |
|
69 | this._view_displayed_callback = callback; | |
|
70 | } | |
|
71 | ||
|
72 | ||
|
73 | on_close: function (callback) { | |
|
74 | this._close_callback = callback; | |
|
75 | } | |
|
76 | ||
|
77 | ||
|
68 | 78 | // Handle when a widget is closed. |
|
69 | 79 | _handle_comm_closed: function (msg) { |
|
70 | 80 | for (var cell in this.views) { |
@@ -83,7 +93,7 b' define(["components/underscore/underscore-min",' | |||
|
83 | 93 | switch (method){ |
|
84 | 94 | case 'display': |
|
85 | 95 | |
|
86 |
// Try to get the cell |
|
|
96 | // Try to get the cell. | |
|
87 | 97 | var cell = this._get_msg_cell(msg.parent_header.msg_id); |
|
88 | 98 | if (cell == null) { |
|
89 | 99 | console.log("Could not determine where the display" + |
@@ -206,6 +216,17 b' define(["components/underscore/underscore-min",' | |||
|
206 | 216 | }, |
|
207 | 217 | |
|
208 | 218 | |
|
219 | _handle_view_displayed: function(view) { | |
|
220 | if (this._view_displayed_callback) { | |
|
221 | try { | |
|
222 | this._view_displayed_callback(view) | |
|
223 | } catch (e) { | |
|
224 | console.log("Exception in widget model view displayed callback", e, view, this); | |
|
225 | } | |
|
226 | } | |
|
227 | } | |
|
228 | ||
|
229 | ||
|
209 | 230 | // Create view that represents the model. |
|
210 | 231 | _display_view: function (view_name, parent_comm_id, cell) { |
|
211 | 232 | var new_views = []; |
@@ -224,6 +245,7 b' define(["components/underscore/underscore-min",' | |||
|
224 | 245 | new_views.push(view); |
|
225 | 246 | parent_view.display_child(view); |
|
226 | 247 | displayed = true; |
|
248 | this._handle_view_displayed(view); | |
|
227 | 249 | } |
|
228 | 250 | } |
|
229 | 251 | } |
@@ -239,6 +261,7 b' define(["components/underscore/underscore-min",' | |||
|
239 | 261 | if (cell.widget_subarea != undefined && cell.widget_subarea != null) { |
|
240 | 262 | cell.widget_area.show(); |
|
241 | 263 | cell.widget_subarea.append(view.$el); |
|
264 | this._handle_view_displayed(view); | |
|
242 | 265 | } |
|
243 | 266 | } |
|
244 | 267 | } |
@@ -277,6 +300,13 b' define(["components/underscore/underscore-min",' | |||
|
277 | 300 | |
|
278 | 301 | // Close the comm if there are no views left. |
|
279 | 302 | if (that.views.length()==0) { |
|
303 | if (that._close_callback) { | |
|
304 | try { | |
|
305 | that._close_callback(that) | |
|
306 | } catch (e) { | |
|
307 | console.log("Exception in widget model close callback", e, that); | |
|
308 | } | |
|
309 | } | |
|
280 | 310 | that.comm.close(); |
|
281 | 311 | } |
|
282 | 312 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now