From 2ecb612fdace93f931988d517b0f52f9ce618a19 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 25 Apr 2024 08:34:10 -0400 Subject: [PATCH] close share dialog and copy the text when clicking anywhere --- resources/js/app.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/resources/js/app.js b/resources/js/app.js index 81320ba..e49402c 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -337,7 +337,8 @@ function SetupLayout() { let shareDialog = document.createElement('div'); - shareDialog.setAttribute("class", "dialog"); + shareDialog.classList.toggle("dialog", "true"); + shareDialog.classList.toggle("share-dialog", "true"); shareDialog.innerHTML = `
Share Your Masterpiece!
@@ -475,6 +476,16 @@ function UpdateStatusBar() `; } +// you're welcome dandistine +window.addEventListener("click", (event) => +{ + let shareDialog = document.querySelector(".share-dialog"); + if(shareDialog == null) + return; + + shareDialog.querySelector("button").dispatchEvent(new Event("click")); +}); + window.addEventListener("message", (event) => { if(typeof event.data !== "object")