File size: 2,865 Bytes
1662a18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(() => {
  const VERSION = "1.0.2";
  // Optional: set window.GGFC_ADMIN_EMAIL before this script to enable mailto forwarding.
  const ADMIN_EMAIL =
    (typeof window !== "undefined" && window.GGFC_ADMIN_EMAIL) || "";

  document.querySelectorAll("[data-version]").forEach((el) => {
    el.textContent = `v${VERSION}`;
  });

  const header = document.querySelector("[data-header]");
  const onScroll = () => {
    if (!header) return;
    header.classList.toggle("is-solid", window.scrollY > 24);
  };
  onScroll();
  window.addEventListener("scroll", onScroll, { passive: true });

  const targets = document.querySelectorAll(
    ".about .section-rail, .facts, .spirit-visual, .spirit-copy, .connect .eyebrow, .connect h2, .connect .section-lead, .social-list, .collaborate .eyebrow, .collaborate h2, .collaborate .section-lead, .collaborate-grid"
  );
  targets.forEach((el) => el.classList.add("reveal"));

  if ("IntersectionObserver" in window) {
    const io = new IntersectionObserver(
      (entries) => {
        entries.forEach((entry) => {
          if (entry.isIntersecting) {
            entry.target.classList.add("is-in");
            io.unobserve(entry.target);
          }
        });
      },
      { threshold: 0.18, rootMargin: "0px 0px -8% 0px" }
    );
    targets.forEach((el) => io.observe(el));
  } else {
    targets.forEach((el) => el.classList.add("is-in"));
  }

  const form = document.getElementById("collaborateForm");
  const status = document.getElementById("collaborateFormStatus");
  if (form && status) {
    form.addEventListener("submit", (event) => {
      event.preventDefault();
      const name = form.name.value.trim();
      const organisation = form.organisation.value.trim();
      const email = form.email.value.trim();
      const type = form.type.value;
      const message = form.message.value.trim();

      if (!name || !email || !type || !message) {
        status.textContent = "Please complete the required fields.";
        status.dataset.state = "error";
        return;
      }

      const subject = encodeURIComponent(`Golden Green collaboration: ${type}`);
      const body = encodeURIComponent(
        [
          `Name: ${name}`,
          `Organisation: ${organisation || "—"}`,
          `Email: ${email}`,
          `Type: ${type}`,
          "",
          message,
        ].join("\n")
      );

      if (ADMIN_EMAIL) {
        window.location.href = `mailto:${ADMIN_EMAIL}?subject=${subject}&body=${body}`;
        status.textContent = "Opening your email app to send the enquiry…";
        status.dataset.state = "ok";
      } else {
        status.textContent =
          "Thanks — your enquiry is ready. Add an admin email (window.GGFC_ADMIN_EMAIL) to enable direct send, or message the club on Instagram / Facebook.";
        status.dataset.state = "ok";
      }
    });
  }
})();