PageSourceSearch

https://greatergood.com/cdn/shop/t/57/assets/cusa-cause-selector.js?v=65292628036987906951774468832

js greatergood.com collected 2026-10-01 10:18:30 UTC 7,329 bytes, 2 lines download raw bytes

1class CauseSelector extends HTMLElement{constructor(){super(),this.openBtn=this.querySelector(".cusa-cause-selector-btn"),this.closeBtn=this.querySelector(".cusa-cause-selector-close-btn"),this.openBtnCaretWrapper=this.querySelector(".cusa-cause-selector-btn-caret-wrapper"),this.dialogEl=this.querySelector(".cusa-cause-selector-dialog"),this.causeLabels=[...this.querySelectorAll(".cusa-cause-selector-label")],this.causeRadioBtns=[...this.querySelectorAll(".cusa-cause-selector-radio")],this.productTour=this.querySelector(".cusa-cause-selector-product-tour"),this.productTourBtn=this.querySelector(".cusa-cause-selector-info-btn"),this.productTourSteps=[...this.querySelectorAll(".cusa-cause-selector-step")],this.productTourStepBns=[...this.querySelectorAll(".step-button")],this.siteName=this.dataset.siteName}connectedCallback(){let causeInitialized=!1;const waitForTrackingReady=()=>{!causeInitialized&&window.cusaCartAttributes?._cusa_click_tracking_is_active?(causeInitialized=!0,this.setInitialSelectedCause()):causeInitialized||setTimeout(waitForTrackingReady,50)};waitForTrackingReady(),setTimeout(()=>{causeInitialized||(console.warn("Forcing initial cause selection after timeout."),this.setInitialSelectedCause())},2e3),window.addEventListener("cusa-tracking-ready",()=>{waitForTrackingReady()},{once:!0}),this.openBtn.addEventListener("click",this.handleCauseSelectorBtnClick),this.closeBtn.addEventListener("click",this.closeCauseSelector),this.dialogEl.addEventListener("submit",e=>e.preventDefault()),this.dialogEl.addEventListener("keydown",this.handleKeyDown),this.causeLabels.map(labelEl=>{labelEl.addEventListener("click",this.handleLabelClick)}),window.addEventListener("click",this.clickOutsideDialog),this.productTourBtn.addEventListener("click",this.handleProductTourBtnClick),this.productTourStepBns.map(btn=>{btn.addEventListener("click",this.handleStepBtnClick)}),publish(PUB_SUB_EVENTS.updateRoyalty,this.getSelectedCauseRadioEl())}disconnectedCallback(){}clickOutsideDialog=e=>{if(e.target.classList.contains("cusa-cause-selector-btn")||e.target.classList.contains("cusa-cause-selector-info-btn")||this.dialogEl.contains(e.target))return;const dialogDimensions=this.dialogEl.getBoundingClientRect(),causeSelectorBtn=this.openBtn.getBoundingClientRect(),productTourBtn=this.productTourBtn.getBoundingClientRect();this.dialogEl.open&&(e.clientX<dialogDimensions.left||e.clientX>dialogDimensions.right||e.clientY<dialogDimensions.top||e.clientY>dialogDimensions.bottom)&&(e.clientX<causeSelectorBtn.left||e.clientX>causeSelectorBtn.right||e.clientY<causeSelectorBtn.top||e.clientY>causeSelectorBtn.bottom)&&(e.clientX<productTourBtn.left||e.clientX>productTourBtn.right||e.clientY<productTourBtn.top||e.clientY>productTourBtn.bottom)&&this.dialogEl.close()};handleCauseSelectorBtnClick=()=>{this.dialogEl.open?this.closeCauseSelector():this.openCauseSelector()};handleProductTourBtnClick=()=>{this.dialogEl.open||this.openCauseSelector(),!this.productTourSteps.filter(step=>!step.classList.contains("hidden"))[0]&&setTimeout(()=>{this.productTourSteps[0].classList.remove("hidden")},0)};handleStepBtnClick=e=>{if(e.target.classList.contains("accept-btn")){e.target.closest(".cusa-cause-selector-step").classList.add("hidden"),setLocalStorage("hideCauseSelectorTour","true");return}const currentStep=e.target.closest(".cusa-cause-selector-step");let otherStepNum=0;e.target.classList.contains("next-step")?otherStepNum=parseInt(currentStep.dataset.step)+1:otherStepNum=parseInt(currentStep.dataset.step)-1;const otherStep=document.querySelector(`[data-step="${otherStepNum}"]`);if(otherStep){if(currentStep.classList.add("hidden"),otherStep.classList.remove("hidden"),e.type!=="keydown")return;otherStepNum<this.productTourSteps.length?otherStep.querySelector(".next-step").focus():otherStep.querySelector(".prev-step").focus()}};updateCaret=()=>{this.openBtnCaretWrapper.classList.toggle("open")};openCauseSelector=()=>{this.dialogEl.open||this.dialogEl.show(),this.updateCaret()};closeCauseSelector=()=>{this.dialogEl.open&&this.dialogEl.close(),[...this.dialogEl.querySelectorAll(".cusa-cause-selector-step")].map(el=>{el.classList.contains("hidden")||el.classList.add("hidden")}),this.updateCaret()};handleKeyDown=e=>{(e.code==="Escape"||e.code==="Esc")&&this.closeCauseSelector(),(e.code==="Space"||e.code===" "||e.code==="Enter"||e.code==="Return")&&(e.preventDefault(),document.activeElement===this.closeBtn&&this.closeCauseSelector(),e.target.classList.contains("step-button")&&this.handleStepBtnClick(e),this.handleLabelClick())};handleLabelClick=()=>{const clickTimer=setTimeout(()=>{const labelText=this.getLabelText(),causeHandle=this.getSelectedCauseRadioEl().id.split("-radio")[0];
1this.updateOpenBtn(labelText,this.getSVG()),setLocalStorage("selected-cause",causeHandle),publish(PUB_SUB_EVENTS.updateRoyalty,causeHandle),clearTimeout(clickTimer)},0)};getSelectedCauseRadioEl=()=>this.dialogEl.querySelector('input[name="selected-cause"]:checked');getLabelText=()=>this.getSelectedCauseRadioEl().closest(".cusa-cause-selector-input-group").querySelector(".cusa-cause-selector-name").textContent;getSVG=()=>this.getSelectedCauseRadioEl().closest(".cusa-cause-selector-input-group").querySelector(".cusa-cause-selector-icon").innerHTML;updateOpenBtn=(selectedName,svgCode)=>{this.openBtn.querySelector(".cusa-cause-selector-btn-text").textContent=selectedName,this.openBtn.querySelector(".cusa-cause-selector-btn-icon").innerHTML=svgCode,this.debouncedSetCauseCartAttribute(selectedName)};setSelectedCauseRadioToChecked=selectedCauseId=>{try{document.getElementById(selectedCauseId).checked=!0}catch(error){console.error(error)}};checkForCauseParam=()=>new URLSearchParams(window.location.search).get("selected-cause");setCauseCartAttribute=async selectedName=>{if(!window.cusaCartAttributes?._cusa_click_tracking_is_active){console.warn("Tracking not yet initialized. Skipping cart attribute write.");return}registerCartAttributeUpdate({Cause:selectedName,Site:this.siteName}),selectedName!==getLocalStorage("selected-cause-name")&&setLocalStorage("selected-cause-name",selectedName),console.log(`Cause update registered: ${selectedName}`),console.log(`Site update registered: ${this.siteName}`)};debouncedSetCauseCartAttribute=debounce(selectedName=>{const storedCause=window.cusaCartAttributes?.Cause,cartCauseMismatch=storedCause&&storedCause!==selectedName;(selectedName!==getLocalStorage("selected-cause-name")||cartCauseMismatch)&&this.setCauseCartAttribute(selectedName)},FETCH_DEBOUNCE_TIMER);setInitialSelectedCause=()=>{let selectedCause=this.checkForCauseParam(),radioId=`${selectedCause}-radio`;document.getElementById(radioId)||(selectedCause=getLocalStorage("selected-cause"),selectedCause&&document.getElementById(`${selectedCause}-radio`)?radioId=`${selectedCause}-radio`:(radioId=this.causeRadioBtns[0].id,selectedCause=radioId.split("-radio")[0])),setLocalStorage("selected-cause",selectedCause),this.setSelectedCauseRadioToChecked(radioId),this.updateOpenBtn(this.getLabelText(),this.getSVG());const pubTimer=setTimeout(()=>{publish(PUB_SUB_EVENTS.updateRoyalty,selectedCause),clearTimeout(pubTimer)},150)}}customElements.define("cusa-cause-selector",CauseSelector);
2//# sourceMappingURL=/cdn/shop/t/57/assets/cusa-cause-selector.js.map?v=65292628036987906951774468832

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.