Repository navigation
Force external links to open in a new tab #920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
06af6d1
6cbb422
01c8d4f
8f8533c
256a260
6a1ca3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* ---------------------------------------------------------------------------- | ||
| * Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * ------------------------------------------------------------------------- */ | ||
|
|
||
| /* | ||
| Adds target=_blank to external links so they open in a new tab: | ||
| - noopener: prevents the new page accessing window.opener (tabnabbing protection) | ||
| - noreferrer: removes referrer info and adds extra safety | ||
| - title and aria-label: provide context for screen readers and tooltips | ||
| */ | ||
| document.addEventListener("DOMContentLoaded", function () { | ||
| document.querySelectorAll('a.external').forEach(link => { | ||
| link.setAttribute('target', '_blank'); | ||
| link.setAttribute('rel', 'noopener noreferrer'); | ||
| link.setAttribute('title', 'Opens in a new tab.'); | ||
| link.setAttribute('aria-label', 'External link: opens in a new tab'); | ||
| }); | ||
| }); | ||
|
Comment on lines
+18
to
+31
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure on preferred code/comment style for JS yet, hopefully this is ok?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine by me. We generally use eslint "standard" for JS. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,18 +239,29 @@ def generate_task_icon_modifier_rst(): | |
| 'sidebar_version_name': None, # override name in version picker | ||
| } | ||
|
|
||
| html_static_path = ['_static'] | ||
|
|
||
| # These paths are either relative to html_static_path | ||
| # or fully qualified paths (eg. https://...) | ||
| html_css_files = ['css/custom.css'] | ||
|
|
||
| # Disable timestamp otherwise inserted at bottom of every page. | ||
| html_last_updated_fmt = '' | ||
|
|
||
| # Output file base name for HTML help builder. | ||
| htmlhelp_basename = 'cylcdoc' | ||
|
|
||
| # -- Static file locations ----------------------------------------------- | ||
| html_static_path = ['_static'] | ||
|
|
||
| # These paths are either relative to html_static_path | ||
| # or fully qualified paths (eg. https://...) | ||
| # NOTE: these are added to the end of the default/theme static files, so | ||
| # will override them if there are any conflicts. | ||
|
|
||
| # Custom CSS | ||
| html_css_files = [ | ||
| 'css/custom.css', | ||
| ] | ||
|
|
||
| # Custom JS | ||
| html_js_files = [ | ||
| 'js/extern_links_new_tab.js', | ||
| ] | ||
|
Comment on lines
+248
to
+264
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved the static file settings to their own block. |
||
|
|
||
| # -- Options for LaTeX output --------------------------------------------- | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additional information for a screen reader.