18 lines
		
	
	
		
			486 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			486 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import { Controller } from "https://unpkg.com/@hotwired/stimulus@v3.2.2/dist/stimulus.js"
 | |
| 
 | |
| export default class extends Controller {
 | |
|     static targets = ["message"];
 | |
| 
 | |
|     showMessage(msg) {
 | |
|         this.messageTarget.innerText = msg;
 | |
|         this.element.classList.add("show");
 | |
| 
 | |
|         if (this._waitTimer) {
 | |
|             clearTimeout(this._waitTimer);
 | |
|         }
 | |
| 
 | |
|         this._waitTimer = setTimeout(() => {
 | |
|             this.element.classList.remove("show");
 | |
|         }, 3000);
 | |
|     }
 | |
| } |