##// END OF EJS Templates
Merge branch 'viewlists' of https://github.com/jasongrout/ipython into viewlists
Jason Grout -
r19057:a8bea3d8 merge
parent child Browse files
Show More
@@ -603,7 +603,7 b' define(["widgets/js/manager",'
603 603 // will be called in that context.
604 604
605 605 this.initialize.apply(this, arguments);
606 }
606 };
607 607
608 608 _.extend(ViewList.prototype, {
609 609 initialize: function(create_view, remove_view, context) {
@@ -663,7 +663,7 b' define(["widgets/js/manager",'
663 663 this.state_change = this.state_change.then(function() {
664 664 for (var i = 0, len=that.views.length; i <len; i++) {
665 665 that._remove_view.call(that._handler_context, that.views[i]);
666 };
666 }
667 667 that._models = [];
668 668 that.views = [];
669 669 });
@@ -9,18 +9,23 b' define(['
9 9 ], function(widget, utils, $){
10 10
11 11 var AccordionView = widget.DOMWidgetView.extend({
12 initialize: function(){
13 AccordionView.__super__.initialize.apply(this, arguments);
14
15 this.containers = [];
16 this.model_containers = {};
17 this.children_views = new widget.ViewList(this.add_child_model, this.remove_child_model, this);
18 this.listenTo(this.model, 'change:children', function(model, value) {
19 this.children_views.update(value);
20 }, this);
21 },
22
12 23 render: function(){
13 24 // Called when view is rendered.
14 25 var guid = 'panel-group' + utils.uuid();
15 26 this.$el
16 27 .attr('id', guid)
17 28 .addClass('panel-group');
18 this.containers = [];
19 this.model_containers = {};
20 this.update_children([], this.model.get('children'));
21 this.model.on('change:children', function(model, value, options) {
22 this.update_children(model.previous('children'), value);
23 }, this);
24 29 this.model.on('change:selected_index', function(model, value, options) {
25 30 this.update_selected_index(model.previous('selected_index'), value, options);
26 31 }, this);
@@ -31,6 +36,7 b' define(['
31 36 this.on('displayed', function() {
32 37 this.update_titles();
33 38 }, this);
39 this.children_views.update(this.model.get('children'));
34 40 },
35 41
36 42 update_titles: function(titles) {
@@ -61,14 +67,6 b' define(['
61 67 }
62 68 }
63 69 },
64
65 update_children: function(old_list, new_list) {
66 // Called when the children list is modified.
67 this.do_diff(old_list,
68 new_list,
69 $.proxy(this.remove_child_model, this),
70 $.proxy(this.add_child_model, this));
71 },
72 70
73 71 remove_child_model: function(model) {
74 72 // Called when a child is removed from children list.
@@ -128,14 +126,24 b' define(['
128 126 return view;
129 127 }, utils.reject("Couldn't add child view to box", true));
130 128 },
129
130 remove: function() {
131 AccordionView.__super__.remove.apply(this, arguments);
132 this.children_views.remove();
133 },
131 134 });
132 135
133 136
134 137 var TabView = widget.DOMWidgetView.extend({
135 138 initialize: function() {
136 139 // Public constructor.
137 this.containers = [];
138 140 TabView.__super__.initialize.apply(this, arguments);
141
142 this.containers = [];
143 this.children_views = new widget.ViewList(this.add_child_model, this.remove_child_model, this);
144 this.listenTo(this.model, 'change:children', function(model, value) {
145 this.children_views.update(value);
146 }, this);
139 147 },
140 148
141 149 render: function(){
@@ -149,11 +157,7 b' define(['
149 157 this.$tab_contents = $('<div />', {id: uuid + 'Content'})
150 158 .addClass('tab-content')
151 159 .appendTo(this.$el);
152 this.containers = [];
153 this.update_children([], this.model.get('children'));
154 this.model.on('change:children', function(model, value, options) {
155 this.update_children(model.previous('children'), value);
156 }, this);
160 this.children_views.update(this.model.get('children'));
157 161 },
158 162
159 163 update_attr: function(name, value) {
@@ -161,14 +165,6 b' define(['
161 165 this.$tabs.css(name, value);
162 166 },
163 167
164 update_children: function(old_list, new_list) {
165 // Called when the children list is modified.
166 this.do_diff(old_list,
167 new_list,
168 $.proxy(this.remove_child_model, this),
169 $.proxy(this.add_child_model, this));
170 },
171
172 168 remove_child_model: function(model) {
173 169 // Called when a child is removed from children list.
174 170 var view = this.pop_child_view(model);
@@ -254,6 +250,11 b' define(['
254 250 .removeClass('active');
255 251 this.containers[index].tab('show');
256 252 },
253
254 remove: function() {
255 TabView.__super__.remove.apply(this, arguments);
256 this.children_views.remove();
257 },
257 258 });
258 259
259 260 return {
General Comments 0
You need to be logged in to leave comments. Login now