mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
widget simplification continued
This commit is contained in:
parent
8e8e6291d4
commit
972fbb5f34
@ -405,7 +405,7 @@ define(["widgets/js/manager",
|
|||||||
|
|
||||||
|
|
||||||
var DOMWidgetView = WidgetView.extend({
|
var DOMWidgetView = WidgetView.extend({
|
||||||
initialize: function (options) {
|
initialize: function () {
|
||||||
// Public constructor
|
// Public constructor
|
||||||
DOMWidgetView.__super__.initialize.apply(this, arguments);
|
DOMWidgetView.__super__.initialize.apply(this, arguments);
|
||||||
this.on('displayed', this.show, this);
|
this.on('displayed', this.show, this);
|
||||||
|
@ -8,20 +8,23 @@ define([
|
|||||||
], function(widget, $){
|
], function(widget, $){
|
||||||
|
|
||||||
var ContainerView = widget.DOMWidgetView.extend({
|
var ContainerView = widget.DOMWidgetView.extend({
|
||||||
render: function(){
|
initialize: function(){
|
||||||
// Called when view is rendered.
|
// Public constructor
|
||||||
this.$el.addClass('widget-container')
|
ContainerView.__super__.initialize.apply(this, arguments);
|
||||||
.addClass('vbox');
|
|
||||||
this.update_children([], this.model.get('children'));
|
this.update_children([], this.model.get('children'));
|
||||||
this.model.on('change:children', function(model, value) {
|
this.model.on('change:children', function(model, value) {
|
||||||
this.update_children(model.previous('children'), value);
|
this.update_children(model.previous('children'), value);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
render: function(){
|
||||||
|
// Called when view is rendered.
|
||||||
|
this.$el.addClass('widget-container').addClass('vbox');
|
||||||
|
},
|
||||||
|
|
||||||
update_children: function(old_list, new_list) {
|
update_children: function(old_list, new_list) {
|
||||||
// Called when the children list changes.
|
// Called when the children list changes.
|
||||||
this.do_diff(old_list,
|
this.do_diff(old_list, new_list,
|
||||||
new_list,
|
|
||||||
$.proxy(this.remove_child_model, this),
|
$.proxy(this.remove_child_model, this),
|
||||||
$.proxy(this.add_child_model, this));
|
$.proxy(this.add_child_model, this));
|
||||||
},
|
},
|
||||||
@ -203,8 +206,7 @@ define([
|
|||||||
|
|
||||||
update_children: function(old_list, new_list) {
|
update_children: function(old_list, new_list) {
|
||||||
// Called when the children list is modified.
|
// Called when the children list is modified.
|
||||||
this.do_diff(old_list,
|
this.do_diff(old_list, new_list,
|
||||||
new_list,
|
|
||||||
$.proxy(this.remove_child_model, this),
|
$.proxy(this.remove_child_model, this),
|
||||||
$.proxy(this.add_child_model, this));
|
$.proxy(this.add_child_model, this));
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user