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