mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
25 lines
579 B
JavaScript
25 lines
579 B
JavaScript
import { Controller } from "stimulus";
|
|
import { useOpenAndCloseAsAModal } from "./mixins/useOpenAndCloseAsAModal";
|
|
|
|
export default class extends Controller {
|
|
static targets = ["background", "modal"];
|
|
static values = { instant: { type: Boolean, default: false } };
|
|
|
|
connect() {
|
|
useOpenAndCloseAsAModal(this);
|
|
window.addEventListener("modal:close", this.close.bind(this));
|
|
|
|
if (this.instantValue) {
|
|
this.open();
|
|
}
|
|
}
|
|
|
|
disconnect() {
|
|
window.removeEventListener("modal:close", this.close);
|
|
}
|
|
|
|
remove(event) {
|
|
this.close(event, true);
|
|
}
|
|
}
|