mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
- checked_controller close details element on checkboxes
- dropdown_controller.js is to rebuild controller from many divs
to be hidden and visible to an html detail elmnt one
- details html element styling
30 lines
605 B
JavaScript
30 lines
605 B
JavaScript
import { Controller } from "stimulus";
|
|
|
|
export default class extends Controller {
|
|
|
|
connect() {
|
|
document.body.addEventListener("click", this.#close.bind(this));
|
|
this.element.addEventListener("click", this.#stopPropagation.bind(this));
|
|
}
|
|
|
|
disconnect() {
|
|
document.removeEventListener("click", this.#close);
|
|
document.removeEventListener("click", this.#stopPropagation);
|
|
}
|
|
|
|
closeOnMenu(event) {
|
|
this.#close();
|
|
this.#stopPropagation(event);
|
|
}
|
|
|
|
// private
|
|
|
|
#close(event) {
|
|
this.element.open = false;
|
|
}
|
|
|
|
#stopPropagation(event) {
|
|
event.stopPropagation();
|
|
}
|
|
}
|