From 4d89287887a523dfe99fd039532fdb6d7b8f5538 Mon Sep 17 00:00:00 2001 From: Owen Leonard <oleonard@myacpl.org> Date: Wed, 2 Apr 2025 13:00:30 +0000 Subject: [PATCH] Bug 36275: (follow-up) Add tooltip feedback This patch adds some code to the copytoClipBoard function so that it triggers a Bootstrap tooltip with the text "Copied to clipboard", providing feedback to the user that something has happened. The tooltip self-destructs after a few seconds. Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> --- .../prog/en/includes/copy-to-clipboard-button.inc | 4 +++- koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc index 2c5f5746d9..adfca8d67b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc @@ -1 +1,3 @@ -<button type="button" class="btn btn-xs btn-primary" data-copy-to-clipboard data-value="[% copy_to_clipboard_value | html %]"> <i class="fa-solid fa-clipboard"></i> Copy to clipboard </button> +<button type="button" class="btn btn-xs btn-primary" data-bs-placement="right" data-bs-delay='{"show":0,"hide":2000}' data-copy-to-clipboard data-value="[% copy_to_clipboard_value | html %]"> + <i class="fa-solid fa-clipboard"></i> Copy to clipboard +</button> diff --git a/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js b/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js index e339958273..e82ee8ceb3 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js +++ b/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js @@ -14,6 +14,14 @@ } navigator.clipboard.writeText(value); + + target.title = __("Copied to clipboard"); + const tooltip = bootstrap.Tooltip.getOrCreateInstance(target); + tooltip.show(); + setTimeout(() => { + tooltip.dispose(); + target.title = ""; + }, 3000); }; copyToClipboardButtons.forEach(copyToClipboardButton => { -- 2.39.5