https://www.georgetowncoc.com/assets/controllers/event_registration_selection_controller-496e6205.js
1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 static targets = [ 5 "selection", "sponsorshipFields", "logoVisibility", 6 "regularOnly", "organizationInput", "submitButton" 7 ] 8 static values = { 9 organizationRequired: { type: Boolean, default: false }, 10 registrationLabel: { type: String, default: "Register" }, 11 sponsorshipLabel: { type: String, default: "Continue to sponsorship payment" }, 12 freeSponsorshipLabel: { type: String, default: "Register" }, 13 } 14 15 connect() { 16 this.regularOnlyTargets.forEach((target) => this.rememberDisabledInputs(target)) 17 this.refresh() 18 } 19 20 regularOnlyTargetConnected(target) { 21 this.rememberDisabledInputs(target) 22 this.applyRegularOnly(target, this.sponsorshipSelected()) 23 } 24 25 refresh() { 26 if (!this.hasSelectionTarget) return 27 28 const sponsorship = this.sponsorshipSelected() 29 if (this.hasSponsorshipFieldsTarget) { 30 this.sponsorshipFieldsTarget.classList.toggle("hidden", !sponsorship) 31 this.sponsorshipFieldsTarget.disabled = !sponsorship 32 } 33 this.regularOnlyTargets.forEach((target) => this.applyRegularOnly(target, sponsorship)) 34 35 if (this.hasOrganizationInputTarget) { 36 this.organizationInputTarget.required = sponsorship || this.organizationRequiredValue 37 this.organizationInputTarget.placeholder = this.organizationInputTarget.required ? "" : "Optional" 38 } 39 40 if (this.hasLogoVisibilityTarget) { 41 const logoOffered = sponsorship && this.selectedOption()?.dataset.displayLogoPublicly === "true" 42 this.logoVisibilityTarget.classList.toggle("hidden", !logoOffered) 43 this.logoVisibilityTarget.querySelectorAll("input").forEach((input) => { input.disabled = !logoOffered }) 44 } 45 46 if (this.hasSubmitButtonTarget) { 47 const sponsorshipLabel = Number(this.selectedOption()?.dataset.sponsorshipPriceCents) > 0 48 ? this.sponsorshipLabelValue 49 : this.freeSponsorshipLabelValue 50 this.submitButtonTarget.textContent = sponsorship ? sponsorshipLabel : this.registrationLabelValue 51 } 52 } 53 54 sponsorshipSelected() { 55 return this.selectedOption()?.dataset.sponsorship === "true" 56 } 57 58 selectedOption() { 59 return this.hasSelectionTarget ? this.selectionTarget.selectedOptions[0] : null 60 } 61 62 rememberDisabledInputs(target) { 63 target.querySelectorAll("input, select, textarea, button").forEach((input) => { 64 if (!Object.prototype.hasOwnProperty.call(input.dataset, "registrationSelectionInitiallyDisabled")) { 65 input.dataset.registrationSelectionInitiallyDisabled = input.disabled ? "true" : "false" 66 } 67 }) 68 } 69 70 applyRegularOnly(target, sponsorship) { 71 target.classList.toggle("hidden", sponsorship) 72 target.querySelectorAll("input, select, textarea, button").forEach((input) => { 73 const initiallyDisabled = input.dataset.registrationSelectionInitiallyDisabled === "true" 74 input.disabled = sponsorship || initiallyDisabled 75 }) 76 } 77}
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.