Added support for multiple lines in button-like widgets

This commit is contained in:
Jonathan Frederic 2013-11-14 23:31:10 +00:00
parent 59e7a04723
commit 6c860e32c0
2 changed files with 6 additions and 4 deletions

View File

@ -38,11 +38,12 @@ define(["notebook/js/widget"], function(){
// Frontent -> Frontend Sync
update : function(){
var description = this.model.get('description');
description.replace(' ', ' ')
description = description.replace(' ', ' ');
description = description.replace('\n', '<br>\n');
if (description.length == 0) {
this.$el.html('&nbsp;'); // Preserve button height
} else {
this.$el.html(this.model.get('description'));
this.$el.html(description);
}
return IPython.WidgetView.prototype.update.call(this);

View File

@ -60,11 +60,12 @@ define(["notebook/js/widget"], function(){
update : function(){
var selected_item_text = this.model.get('value');
selected_item_text.replace(' ', '&nbsp;');
selected_item_text = selected_item_text.replace(' ', '&nbsp;');
selected_item_text = selected_item_text.replace('\n', '<br>\n');
if (selected_item_text.length == 0) {
this.$droplabel.html('&nbsp;');
} else {
this.$droplabel.html(this.model.get('value'));
this.$droplabel.html(selected_item_text);
}
var items = this.model.get('values');