From 6d7f1c7014af9711eca335743855cf48017ac2a9 2014-01-16 10:57:15 From: Jonathan Frederic Date: 2014-01-16 10:57:15 Subject: [PATCH] handle_msg a display_model method. --- diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index 88ea253..3612ae1 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -71,28 +71,24 @@ }; - WidgetManager.prototype.handle_msg = function(msg, model) { - var method = msg.content.data.method; - switch (method) { - case 'display': - var cell = this.get_msg_cell(msg.parent_header.msg_id); - if (cell === null) { - console.log("Could not determine where the display" + - " message was from. Widget will not be displayed"); - } else { - var view = this.create_view(model); - if (view !== undefined - && cell.widget_subarea !== undefined - && cell.widget_subarea !== null) { - - view.cell = cell; - cell.widget_area.show(); - cell.widget_subarea.append(view.$el); - } - } - break; + WidgetManager.prototype.display_view = function(msg_id, model) { + var cell = this.get_msg_cell(msg_id); + if (cell === null) { + console.log("Could not determine where the display" + + " message was from. Widget will not be displayed"); + } else { + var view = this.create_view(model); + if (view !== undefined + && cell.widget_subarea !== undefined + && cell.widget_subarea !== null) { + + view.cell = cell; + cell.widget_area.show(); + cell.widget_subarea.append(view.$el); + } } - } + }, + <<<<<<< HEAD <<<<<<< HEAD @@ -174,6 +170,7 @@ } }, + WidgetManager.prototype.get_msg_cell = function (msg_id) { var cell = null; // First, check to see if the msg was triggered by cell execution. diff --git a/IPython/html/static/notebook/js/widgets/widget.js b/IPython/html/static/notebook/js/widgets/widget.js index ae2bcae..f5a746b 100644 --- a/IPython/html/static/notebook/js/widgets/widget.js +++ b/IPython/html/static/notebook/js/widgets/widget.js @@ -70,9 +70,9 @@ function(widget_manager, underscore, backbone){ case 'custom': this.trigger('msg:custom', msg.content.data.custom_content); break; - default: - // pass on to widget manager - this.widget_manager.handle_msg(msg, this); + case 'display': + this.widget_manager.display_view(msg.parent_header.msg_id, this); + break; } },