PageSourceSearch

https://cloud.mysteryscience.com/raw/upload/assets/controllers/mul…db1ec44b7fee2b4eead507c6bbbe15d4c1bfecb1.js

js mysteryscience.com collected 2026-09-24 09:23:14 UTC 3,659 bytes, 1 lines download raw bytes

1import{Controller}from"@hotwired/stimulus";export default class extends Controller{static targets=["dropdown","chevron","placeholder","trigger","label","subLabel","emptyInput","option"];static values={placeholder:{type:String,default:"Select options"}};connect(){this.boundHandleClickOutside=this.handleClickOutside.bind(this),this.activeOptionIndex=-1,this.updateSelection()}disconnect(){document.removeEventListener("click",this.boundHandleClickOutside)}toggle(t){t.preventDefault(),t.stopPropagation();"true"===this.triggerTarget.getAttribute("aria-expanded")?this.close():this.open()}open(){this.dropdownTarget.classList.remove("mds-hidden"),this.triggerTarget.setAttribute("aria-expanded","true"),this.activeOptionIndex=-1,this.triggerTarget.focus(),this.applyActiveStyles(),this.hasChevronTarget&&this.chevronTarget.classList.add("mds-rotate-180"),setTimeout(()=>{document.addEventListener("click",this.boundHandleClickOutside)},0)}close(t=!0){this.dropdownTarget.classList.add("mds-hidden"),this.triggerTarget.setAttribute("aria-expanded","false"),t&&this.removeActiveStyles(),this.hasChevronTarget&&this.chevronTarget.classList.remove("mds-rotate-180"),this.clearFocusedOptions(),this.activeOptionIndex=-1,document.removeEventListener("click",this.boundHandleClickOutside)}updateSelection(){const t=this.dropdownTarget.querySelectorAll('input[type="checkbox"]'),e=[];t.forEach(t=>{if(t.checked){const i=t.closest("label")?.querySelector(".mds-checkbox-checkbox-label-text")?.textContent?.trim();i&&e.push(i)}}),e.length>0?(this.placeholderTarget.textContent=e.join("; "),this.hasEmptyInputTarget&&(this.emptyInputTarget.disabled=!0)):(this.placeholderTarget.textContent=this.placeholderValue,this.hasEmptyInputTarget&&(this.emptyInputTarget.disabled=!1))}handleClickOutside(t){this.element.contains(t.target)||this.close()}onFocus(){this.applyActiveStyles()}onBlur(){"true"===this.triggerTarget.getAttribute("aria-expanded")||this.removeActiveStyles()}handleKeydown(t){const e="true"===this.triggerTarget.getAttribute("aria-expanded");switch(t.key){case"Escape":e&&(this.close(!1),this.triggerTarget.focus(),t.preventDefault());break;case"Enter":case" ":e?this.activeOptionIndex>=0&&(this.toggleOptionAtIndex(this.activeOptionIndex),t.preventDefault()):(this.open(),t.preventDefault());break;case"ArrowDown":t.preventDefault(),e?this.moveActiveOption(1):this.open();break;case"ArrowUp":t.preventDefault(),e&&this.moveActiveOption(-1);break;case"Tab":e&&this.close()}}moveActiveOption(t){const e=this.optionTargets;if(0===e.length)return;this.clearFocusedOptions(),this.activeOptionIndex+=t,this.activeOptionIndex<0?this.activeOptionIndex=0:this.activeOptionIndex>=e.length&&(this.activeOptionIndex=e.length-1);const i=e[this.activeOptionIndex];i.classList.add("focused"),i.scrollIntoView({block:"nearest"}),this.triggerTarget.setAttribute("aria-activedescendant",i.id)}clearFocusedOptions(){this.optionTargets.forEach(t=>t.classList.remove("focused")),this.triggerTarget.setAttribute("aria-activedescendant","")}toggleOptionAtIndex(t){const e=this.optionTargets[t];if(!e)return;const i=e.querySelector('input[type="checkbox"]');i&&(i.checked=!i.checked,i.dispatchEvent(new Event("change",{bubbles:!0})))}applyActiveStyles(){this.triggerTarget.classList.contains("error")||(this.triggerTarget.classList.add("active"),this.hasLabelTarget&&this.labelTarget.classList.add("active"),this.hasSubLabelTarget&&this.subLabelTarget.classList.add("active"))}removeActiveStyles(){this.triggerTarget.classList.remove("active"),this.hasLabelTarget&&this.labelTarget.classList.remove("active"),this.hasSubLabelTarget&&this.subLabelTarget.classList.remove("active")}}

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.