Show More
@@ -72,6 +72,7 | |||
|
72 | 72 | // Instance level |
|
73 | 73 | //-------------------------------------------------------------------- |
|
74 | 74 | WidgetManager.prototype.display_view = function(msg, model) { |
|
75 | // Displays a view for a particular model. | |
|
75 | 76 | var cell = this.get_msg_cell(msg.parent_header.msg_id); |
|
76 | 77 | if (cell === null) { |
|
77 | 78 | console.log("Could not determine where the display" + |
@@ -88,9 +89,10 | |||
|
88 | 89 | cell.widget_subarea.append(view.$el); |
|
89 | 90 | } |
|
90 | 91 | } |
|
91 |
} |
|
|
92 | }; | |
|
92 | 93 | |
|
93 | 94 | WidgetManager.prototype.create_view = function(model, options, view) { |
|
95 | // Creates a view for a particular model. | |
|
94 | 96 | var view_name = model.get('_view_name'); |
|
95 | 97 | var ViewType = WidgetManager._view_types[view_name]; |
|
96 | 98 | if (ViewType !== undefined && ViewType !== null) { |
@@ -102,16 +104,29 | |||
|
102 | 104 | options.cell = view.options.cell; |
|
103 | 105 | } |
|
104 | 106 | |
|
107 | // Create and render the view... | |
|
105 | 108 | var parameters = {model: model, options: options}; |
|
106 | 109 | var view = new ViewType(parameters); |
|
107 | 110 | view.render(); |
|
108 | IPython.keyboard_manager.register_events(view.$el); | |
|
109 | 111 | model.views.push(view); |
|
110 | 112 | model.on('destroy', view.remove, view); |
|
113 | ||
|
114 | this._handle_new_view(view); | |
|
111 | 115 | return view; |
|
112 | 116 | } |
|
113 | 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 | 131 | WidgetManager.prototype.get_msg_cell = function (msg_id) { |
|
117 | 132 | var cell = null; |
General Comments 0
You need to be logged in to leave comments.
Login now