Ghost/core/client/components/gh-file-upload.js
2014-05-28 15:26:16 -04:00

24 lines
652 B
JavaScript

var FileUpload = Ember.Component.extend({
_file: null,
uploadButtonText: 'Text',
uploadButtonDisabled: true,
change: function (event) {
this.set('uploadButtonDisabled', false);
this.sendAction('onAdd');
this._file = event.target.files[0];
},
actions: {
upload: function () {
var self = this;
if (!this.uploadButtonDisabled && self._file) {
self.sendAction('onUpload', self._file);
}
// Prevent double post by disabling the button.
this.set('uploadButtonDisabled', true);
}
}
});
export default FileUpload;