Show More
@@ -72,6 +72,7 b'' | |||||
72 | // Instance level |
|
72 | // Instance level | |
73 | //-------------------------------------------------------------------- |
|
73 | //-------------------------------------------------------------------- | |
74 | WidgetManager.prototype.display_view = function(msg, model) { |
|
74 | WidgetManager.prototype.display_view = function(msg, model) { | |
|
75 | // Displays a view for a particular model. | |||
75 | var cell = this.get_msg_cell(msg.parent_header.msg_id); |
|
76 | var cell = this.get_msg_cell(msg.parent_header.msg_id); | |
76 | if (cell === null) { |
|
77 | if (cell === null) { | |
77 | console.log("Could not determine where the display" + |
|
78 | console.log("Could not determine where the display" + | |
@@ -88,9 +89,10 b'' | |||||
88 | cell.widget_subarea.append(view.$el); |
|
89 | cell.widget_subarea.append(view.$el); | |
89 | } |
|
90 | } | |
90 | } |
|
91 | } | |
91 |
} |
|
92 | }; | |
92 |
|
93 | |||
93 | WidgetManager.prototype.create_view = function(model, options, view) { |
|
94 | WidgetManager.prototype.create_view = function(model, options, view) { | |
|
95 | // Creates a view for a particular model. | |||
94 | var view_name = model.get('_view_name'); |
|
96 | var view_name = model.get('_view_name'); | |
95 | var ViewType = WidgetManager._view_types[view_name]; |
|
97 | var ViewType = WidgetManager._view_types[view_name]; | |
96 | if (ViewType !== undefined && ViewType !== null) { |
|
98 | if (ViewType !== undefined && ViewType !== null) { | |
@@ -102,16 +104,29 b'' | |||||
102 | options.cell = view.options.cell; |
|
104 | options.cell = view.options.cell; | |
103 | } |
|
105 | } | |
104 |
|
106 | |||
|
107 | // Create and render the view... | |||
105 | var parameters = {model: model, options: options}; |
|
108 | var parameters = {model: model, options: options}; | |
106 | var view = new ViewType(parameters); |
|
109 | var view = new ViewType(parameters); | |
107 | view.render(); |
|
110 | view.render(); | |
108 | IPython.keyboard_manager.register_events(view.$el); |
|
|||
109 | model.views.push(view); |
|
111 | model.views.push(view); | |
110 | model.on('destroy', view.remove, view); |
|
112 | model.on('destroy', view.remove, view); | |
|
113 | ||||
|
114 | this._handle_new_view(view); | |||
111 | return view; |
|
115 | return view; | |
112 | } |
|
116 | } | |
113 | return null; |
|
117 | return null; | |
114 |
} |
|
118 | }; | |
|
119 | ||||
|
120 | WidgetManager.prototype._handle_new_view = function (view) { | |||
|
121 | // Called when a view has been created and rendered. | |||
|
122 | ||||
|
123 | // If the view has a well defined element, inform the keyboard | |||
|
124 | // manager about the view's element, so as the element can | |||
|
125 | // escape the dreaded command mode. | |||
|
126 | if (view.$el !== undefined && view.$el !== null) { | |||
|
127 | IPython.keyboard_manager.register_events(view.$el); | |||
|
128 | } | |||
|
129 | } | |||
115 |
|
130 | |||
116 | WidgetManager.prototype.get_msg_cell = function (msg_id) { |
|
131 | WidgetManager.prototype.get_msg_cell = function (msg_id) { | |
117 | var cell = null; |
|
132 | var cell = null; |
General Comments 0
You need to be logged in to leave comments.
Login now