1export default function GDMAddCloseButton( 2 modalsSelector, 3 4 buttonClass, 5 6 buttonText, 7 8 handler, 9 10 className1, 11 12 className2, 13 14 modalSelectorIsVariable 15) { 16 document.querySelectorAll(modalsSelector).forEach((modal) => { 17 // Guard clause: return if the close button has already been added 18 if (modal.querySelector(`.${buttonClass}`)) return; 19 20 if(modal.classList.contains('remove-user-modal')) return; 21 22 const closeButton = document.createElement("div"); 23 24 // Using setAttribute so you can add multiple classes as a string if wanted 25 closeButton.setAttribute("class", buttonClass); 26 closeButton.textContent = buttonText; 27 28 const closeModal = () => { 29 modal.parentElement.classList.remove(className1); 30 31 modal.classList.remove(className1, className2); 32 document.body.classList.remove("freeze-element"); 33 }; 34 35 if (handler) { 36 closeButton.addEventListener("click", (e) => { 37 handler(className1, className2); 38 }); 39 } else { 40 closeButton.addEventListener("click", () => closeModal()); 41 } 42 43 modal.insertAdjacentElement("beforeend", closeButton); 44 }); 45}
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.