Show More
@@ -40,6 +40,19 define(["notebook/js/widget"], function(){ | |||||
40 | } |
|
40 | } | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
|
43 | // Set selected page | |||
|
44 | var selected_index = this.model.get("selected_index"); | |||
|
45 | if (0 <= selected_index && selected_index < this.containers.length) { | |||
|
46 | for (var index in this.containers) { | |||
|
47 | if (index==selected_index) { | |||
|
48 | this.containers[index].find('.accordion-body').collapse('show'); | |||
|
49 | } else { | |||
|
50 | this.containers[index].find('.accordion-body').collapse('hide'); | |||
|
51 | } | |||
|
52 | ||||
|
53 | } | |||
|
54 | } | |||
|
55 | ||||
43 | return IPython.WidgetView.prototype.update.call(this); |
|
56 | return IPython.WidgetView.prototype.update.call(this); | |
44 | }, |
|
57 | }, | |
45 |
|
58 | |||
@@ -53,11 +66,16 define(["notebook/js/widget"], function(){ | |||||
53 | var accordion_heading = $('<div />') |
|
66 | var accordion_heading = $('<div />') | |
54 | .addClass('accordion-heading') |
|
67 | .addClass('accordion-heading') | |
55 | .appendTo(accordion_group); |
|
68 | .appendTo(accordion_group); | |
|
69 | var that = this; | |||
56 | var accordion_toggle = $('<a />') |
|
70 | var accordion_toggle = $('<a />') | |
57 | .addClass('accordion-toggle') |
|
71 | .addClass('accordion-toggle') | |
58 | .attr('data-toggle', 'collapse') |
|
72 | .attr('data-toggle', 'collapse') | |
59 | .attr('data-parent', '#' + this.$el.attr('id')) |
|
73 | .attr('data-parent', '#' + this.$el.attr('id')) | |
60 | .attr('href', '#' + uuid) |
|
74 | .attr('href', '#' + uuid) | |
|
75 | .click(function(evt){ | |||
|
76 | that.model.set("selected_index", index); | |||
|
77 | that.model.update_other_views(that); | |||
|
78 | }) | |||
61 | .html('Page ' + index) |
|
79 | .html('Page ' + index) | |
62 | .appendTo(accordion_heading); |
|
80 | .appendTo(accordion_heading); | |
63 | var accordion_body = $('<div />', {id: uuid}) |
|
81 | var accordion_body = $('<div />', {id: uuid}) | |
@@ -67,9 +85,15 define(["notebook/js/widget"], function(){ | |||||
67 | .addClass('accordion-inner') |
|
85 | .addClass('accordion-inner') | |
68 | .appendTo(accordion_body); |
|
86 | .appendTo(accordion_body); | |
69 | this.containers.push(accordion_group); |
|
87 | this.containers.push(accordion_group); | |
70 |
|
||||
71 | accordion_inner.append(view.$el); |
|
88 | accordion_inner.append(view.$el); | |
|
89 | ||||
72 | this.update(); |
|
90 | this.update(); | |
|
91 | ||||
|
92 | // Stupid workaround to close the bootstrap accordion tabs which | |||
|
93 | // open by default even though they don't have the `in` class | |||
|
94 | // attached to them. For some reason a delay is required. | |||
|
95 | // TODO: Better fix. | |||
|
96 | setTimeout(function(){that.update()}, 500); | |||
73 | }, |
|
97 | }, | |
74 | }); |
|
98 | }); | |
75 |
|
99 | |||
@@ -91,7 +115,7 define(["notebook/js/widget"], function(){ | |||||
91 |
|
115 | |||
92 | this.containers = []; |
|
116 | this.containers = []; | |
93 | }, |
|
117 | }, | |
94 |
|
118 | |||
95 | update: function() { |
|
119 | update: function() { | |
96 | // Set tab titles |
|
120 | // Set tab titles | |
97 | var titles = this.model.get('_titles'); |
|
121 | var titles = this.model.get('_titles'); | |
@@ -151,5 +175,4 define(["notebook/js/widget"], function(){ | |||||
151 | }); |
|
175 | }); | |
152 |
|
176 | |||
153 | IPython.widget_manager.register_widget_view('TabView', TabView); |
|
177 | IPython.widget_manager.register_widget_view('TabView', TabView); | |
154 |
|
||||
155 | }); |
|
178 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now