mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-11 13:48:13 +03:00
Updated another set of components
This commit is contained in:
@ -1,18 +1,20 @@
|
||||
import {Component} from "./component";
|
||||
|
||||
class SettingColorPicker {
|
||||
export class SettingColorPicker extends Component {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.colorInput = elem.querySelector('input[type=color]');
|
||||
this.resetButton = elem.querySelector('[setting-color-picker-reset]');
|
||||
this.defaultButton = elem.querySelector('[setting-color-picker-default]');
|
||||
this.resetButton.addEventListener('click', event => {
|
||||
this.colorInput.value = this.colorInput.dataset.current;
|
||||
});
|
||||
this.defaultButton.addEventListener('click', event => {
|
||||
this.colorInput.value = this.colorInput.dataset.default;
|
||||
});
|
||||
setup() {
|
||||
this.colorInput = this.$refs.input;
|
||||
this.resetButton = this.$refs.resetButton;
|
||||
this.defaultButton = this.$refs.defaultButton;
|
||||
this.currentColor = this.$opts.current;
|
||||
this.defaultColor = this.$opts.default;
|
||||
|
||||
this.resetButton.addEventListener('click', () => this.setValue(this.currentColor));
|
||||
this.defaultButton.addEventListener('click', () => this.setValue(this.defaultColor));
|
||||
}
|
||||
}
|
||||
|
||||
export default SettingColorPicker;
|
||||
setValue(value) {
|
||||
this.colorInput.value = value;
|
||||
this.colorInput.dispatchEvent(new Event('change'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user