]> BookStack Code Mirror - bookstack/blob - resources/js/components/setting-color-picker.js
Merge branch 'development' of github.com:BookStackApp/BookStack into development
[bookstack] / resources / js / components / setting-color-picker.js
1 import {Component} from './component';
2
3 export class SettingColorPicker extends Component {
4
5     setup() {
6         this.colorInput = this.$refs.input;
7         this.resetButton = this.$refs.resetButton;
8         this.defaultButton = this.$refs.defaultButton;
9         this.currentColor = this.$opts.current;
10         this.defaultColor = this.$opts.default;
11
12         this.resetButton.addEventListener('click', () => this.setValue(this.currentColor));
13         this.defaultButton.addEventListener('click', () => this.setValue(this.defaultColor));
14     }
15
16     setValue(value) {
17         this.colorInput.value = value;
18         this.colorInput.dispatchEvent(new Event('change', {bubbles: true}));
19     }
20
21 }