Initial commit

This commit is contained in:
2023-07-23 13:34:00 +01:00
commit 967c16b6bf
65 changed files with 2868 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import { Controller } from "/lib/hotwired/stimulus/dist/stimulus.js";
export default class ListFilterController extends Controller {
static targets = ["option"];
filter(event) {
for (const option of this.optionTargets) {
if (!event.target.value) {
option.disabled = false;
continue;
}
const value = option.getAttribute("data-list-filter-value");
option.disabled = value !== event.target.value;
}
}
}

View File

@ -0,0 +1,33 @@
import { Controller } from "/lib/hotwired/stimulus/dist/stimulus.js";
export default class ModalController extends Controller {
static targets = ["frame"];
open() {
if (!this.element.open) {
this.element.showModal();
}
}
close(event) {
if (!this.element.open) {
return;
}
event.preventDefault();
this.element.close();
this.frameTarget.src = undefined;
this.frameTarget.innerHTML = "";
switch (event.type) {
case "turbo:submit-end":
Turbo.visit(location.href, { action: "replace" });
break;
case "popstate":
event.stopImmediatePropagation();
history.go(1);
break;
}
}
}

View File

@ -0,0 +1,21 @@
import { Controller } from "/lib/hotwired/stimulus/dist/stimulus.js";
export default class SearchFormController extends Controller {
static targets = ["button"];
#timeoutHandle;
connect() {
this.buttonTarget.hidden = true;
}
disconnect() {
clearTimeout(this.#timeoutHandle);
this.buttonTarget.hidden = false;
}
input() {
clearTimeout(this.#timeoutHandle);
this.#timeoutHandle = setTimeout(() => this.element.requestSubmit(), 500);
}
}