2015-08-10 18:43:49 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
tagName: 'button',
|
|
|
|
buttonText: '',
|
|
|
|
submitting: false,
|
2015-08-20 06:39:07 +03:00
|
|
|
showSpinner: false,
|
2015-08-10 18:43:49 +03:00
|
|
|
autoWidth: true,
|
|
|
|
|
|
|
|
// Disable Button when isLoading equals true
|
|
|
|
attributeBindings: ['disabled'],
|
|
|
|
|
|
|
|
// Must be set on the controller
|
|
|
|
disabled: Ember.computed.equal('submitting', true),
|
|
|
|
|
|
|
|
click: function () {
|
|
|
|
if (this.get('action')) {
|
|
|
|
this.sendAction('action');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2015-08-20 06:39:07 +03:00
|
|
|
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('');
|
2015-08-10 18:43:49 +03:00
|
|
|
}
|
2015-08-20 06:39:07 +03:00
|
|
|
this.set('showSpinner', this.get('submitting'));
|
|
|
|
})
|
2015-08-10 18:43:49 +03:00
|
|
|
});
|