Skip to content

Commit

Permalink
Add icon and note for external links
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMc1089 committed Sep 9, 2024
1 parent d17ee8d commit a003602
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 4 additions & 2 deletions R/nhs_footer.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ nhs_footer <- function() {
style = "text-decoration: underline;",
href = "https://www.nhsbsa.nhs.uk/accessibility-statement-website-estimated-prescribing-patterns-care-home-patients-aged-65-years-or",
target = "_blank",
"Accessibility statement"
"Accessibility statement",
icon("up-right-from-square")
)
),
tags$li(
Expand All @@ -41,7 +42,8 @@ nhs_footer <- function() {
style = "text-decoration: underline;",
href = "https://github.com/nhsbsa-data-analytics/care-home-prescribing-2020-2023",
target = "_blank",
"GitHub"
"GitHub",
icon("up-right-from-square")
)
)
),
Expand Down
29 changes: 14 additions & 15 deletions inst/app/www/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ $(document).ready(function () {
window.scrollTo(0, 0);
});

// Add new tab icon for external links and set to open in new tab
var links = $("a[target!=_blank]");
links.each(function(){
var a = $(this);
if (
!a.attr('href').match(/^mailto\:/)
&& (a[0].hostname != window.location.hostname)
&& !a.attr('href').match(/^javascript\:/)
&& !a.attr('href').match(/^$/)
) {
a.after('&nbsp;<i class="fa-solid fa-arrow-up-right-from-square"></i>');
a.attr('target', '_blank');
}
});

// Remove aria attributes from anchor tags to prevent accessibility issues
var observer = new MutationObserver(function(mutations) {
Expand All @@ -25,21 +39,6 @@ $(document).ready(function () {
});


// Add target='_blank' to external links so they open a new tab
$(document.body).on('mouseover', 'a[target!=_blank]:not(.local)', function (e) {
var a = $(this);
if (
!a.attr('href').match(/^mailto\:/)
&& (a[0].hostname != window.location.hostname)
&& !a.attr('href').match(/^javascript\:/)
&& !a.attr('href').match(/^$/)
) {
a.attr('target', '_blank');
} else {
a.addClass('local');
}
});

// Handle clicks on mod_06 datatable, to outline selected map region
Shiny.addCustomMessageHandler("rowClicked",
function(message) {
Expand Down
1 change: 1 addition & 0 deletions inst/markdown/15_updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ In this section we will give details of any updates to the report since it's ini
* 09-11-2023: Addition of total items and total cost in the BNF-level analyses.
* 10-11-2023: Added rounding details in all chart captions.
* 10-11-2023: Pre-compute data download for _BNF-level prescribing estimates by geography_ charts and table.
* 09-09-2024: Note that links to external URLs will open in a new tab. An icon indicating this will be at the end of such links.

0 comments on commit a003602

Please sign in to comment.