Skip to content

Commit

Permalink
Merge pull request #21 from Moros1138/close-and-copy-when-clicking-an…
Browse files Browse the repository at this point in the history
…ywhere

close share dialog and copy the text when clicking anywhere
  • Loading branch information
Moros1138 authored Apr 25, 2024
2 parents df0154c + 2ecb612 commit f0ec0a9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<div class="window">
<div class="header">Share Your Masterpiece!</div>
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit f0ec0a9

Please sign in to comment.