summaryrefslogtreecommitdiff
path: root/p
diff options
context:
space:
mode:
Diffstat (limited to 'p')
-rw-r--r--p/scripts/main.js25
-rw-r--r--p/themes/base-theme/template.css1
-rw-r--r--p/themes/base-theme/template.rtl.css1
3 files changed, 22 insertions, 5 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index c9627b606..be1f7c924 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1018,7 +1018,7 @@ function init_stream(stream) {
return true;
}
- el = ev.target.closest('.item.share > a[data-type="print"]');
+ el = ev.target.closest('.item.share > button[data-type="print"]');
if (el) { // Print
const tmp_window = window.open();
for (let i = 0; i < document.styleSheets.length; i++) {
@@ -1032,9 +1032,19 @@ function init_stream(stream) {
return false;
}
- el = ev.target.closest('.item.share > a[data-type="clipboard"]');
+ el = ev.target.closest('.item.share > button[data-type="clipboard"]');
if (el && navigator.clipboard) { // Clipboard
- navigator.clipboard.writeText(el.href);
+ navigator.clipboard.writeText(el.dataset.url);
+ return false;
+ }
+
+ el = ev.target.closest('.item.share > button[data-type="web-sharing-api"]');
+ if (el && navigator.share) { // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
+ const shareData = {
+ url: el.dataset.url,
+ title: decodeURI(el.dataset.title),
+ };
+ navigator.share(shareData);
return false;
}
@@ -1068,6 +1078,15 @@ function init_stream(stream) {
}
};
+ if (!navigator.share) {
+ // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
+ // do not show the menu entry if browser does not support navigator.share
+ document.styleSheets[0].insertRule(
+ 'button.as-link[data-type="web-sharing-api"] {display: none !important;}',
+ document.styleSheets[0].cssRules.length
+ );
+ }
+
stream.onmouseup = function (ev) { // Mouseup enables us to catch middle click, and control+click in IE/Edge
if (ev.altKey || ev.metaKey || ev.shiftKey) {
return;
diff --git a/p/themes/base-theme/template.css b/p/themes/base-theme/template.css
index d4a052860..8b35175e4 100644
--- a/p/themes/base-theme/template.css
+++ b/p/themes/base-theme/template.css
@@ -1077,7 +1077,6 @@ a.website:hover .favicon {
overflow: hidden;
}
-.flux .item.share > a,
.item.query > a {
display: list-item;
list-style-position: inside;
diff --git a/p/themes/base-theme/template.rtl.css b/p/themes/base-theme/template.rtl.css
index eff8ad044..e79bbadfb 100644
--- a/p/themes/base-theme/template.rtl.css
+++ b/p/themes/base-theme/template.rtl.css
@@ -1077,7 +1077,6 @@ a.website:hover .favicon {
overflow: hidden;
}
-.flux .item.share > a,
.item.query > a {
display: list-item;
list-style-position: inside;