PageSourceSearch

https://don.halteobsolescence.org/themes/default/js/visibility-tog…?hash=780b99b3a0928dcc5ff82ee20f36a435

js halteobsolescence.org collected 2026-10-01 12:02:26 UTC 4,040 bytes, 31 lines download raw bytes

1class VisibilityToggleElement{static CONCERNED_CLASSES=['individual-infos','frequency-related','company-infos'];#element;#form;#frequency='';#isCompany=false;#isCompanyInfo;#isFrequencyRelated;#isIndividualInfo;constructor(element){this.#validate(element);this.#element=element;this.#form=element.closest('form');this.#isFrequencyRelated=element.classList.contains('frequency-related');this.#isIndividualInfo=element.classList.contains('individual-infos');this.#isCompanyInfo=element.classList.contains('company-infos');}
2set frequency(frequency){this.#frequency=frequency;this.toggle();}
3set isCompany(isCompany){this.#isCompany=isCompany;this.toggle();}
4toggle(){if(!this.#isConcernedForToggle()){return;}
5this.#toggleVisibility();}
6get _element(){return this.#element;}
7get _elementsToToggle(){return[this.#element];}
8#isAwaitedFrequency(){return!this.#isFrequencyRelated||this.#element.classList.contains(`frequency-${this.#frequency}`);}
9#isConcernedForToggle(){return this.#isFrequencyRelated||this.#isIndividualInfo||this.#isCompanyInfo;}
10#toggleVisibility(){const hiddenByFrequency=!this.#isAwaitedFrequency();const hiddenByCompany=this.#isCompanyInfo&&!this.#isCompany;const hiddenByIndividual=this.#isIndividualInfo&&this.#isCompany;this._elementsToToggle.forEach(element=>{element.hidden=hiddenByFrequency||hiddenByCompany||hiddenByIndividual;$(element).toggle(!element.hidden);});}
11#validate(element){const classList=element.classList;const isConcerned=VisibilityToggleElement.CONCERNED_CLASSES.some(classname=>classList.contains(classname))
12if(!isConcerned){throw Error("The given element is not supposed to be managed by the VisibilityToggleElement service!");}
13if(element.donationReservedElement){throw Error("The element is already attached!");}}}
14class VisibilityToggleField extends VisibilityToggleElement{#isRequired;constructor(element){super(element);this.#isRequired=element.querySelector('label .required')!==null;}
15toggle(){super.toggle();this.#updateInputRequiredValue();}
16get _listManageableRequiredValueElements(){const inputs=this._element.querySelectorAll(`[name='${this._relatedInputName}']`);return Array.from(inputs);}
17get _relatedInputName(){return this._element.querySelector('label')?.getAttribute('for');}
18#updateInputRequiredValue(){if(!this.#isRequired){return;}
19this._listManageableRequiredValueElements.forEach(element=>{if(this._element.hidden){return element.removeAttribute('data-required');}
20element.setAttribute('data-required','1');});}}
21class VisibilityToggleSignature extends VisibilityToggleField{get _elementsToToggle(){const signaturePadZone=document.getElementById(this._relatedInputName).closest('[id^=sigPadreserved_]');return[...super._elementsToToggle,signaturePadZone];}
22get _listManageableRequiredValueElements(){return[document.getElementById(this._relatedInputName)];}}
23class VisibilityToggleElementFactory{static create(element){if(element.classList.contains('custom-content')){return new VisibilityToggleElement(element);}
24switch(element.dataset.type){case'signature':return new VisibilityToggleSignature(element);default:return new VisibilityToggleField(element);}}}
25class VisibilityToggleElementsCollection{#attachedElements=[];static#instance=undefined;static async getInstance(){if(this.#instance===undefined){this.#instance=new VisibilityToggleElementsCollection();}
26return this.#instance.#attachAll();}
27applyFrequency(frequency){this.#attachedElements.forEach(attachedElement=>attachedElement.frequency=frequency)}
28applyCompanyFlag(isCompany){this.#attachedElements.forEach(attachedElement=>attachedElement.isCompany=isCompany)}
29#attachAll(){const selector=VisibilityToggleElement.CONCERNED_CLASSES.map(classname=>`.${classname}`).join(', ');document.querySelectorAll(selector).forEach((element)=>this.#attach(element));return this;}
30#attach(element){if(element.donationReservedElement!==undefined){return;}
31const reservedElement=VisibilityToggleElementFactory.create(element);element.donationReservedElement=reservedElement;this.#attachedElements.push(reservedElement);}}

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.