##// END OF EJS Templates
Address @takluyver 's review comments
Jonathan Frederic -
Show More
@@ -661,7 +661,7 b' define(['
661 });
661 });
662 };
662 };
663
663
664 var resolve_dict = function(d) {
664 var resolve_promises_dict = function(d) {
665 // Resolve a promiseful dictionary.
665 // Resolve a promiseful dictionary.
666 // Returns a single Promise.
666 // Returns a single Promise.
667 var keys = Object.keys(d);
667 var keys = Object.keys(d);
@@ -749,7 +749,7 b' define(['
749 promising_ajax : promising_ajax,
749 promising_ajax : promising_ajax,
750 WrappedError: WrappedError,
750 WrappedError: WrappedError,
751 load_class: load_class,
751 load_class: load_class,
752 resolve_dict: resolve_dict,
752 resolve_promises_dict: resolve_promises_dict,
753 reject: reject,
753 reject: reject,
754 };
754 };
755
755
@@ -54,18 +54,12 b' define(['
54 if (cell === null) {
54 if (cell === null) {
55 reject(new Error("Could not determine where the display" +
55 reject(new Error("Could not determine where the display" +
56 " message was from. Widget will not be displayed"));
56 " message was from. Widget will not be displayed"));
57 } else {
57 } else if (cell.widget_subarea) {
58 var dummy = null;
58 var dummy = $('<div />');
59 if (cell.widget_subarea) {
59 cell.widget_subarea.append(dummy);
60 dummy = $('<div />');
61 cell.widget_subarea.append(dummy);
62 }
63
64 that.create_view(model, {cell: cell}).then(function(view) {
60 that.create_view(model, {cell: cell}).then(function(view) {
65 that._handle_display_view(view);
61 that._handle_display_view(view);
66 if (dummy) {
62 dummy.replaceWith(view.$el);
67 dummy.replaceWith(view.$el);
68 }
69 view.trigger('displayed');
63 view.trigger('displayed');
70 resolve(view);
64 resolve(view);
71 }, function(error) {
65 }, function(error) {
@@ -178,6 +172,7 b' define(['
178 };
172 };
179
173
180 WidgetManager.prototype.get_model = function (model_id) {
174 WidgetManager.prototype.get_model = function (model_id) {
175 // Get a promise for a model by model id.
181 return this._models[model_id];
176 return this._models[model_id];
182 };
177 };
183
178
@@ -80,7 +80,7 b' define(["widgets/js/manager",'
80 this.trigger('msg:custom', msg.content.data.content);
80 this.trigger('msg:custom', msg.content.data.content);
81 break;
81 break;
82 case 'display':
82 case 'display':
83 this.widget_manager.display_view(msg, that);
83 this.widget_manager.display_view(msg, this);
84 break;
84 break;
85 }
85 }
86 },
86 },
@@ -262,7 +262,7 b' define(["widgets/js/manager",'
262 _.each(value, function(sub_value, key) {
262 _.each(value, function(sub_value, key) {
263 unpacked[key] = that._unpack_models(sub_value);
263 unpacked[key] = that._unpack_models(sub_value);
264 });
264 });
265 return utils.resolve_dict(unpacked);
265 return utils.resolve_promises_dict(unpacked);
266 } else if (typeof value === 'string' && value.slice(0,10) === "IPY_MODEL_") {
266 } else if (typeof value === 'string' && value.slice(0,10) === "IPY_MODEL_") {
267 // get_model returns a promise already
267 // get_model returns a promise already
268 return this.widget_manager.get_model(value.slice(10, value.length));
268 return this.widget_manager.get_model(value.slice(10, value.length));
General Comments 0
You need to be logged in to leave comments. Login now