first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 21:30:42 +03:00
commit 4d92991817
1982 changed files with 284835 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
let bodyClickListenerAdded = false
/** @type {Record<string, any>} */
const clickHandlers = {}
/**
* @this {any}
* @param {string} attr
*/
export function bindClickHandler(attr = 'data-swal-template') {
clickHandlers[attr] = this
if (!bodyClickListenerAdded) {
document.body.addEventListener('click', bodyClickListener)
bodyClickListenerAdded = true
}
}
/**
* @param {MouseEvent} event
*/
const bodyClickListener = (event) => {
for (let el = /** @type {any} */ (event.target); el && el !== document; el = el.parentNode) {
for (const attr in clickHandlers) {
const template = el.getAttribute && el.getAttribute(attr)
if (template) {
clickHandlers[attr].fire({ template })
return
}
}
}
}