From db2f5f87fa64ff9986a5e2fd721874ba0b155664 2014-11-20 21:52:46 From: Jonathan Frederic Date: 2014-11-20 21:52:46 Subject: [PATCH] Implement view logic in selection containers. --- diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js index 6f6cb25..d00457e 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -359,8 +359,6 @@ define(["widgets/js/manager", // Callback that is called for each item added. // Walk the lists until an unequal entry is found. - console.error("Deprecated _do_diff; use a ViewList or similar class instead"); - var i; for (i = 0; i < new_list.length; i++) { if (i >= old_list.length || new_list[i] !== old_list[i]) { @@ -605,7 +603,7 @@ define(["widgets/js/manager", // will be called in that context. this.initialize.apply(this, arguments); - } + }; _.extend(ViewList.prototype, { initialize: function(create_view, remove_view, context) { @@ -661,7 +659,7 @@ define(["widgets/js/manager", this.state_change = this.state_change.then(function() { for (var i = 0, len=that.views.length; i ', {id: uuid + 'Content'}) .addClass('tab-content') .appendTo(this.$el); - this.containers = []; - this.update_children([], this.model.get('children')); - this.model.on('change:children', function(model, value, options) { - this.update_children(model.previous('children'), value); - }, this); + this.children_views.update(this.model.get('children')); }, update_attr: function(name, value) { @@ -161,14 +165,6 @@ define([ this.$tabs.css(name, value); }, - update_children: function(old_list, new_list) { - // Called when the children list is modified. - this.do_diff(old_list, - new_list, - $.proxy(this.remove_child_model, this), - $.proxy(this.add_child_model, this)); - }, - remove_child_model: function(model) { // Called when a child is removed from children list. var view = this.pop_child_view(model); @@ -254,6 +250,11 @@ define([ .removeClass('active'); this.containers[index].tab('show'); }, + + remove: function() { + TabView.__super__.remove.apply(this, arguments); + this.children_views.remove(); + }, }); return {