Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions assets/javascripts/templates/notice_tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ app.templates.singleDocNotice = (doc) =>
app.templates.disabledDocNotice = () =>
notice(` <strong>This documentation is disabled.</strong>
To enable it, go to <a href="/settings" class="_notice-link">Preferences</a>. `);

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. `);
19 changes: 17 additions & 2 deletions assets/javascripts/views/content/entry_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};