1import {Controller} from '@hotwired/stimulus' 2import {CookieUtils} from 'sites/cookie_utils' 3import {BootstrapWrapper} from 'sites/bootstrap_wrapper' 4 5export default class extends Controller { 6 static targets = ['launcher', 'window', 'badge', 'text', 'toast'] 7 8 launcherTargetConnected() { 9 console.debug('Chatbot container controller: Launcher connected') 10 switch(Cookies.get('chatbot_launcher_state')) { 11 case 'opened': 12 this.open() 13 break 14 case undefined: 15 this.presentLauncherHighlights() 16 break 17 } 18 } 19 20 toggleVisibility() { 21 if (this.launcherTarget.classList.contains('opened')) { 22 this.close() 23 } else { 24 this.open() 25 } 26 } 27 28 open() { 29 console.debug('Chatbot container controller: Opening') 30 this.launcherTarget.classList.add('opened') 31 this.windowTarget.show() 32 this.persistLauncherState('opened') 33 if (this.hasBadgeTarget) { 34 this.badgeTarget.classList.add('d-none') 35 } 36 } 37 38 close() { 39 this.launcherTarget.classList.remove('opened') 40 this.windowTarget.close() 41 this.persistLauncherState('closed') 42 if (this.hasTextTarget) { 43 this.textTarget.classList.remove('expanded') 44 } 45 if (this.hasToastTarget) { 46 BootstrapWrapper.hideToast(this.toastTarget) 47 } 48 } 49 50 persistLauncherState(value) { 51 CookieUtils.setCookie('chatbot_launcher_state', value) 52 } 53 54 presentLauncherHighlights() { 55 if (this.hasBadgeTarget) { 56 this.badgeTarget.classList.remove('d-none') 57 } 58 if (this.hasTextTarget) { 59 this.textTarget.classList.add('expanded') 60 } 61 if (this.hasToastTarget) { 62 setTimeout(() => { 63 BootstrapWrapper.showToast(this.toastTarget) 64 }, 3000) 65 } 66 } 67}
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.