From 06898e6db472660256869be1da97c07804818a57 Mon Sep 17 00:00:00 2001 From: Joris Vervuurt Date: Fri, 8 Dec 2017 18:31:47 +0100 Subject: [PATCH 1/2] iOS Web App: prevent same-window links from being opened externally By default, iOS Web Apps open any link (`` tag) in an external browser. This happens even when the `target` attribute isn't set to `_blank`. This change prevents links targetting the same window from being opened externally. They are instead opened within the Web App itself. --- dsmr_frontend/templates/dsmr_frontend/base.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dsmr_frontend/templates/dsmr_frontend/base.html b/dsmr_frontend/templates/dsmr_frontend/base.html index 8b3d83b16..2083c11ec 100644 --- a/dsmr_frontend/templates/dsmr_frontend/base.html +++ b/dsmr_frontend/templates/dsmr_frontend/base.html @@ -164,12 +164,19 @@ - {% block javascript %} + {% block javascript %} - - + {% endblock %} \ No newline at end of file From 0f5eb8098bf35a5d6ec4fbcf5a83b33e3d26bf04 Mon Sep 17 00:00:00 2001 From: Joris Vervuurt Date: Sat, 9 Dec 2017 14:04:18 +0100 Subject: [PATCH 2/2] Moved global JavaScript to a separate file (for caching purposes) --- dsmr_frontend/static/dsmr_frontend/js/global.js | 7 +++++++ dsmr_frontend/templates/dsmr_frontend/base.html | 10 +--------- 2 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 dsmr_frontend/static/dsmr_frontend/js/global.js diff --git a/dsmr_frontend/static/dsmr_frontend/js/global.js b/dsmr_frontend/static/dsmr_frontend/js/global.js new file mode 100644 index 000000000..9bb4f9f0e --- /dev/null +++ b/dsmr_frontend/static/dsmr_frontend/js/global.js @@ -0,0 +1,7 @@ +$('a').click(function(event) { + // When DSMR Reader is ran as a standalone iOS Web App, prevent links targetting the same window from being opened externally. + if (navigator.standalone === true && $(this).attr('target') !== '_blank') { + event.preventDefault(); + location.href = $(this).attr('href'); + } +}); \ No newline at end of file diff --git a/dsmr_frontend/templates/dsmr_frontend/base.html b/dsmr_frontend/templates/dsmr_frontend/base.html index 2083c11ec..d2f54a91b 100644 --- a/dsmr_frontend/templates/dsmr_frontend/base.html +++ b/dsmr_frontend/templates/dsmr_frontend/base.html @@ -168,15 +168,7 @@ - + {% endblock %} \ No newline at end of file