|
|
|
|
@ -8,21 +8,23 @@ define([
|
|
|
|
|
], function(widget, $){
|
|
|
|
|
|
|
|
|
|
var ContainerView = widget.DOMWidgetView.extend({
|
|
|
|
|
render: function(){
|
|
|
|
|
// Called when view is rendered.
|
|
|
|
|
this.$el.addClass('widget-container')
|
|
|
|
|
.addClass('vbox');
|
|
|
|
|
initialize: function(){
|
|
|
|
|
// Public constructor
|
|
|
|
|
ContainerView.__super__.initialize.apply(this, arguments);
|
|
|
|
|
this.update_children([], this.model.get('children'));
|
|
|
|
|
this.model.on('change:children', function(model, value, options) {
|
|
|
|
|
this.model.on('change:children', function(model, value) {
|
|
|
|
|
this.update_children(model.previous('children'), value);
|
|
|
|
|
}, this);
|
|
|
|
|
this.update();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
render: function(){
|
|
|
|
|
// Called when view is rendered.
|
|
|
|
|
this.$el.addClass('widget-container').addClass('vbox');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
update_children: function(old_list, new_list) {
|
|
|
|
|
// Called when the children list changes.
|
|
|
|
|
this.do_diff(old_list,
|
|
|
|
|
new_list,
|
|
|
|
|
this.do_diff(old_list, new_list,
|
|
|
|
|
$.proxy(this.remove_child_model, this),
|
|
|
|
|
$.proxy(this.add_child_model, this));
|
|
|
|
|
},
|
|
|
|
|
@ -37,19 +39,11 @@ define([
|
|
|
|
|
var view = this.create_child_view(model);
|
|
|
|
|
this.$el.append(view.$el);
|
|
|
|
|
|
|
|
|
|
// Trigger the displayed event once this view is displayed.
|
|
|
|
|
// Trigger the displayed event of the child view.
|
|
|
|
|
this.after_displayed(function() {
|
|
|
|
|
view.trigger('displayed');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
update: function(){
|
|
|
|
|
// Update the contents of this view
|
|
|
|
|
//
|
|
|
|
|
// Called when the model is changed. The model may have been
|
|
|
|
|
// changed by another view or by a state update from the back-end.
|
|
|
|
|
return ContainerView.__super__.update.apply(this);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -163,10 +157,9 @@ define([
|
|
|
|
|
this.popped_out = true;
|
|
|
|
|
|
|
|
|
|
this.update_children([], this.model.get('children'));
|
|
|
|
|
this.model.on('change:children', function(model, value, options) {
|
|
|
|
|
this.model.on('change:children', function(model, value) {
|
|
|
|
|
this.update_children(model.previous('children'), value);
|
|
|
|
|
}, this);
|
|
|
|
|
this.update();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
|
@ -213,8 +206,7 @@ define([
|
|
|
|
|
|
|
|
|
|
update_children: function(old_list, new_list) {
|
|
|
|
|
// Called when the children list is modified.
|
|
|
|
|
this.do_diff(old_list,
|
|
|
|
|
new_list,
|
|
|
|
|
this.do_diff(old_list, new_list,
|
|
|
|
|
$.proxy(this.remove_child_model, this),
|
|
|
|
|
$.proxy(this.add_child_model, this));
|
|
|
|
|
},
|
|
|
|
|
@ -229,7 +221,7 @@ define([
|
|
|
|
|
var view = this.create_child_view(model);
|
|
|
|
|
this.$body.append(view.$el);
|
|
|
|
|
|
|
|
|
|
// Trigger the displayed event once this view is displayed.
|
|
|
|
|
// Trigger the displayed event of the child view.
|
|
|
|
|
this.after_displayed(function() {
|
|
|
|
|
view.trigger('displayed');
|
|
|
|
|
});
|
|
|
|
|
|