container.js
33 lines
| 1.2 KiB
| application/javascript
|
JavascriptLexer
Jonathan Frederic
|
r14285 | require(["notebook/js/widget"], function(){ | |
Jonathan Frederic
|
r14263 | var ContainerModel = IPython.WidgetModel.extend({}); | |
Jonathan Frederic
|
r14275 | IPython.notebook.widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel); | |
Jonathan Frederic
|
r14252 | ||
Jonathan Frederic
|
r14263 | var ContainerView = IPython.WidgetView.extend({ | |
render : function(){ | |||
Jonathan Frederic
|
r14268 | this.$el = $('<div />') | |
Jonathan Frederic
|
r14293 | .addClass('widget-container'); | |
Jonathan Frederic
|
r14263 | }, | |
Jonathan Frederic
|
r14268 | update : function(){ | |
Jonathan Frederic
|
r14269 | ||
// Apply flexible box model properties by adding and removing | |||
// corrosponding CSS classes. | |||
// Defined in IPython/html/static/base/less/flexbox.less | |||
var flex_properties = ['vbox', 'hbox', 'center', 'end', 'center']; | |||
for (var index in flex_properties) { | |||
if (this.model.get('_' + flex_properties[index])) { | |||
this.$el.addClass(flex_properties[index]); | |||
} else { | |||
this.$el.removeClass(flex_properties[index]); | |||
} | |||
Jonathan Frederic
|
r14268 | } | |
Jonathan Frederic
|
r14279 | return IPython.WidgetView.prototype.update.call(this); | |
Jonathan Frederic
|
r14268 | }, | |
Jonathan Frederic
|
r14278 | ||
Jonathan Frederic
|
r14280 | display_child : function(view) { | |
this.$el.append(view.$el); | |||
Jonathan Frederic
|
r14278 | }, | |
Jonathan Frederic
|
r14263 | }); | |
Jonathan Frederic
|
r14252 | ||
Jonathan Frederic
|
r14263 | IPython.notebook.widget_manager.register_widget_view('ContainerView', ContainerView); | |
}); |