Show More
@@ -20,8 +20,8 b'' | |||||
20 | // Use require.js 'define' method so that require.js is intelligent enough to |
|
20 | // Use require.js 'define' method so that require.js is intelligent enough to | |
21 | // syncronously load everything within this file when it is being 'required' |
|
21 | // syncronously load everything within this file when it is being 'required' | |
22 | // elsewhere. |
|
22 | // elsewhere. | |
23 |
define([" |
|
23 | define(["components/underscore/underscore-min", | |
24 |
" |
|
24 | "components/backbone/backbone-min", | |
25 | ], function(){ |
|
25 | ], function(){ | |
26 |
|
26 | |||
27 | // Only run once on a notebook. |
|
27 | // Only run once on a notebook. | |
@@ -188,6 +188,45 b' define(["../../components/underscore/underscore-min.js",' | |||||
188 |
|
188 | |||
189 | // Create view that represents the model. |
|
189 | // Create view that represents the model. | |
190 | display_view: function (view_name, parent_comm_id, cell_index) { |
|
190 | display_view: function (view_name, parent_comm_id, cell_index) { | |
|
191 | var new_views = []; | |||
|
192 | ||||
|
193 | var displayed = false; | |||
|
194 | if (parent_comm_id != undefined) { | |||
|
195 | var parent_comm = this.comm_manager.comms[parent_comm_id]; | |||
|
196 | var parent_model = parent_comm.model; | |||
|
197 | var parent_views = parent_model.views[cell_index]; | |||
|
198 | for (var parent_view_index in parent_views) { | |||
|
199 | var parent_view = parent_views[parent_view_index]; | |||
|
200 | if (parent_view.display_child != undefined) { | |||
|
201 | var view = this._create_view(view_name, cell_index); | |||
|
202 | new_views.push(view); | |||
|
203 | parent_view.display_child(view); | |||
|
204 | displayed = true; | |||
|
205 | } | |||
|
206 | } | |||
|
207 | } | |||
|
208 | ||||
|
209 | if (!displayed) { | |||
|
210 | // No parent view is defined or exists. Add the view's | |||
|
211 | // element to cell's widget div. | |||
|
212 | var view = this._create_view(view_name, cell_index); | |||
|
213 | new_views.push(view); | |||
|
214 | var cell = IPython.notebook.get_cell(cell_index); | |||
|
215 | cell.element.find('.widget_area').find('.widget_subarea') | |||
|
216 | .append(view.$el) | |||
|
217 | .parent().show(); // Show the widget_area (parent of widget_subarea) | |||
|
218 | ||||
|
219 | } | |||
|
220 | ||||
|
221 | for (var view_index in new_views) { | |||
|
222 | var view = new_views[view_index]; | |||
|
223 | view.update(); | |||
|
224 | } | |||
|
225 | }, | |||
|
226 | ||||
|
227 | ||||
|
228 | // Create a view | |||
|
229 | _create_view: function (view_name, cell_index) { | |||
191 | var view = new this.widget_view_types[view_name]({model: this}); |
|
230 | var view = new this.widget_view_types[view_name]({model: this}); | |
192 | view.render(); |
|
231 | view.render(); | |
193 | if (this.views[cell_index]==undefined) { |
|
232 | if (this.views[cell_index]==undefined) { | |
@@ -213,30 +252,7 b' define(["../../components/underscore/underscore-min.js",' | |||||
213 | that.comm.close(); |
|
252 | that.comm.close(); | |
214 | } |
|
253 | } | |
215 | }); |
|
254 | }); | |
216 |
|
255 | return view; | ||
217 | var displayed = false; |
|
|||
218 | if (parent_comm_id != undefined) { |
|
|||
219 | var parent_comm = this.comm_manager.comms[parent_comm_id]; |
|
|||
220 | var parent_model = parent_comm.model; |
|
|||
221 | var parent_view = parent_model.views[cell_index]; |
|
|||
222 | if (parent_view.display_child != undefined) { |
|
|||
223 | parent_view.display_child(view); |
|
|||
224 | displayed = true; |
|
|||
225 | } |
|
|||
226 | } |
|
|||
227 |
|
||||
228 | if (!displayed) { |
|
|||
229 | // No parent view is defined or exists. Add the view's |
|
|||
230 | // element to cell's widget div. |
|
|||
231 | var cell = IPython.notebook.get_cell(cell_index); |
|
|||
232 | cell.element.find('.widget_area').find('.widget_subarea') |
|
|||
233 | .append(view.$el) |
|
|||
234 | .parent().show(); // Show the widget_area (parent of widget_subarea) |
|
|||
235 |
|
||||
236 | } |
|
|||
237 |
|
||||
238 | // Update the view based on the model contents. |
|
|||
239 | view.update(); |
|
|||
240 | }, |
|
256 | }, | |
241 |
|
257 | |||
242 |
|
258 | |||
@@ -262,7 +278,7 b' define(["../../components/underscore/underscore-min.js",' | |||||
262 | // Get the cell index corresponding to the msg_id. |
|
278 | // Get the cell index corresponding to the msg_id. | |
263 | _get_cell_index: function (msg_id) { |
|
279 | _get_cell_index: function (msg_id) { | |
264 | var cells = IPython.notebook.get_cells(); |
|
280 | var cells = IPython.notebook.get_cells(); | |
265 | for (cell_index in cells) { |
|
281 | for (var cell_index in cells) { | |
266 | if (cells[cell_index].last_msg_id == msg_id) { |
|
282 | if (cells[cell_index].last_msg_id == msg_id) { | |
267 | return cell_index; |
|
283 | return cell_index; | |
268 | } |
|
284 | } |
@@ -1,5 +1,5 b'' | |||||
1 |
|
1 | |||
2 |
require([" |
|
2 | require(["notebook/js/widget"], function(){ | |
3 |
|
3 | |||
4 | var BoolWidgetModel = IPython.WidgetModel.extend({}); |
|
4 | var BoolWidgetModel = IPython.WidgetModel.extend({}); | |
5 | IPython.notebook.widget_manager.register_widget_model('BoolWidgetModel', BoolWidgetModel); |
|
5 | IPython.notebook.widget_manager.register_widget_model('BoolWidgetModel', BoolWidgetModel); |
@@ -1,5 +1,5 b'' | |||||
1 |
|
1 | |||
2 |
require([" |
|
2 | require(["notebook/js/widget"], function(){ | |
3 |
|
3 | |||
4 | var ButtonWidgetModel = IPython.WidgetModel.extend({}); |
|
4 | var ButtonWidgetModel = IPython.WidgetModel.extend({}); | |
5 | IPython.notebook.widget_manager.register_widget_model('ButtonWidgetModel', ButtonWidgetModel); |
|
5 | IPython.notebook.widget_manager.register_widget_model('ButtonWidgetModel', ButtonWidgetModel); |
@@ -1,4 +1,4 b'' | |||||
1 |
require([" |
|
1 | require(["notebook/js/widget"], function(){ | |
2 | var ContainerModel = IPython.WidgetModel.extend({}); |
|
2 | var ContainerModel = IPython.WidgetModel.extend({}); | |
3 | IPython.notebook.widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel); |
|
3 | IPython.notebook.widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel); | |
4 |
|
4 |
@@ -1,4 +1,4 b'' | |||||
1 |
require([" |
|
1 | require(["notebook/js/widget"], function(){ | |
2 | var FloatWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var FloatWidgetModel = IPython.WidgetModel.extend({}); | |
3 | IPython.notebook.widget_manager.register_widget_model('FloatWidgetModel', FloatWidgetModel); |
|
3 | IPython.notebook.widget_manager.register_widget_model('FloatWidgetModel', FloatWidgetModel); | |
4 | }); No newline at end of file |
|
4 | }); |
@@ -1,4 +1,4 b'' | |||||
1 |
require([" |
|
1 | require(["notebook/js/widget"], function(){ | |
2 | var FloatRangeWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var FloatRangeWidgetModel = IPython.WidgetModel.extend({}); | |
3 | IPython.notebook.widget_manager.register_widget_model('FloatRangeWidgetModel', FloatRangeWidgetModel); |
|
3 | IPython.notebook.widget_manager.register_widget_model('FloatRangeWidgetModel', FloatRangeWidgetModel); | |
4 |
|
4 |
@@ -1,4 +1,4 b'' | |||||
1 |
require([" |
|
1 | require(["notebook/js/widget"], function(){ | |
2 | var IntWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var IntWidgetModel = IPython.WidgetModel.extend({}); | |
3 | IPython.notebook.widget_manager.register_widget_model('IntWidgetModel', IntWidgetModel); |
|
3 | IPython.notebook.widget_manager.register_widget_model('IntWidgetModel', IntWidgetModel); | |
4 | }); No newline at end of file |
|
4 | }); |
@@ -1,4 +1,4 b'' | |||||
1 |
require([" |
|
1 | require(["notebook/js/widget"], function(){ | |
2 | var IntRangeWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var IntRangeWidgetModel = IPython.WidgetModel.extend({}); | |
3 | IPython.notebook.widget_manager.register_widget_model('IntRangeWidgetModel', IntRangeWidgetModel); |
|
3 | IPython.notebook.widget_manager.register_widget_model('IntRangeWidgetModel', IntRangeWidgetModel); | |
4 |
|
4 |
@@ -1,4 +1,4 b'' | |||||
1 |
require([" |
|
1 | require(["notebook/js/widget"], function(){ | |
2 | var SelectionWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var SelectionWidgetModel = IPython.WidgetModel.extend({}); | |
3 | IPython.notebook.widget_manager.register_widget_model('SelectionWidgetModel', SelectionWidgetModel); |
|
3 | IPython.notebook.widget_manager.register_widget_model('SelectionWidgetModel', SelectionWidgetModel); | |
4 |
|
4 |
@@ -1,4 +1,4 b'' | |||||
1 |
require([" |
|
1 | require(["notebook/js/widget"], function(){ | |
2 | var StringWidgetModel = IPython.WidgetModel.extend({}); |
|
2 | var StringWidgetModel = IPython.WidgetModel.extend({}); | |
3 | IPython.notebook.widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel); |
|
3 | IPython.notebook.widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel); | |
4 |
|
4 |
General Comments 0
You need to be logged in to leave comments.
Login now