24 lines
548 B
TypeScript
Raw Normal View History

2024-05-02 22:04:43 -05:00
import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static override targets = ["notice"];
declare noticeTarget: HTMLElement;
timeout: number | undefined;
// automatically close
override connect() {
this.timeout = setTimeout(() => this._close(), 3500);
}
_close() {
$(this.noticeTarget).fadeOut("fast");
}
2024-05-02 22:04:43 -05:00
close(event: KeyboardEvent) {
if (this.timeout) {
clearTimeout(this.timeout);
}
2024-05-02 22:04:43 -05:00
event.preventDefault();
}
}