mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Valid widget
This commit is contained in:
parent
21013cb5a3
commit
c1a3e7f389
6
IPython/html/static/style/ipython.min.css
vendored
6
IPython/html/static/style/ipython.min.css
vendored
@ -1477,6 +1477,12 @@ h6:hover .anchor-link {
|
|||||||
.widget_item .dropdown-menu li a {
|
.widget_item .dropdown-menu li a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
.widget-valid {
|
||||||
|
margin-top: 9px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
.widget-hbox {
|
.widget-hbox {
|
||||||
/* Horizontal widgets */
|
/* Horizontal widgets */
|
||||||
/* Old browsers */
|
/* Old browsers */
|
||||||
|
6
IPython/html/static/style/style.min.css
vendored
6
IPython/html/static/style/style.min.css
vendored
@ -10269,6 +10269,12 @@ h6:hover .anchor-link {
|
|||||||
.widget_item .dropdown-menu li a {
|
.widget_item .dropdown-menu li a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
.widget-valid {
|
||||||
|
margin-top: 9px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
.widget-hbox {
|
.widget-hbox {
|
||||||
/* Horizontal widgets */
|
/* Horizontal widgets */
|
||||||
/* Old browsers */
|
/* Old browsers */
|
||||||
|
@ -71,7 +71,6 @@ define([
|
|||||||
}
|
}
|
||||||
return CheckboxView.__super__.update.apply(this);
|
return CheckboxView.__super__.update.apply(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -150,8 +149,41 @@ define([
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var ValidView = widget.DOMWidgetView.extend({
|
||||||
|
render: function() {
|
||||||
|
/**
|
||||||
|
* Called when view is rendered.
|
||||||
|
*/
|
||||||
|
this.$el.addClass("fa widget-valid");
|
||||||
|
this.model.on("change:value", this.update, this);
|
||||||
|
this.update();
|
||||||
|
},
|
||||||
|
update: function() {
|
||||||
|
/**
|
||||||
|
* Update the contents of this view
|
||||||
|
*
|
||||||
|
* Called when the model is changed. The model may have been
|
||||||
|
* changed by another view or by a state update from the back-end.
|
||||||
|
*/
|
||||||
|
if (this.model.get("value")) {
|
||||||
|
this.$el.removeClass("fa-close").addClass("fa-check");
|
||||||
|
this.after_displayed(function() {
|
||||||
|
this.$el.css("color", "green");
|
||||||
|
}, this);
|
||||||
|
} else {
|
||||||
|
this.$el.removeClass("fa-check").addClass("fa-close");
|
||||||
|
this.after_displayed(function() {
|
||||||
|
this.$el.css("color", "red");
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'CheckboxView': CheckboxView,
|
'CheckboxView': CheckboxView,
|
||||||
'ToggleButtonView': ToggleButtonView,
|
'ToggleButtonView': ToggleButtonView,
|
||||||
|
'ValidView': ValidView,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -209,6 +209,13 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.widget-valid {
|
||||||
|
margin-top: 9px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
.widget-hbox {
|
.widget-hbox {
|
||||||
/* Horizontal widgets */
|
/* Horizontal widgets */
|
||||||
.hbox();
|
.hbox();
|
||||||
|
@ -2,7 +2,7 @@ from .widget import Widget, DOMWidget, CallbackDispatcher, register
|
|||||||
|
|
||||||
from .trait_types import Color
|
from .trait_types import Color
|
||||||
|
|
||||||
from .widget_bool import Checkbox, ToggleButton
|
from .widget_bool import Checkbox, ToggleButton, Valid
|
||||||
from .widget_button import Button
|
from .widget_button import Button
|
||||||
from .widget_box import Box, FlexBox, HBox, VBox
|
from .widget_box import Box, FlexBox, HBox, VBox
|
||||||
from .widget_float import FloatText, BoundedFloatText, FloatSlider, FloatProgress, FloatRangeSlider
|
from .widget_float import FloatText, BoundedFloatText, FloatSlider, FloatProgress, FloatRangeSlider
|
||||||
|
@ -60,7 +60,6 @@ class ToggleButton(_Bool):
|
|||||||
icon: str
|
icon: str
|
||||||
font-awesome icon name
|
font-awesome icon name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_view_name = Unicode('ToggleButtonView', sync=True)
|
_view_name = Unicode('ToggleButtonView', sync=True)
|
||||||
tooltip = Unicode(help="Tooltip caption of the toggle button.", sync=True)
|
tooltip = Unicode(help="Tooltip caption of the toggle button.", sync=True)
|
||||||
icon = Unicode('', help= "Font-awesome icon.", sync=True)
|
icon = Unicode('', help= "Font-awesome icon.", sync=True)
|
||||||
@ -71,6 +70,19 @@ class ToggleButton(_Bool):
|
|||||||
predefined styling for the button.""")
|
predefined styling for the button.""")
|
||||||
|
|
||||||
|
|
||||||
|
@register('IPython.Valid')
|
||||||
|
class Valid(_Bool):
|
||||||
|
|
||||||
|
"""Displays a boolean `value` in the form of a green check (True / valid)
|
||||||
|
or a red cross (False / invalid).
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
value: {True,False}
|
||||||
|
value of the Valid widget
|
||||||
|
"""
|
||||||
|
_view_name = Unicode('ValidView', sync=True)
|
||||||
|
|
||||||
# Remove in IPython 4.0
|
# Remove in IPython 4.0
|
||||||
CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget')
|
CheckboxWidget = DeprecatedClass(Checkbox, 'CheckboxWidget')
|
||||||
ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget')
|
ToggleButtonWidget = DeprecatedClass(ToggleButton, 'ToggleButtonWidget')
|
||||||
|
Loading…
Reference in New Issue
Block a user