mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
4d5c43305b
no issue - converted remaining uses of `this.$()` that I could find over to native DOM - deprecation is still silenced for now because both `liquid-fire` and `liquid-wormhole` trigger it
38 lines
833 B
JavaScript
38 lines
833 B
JavaScript
import Component from '@ember/component';
|
|
|
|
export default Component.extend({
|
|
_file: null,
|
|
|
|
acceptEncoding: null,
|
|
uploadButtonText: 'Text',
|
|
uploadButtonDisabled: true,
|
|
|
|
shouldResetForm: true,
|
|
|
|
// closure actions
|
|
onUpload() {},
|
|
onAdd() {},
|
|
|
|
actions: {
|
|
upload() {
|
|
if (!this.uploadButtonDisabled && this._file) {
|
|
this.onUpload(this._file);
|
|
}
|
|
|
|
// Prevent double post by disabling the button.
|
|
this.set('uploadButtonDisabled', true);
|
|
|
|
// Reset form
|
|
if (this.shouldResetForm) {
|
|
this.element.closest('form').reset();
|
|
}
|
|
}
|
|
},
|
|
|
|
change(event) {
|
|
this.set('uploadButtonDisabled', false);
|
|
this.onAdd();
|
|
this._file = event.target.files[0];
|
|
}
|
|
});
|