Ghost/ghost/admin/app/components/gh-spin-button.js
Hannah Wolfe 25ba3b0d22 Improve markup + tabindex etc on setup/two
refs #5652

- ensure gh-spin-button passes type & tabindex through to markup
- add gh-input class to auto focus input
- add tabindexes to setup/two + make first field autofocus and button submit
2015-08-26 16:20:52 +01:00

35 lines
917 B
JavaScript

import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
buttonText: '',
submitting: false,
showSpinner: false,
autoWidth: true,
// Disable Button when isLoading equals true
attributeBindings: ['disabled', 'type', 'tabindex'],
// 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;
},
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('');
}
this.set('showSpinner', this.get('submitting'));
})
});