1const config = { 2 // selector 3 closeButtonSelector: '.js-dialog__closeButton', 4 5 // class name 6 stateClassName: 'is-dialog-opened', 7}; 8 9export const setDialog = (element) => { 10 /** @type {HTMLElement} ãã¤ã¢ãã°ã表示ããããªã¬ã¼ */ 11 const button = element; 12 /** @type {string} ãã¤ã¢ãã°æ¬ä½ã«ä»ä¸ãããID屿§å¤ */ 13 const dialogId = button.dataset.dialogTarget; 14 /** @type {HTMLDialogElement} ãã¤ã¢ãã°æ¬ä½ */ 15 const dialog = document.getElementById(dialogId); 16 /** @type {NodeListOf<HTMLButtonElement>} éãããã¿ã³ */ 17 const closeButtons = dialog.querySelectorAll(config.closeButtonSelector); 18 19 if (!dialogId || dialogId === '' || !dialog) { 20 return; 21 } 22 23 const showDialog = () => { 24 dialog.showModal(); 25 }; 26 27 const hideDialog = () => { 28 dialog.close(); 29 }; 30 31 const bindEvent = () => { 32 button.addEventListener('click', (event) => { 33 event.preventDefault(); 34 showDialog(); 35 }); 36 37 closeButtons.forEach((closeButton) => { 38 closeButton.addEventListener('click', () => { 39 hideDialog(); 40 }); 41 }); 42 }; 43 44 bindEvent(); 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.