##// END OF EJS Templates
Merge pull request #7675 from SylvainCorlay/valid...
Jonathan Frederic -
r20823:d35689e1 merge
parent child Browse files
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,45 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("widget-valid");
159 this.model.on("change", 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 var icon, color, readout;
170 if (this.model.get("value")) {
171 icon = "fa-check";
172 color = "green";
173 readout = "";
174 } else {
175 icon = "fa-close";
176 color = "red";
177 readout = this.model.get("readout");
178 }
179 this.$el.text(readout);
180 $('<i class="fa"></i>').prependTo(this.$el).addClass(icon);
181 this.after_displayed(function() {
182 this.$el.css("color", color);
183 }, this);
184 }
185 });
186
187
153 return {
188 return {
154 'CheckboxView': CheckboxView,
189 'CheckboxView': CheckboxView,
155 'ToggleButtonView': ToggleButtonView,
190 'ToggleButtonView': ToggleButtonView,
191 'ValidView': ValidView,
156 };
192 };
157 });
193 });
@@ -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,20 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 readout = Unicode(help="Message displayed when the value is False", sync=True)
85 _view_name = Unicode('ValidView', sync=True)
86
74 # Remove in IPython 4.0
87 # Remove in IPython 4.0
75 CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget')
88 CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget')
76 ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget')
89 ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget')
General Comments 0
You need to be logged in to leave comments. Login now