##// END OF EJS Templates
Adding readout for Valid widget
Sylvain Corlay -
Show More
@@ -155,8 +155,8 define([
155 155 /**
156 156 * Called when view is rendered.
157 157 */
158 this.$el.addClass("fa widget-valid");
159 this.model.on("change:value", this.update, this);
158 this.$el.addClass("widget-valid");
159 this.model.on("change", this.update, this);
160 160 this.update();
161 161 },
162 162 update: function() {
@@ -166,17 +166,21 define([
166 166 * Called when the model is changed. The model may have been
167 167 * changed by another view or by a state update from the back-end.
168 168 */
169 var icon, color, readout;
169 170 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);
171 icon = "fa-check";
172 color = "green";
173 readout = "";
174 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 }
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);
180 184 }
181 185 });
182 186
@@ -81,6 +81,7 class Valid(_Bool):
81 81 value: {True,False}
82 82 value of the Valid widget
83 83 """
84 readout = Unicode(help="Message displayed when the value is False", sync=True)
84 85 _view_name = Unicode('ValidView', sync=True)
85 86
86 87 # Remove in IPython 4.0
General Comments 0
You need to be logged in to leave comments. Login now