Show More
@@ -0,0 +1,60 b'' | |||||
|
1 | require(["notebook/js/widget"], function(){ | |||
|
2 | var MulticontainerModel = IPython.WidgetModel.extend({}); | |||
|
3 | IPython.notebook.widget_manager.register_widget_model('MulticontainerWidgetModel', MulticontainerModel); | |||
|
4 | ||||
|
5 | var AccordionView = IPython.WidgetView.extend({ | |||
|
6 | ||||
|
7 | render: function(){ | |||
|
8 | this.$el = $('<div />', {id: IPython.utils.uuid()}) | |||
|
9 | .addClass('accordion'); | |||
|
10 | this.containers = []; | |||
|
11 | }, | |||
|
12 | ||||
|
13 | update: function() { | |||
|
14 | // TODO: Set tab titles | |||
|
15 | ||||
|
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 | return IPython.WidgetView.prototype.update.call(this); | |||
|
28 | }, | |||
|
29 | ||||
|
30 | display_child: function(view) { | |||
|
31 | ||||
|
32 | var index = this.containers.length; | |||
|
33 | var uuid = IPython.utils.uuid(); | |||
|
34 | var accordion_group = $('<div />') | |||
|
35 | .addClass('accordion-group') | |||
|
36 | .appendTo(this.$el); | |||
|
37 | var accordion_heading = $('<div />') | |||
|
38 | .addClass('accordion-heading') | |||
|
39 | .appendTo(accordion_group); | |||
|
40 | var accordion_toggle = $('<a />') | |||
|
41 | .addClass('accordion-toggle') | |||
|
42 | .attr('data-toggle', 'collapse') | |||
|
43 | .attr('data-parent', '#' + this.$el.attr('id')) | |||
|
44 | .attr('href', '#' + uuid) | |||
|
45 | .html('Page ' + index) | |||
|
46 | .appendTo(accordion_heading); | |||
|
47 | var accordion_body = $('<div />', {id: uuid}) | |||
|
48 | .addClass('accordion-body collapse in') | |||
|
49 | .appendTo(accordion_group); | |||
|
50 | var accordion_inner = $('<div />') | |||
|
51 | .addClass('accordion-inner') | |||
|
52 | .appendTo(accordion_body); | |||
|
53 | this.containers.push(accordion_group); | |||
|
54 | ||||
|
55 | accordion_inner.append(view.$el); | |||
|
56 | }, | |||
|
57 | }); | |||
|
58 | ||||
|
59 | IPython.notebook.widget_manager.register_widget_view('AccordionView', AccordionView); | |||
|
60 | }); No newline at end of file |
@@ -0,0 +1,25 b'' | |||||
|
1 | """MulticontainerWidget class. | |||
|
2 | ||||
|
3 | Represents a multipage container that can be used to group other widgets into | |||
|
4 | pages. | |||
|
5 | """ | |||
|
6 | #----------------------------------------------------------------------------- | |||
|
7 | # Copyright (c) 2013, the IPython Development Team. | |||
|
8 | # | |||
|
9 | # Distributed under the terms of the Modified BSD License. | |||
|
10 | # | |||
|
11 | # The full license is in the file COPYING.txt, distributed with this software. | |||
|
12 | #----------------------------------------------------------------------------- | |||
|
13 | ||||
|
14 | #----------------------------------------------------------------------------- | |||
|
15 | # Imports | |||
|
16 | #----------------------------------------------------------------------------- | |||
|
17 | from widget import Widget | |||
|
18 | from IPython.utils.traitlets import Unicode | |||
|
19 | ||||
|
20 | #----------------------------------------------------------------------------- | |||
|
21 | # Classes | |||
|
22 | #----------------------------------------------------------------------------- | |||
|
23 | class MulticontainerWidget(Widget): | |||
|
24 | target_name = Unicode('MulticontainerWidgetModel') | |||
|
25 | default_view_name = Unicode('AccordionView') |
@@ -7,5 +7,6 b' from widget_float import FloatWidget' | |||||
7 | from widget_float_range import FloatRangeWidget |
|
7 | from widget_float_range import FloatRangeWidget | |
8 | from widget_int import IntWidget |
|
8 | from widget_int import IntWidget | |
9 | from widget_int_range import IntRangeWidget |
|
9 | from widget_int_range import IntRangeWidget | |
|
10 | from widget_multicontainer import MulticontainerWidget | |||
10 | from widget_selection import SelectionWidget |
|
11 | from widget_selection import SelectionWidget | |
11 | from widget_string import StringWidget |
|
12 | from widget_string import StringWidget |
General Comments 0
You need to be logged in to leave comments.
Login now