File size: 1,388 Bytes
187ef74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(() => {
  "use strict";

  const menuButton = document.querySelector(".menu-button");
  const menu = document.querySelector("#main-menu");
  if (menuButton && menu) {
    menuButton.addEventListener("click", () => {
      const open = menu.classList.toggle("open");
      menuButton.setAttribute("aria-expanded", String(open));
    });
  }

  document.querySelectorAll("[data-amount]").forEach((button) => {
    button.addEventListener("click", () => {
      const input = document.querySelector('input[name="amount"]');
      if (input) {
        input.value = button.dataset.amount || "10";
        input.focus();
      }
    });
  });

  document.querySelectorAll(".filter-form select").forEach((select) => {
    select.addEventListener("change", () => select.form?.requestSubmit());
  });

  document.querySelectorAll("[data-copy-link]").forEach((button) => {
    button.addEventListener("click", async () => {
      const localUrl = `${window.location.origin}/project/make-block-bloom/`;
      try {
        await navigator.clipboard.writeText(localUrl);
        button.textContent = "Local link copied";
      } catch (_error) {
        button.textContent = "Copy unavailable";
      }
    });
  });

  document.querySelectorAll("[data-gallery]").forEach((button) => {
    button.addEventListener("click", () => {
      button.textContent = "1 archived photo";
    });
  });
})();