Show More
@@ -1,221 +1,269 | |||||
1 |
|
1 | |||
2 | /* Flexible box model classes */ |
|
2 | /* Flexible box model classes */ | |
3 | /* Taken from Alex Russell http://infrequently.org/2009/08/css-3-progress/ */ |
|
3 | /* Taken from Alex Russell http://infrequently.org/2009/08/css-3-progress/ */ | |
4 |
|
4 | |||
5 | /* This file is a compatability layer. It allows the usage of flexible box |
|
5 | /* This file is a compatability layer. It allows the usage of flexible box | |
6 | model layouts accross multiple browsers, including older browsers. The newest, |
|
6 | model layouts accross multiple browsers, including older browsers. The newest, | |
7 | universal implementation of the flexible box model is used when available (see |
|
7 | universal implementation of the flexible box model is used when available (see | |
8 | `Modern browsers` comments below). Browsers that are known to implement this |
|
8 | `Modern browsers` comments below). Browsers that are known to implement this | |
9 | new spec completely include: |
|
9 | new spec completely include: | |
10 |
|
10 | |||
11 | Firefox 28.0+ |
|
11 | Firefox 28.0+ | |
12 | Chrome 29.0+ |
|
12 | Chrome 29.0+ | |
13 | Internet Explorer 11+ |
|
13 | Internet Explorer 11+ | |
14 | Opera 17.0+ |
|
14 | Opera 17.0+ | |
15 |
|
15 | |||
16 | Browsers not listed, including Safari, are supported via the styling under the |
|
16 | Browsers not listed, including Safari, are supported via the styling under the | |
17 | `Old browsers` comments below. |
|
17 | `Old browsers` comments below. | |
18 | */ |
|
18 | */ | |
19 |
|
19 | |||
20 |
|
20 | |||
21 | .hbox { |
|
21 | .hbox { | |
22 | /* Old browsers */ |
|
22 | /* Old browsers */ | |
23 | display: -webkit-box; |
|
23 | display: -webkit-box; | |
24 | -webkit-box-orient: horizontal; |
|
24 | -webkit-box-orient: horizontal; | |
25 | -webkit-box-align: stretch; |
|
25 | -webkit-box-align: stretch; | |
26 |
|
26 | |||
27 | display: -moz-box; |
|
27 | display: -moz-box; | |
28 | -moz-box-orient: horizontal; |
|
28 | -moz-box-orient: horizontal; | |
29 | -moz-box-align: stretch; |
|
29 | -moz-box-align: stretch; | |
30 |
|
30 | |||
31 | display: box; |
|
31 | display: box; | |
32 | box-orient: horizontal; |
|
32 | box-orient: horizontal; | |
33 | box-align: stretch; |
|
33 | box-align: stretch; | |
34 |
|
34 | |||
35 | /* Modern browsers */ |
|
35 | /* Modern browsers */ | |
36 | display: flex; |
|
36 | display: flex; | |
37 | flex-direction: row; |
|
37 | flex-direction: row; | |
38 | align-items: stretch; |
|
38 | align-items: stretch; | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | .hbox > * { |
|
41 | .hbox > * { | |
42 | /* Old browsers */ |
|
42 | /* Old browsers */ | |
43 | -webkit-box-flex: 0; |
|
43 | -webkit-box-flex: 0; | |
44 | -moz-box-flex: 0; |
|
44 | -moz-box-flex: 0; | |
45 | box-flex: 0; |
|
45 | box-flex: 0; | |
46 |
|
46 | |||
47 | /* Modern browsers */ |
|
47 | /* Modern browsers */ | |
48 | flex: none; |
|
48 | flex: none; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | .vbox { |
|
51 | .vbox { | |
52 | /* Old browsers */ |
|
52 | /* Old browsers */ | |
53 | display: -webkit-box; |
|
53 | display: -webkit-box; | |
54 | -webkit-box-orient: vertical; |
|
54 | -webkit-box-orient: vertical; | |
55 | -webkit-box-align: stretch; |
|
55 | -webkit-box-align: stretch; | |
56 |
|
56 | |||
57 | display: -moz-box; |
|
57 | display: -moz-box; | |
58 | -moz-box-orient: vertical; |
|
58 | -moz-box-orient: vertical; | |
59 | -moz-box-align: stretch; |
|
59 | -moz-box-align: stretch; | |
60 |
|
60 | |||
61 | display: box; |
|
61 | display: box; | |
62 | box-orient: vertical; |
|
62 | box-orient: vertical; | |
63 | box-align: stretch; |
|
63 | box-align: stretch; | |
64 |
|
64 | |||
65 | /* Modern browsers */ |
|
65 | /* Modern browsers */ | |
66 | display: flex; |
|
66 | display: flex; | |
67 | flex-direction: column; |
|
67 | flex-direction: column; | |
68 | align-items: stretch; |
|
68 | align-items: stretch; | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | .vbox > * { |
|
71 | .vbox > * { | |
72 | /* Old browsers */ |
|
72 | /* Old browsers */ | |
73 | -webkit-box-flex: 0; |
|
73 | -webkit-box-flex: 0; | |
74 | -moz-box-flex: 0; |
|
74 | -moz-box-flex: 0; | |
75 | box-flex: 0; |
|
75 | box-flex: 0; | |
76 |
|
76 | |||
77 | /* Modern browsers */ |
|
77 | /* Modern browsers */ | |
78 | flex: none; |
|
78 | flex: none; | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | .hbox.reverse, |
|
81 | .hbox.reverse, | |
82 | .vbox.reverse, |
|
82 | .vbox.reverse, | |
83 | .reverse { |
|
83 | .reverse { | |
84 | /* Old browsers */ |
|
84 | /* Old browsers */ | |
85 | -webkit-box-direction: reverse; |
|
85 | -webkit-box-direction: reverse; | |
86 | -moz-box-direction: reverse; |
|
86 | -moz-box-direction: reverse; | |
87 | box-direction: reverse; |
|
87 | box-direction: reverse; | |
88 |
|
88 | |||
89 | /* Modern browsers */ |
|
89 | /* Modern browsers */ | |
90 | flex-direction: row-reverse; |
|
90 | flex-direction: row-reverse; | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | .hbox.box-flex0, |
|
93 | .hbox.box-flex0, | |
94 | .vbox.box-flex0, |
|
94 | .vbox.box-flex0, | |
95 | .box-flex0 { |
|
95 | .box-flex0 { | |
96 | /* Old browsers */ |
|
96 | /* Old browsers */ | |
97 | -webkit-box-flex: 0; |
|
97 | -webkit-box-flex: 0; | |
98 | -moz-box-flex: 0; |
|
98 | -moz-box-flex: 0; | |
99 | box-flex: 0; |
|
99 | box-flex: 0; | |
100 |
|
100 | |||
101 | /* Modern browsers */ |
|
101 | /* Modern browsers */ | |
102 | flex: none; |
|
102 | flex: none; | |
103 | width: auto; |
|
103 | width: auto; | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | .hbox.box-flex1, |
|
106 | .hbox.box-flex1, | |
107 | .vbox.box-flex1, |
|
107 | .vbox.box-flex1, | |
108 | .box-flex1 { |
|
108 | .box-flex1 { | |
109 | /* Old browsers */ |
|
109 | /* Old browsers */ | |
110 | -webkit-box-flex: 1; |
|
110 | -webkit-box-flex: 1; | |
111 | -moz-box-flex: 1; |
|
111 | -moz-box-flex: 1; | |
112 | box-flex: 1; |
|
112 | box-flex: 1; | |
113 |
|
113 | |||
114 | /* Modern browsers */ |
|
114 | /* Modern browsers */ | |
115 | flex: 1; |
|
115 | flex: 1; | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | .hbox.box-flex, |
|
118 | .hbox.box-flex, | |
119 | .vbox.box-flex, |
|
119 | .vbox.box-flex, | |
120 | .box-flex { |
|
120 | .box-flex { | |
121 | /* Old browsers */ |
|
121 | /* Old browsers */ | |
122 | .box-flex1(); |
|
122 | .box-flex1(); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | .hbox.box-flex2, |
|
125 | .hbox.box-flex2, | |
126 | .vbox.box-flex2, |
|
126 | .vbox.box-flex2, | |
127 | .box-flex2 { |
|
127 | .box-flex2 { | |
128 | /* Old browsers */ |
|
128 | /* Old browsers */ | |
129 | -webkit-box-flex: 2; |
|
129 | -webkit-box-flex: 2; | |
130 | -moz-box-flex: 2; |
|
130 | -moz-box-flex: 2; | |
131 | box-flex: 2; |
|
131 | box-flex: 2; | |
132 |
|
132 | |||
133 | /* Modern browsers */ |
|
133 | /* Modern browsers */ | |
134 | flex: 2; |
|
134 | flex: 2; | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | .box-group1 { |
|
137 | .box-group1 { | |
138 | /* Deprecated */ |
|
138 | /* Deprecated */ | |
139 | -webkit-box-flex-group: 1; |
|
139 | -webkit-box-flex-group: 1; | |
140 | -moz-box-flex-group: 1; |
|
140 | -moz-box-flex-group: 1; | |
141 | box-flex-group: 1; |
|
141 | box-flex-group: 1; | |
142 | } |
|
142 | } | |
143 |
|
143 | |||
144 | .box-group2 { |
|
144 | .box-group2 { | |
145 | /* Deprecated */ |
|
145 | /* Deprecated */ | |
146 | -webkit-box-flex-group: 2; |
|
146 | -webkit-box-flex-group: 2; | |
147 | -moz-box-flex-group: 2; |
|
147 | -moz-box-flex-group: 2; | |
148 | box-flex-group: 2; |
|
148 | box-flex-group: 2; | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | .hbox.start, |
|
151 | .hbox.start, | |
152 | .vbox.start, |
|
152 | .vbox.start, | |
153 | .start { |
|
153 | .start { | |
154 | /* Old browsers */ |
|
154 | /* Old browsers */ | |
155 | -webkit-box-pack: start; |
|
155 | -webkit-box-pack: start; | |
156 | -moz-box-pack: start; |
|
156 | -moz-box-pack: start; | |
157 | box-pack: start; |
|
157 | box-pack: start; | |
158 |
|
158 | |||
159 | /* Modern browsers */ |
|
159 | /* Modern browsers */ | |
160 | justify-content: flex-start; |
|
160 | justify-content: flex-start; | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | .hbox.end, |
|
163 | .hbox.end, | |
164 | .vbox.end, |
|
164 | .vbox.end, | |
165 | .end { |
|
165 | .end { | |
166 | /* Old browsers */ |
|
166 | /* Old browsers */ | |
167 | -webkit-box-pack: end; |
|
167 | -webkit-box-pack: end; | |
168 | -moz-box-pack: end; |
|
168 | -moz-box-pack: end; | |
169 | box-pack: end; |
|
169 | box-pack: end; | |
170 |
|
170 | |||
171 | /* Modern browsers */ |
|
171 | /* Modern browsers */ | |
172 | justify-content: flex-end; |
|
172 | justify-content: flex-end; | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | .hbox.center, |
|
175 | .hbox.center, | |
176 | .vbox.center, |
|
176 | .vbox.center, | |
177 | .center { |
|
177 | .center { | |
178 | /* Old browsers */ |
|
178 | /* Old browsers */ | |
179 | -webkit-box-pack: center; |
|
179 | -webkit-box-pack: center; | |
180 | -moz-box-pack: center; |
|
180 | -moz-box-pack: center; | |
181 | box-pack: center; |
|
181 | box-pack: center; | |
182 |
|
182 | |||
183 | /* Modern browsers */ |
|
183 | /* Modern browsers */ | |
184 | justify-content: center; |
|
184 | justify-content: center; | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
|
187 | .hbox.baseline, | |||
|
188 | .vbox.baseline, | |||
|
189 | .baseline { | |||
|
190 | /* Old browsers */ | |||
|
191 | -webkit-box-pack: baseline; | |||
|
192 | -moz-box-pack: baseline; | |||
|
193 | box-pack: baseline; | |||
|
194 | ||||
|
195 | /* Modern browsers */ | |||
|
196 | justify-content: baseline; | |||
|
197 | } | |||
|
198 | ||||
|
199 | .hbox.stretch, | |||
|
200 | .vbox.stretch, | |||
|
201 | .stretch { | |||
|
202 | /* Old browsers */ | |||
|
203 | -webkit-box-pack: stretch; | |||
|
204 | -moz-box-pack: stretch; | |||
|
205 | box-pack: stretch; | |||
|
206 | ||||
|
207 | /* Modern browsers */ | |||
|
208 | justify-content: stretch; | |||
|
209 | } | |||
|
210 | ||||
187 | .hbox.align-start, |
|
211 | .hbox.align-start, | |
188 | .vbox.align-start, |
|
212 | .vbox.align-start, | |
189 | .align-start { |
|
213 | .align-start { | |
190 | /* Old browsers */ |
|
214 | /* Old browsers */ | |
191 | -webkit-box-align: start; |
|
215 | -webkit-box-align: start; | |
192 | -moz-box-align: start; |
|
216 | -moz-box-align: start; | |
193 | box-align: start; |
|
217 | box-align: start; | |
194 |
|
218 | |||
195 | /* Modern browsers */ |
|
219 | /* Modern browsers */ | |
196 | align-items: flex-start; |
|
220 | align-items: flex-start; | |
197 | } |
|
221 | } | |
198 |
|
222 | |||
199 | .hbox.align-end, |
|
223 | .hbox.align-end, | |
200 | .vbox.align-end, |
|
224 | .vbox.align-end, | |
201 | .align-end { |
|
225 | .align-end { | |
202 | /* Old browsers */ |
|
226 | /* Old browsers */ | |
203 | -webkit-box-align: end; |
|
227 | -webkit-box-align: end; | |
204 | -moz-box-align: end; |
|
228 | -moz-box-align: end; | |
205 | box-align: end; |
|
229 | box-align: end; | |
206 |
|
230 | |||
207 | /* Modern browsers */ |
|
231 | /* Modern browsers */ | |
208 | align-items: flex-end; |
|
232 | align-items: flex-end; | |
209 | } |
|
233 | } | |
210 |
|
234 | |||
211 | .hbox.align-center, |
|
235 | .hbox.align-center, | |
212 | .vbox.align-center, |
|
236 | .vbox.align-center, | |
213 | .align-center { |
|
237 | .align-center { | |
214 | /* Old browsers */ |
|
238 | /* Old browsers */ | |
215 | -webkit-box-align: center; |
|
239 | -webkit-box-align: center; | |
216 | -moz-box-align: center; |
|
240 | -moz-box-align: center; | |
217 | box-align: center; |
|
241 | box-align: center; | |
218 |
|
242 | |||
219 | /* Modern browsers */ |
|
243 | /* Modern browsers */ | |
220 | align-items: center; |
|
244 | align-items: center; | |
221 | } |
|
245 | } | |
|
246 | ||||
|
247 | .hbox.align-baseline, | |||
|
248 | .vbox.align-baseline, | |||
|
249 | .align-baseline { | |||
|
250 | /* Old browsers */ | |||
|
251 | -webkit-box-align: baseline; | |||
|
252 | -moz-box-align: baseline; | |||
|
253 | box-align: baseline; | |||
|
254 | ||||
|
255 | /* Modern browsers */ | |||
|
256 | align-items: baseline; | |||
|
257 | } | |||
|
258 | ||||
|
259 | .hbox.align-stretch, | |||
|
260 | .vbox.align-stretch, | |||
|
261 | .align-stretch { | |||
|
262 | /* Old browsers */ | |||
|
263 | -webkit-box-align: stretch; | |||
|
264 | -moz-box-align: stretch; | |||
|
265 | box-align: stretch; | |||
|
266 | ||||
|
267 | /* Modern browsers */ | |||
|
268 | align-items: stretch; | |||
|
269 | } |
@@ -1,12 +1,12 | |||||
1 | from .widget import Widget, DOMWidget, CallbackDispatcher |
|
1 | from .widget import Widget, DOMWidget, CallbackDispatcher | |
2 |
|
2 | |||
3 | from .widget_bool import CheckboxWidget, ToggleButtonWidget |
|
3 | from .widget_bool import CheckboxWidget, ToggleButtonWidget | |
4 | from .widget_button import ButtonWidget |
|
4 | from .widget_button import ButtonWidget | |
5 |
from .widget_container import ContainerWidget, PopupWidget, FlexContainerWidget, HBox |
|
5 | from .widget_container import ContainerWidget, PopupWidget, FlexContainerWidget, HBoxWidget, VBoxWidget | |
6 | from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget |
|
6 | from .widget_float import FloatTextWidget, BoundedFloatTextWidget, FloatSliderWidget, FloatProgressWidget | |
7 | from .widget_image import ImageWidget |
|
7 | from .widget_image import ImageWidget | |
8 | from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget |
|
8 | from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, IntProgressWidget | |
9 | from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget |
|
9 | from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget | |
10 | from .widget_selectioncontainer import TabWidget, AccordionWidget |
|
10 | from .widget_selectioncontainer import TabWidget, AccordionWidget | |
11 | from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget |
|
11 | from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget | |
12 | from .interaction import interact, interactive, fixed |
|
12 | from .interaction import interact, interactive, fixed |
@@ -1,55 +1,59 | |||||
1 | """ContainerWidget class. |
|
1 | """ContainerWidget class. | |
2 |
|
2 | |||
3 | Represents a container that can be used to group other widgets. |
|
3 | Represents a container that can be used to group other widgets. | |
4 | """ |
|
4 | """ | |
5 |
|
5 | |||
6 | # Copyright (c) IPython Development Team. |
|
6 | # Copyright (c) IPython Development Team. | |
7 | # Distributed under the terms of the Modified BSD License. |
|
7 | # Distributed under the terms of the Modified BSD License. | |
8 |
|
8 | |||
9 | from .widget import DOMWidget |
|
9 | from .widget import DOMWidget | |
10 | from IPython.utils.traitlets import Unicode, Tuple, TraitError, Int, CaselessStrEnum |
|
10 | from IPython.utils.traitlets import Unicode, Tuple, TraitError, Int, CaselessStrEnum | |
11 |
|
11 | |||
12 | class ContainerWidget(DOMWidget): |
|
12 | class ContainerWidget(DOMWidget): | |
13 | _view_name = Unicode('ContainerView', sync=True) |
|
13 | _view_name = Unicode('ContainerView', sync=True) | |
14 |
|
14 | |||
15 | # Child widgets in the container. |
|
15 | # Child widgets in the container. | |
16 | # Using a tuple here to force reassignment to update the list. |
|
16 | # Using a tuple here to force reassignment to update the list. | |
17 | # When a proper notifying-list trait exists, that is what should be used here. |
|
17 | # When a proper notifying-list trait exists, that is what should be used here. | |
18 | children = Tuple(sync=True, allow_none=False) |
|
18 | children = Tuple(sync=True, allow_none=False) | |
19 |
|
19 | |||
20 | def __init__(self, children = (), **kwargs): |
|
20 | def __init__(self, children = (), **kwargs): | |
21 | kwargs['children'] = children |
|
21 | kwargs['children'] = children | |
22 | super(ContainerWidget, self).__init__(**kwargs) |
|
22 | super(ContainerWidget, self).__init__(**kwargs) | |
23 | self.on_displayed(ContainerWidget._fire_children_displayed) |
|
23 | self.on_displayed(ContainerWidget._fire_children_displayed) | |
24 |
|
24 | |||
25 | def _fire_children_displayed(self): |
|
25 | def _fire_children_displayed(self): | |
26 | for child in self.children: |
|
26 | for child in self.children: | |
27 | child._handle_displayed() |
|
27 | child._handle_displayed() | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | class PopupWidget(ContainerWidget): |
|
30 | class PopupWidget(ContainerWidget): | |
31 | _view_name = Unicode('PopupView', sync=True) |
|
31 | _view_name = Unicode('PopupView', sync=True) | |
32 |
|
32 | |||
33 | description = Unicode(sync=True) |
|
33 | description = Unicode(sync=True) | |
34 | button_text = Unicode(sync=True) |
|
34 | button_text = Unicode(sync=True) | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | class FlexContainerWidget(ContainerWidget): |
|
37 | class FlexContainerWidget(ContainerWidget): | |
38 | _view_name = Unicode('FlexContainerView', sync=True) |
|
38 | _view_name = Unicode('FlexContainerView', sync=True) | |
39 | flex = Int(0, sync=True, help="""Specify the flexible-ness of the model.""") |
|
39 | flex = Int(0, sync=True, help="""Specify the flexible-ness of the model.""") | |
40 | def _flex_changed(self, name, old, new): |
|
40 | def _flex_changed(self, name, old, new): | |
41 | new = min(max(0, new), 2) |
|
41 | new = min(max(0, new), 2) | |
42 | if self.flex != new: |
|
42 | if self.flex != new: | |
43 | self.flex = new |
|
43 | self.flex = new | |
44 |
|
44 | |||
45 | _locations = ['start', 'center', 'end'] |
|
45 | _locations = ['start', 'center', 'end', 'baseline', 'stretch'] | |
46 | pack = CaselessStrEnum(values=_locations, default_value='start', allow_none=False, sync=True) |
|
46 | pack = CaselessStrEnum( | |
47 | align = CaselessStrEnum(values=_locations, default_value='start', allow_none=False, sync=True) |
|
47 | values=_locations, | |
|
48 | default_value='start', allow_none=False, sync=True) | |||
|
49 | align = CaselessStrEnum( | |||
|
50 | values=_locations, | |||
|
51 | default_value='start', allow_none=False, sync=True) | |||
48 |
|
52 | |||
49 |
|
53 | |||
50 |
class VBox |
|
54 | class VBoxWidget(FlexContainerWidget): | |
51 | _view_name = Unicode('VBoxContainerView', sync=True) |
|
55 | _view_name = Unicode('VBoxContainerView', sync=True) | |
52 |
|
56 | |||
53 |
|
57 | |||
54 |
class HBox |
|
58 | class HBoxWidget(FlexContainerWidget): | |
55 | _view_name = Unicode('HBoxContainerView', sync=True) |
|
59 | _view_name = Unicode('HBoxContainerView', sync=True) |
General Comments 0
You need to be logged in to leave comments.
Login now