mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Adding readout for Valid widget
This commit is contained in:
parent
c1a3e7f389
commit
55246125e4
@ -155,8 +155,8 @@ define([
|
|||||||
/**
|
/**
|
||||||
* Called when view is rendered.
|
* Called when view is rendered.
|
||||||
*/
|
*/
|
||||||
this.$el.addClass("fa widget-valid");
|
this.$el.addClass("widget-valid");
|
||||||
this.model.on("change:value", this.update, this);
|
this.model.on("change", this.update, this);
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
update: function() {
|
update: function() {
|
||||||
@ -166,17 +166,21 @@ define([
|
|||||||
* Called when the model is changed. The model may have been
|
* Called when the model is changed. The model may have been
|
||||||
* changed by another view or by a state update from the back-end.
|
* changed by another view or by a state update from the back-end.
|
||||||
*/
|
*/
|
||||||
|
var icon, color, readout;
|
||||||
if (this.model.get("value")) {
|
if (this.model.get("value")) {
|
||||||
this.$el.removeClass("fa-close").addClass("fa-check");
|
icon = "fa-check";
|
||||||
this.after_displayed(function() {
|
color = "green";
|
||||||
this.$el.css("color", "green");
|
readout = "";
|
||||||
}, this);
|
|
||||||
} else {
|
} else {
|
||||||
this.$el.removeClass("fa-check").addClass("fa-close");
|
icon = "fa-close";
|
||||||
this.after_displayed(function() {
|
color = "red";
|
||||||
this.$el.css("color", "red");
|
readout = this.model.get("readout");
|
||||||
}, this);
|
}
|
||||||
}
|
this.$el.text(readout);
|
||||||
|
$('<i class="fa"></i>').prependTo(this.$el).addClass(icon);
|
||||||
|
this.after_displayed(function() {
|
||||||
|
this.$el.css("color", color);
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ class Valid(_Bool):
|
|||||||
value: {True,False}
|
value: {True,False}
|
||||||
value of the Valid widget
|
value of the Valid widget
|
||||||
"""
|
"""
|
||||||
|
readout = Unicode(help="Message displayed when the value is False", sync=True)
|
||||||
_view_name = Unicode('ValidView', sync=True)
|
_view_name = Unicode('ValidView', sync=True)
|
||||||
|
|
||||||
# Remove in IPython 4.0
|
# Remove in IPython 4.0
|
||||||
|
Loading…
Reference in New Issue
Block a user