Show More
@@ -5,7 +5,7 b' define([' | |||||
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'jquery', |
|
6 | 'jquery', | |
7 | 'codemirror/lib/codemirror', |
|
7 | 'codemirror/lib/codemirror', | |
8 | 'components/rsvp/rsvp.min', |
|
8 | 'rsvp', | |
9 | ], function(IPython, $, CodeMirror, rsvp){ |
|
9 | ], function(IPython, $, CodeMirror, rsvp){ | |
10 | "use strict"; |
|
10 | "use strict"; | |
11 |
|
11 |
@@ -5,7 +5,7 b' define([' | |||||
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'jquery', |
|
6 | 'jquery', | |
7 | 'base/js/utils', |
|
7 | 'base/js/utils', | |
8 | 'components/rsvp/rsvp.min', |
|
8 | 'rsvp', | |
9 | ], function(IPython, $, utils, rsvp) { |
|
9 | ], function(IPython, $, utils, rsvp) { | |
10 | "use strict"; |
|
10 | "use strict"; | |
11 |
|
11 | |||
@@ -78,8 +78,9 b' define([' | |||||
78 | } catch (e) { |
|
78 | } catch (e) { | |
79 | comm.close(); |
|
79 | comm.close(); | |
80 | that.unregister_comm(comm); |
|
80 | that.unregister_comm(comm); | |
81 | var error = new utils.WrappedError("Exception opening new comm", e); |
|
81 | var wrapped_error = new utils.WrappedError("Exception opening new comm", e); | |
82 | return rsvp.Promise.reject(error); |
|
82 | console.error(wrapped_error); | |
|
83 | return rsvp.Promise.reject(wrapped_error); | |||
83 | } |
|
84 | } | |
84 | return comm; |
|
85 | return comm; | |
85 | }, utils.reject('Could not open comm', true)); |
|
86 | }, utils.reject('Could not open comm', true)); |
@@ -7,7 +7,7 b' define([' | |||||
7 | "jquery", |
|
7 | "jquery", | |
8 | "base/js/utils", |
|
8 | "base/js/utils", | |
9 | "base/js/namespace", |
|
9 | "base/js/namespace", | |
10 | 'components/rsvp/rsvp.min', |
|
10 | 'rsvp', | |
11 | ], function (_, Backbone, $, utils, IPython, rsvp) { |
|
11 | ], function (_, Backbone, $, utils, IPython, rsvp) { | |
12 | "use strict"; |
|
12 | "use strict"; | |
13 | //-------------------------------------------------------------------- |
|
13 | //-------------------------------------------------------------------- | |
@@ -49,8 +49,9 b' define([' | |||||
49 | //-------------------------------------------------------------------- |
|
49 | //-------------------------------------------------------------------- | |
50 | WidgetManager.prototype.display_view = function(msg, model) { |
|
50 | WidgetManager.prototype.display_view = function(msg, model) { | |
51 | // Displays a view for a particular model. |
|
51 | // Displays a view for a particular model. | |
|
52 | var that = this; | |||
52 | return new rsvp.Promise(function(resolve, reject) { |
|
53 | return new rsvp.Promise(function(resolve, reject) { | |
53 |
var cell = th |
|
54 | var cell = that.get_msg_cell(msg.parent_header.msg_id); | |
54 | if (cell === null) { |
|
55 | if (cell === null) { | |
55 | reject(new Error("Could not determine where the display" + |
|
56 | reject(new Error("Could not determine where the display" + | |
56 | " message was from. Widget will not be displayed")); |
|
57 | " message was from. Widget will not be displayed")); | |
@@ -61,8 +62,7 b' define([' | |||||
61 | cell.widget_subarea.append(dummy); |
|
62 | cell.widget_subarea.append(dummy); | |
62 | } |
|
63 | } | |
63 |
|
64 | |||
64 | var that = this; |
|
65 | that.create_view(model, {cell: cell}).then(function(view) { | |
65 | this.create_view(model, {cell: cell}).then(function(view) { |
|
|||
66 | that._handle_display_view(view); |
|
66 | that._handle_display_view(view); | |
67 | if (dummy) { |
|
67 | if (dummy) { | |
68 | dummy.replaceWith(view.$el); |
|
68 | dummy.replaceWith(view.$el); | |
@@ -74,8 +74,6 b' define([' | |||||
74 | }); |
|
74 | }); | |
75 | } |
|
75 | } | |
76 | }); |
|
76 | }); | |
77 |
|
||||
78 |
|
||||
79 | }; |
|
77 | }; | |
80 |
|
78 | |||
81 | WidgetManager.prototype._handle_display_view = function (view) { |
|
79 | WidgetManager.prototype._handle_display_view = function (view) { | |
@@ -174,7 +172,7 b' define([' | |||||
174 | }; |
|
172 | }; | |
175 |
|
173 | |||
176 | WidgetManager.prototype.get_model = function (model_id) { |
|
174 | WidgetManager.prototype.get_model = function (model_id) { | |
177 |
return th |
|
175 | return this._models[model_id]; | |
178 | }; |
|
176 | }; | |
179 |
|
177 | |||
180 | WidgetManager.prototype._handle_comm_open = function (comm, msg) { |
|
178 | WidgetManager.prototype._handle_comm_open = function (comm, msg) { | |
@@ -182,7 +180,7 b' define([' | |||||
182 | this.create_model({ |
|
180 | this.create_model({ | |
183 | model_name: msg.content.data.model_name, |
|
181 | model_name: msg.content.data.model_name, | |
184 | model_module: msg.content.data.model_module, |
|
182 | model_module: msg.content.data.model_module, | |
185 |
comm: comm}).h |
|
183 | comm: comm}).catch($.proxy(console.error, console)); | |
186 | }; |
|
184 | }; | |
187 |
|
185 | |||
188 | WidgetManager.prototype.create_model = function (options) { |
|
186 | WidgetManager.prototype.create_model = function (options) { |
@@ -7,7 +7,7 b' define(["widgets/js/manager",' | |||||
7 | "jquery", |
|
7 | "jquery", | |
8 | "base/js/utils", |
|
8 | "base/js/utils", | |
9 | "base/js/namespace", |
|
9 | "base/js/namespace", | |
10 |
" |
|
10 | "rsvp", | |
11 | ], function(widgetmanager, _, Backbone, $, utils, IPython, rsvp){ |
|
11 | ], function(widgetmanager, _, Backbone, $, utils, IPython, rsvp){ | |
12 |
|
12 | |||
13 | var WidgetModel = Backbone.Model.extend({ |
|
13 | var WidgetModel = Backbone.Model.extend({ | |
@@ -75,15 +75,21 b' define(["widgets/js/manager",' | |||||
75 | case 'update': |
|
75 | case 'update': | |
76 | this.state_change = this.state_change.then(function() { |
|
76 | this.state_change = this.state_change.then(function() { | |
77 | return that.set_state(msg.content.data.state); |
|
77 | return that.set_state(msg.content.data.state); | |
78 |
}) |
|
78 | }).catch(utils.reject({ | |
|
79 | message: "Couldn't process update msg", | |||
|
80 | model_id: that.id | |||
|
81 | }, true)); | |||
79 | break; |
|
82 | break; | |
80 | case 'custom': |
|
83 | case 'custom': | |
81 | this.trigger('msg:custom', msg.content.data.content); |
|
84 | this.trigger('msg:custom', msg.content.data.content); | |
82 | break; |
|
85 | break; | |
83 | case 'display': |
|
86 | case 'display': | |
84 | this.state_change = this.state_change.then(function () { |
|
87 | this.state_change = this.state_change.then(function () { | |
85 | that.widget_manager.display_view(msg, that); |
|
88 | return that.widget_manager.display_view(msg, that); | |
86 |
}) |
|
89 | }).catch(utils.reject({ | |
|
90 | message: "Couldn't process display msg", | |||
|
91 | model_id: that.id | |||
|
92 | }, true)); | |||
87 | break; |
|
93 | break; | |
88 | } |
|
94 | } | |
89 | }, |
|
95 | }, |
@@ -31,6 +31,7 b'' | |||||
31 | codemirror: 'components/codemirror', |
|
31 | codemirror: 'components/codemirror', | |
32 | termjs: "components/term.js/src/term", |
|
32 | termjs: "components/term.js/src/term", | |
33 | contents: '{{ contents_js_source }}', |
|
33 | contents: '{{ contents_js_source }}', | |
|
34 | rsvp: "components/rsvp/rsvp", | |||
34 | }, |
|
35 | }, | |
35 | shim: { |
|
36 | shim: { | |
36 | underscore: { |
|
37 | underscore: { |
General Comments 0
You need to be logged in to leave comments.
Login now