mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
fix auto width and height of spin button component
refs #5652 - changes the spin-button so that it only sets the size when the button is submitting instead of all of the time
This commit is contained in:
parent
ae695a3e8e
commit
a7ed98cc3e
@ -4,6 +4,7 @@ export default Ember.Component.extend({
|
||||
tagName: 'button',
|
||||
buttonText: '',
|
||||
submitting: false,
|
||||
showSpinner: false,
|
||||
autoWidth: true,
|
||||
|
||||
// Disable Button when isLoading equals true
|
||||
@ -20,19 +21,14 @@ export default Ember.Component.extend({
|
||||
return true;
|
||||
},
|
||||
|
||||
setSize: function () {
|
||||
if (!this.get('submitting') && this.get('autoWidth')) {
|
||||
// this exists so that the spinner doesn't change the size of the button
|
||||
this.$().width(this.$().width()); // sets width of button
|
||||
this.$().height(this.$().height()); // sets height of button
|
||||
setSize: Ember.observer('submitting', function () {
|
||||
if (this.get('submitting') && this.get('autoWidth')) {
|
||||
this.$().width(this.$().width());
|
||||
this.$().height(this.$().height());
|
||||
} else {
|
||||
this.$().width('');
|
||||
this.$().height('');
|
||||
}
|
||||
},
|
||||
|
||||
width: Ember.observer('buttonText', 'autoWidth', function () {
|
||||
this.setSize();
|
||||
}),
|
||||
|
||||
didInsertElement: function () {
|
||||
this.setSize();
|
||||
}
|
||||
this.set('showSpinner', this.get('submitting'));
|
||||
})
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
{{#unless submitting}}
|
||||
{{#if showSpinner}}
|
||||
<span class="spinner"></span>
|
||||
{{else}}
|
||||
{{#if buttonText}}
|
||||
{{buttonText}}
|
||||
{{else}}
|
||||
{{{yield}}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<span class="spinner"></span>
|
||||
{{/unless}}
|
||||
{{/if}}
|
Loading…
Reference in New Issue
Block a user