diff --git a/assets/javascripts/templates/notice_tmpl.js b/assets/javascripts/templates/notice_tmpl.js
index 49793eb571..26c8c947b1 100644
--- a/assets/javascripts/templates/notice_tmpl.js
+++ b/assets/javascripts/templates/notice_tmpl.js
@@ -7,3 +7,9 @@ app.templates.singleDocNotice = (doc) =>
app.templates.disabledDocNotice = () =>
notice(` This documentation is disabled.
To enable it, go to Preferences. `);
+
+app.templates.noOriginalLinkNotice = () =>
+ notice(` The original page link is not available for this documentation. `);
+
+app.templates.copyFailedNotice = () =>
+ notice(` Couldn't copy the original page link to the clipboard. `);
diff --git a/assets/javascripts/views/content/entry_page.js b/assets/javascripts/views/content/entry_page.js
index 961d90e1fa..8b7bc4dd52 100644
--- a/assets/javascripts/views/content/entry_page.js
+++ b/assets/javascripts/views/content/entry_page.js
@@ -221,17 +221,32 @@ app.views.EntryPage = class EntryPage extends app.View {
onAltC() {
const link = this.find("._attribution:last-child ._attribution-link");
if (!link) {
+ this.showTransientNotice("noOriginalLink");
return;
}
- console.log(link.href + location.hash);
- navigator.clipboard.writeText(link.href + location.hash);
+ navigator.clipboard.writeText(link.href + location.hash).catch(() =>
+ this.showTransientNotice("copyFailed"),
+ );
}
onAltO() {
const link = this.find("._attribution:last-child ._attribution-link");
if (!link) {
+ this.showTransientNotice("noOriginalLink");
return;
}
this.delay(() => $.popup(link.href + location.hash));
}
+
+ showTransientNotice(type) {
+ if (this.transientNotice) {
+ clearTimeout(this.transientNoticeTimer);
+ this.transientNotice.deactivate();
+ }
+ this.transientNotice = new app.views.Notice(type);
+ this.transientNoticeTimer = setTimeout(() => {
+ this.transientNotice.deactivate();
+ this.transientNotice = null;
+ }, 3000);
+ }
};