PageSourceSearch

https://cache.stocklight.com/assets/pricing/pricing_toggle_component_controller-f4d6312b.js

js stocklight.com collected 2026-10-02 04:15:19 UTC 1,910 bytes, 78 lines download raw bytes

1import { Controller } from "@hotwired/stimulus";
2
3export default class extends Controller {
4	static targets = [
5		"period",
6		"purchase",
7		"currency",
8		"monthlyPrice",
9		"annualPrice",
10		"usdPrice",
11		"audPrice",
12		"websitePrice",
13		"appstorePrice",
14	];
15
16	connect() {
17		this.updatePriceVisibility();
18	}
19
20	onToggle(event) {
21		event.preventDefault();
22		this.updatePriceVisibility();
23	}
24
25	updatePriceVisibility() {
26		const periodValue = this.getSelectedValue("period");
27		const purchaseValue = this.getSelectedValue("purchase");
28		const currencyValue = this.getSelectedValue("currency");
29
30		// Toggle purchase medium prices
31		if (purchaseValue === "appstore") {
32			this.showElements(this.appstorePriceTargets);
33			this.hideElements(this.websitePriceTargets);
34		} else {
35			this.showElements(this.websitePriceTargets);
36			this.hideElements(this.appstorePriceTargets);
37		}
38
39		// Toggle period prices
40		if (periodValue === "monthly") {
41			this.showElements(this.monthlyPriceTargets);
42			this.hideElements(this.annualPriceTargets);
43		} else {
44			this.showElements(this.annualPriceTargets);
45			this.hideElements(this.monthlyPriceTargets);
46		}
47
48		// Toggle currency prices (based on currency selection only)
49		if (currencyValue === "usd") {
50			this.showElements(this.usdPriceTargets);
51			this.hideElements(this.audPriceTargets);
52		} else {
53			this.showElements(this.audPriceTargets);
54			this.hideElements(this.usdPriceTargets);
55		}
56	}
57
58	getSelectedValue(targetName) {
59		const target = this[`${targetName}Target`];
60		if (!target) return null;
61		const form = target.closest("form");
62		if (!form) return null;
63		const checked = form.querySelector('input[type="radio"]:checked');
64		return checked ? checked.value : null;
65	}
66
67	showElements(elements) {
68		for (const el of elements) {
69			el.classList.remove("d-none");
70		}
71	}
72
73	hideElements(elements) {
74		for (const el of elements) {
75			el.classList.add("d-none");
76		}
77	}
78}

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.