* Initialize and show tutorial if needed
()
| 79 | * Initialize and show tutorial if needed |
| 80 | */ |
| 81 | init(): void { |
| 82 | this.overlay = document.getElementById('tutorialOverlay'); |
| 83 | this.content = document.getElementById('tutorialContent'); |
| 84 | this.dots = document.getElementById('tutorialDots'); |
| 85 | this.prevBtn = document.getElementById('tutorialPrev'); |
| 86 | this.nextBtn = document.getElementById('tutorialNext'); |
| 87 | this.skipBtn = document.getElementById('tutorialSkip'); |
| 88 | |
| 89 | if (!this.overlay || !this.content || !this.dots || !this.prevBtn || !this.nextBtn || !this.skipBtn) { |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | // Set up event listeners |
| 94 | this.prevBtn.addEventListener('click', () => this.prev()); |
| 95 | this.nextBtn.addEventListener('click', () => this.next()); |
| 96 | this.skipBtn.addEventListener('click', () => this.complete()); |
| 97 | |
| 98 | // Close on overlay click |
| 99 | this.overlay.addEventListener('click', (e) => { |
| 100 | if (e.target === this.overlay) { |
| 101 | this.complete(); |
| 102 | } |
| 103 | }); |
| 104 | |
| 105 | // Close on Escape |
| 106 | document.addEventListener('keydown', (e) => { |
| 107 | if (e.key === 'Escape' && this.overlay?.style.display !== 'none') { |
| 108 | this.complete(); |
| 109 | } |
| 110 | }); |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Show the tutorial |