Show More
@@ -1477,6 +1477,12 b' h6:hover .anchor-link {' | |||||
1477 | .widget_item .dropdown-menu li a { |
|
1477 | .widget_item .dropdown-menu li a { | |
1478 | color: inherit; |
|
1478 | color: inherit; | |
1479 | } |
|
1479 | } | |
|
1480 | .widget-valid { | |||
|
1481 | margin-top: 9px; | |||
|
1482 | margin-bottom: 10px; | |||
|
1483 | margin-left: 3px; | |||
|
1484 | margin-right: 3px; | |||
|
1485 | } | |||
1480 | .widget-hbox { |
|
1486 | .widget-hbox { | |
1481 | /* Horizontal widgets */ |
|
1487 | /* Horizontal widgets */ | |
1482 | /* Old browsers */ |
|
1488 | /* Old browsers */ |
@@ -10269,6 +10269,12 b' h6:hover .anchor-link {' | |||||
10269 | .widget_item .dropdown-menu li a { |
|
10269 | .widget_item .dropdown-menu li a { | |
10270 | color: inherit; |
|
10270 | color: inherit; | |
10271 | } |
|
10271 | } | |
|
10272 | .widget-valid { | |||
|
10273 | margin-top: 9px; | |||
|
10274 | margin-bottom: 10px; | |||
|
10275 | margin-left: 3px; | |||
|
10276 | margin-right: 3px; | |||
|
10277 | } | |||
10272 | .widget-hbox { |
|
10278 | .widget-hbox { | |
10273 | /* Horizontal widgets */ |
|
10279 | /* Horizontal widgets */ | |
10274 | /* Old browsers */ |
|
10280 | /* Old browsers */ |
@@ -71,7 +71,6 b' define([' | |||||
71 | } |
|
71 | } | |
72 | return CheckboxView.__super__.update.apply(this); |
|
72 | return CheckboxView.__super__.update.apply(this); | |
73 | }, |
|
73 | }, | |
74 |
|
||||
75 | }); |
|
74 | }); | |
76 |
|
75 | |||
77 |
|
76 | |||
@@ -150,8 +149,41 b' define([' | |||||
150 | }, |
|
149 | }, | |
151 | }); |
|
150 | }); | |
152 |
|
151 | |||
|
152 | ||||
|
153 | var ValidView = widget.DOMWidgetView.extend({ | |||
|
154 | render: function() { | |||
|
155 | /** | |||
|
156 | * Called when view is rendered. | |||
|
157 | */ | |||
|
158 | this.$el.addClass("fa widget-valid"); | |||
|
159 | this.model.on("change:value", this.update, this); | |||
|
160 | this.update(); | |||
|
161 | }, | |||
|
162 | update: function() { | |||
|
163 | /** | |||
|
164 | * Update the contents of this view | |||
|
165 | * | |||
|
166 | * Called when the model is changed. The model may have been | |||
|
167 | * changed by another view or by a state update from the back-end. | |||
|
168 | */ | |||
|
169 | if (this.model.get("value")) { | |||
|
170 | this.$el.removeClass("fa-close").addClass("fa-check"); | |||
|
171 | this.after_displayed(function() { | |||
|
172 | this.$el.css("color", "green"); | |||
|
173 | }, this); | |||
|
174 | } else { | |||
|
175 | this.$el.removeClass("fa-check").addClass("fa-close"); | |||
|
176 | this.after_displayed(function() { | |||
|
177 | this.$el.css("color", "red"); | |||
|
178 | }, this); | |||
|
179 | } | |||
|
180 | } | |||
|
181 | }); | |||
|
182 | ||||
|
183 | ||||
153 | return { |
|
184 | return { | |
154 | 'CheckboxView': CheckboxView, |
|
185 | 'CheckboxView': CheckboxView, | |
155 | 'ToggleButtonView': ToggleButtonView, |
|
186 | 'ToggleButtonView': ToggleButtonView, | |
|
187 | 'ValidView': ValidView, | |||
156 | }; |
|
188 | }; | |
157 | }); |
|
189 | }); |
@@ -209,6 +209,13 b'' | |||||
209 | color: inherit; |
|
209 | color: inherit; | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
|
212 | .widget-valid { | |||
|
213 | margin-top: 9px; | |||
|
214 | margin-bottom: 10px; | |||
|
215 | margin-left: 3px; | |||
|
216 | margin-right: 3px; | |||
|
217 | } | |||
|
218 | ||||
212 | .widget-hbox { |
|
219 | .widget-hbox { | |
213 | /* Horizontal widgets */ |
|
220 | /* Horizontal widgets */ | |
214 | .hbox(); |
|
221 | .hbox(); |
@@ -2,7 +2,7 b' from .widget import Widget, DOMWidget, CallbackDispatcher, register' | |||||
2 |
|
2 | |||
3 | from .trait_types import Color |
|
3 | from .trait_types import Color | |
4 |
|
4 | |||
5 | from .widget_bool import Checkbox, ToggleButton |
|
5 | from .widget_bool import Checkbox, ToggleButton, Valid | |
6 | from .widget_button import Button |
|
6 | from .widget_button import Button | |
7 | from .widget_box import Box, FlexBox, HBox, VBox |
|
7 | from .widget_box import Box, FlexBox, HBox, VBox | |
8 | from .widget_float import FloatText, BoundedFloatText, FloatSlider, FloatProgress, FloatRangeSlider |
|
8 | from .widget_float import FloatText, BoundedFloatText, FloatSlider, FloatProgress, FloatRangeSlider |
@@ -60,7 +60,6 b' class ToggleButton(_Bool):' | |||||
60 | icon: str |
|
60 | icon: str | |
61 | font-awesome icon name |
|
61 | font-awesome icon name | |
62 | """ |
|
62 | """ | |
63 |
|
||||
64 | _view_name = Unicode('ToggleButtonView', sync=True) |
|
63 | _view_name = Unicode('ToggleButtonView', sync=True) | |
65 | tooltip = Unicode(help="Tooltip caption of the toggle button.", sync=True) |
|
64 | tooltip = Unicode(help="Tooltip caption of the toggle button.", sync=True) | |
66 | icon = Unicode('', help= "Font-awesome icon.", sync=True) |
|
65 | icon = Unicode('', help= "Font-awesome icon.", sync=True) | |
@@ -71,6 +70,19 b' class ToggleButton(_Bool):' | |||||
71 | predefined styling for the button.""") |
|
70 | predefined styling for the button.""") | |
72 |
|
71 | |||
73 |
|
72 | |||
|
73 | @register('IPython.Valid') | |||
|
74 | class Valid(_Bool): | |||
|
75 | ||||
|
76 | """Displays a boolean `value` in the form of a green check (True / valid) | |||
|
77 | or a red cross (False / invalid). | |||
|
78 | ||||
|
79 | Parameters | |||
|
80 | ---------- | |||
|
81 | value: {True,False} | |||
|
82 | value of the Valid widget | |||
|
83 | """ | |||
|
84 | _view_name = Unicode('ValidView', sync=True) | |||
|
85 | ||||
74 | # Remove in IPython 4.0 |
|
86 | # Remove in IPython 4.0 | |
75 | CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget') |
|
87 | CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget') | |
76 | ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget') |
|
88 | ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget') |
General Comments 0
You need to be logged in to leave comments.
Login now