From 622b3504520be1b3e09d5798c5e946248fcfa8da Mon Sep 17 00:00:00 2001 From: Igor Tolmachev Date: Tue, 23 Apr 2024 20:45:13 +0900 Subject: Change copy behavior --- script.js | 8 ++++---- style.css | 11 +---------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/script.js b/script.js index b16142f..2f428b9 100644 --- a/script.js +++ b/script.js @@ -1,16 +1,16 @@ function copy(text, tooltip) { return () => { navigator.clipboard.writeText(text); - tooltip.textContent = "[copied]"; - setTimeout(() => (tooltip.textContent = "[click to copy]"), 1000); + tooltip.textContent = " []"; + setTimeout(() => (tooltip.textContent = " []"), 1000); }; } window.onload = () => { document.querySelectorAll(".copy").forEach((element) => { const tooltip = document.createElement("span"); - tooltip.classList.add("copy-tooltip"); - tooltip.textContent = "[click to copy]"; + tooltip.classList.add("copy-button"); + tooltip.textContent = " []"; element.onclick = copy(element.attributes["copy-text"]?.value, tooltip); element.appendChild(tooltip); diff --git a/style.css b/style.css index b88584d..c24e85f 100644 --- a/style.css +++ b/style.css @@ -40,16 +40,7 @@ a, } a:active, -.copy:active { +.copy:hover { cursor: pointer; color: #9b859d; } - -.copy > .copy-tooltip { - visibility: hidden; - margin-left: 1em; -} - -.copy:hover > .copy-tooltip { - visibility: visible; -} -- cgit v1.2.3