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