From 03b884a61506cde398860b42330c4f94105d933a Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Mon, 2 Mar 2015 14:34:37 -0500 Subject: [PATCH] Moving styling to else statement --- IPython/html/static/widgets/js/widget_bool.js | 20 +++++++++---------- .../html/static/widgets/js/widget_button.js | 14 ++++++------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/IPython/html/static/widgets/js/widget_bool.js b/IPython/html/static/widgets/js/widget_bool.js index 27e492875..dc107ec81 100644 --- a/IPython/html/static/widgets/js/widget_bool.js +++ b/IPython/html/static/widgets/js/widget_bool.js @@ -59,10 +59,9 @@ define([ this.$checkbox.prop('checked', this.model.get('value')); if (options === undefined || options.updated_view != this) { - var disabled = this.model.get('disabled'); - this.$checkbox.prop('disabled', disabled); + this.$checkbox.prop("disabled", this.model.get("disabled")); - var description = this.model.get('description'); + var description = this.model.get("description"); if (description.trim().length === 0) { this.$label.hide(); } else { @@ -113,7 +112,7 @@ define([ /** * Update the contents of this view * - * 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. */ if (this.model.get('value')) { @@ -123,17 +122,16 @@ define([ } if (options === undefined || options.updated_view != this) { - - var disabled = this.model.get('disabled'); - this.$el.prop('disabled', disabled); - - var description = this.model.get('description'); + this.$el.prop("disabled", this.model.get("disabled")); this.$el.attr("title", this.model.get("tooltip")); - this.$el.text(description); + + var description = this.model.get("description"); var icon = this.model.get("icon"); - $('').prependTo(this.$el).addClass(icon); if (description.trim().length === 0 && icon.trim().length ===0) { this.$el.html(" "); // Preserve button height + } else { + this.$el.text(description); + $('').prependTo(this.$el).addClass(icon); } } return ToggleButtonView.__super__.update.apply(this); diff --git a/IPython/html/static/widgets/js/widget_button.js b/IPython/html/static/widgets/js/widget_button.js index cc55f47e1..a2e6bd4a9 100644 --- a/IPython/html/static/widgets/js/widget_button.js +++ b/IPython/html/static/widgets/js/widget_button.js @@ -27,21 +27,19 @@ define([ /** * Update the contents of this view * - * 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. */ - var description = this.model.get('description'); + this.$el.prop("disabled", this.model.get("disabled")); this.$el.attr("title", this.model.get("tooltip")); - this.$el.text(description); + + var description = this.model.get("description"); var icon = this.model.get("icon"); - $('').prependTo(this.$el).addClass(icon); if (description.trim().length === 0 && icon.trim().length ===0) { this.$el.html(" "); // Preserve button height - } - if (this.model.get('disabled')) { - this.$el.attr('disabled','disabled'); } else { - this.$el.removeAttr('disabled'); + this.$el.text(description); + $('').prependTo(this.$el).addClass(icon); } return ButtonView.__super__.update.apply(this);