PageSourceSearch

https://www.impactpool.org/assets/controllers/general_dialog_controller-78aade33.js

js impactpool.org collected 2026-09-24 18:25:54 UTC 2,885 bytes, 101 lines download raw bytes

1import { Controller } from "@hotwired/stimulus";
2
3export default class extends Controller {
4  static targets = ["dialog", "frame", "title", "footer"];
5
6  static values = {
7    title: { type: String, default: "" },
8    url: { type: String, default: "" },
9    footer: { type: String, default: "" },
10  };
11
12  // Footer templates - will be populated with preserved params
13  signUpFooter = "";
14  signInFooter = "";
15
16  urlValueChanged() {
17    if (this.urlValue) {
18      this.setUrl(this.urlValue);
19    }
20  }
21
22  titleValueChanged() {
23    if (this.titleValue) {
24      this.setTitle(this.titleValue);
25    }
26  }
27
28  footerValueChanged() {
29    if (this.footerValue) {
30      this.setFooter(this.footerValue);
31    }
32  }
33
34  open(event) {
35    event.preventDefault();
36    event.stopPropagation();
37
38    if (this.dialogTarget.open) {
39      this.dialogTarget.close();
40    }
41
42    let data = event.currentTarget.dataset;
43
44    this.titleValue = data.title;
45    this.urlValue = data.url;
46    this.footerValue = data.footer;
47
48    if (this.footerValue === "") {
49      this.footerTarget.style.display = "none";
50    } else {
51      this.footerTarget.style.display = "flex";
52    }
53
54    this.dialogTarget.showModal();
55  }
56
57  setTitle(title) {
58    this.titleTarget.textContent = title;
59  }
60
61  setFooter(footer) {
62    if (footer === "blank" || !footer || footer.length === 0) {
63      this.footerTarget.style.display = "none";
64    } else {
65      this.footerTarget.style.display = "flex";
66      this.footerTarget.innerHTML = footer;
67    }
68  }
69
70  setUrl(url) {
71    this.frameTarget.src = url;
72
73    // Extract parameters from current URL to preserve context
74    const urlObj = new URL(url, window.location.origin);
75    const params = new URLSearchParams(urlObj.search);
76
77    if (url.includes("signup")) {
78      // Build signin URL with preserved params
79      let signinUrl = "/signin";
80      if (params.toString()) {
81        signinUrl += "?" + params.toString();
82      }
83      this.signUpFooter = `Already have an account? <a href='${signinUrl}' class='ip-link' type='bodylink' color='blue' data-action='click->general-dialog#open' data-title='Login' data-url='${signinUrl}'>Login</a>`;
84      this.setFooter(this.signUpFooter);
85    } else if (url.includes("signin")) {
86      // Build signup URL with preserved params + add onboarding=false
87      params.set("type", "email"); // Ensure email signup form
88      params.set("onboarding", "false"); // Skip onboarding for all signin contexts
89      let signupUrl = "/signup?" + params.toString();
90      this.signInFooter = `Don't have an account? <a href='${signupUrl}' class='ip-link' type='bodylink' color='blue' data-action='click->general-dialog#open' data-title='Sign Up' data-url='${signupUrl}'>Sign up</a>`;
91      this.setFooter(this.signInFooter);
92    }
93  }
94
95  close(event) {
96    event.preventDefault();
97    event.stopPropagation();
98
99    this.dialogTarget.close();
100  }
101}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.