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 | 56 | return IPython.WidgetView.prototype.update.call(this); |
|
44 | 57 | }, |
|
45 | 58 | |
@@ -53,11 +66,16 define(["notebook/js/widget"], function(){ | |||
|
53 | 66 | var accordion_heading = $('<div />') |
|
54 | 67 | .addClass('accordion-heading') |
|
55 | 68 | .appendTo(accordion_group); |
|
69 | var that = this; | |
|
56 | 70 | var accordion_toggle = $('<a />') |
|
57 | 71 | .addClass('accordion-toggle') |
|
58 | 72 | .attr('data-toggle', 'collapse') |
|
59 | 73 | .attr('data-parent', '#' + this.$el.attr('id')) |
|
60 | 74 | .attr('href', '#' + uuid) |
|
75 | .click(function(evt){ | |
|
76 | that.model.set("selected_index", index); | |
|
77 | that.model.update_other_views(that); | |
|
78 | }) | |
|
61 | 79 | .html('Page ' + index) |
|
62 | 80 | .appendTo(accordion_heading); |
|
63 | 81 | var accordion_body = $('<div />', {id: uuid}) |
@@ -67,9 +85,15 define(["notebook/js/widget"], function(){ | |||
|
67 | 85 | .addClass('accordion-inner') |
|
68 | 86 | .appendTo(accordion_body); |
|
69 | 87 | this.containers.push(accordion_group); |
|
70 | ||
|
71 | 88 | accordion_inner.append(view.$el); |
|
89 | ||
|
72 | 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 | 116 | this.containers = []; |
|
93 | 117 | }, |
|
94 | ||
|
118 | ||
|
95 | 119 | update: function() { |
|
96 | 120 | // Set tab titles |
|
97 | 121 | var titles = this.model.get('_titles'); |
@@ -151,5 +175,4 define(["notebook/js/widget"], function(){ | |||
|
151 | 175 | }); |
|
152 | 176 | |
|
153 | 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