From f302f66dcdbd5f7eb0a1a5deb0e8642cf4457abc Mon Sep 17 00:00:00 2001 From: Hypolite Petovan <ben.lort@gmail.com> Date: Sat, 1 Oct 2016 18:19:43 -0400 Subject: [PATCH 1/3] Fix Issue #2800 - Prevent internal links to switch to Safari in standalone mode Add a event delegation to keep internal links inside the standalone window. Fixes 1. of #2800 --- view/templates/head.tpl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/view/templates/head.tpl b/view/templates/head.tpl index 70add44c2f..fe14a29dcd 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -18,12 +18,16 @@ <link rel="shortcut icon" href="{{$shortcut_icon}}" /> <link rel="apple-touch-icon" href="{{$touch_icon}}"/> -<meta name="apple-mobile-web-app-capable" content="yes" /> +<meta name="apple-mobile-web-app-capable" content="yes" /> +<script> +// Prevents links to switch to Safari in a home screen app +(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(chref=d.href).replace(e.href,"").indexOf("#")&&(!/^[a-z\+\.\-]+:/i.test(chref)||chref.indexOf(e.protocol+"//"+e.host)===0)&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone"); +</script> <link rel="search" - href="{{$baseurl}}/opensearch" - type="application/opensearchdescription+xml" + href="{{$baseurl}}/opensearch" + type="application/opensearchdescription+xml" title="Search in Friendica" /> <!--[if IE]> From 4242c3f749b56e1985c8998409af7b17b9e4bb86 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan <ben.lort@gmail.com> Date: Sat, 1 Oct 2016 18:53:25 -0400 Subject: [PATCH 2/3] Fix Issue #2800 - Prevent internal link from switching to Safari in standalone mode - Add link switch prevention to frio theme - Add reference to the script page --- view/templates/head.tpl | 3 +-- view/theme/frio/templates/head.tpl | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/view/templates/head.tpl b/view/templates/head.tpl index fe14a29dcd..cd6bc52a0f 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -20,11 +20,10 @@ <meta name="apple-mobile-web-app-capable" content="yes" /> <script> -// Prevents links to switch to Safari in a home screen app +// Prevents links to switch to Safari in a home screen app - see https://gist.github.com/irae/1042167 (function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(chref=d.href).replace(e.href,"").indexOf("#")&&(!/^[a-z\+\.\-]+:/i.test(chref)||chref.indexOf(e.protocol+"//"+e.host)===0)&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone"); </script> - <link rel="search" href="{{$baseurl}}/opensearch" type="application/opensearchdescription+xml" diff --git a/view/theme/frio/templates/head.tpl b/view/theme/frio/templates/head.tpl index e52ebe49fe..f49b3045f4 100644 --- a/view/theme/frio/templates/head.tpl +++ b/view/theme/frio/templates/head.tpl @@ -39,11 +39,15 @@ <link rel="shortcut icon" href="{{$shortcut_icon}}" /> <link rel="apple-touch-icon" href="{{$touch_icon}}"/> -<meta name="apple-mobile-web-app-capable" content="yes" /> +<meta name="apple-mobile-web-app-capable" content="yes" /> +<script> +// Prevents links to switch to Safari in a home screen app - see https://gist.github.com/irae/1042167 +(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(chref=d.href).replace(e.href,"").indexOf("#")&&(!/^[a-z\+\.\-]+:/i.test(chref)||chref.indexOf(e.protocol+"//"+e.host)===0)&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone"); +</script> <link rel="search" - href="{{$baseurl}}/opensearch" - type="application/opensearchdescription+xml" + href="{{$baseurl}}/opensearch" + type="application/opensearchdescription+xml" title="Search in Friendica" /> From 0094dd824018b8f972bdb1f090c996ebfb7c9b36 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan <ben.lort@gmail.com> Date: Sat, 1 Oct 2016 19:03:32 -0400 Subject: [PATCH 3/3] Remove repeated comment in frio notification template --- view/theme/frio/templates/nav.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/frio/templates/nav.tpl b/view/theme/frio/templates/nav.tpl index 497b8db979..b3dc0b29df 100644 --- a/view/theme/frio/templates/nav.tpl +++ b/view/theme/frio/templates/nav.tpl @@ -275,7 +275,7 @@ {{*The second part of the notifications dropdown menu. It handles the notifications *}} {{if $nav.notifications}} -<ul id="nav-notifications-template" class="media-list" style="display:none;" rel="template"> <!-- needs further investigation. I thought the notifications have their own templates --> +<ul id="nav-notifications-template" class="media-list" style="display:none;" rel="template"> <li class="{4} notif-entry"> <div class="notif-entry-wrapper media"> <div class="notif-photo-wrapper media-object pull-left"><a href="{6}"><img data-src="{1}"></a></div>