From 8cf0cd5a47dfc04dd5a83a152c3323b0720f80fb Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 25 Feb 2021 13:21:32 +0000 Subject: [PATCH] Bug 27594: (QA follow-up): Use clipboard API While the Clipboard API doesn't have 100% coverage (https://www.caniuse.com/?search=clipboard), it has enough coverage for the "copy" operation that it can be counted on for use in the staff interface. This patch removes the global copyToClipboard function and replaces it with a call to ndavigator.clipboard.writeText() in the template. To test, follow the previous test plan and confirm that the public download link is still copied correctly to the clipboard. --- koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt | 4 +++- koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 13 ------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt index 2b2f38160c..d4468dfb54 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt @@ -438,7 +438,9 @@ $(".get-file").on("click", function(e){ e.preventDefault(); - copyToClipboard( $(this).attr("href") ); + if( navigator.clipboard ){ + navigator.clipboard.writeText( $(this).attr("href") ); + } $(this).attr("data-original-title", _( "Link copied to the clipboard" ) ) .tooltip("show"); }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 7411567556..04e1c6176f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -358,16 +358,3 @@ function saveOrClearSimpleSearchParams() { localStorage.setItem('cat_search_pulldown_selection', pulldown_selection ); localStorage.setItem('searchbox_value', searchbox_value ); } - -// https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f -function copyToClipboard( text ){ - var el = document.createElement("textarea"); // Create a