mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Updated a whole load more js components
This commit is contained in:
@ -1,21 +1,25 @@
|
||||
import {Component} from "./component";
|
||||
|
||||
class ImagePicker {
|
||||
export class ImagePicker extends Component {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.imageElem = elem.querySelector('img');
|
||||
this.imageInput = elem.querySelector('input[type=file]');
|
||||
this.resetInput = elem.querySelector('input[data-reset-input]');
|
||||
this.removeInput = elem.querySelector('input[data-remove-input]');
|
||||
setup() {
|
||||
this.imageElem = this.$refs.image;
|
||||
this.imageInput = this.$refs.imageInput;
|
||||
this.resetInput = this.$refs.resetInput;
|
||||
this.removeInput = this.$refs.removeInput;
|
||||
this.resetButton = this.$refs.resetButton;
|
||||
this.removeButton = this.$refs.removeButton || null;
|
||||
|
||||
this.defaultImage = elem.getAttribute('data-default-image');
|
||||
this.defaultImage = this.$opts.defaultImage;
|
||||
|
||||
const resetButton = elem.querySelector('button[data-action="reset-image"]');
|
||||
resetButton.addEventListener('click', this.reset.bind(this));
|
||||
this.setupListeners();
|
||||
}
|
||||
|
||||
const removeButton = elem.querySelector('button[data-action="remove-image"]');
|
||||
if (removeButton) {
|
||||
removeButton.addEventListener('click', this.removeImage.bind(this));
|
||||
setupListeners() {
|
||||
this.resetButton.addEventListener('click', this.reset.bind(this));
|
||||
|
||||
if (this.removeButton) {
|
||||
this.removeButton.addEventListener('click', this.removeImage.bind(this));
|
||||
}
|
||||
|
||||
this.imageInput.addEventListener('change', this.fileInputChange.bind(this));
|
||||
@ -50,6 +54,4 @@ class ImagePicker {
|
||||
this.resetInput.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ImagePicker;
|
||||
}
|
Reference in New Issue
Block a user