]> BookStack Code Mirror - bookstack/blob - resources/js/components/optional-input.js
Updated a whole load more js components
[bookstack] / resources / js / components / optional-input.js
1 import {onSelect} from "../services/dom";
2 import {Component} from "./component";
3
4 export class OptionalInput extends Component {
5     setup() {
6         this.removeButton = this.$refs.remove;
7         this.showButton = this.$refs.show;
8         this.input = this.$refs.input;
9         this.setupListeners();
10     }
11
12     setupListeners() {
13         onSelect(this.removeButton, () => {
14             this.input.value = '';
15             this.input.classList.add('hidden');
16             this.removeButton.classList.add('hidden');
17             this.showButton.classList.remove('hidden');
18         });
19
20         onSelect(this.showButton, () => {
21             this.input.classList.remove('hidden');
22             this.removeButton.classList.remove('hidden');
23             this.showButton.classList.add('hidden');
24         });
25     }
26
27 }