1import { Controller } from '@hotwired/stimulus'; 2 3export default class extends Controller { 4 static targets = ['collapse', 'toggle']; 5 6 static values = { 7 more: String, 8 less: String, 9 }; 10 11 connect() { 12 if (!this.hasCollapseTarget || !this.hasToggleTarget) { 13 return; 14 } 15 16 this._onShown = () => { 17 if (this.hasLessValue) { 18 this.toggleTarget.textContent = this.lessValue; 19 } 20 }; 21 22 this._onHidden = () => { 23 if (this.hasMoreValue) { 24 this.toggleTarget.textContent = this.moreValue; 25 } 26 }; 27 28 this.collapseTarget.addEventListener('shown.bs.collapse', this._onShown); 29 this.collapseTarget.addEventListener('hidden.bs.collapse', this._onHidden); 30 } 31 32 disconnect() { 33 if (!this.hasCollapseTarget) { 34 return; 35 } 36 37 if (this._onShown) { 38 this.collapseTarget.removeEventListener('shown.bs.collapse', this._onShown); 39 } 40 41 if (this._onHidden) { 42 this.collapseTarget.removeEventListener('hidden.bs.collapse', this._onHidden); 43 } 44 } 45}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.