Files
openfoodnetwork/app/webpacker/controllers/modal_controller.js
2025-10-22 15:30:36 +02:00

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);
}
}