From 52e39e792fe0b823cdadd2c4698fd7fd969bab10 Mon Sep 17 00:00:00 2001 From: Richmond Macaspac Date: Thu, 12 Mar 2020 02:50:18 -0500 Subject: [PATCH 1/3] Clipboard API fallback for when browser doesn't support navigator.clipboard --- src/components/itemcontextmenu.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/itemcontextmenu.js b/src/components/itemcontextmenu.js index 62048345e..ad180b2c0 100644 --- a/src/components/itemcontextmenu.js +++ b/src/components/itemcontextmenu.js @@ -346,11 +346,7 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", break; case "copy-stream": var downloadHref = apiClient.getItemDownloadUrl(itemId); - navigator.clipboard.writeText(downloadHref).then(function () { - require(["toast"], function (toast) { - toast(globalize.translate("CopyStreamURLSuccess")); - }); - }, function () { + var textareaCopy = function () { var textArea = document.createElement("textarea"); textArea.value = downloadHref; document.body.appendChild(textArea); @@ -364,7 +360,16 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", prompt(globalize.translate("CopyStreamURL"), downloadHref); } document.body.removeChild(textArea); - }); + }; + if (navigator.clipboard === undefined) { + textareaCopy(); + } else { + navigator.clipboard.writeText(downloadHref).then(function () { + require(["toast"], function (toast) { + toast(globalize.translate("CopyStreamURLSuccess")); + }); + }, textareaCopy); + } getResolveFunction(resolve, id)(); break; case "editsubtitles": From 6a308ffae778fcd1140cfc47510a44dd0b0d02ca Mon Sep 17 00:00:00 2001 From: Richmond Macaspac Date: Thu, 12 Mar 2020 03:12:01 -0500 Subject: [PATCH 2/3] Update src/components/itemcontextmenu.js Co-Authored-By: Julien Machiels --- src/components/itemcontextmenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/itemcontextmenu.js b/src/components/itemcontextmenu.js index ad180b2c0..38f657561 100644 --- a/src/components/itemcontextmenu.js +++ b/src/components/itemcontextmenu.js @@ -346,7 +346,7 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", break; case "copy-stream": var downloadHref = apiClient.getItemDownloadUrl(itemId); - var textareaCopy = function () { + var textAreaCopy = function () { var textArea = document.createElement("textarea"); textArea.value = downloadHref; document.body.appendChild(textArea); From 560fe45087a1d7c46955f8a5c27cae8e29ddbde3 Mon Sep 17 00:00:00 2001 From: Richmond Macaspac Date: Thu, 12 Mar 2020 03:22:04 -0500 Subject: [PATCH 3/3] camelCase var fix --- src/components/itemcontextmenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/itemcontextmenu.js b/src/components/itemcontextmenu.js index 38f657561..bdbcfc782 100644 --- a/src/components/itemcontextmenu.js +++ b/src/components/itemcontextmenu.js @@ -362,13 +362,13 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", document.body.removeChild(textArea); }; if (navigator.clipboard === undefined) { - textareaCopy(); + textAreaCopy(); } else { navigator.clipboard.writeText(downloadHref).then(function () { require(["toast"], function (toast) { toast(globalize.translate("CopyStreamURLSuccess")); }); - }, textareaCopy); + }, textAreaCopy); } getResolveFunction(resolve, id)(); break;