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