Show More
@@ -11,19 +11,15 b' require(["notebook/js/widget"], function(){' | |||
|
11 | 11 | }, |
|
12 | 12 | |
|
13 | 13 | update: function() { |
|
14 |
// |
|
|
14 | // Set tab titles | |
|
15 | var titles = this.model.get('_titles'); | |
|
16 | for (var page_index in titles) { | |
|
17 | var accordian_toggle = this.containers[page_index] | |
|
18 | .find('.accordion-heading') | |
|
19 | .find('.accordion-toggle'); | |
|
20 | accordian_toggle.html(titles[page_index]); | |
|
21 | } | |
|
15 | 22 | |
|
16 | // // Apply flexible box model properties by adding and removing | |
|
17 | // // corrosponding CSS classes. | |
|
18 | // // Defined in IPython/html/static/base/less/flexbox.less | |
|
19 | // var flex_properties = ['vbox', 'hbox', 'center', 'end', 'center']; | |
|
20 | // for (var index in flex_properties) { | |
|
21 | // if (this.model.get('_' + flex_properties[index])) { | |
|
22 | // this.$el.addClass(flex_properties[index]); | |
|
23 | // } else { | |
|
24 | // this.$el.removeClass(flex_properties[index]); | |
|
25 | // } | |
|
26 | // } | |
|
27 | 23 | return IPython.WidgetView.prototype.update.call(this); |
|
28 | 24 | }, |
|
29 | 25 | |
@@ -45,7 +41,7 b' require(["notebook/js/widget"], function(){' | |||
|
45 | 41 | .html('Page ' + index) |
|
46 | 42 | .appendTo(accordion_heading); |
|
47 | 43 | var accordion_body = $('<div />', {id: uuid}) |
|
48 |
.addClass('accordion-body collapse |
|
|
44 | .addClass('accordion-body collapse') | |
|
49 | 45 | .appendTo(accordion_group); |
|
50 | 46 | var accordion_inner = $('<div />') |
|
51 | 47 | .addClass('accordion-inner') |
@@ -15,7 +15,7 b' pages.' | |||
|
15 | 15 | # Imports |
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | from widget import Widget |
|
18 | from IPython.utils.traitlets import Unicode | |
|
18 | from IPython.utils.traitlets import Unicode, Dict | |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | # Classes |
@@ -23,3 +23,33 b' from IPython.utils.traitlets import Unicode' | |||
|
23 | 23 | class MulticontainerWidget(Widget): |
|
24 | 24 | target_name = Unicode('MulticontainerWidgetModel') |
|
25 | 25 | default_view_name = Unicode('AccordionView') |
|
26 | ||
|
27 | # Keys | |
|
28 | _keys = ['_titles'] | |
|
29 | _titles = Dict(help="Titles of the pages") | |
|
30 | ||
|
31 | # Public methods | |
|
32 | def set_title(self, index, title): | |
|
33 | """Sets the title of a container pages | |
|
34 | ||
|
35 | Parameters | |
|
36 | ---------- | |
|
37 | index : int | |
|
38 | Index of the container page | |
|
39 | title : unicode | |
|
40 | New title""" | |
|
41 | self._titles[index] = title | |
|
42 | self.send_state('_titles') | |
|
43 | ||
|
44 | ||
|
45 | def get_title(self, index): | |
|
46 | """Gets the title of a container pages | |
|
47 | ||
|
48 | Parameters | |
|
49 | ---------- | |
|
50 | index : int | |
|
51 | Index of the container page""" | |
|
52 | if index in self._titles: | |
|
53 | return self._titles[index] | |
|
54 | else: | |
|
55 | return None |
General Comments 0
You need to be logged in to leave comments.
Login now