]> git.mxchange.org Git - friendica.git/commitdiff
Fix Issue #2800 - Prevent internal links to switch to Safari in standalone mode
authorHypolite Petovan <ben.lort@gmail.com>
Sat, 1 Oct 2016 22:19:43 +0000 (18:19 -0400)
committerHypolite Petovan <ben.lort@gmail.com>
Sat, 1 Oct 2016 22:19:43 +0000 (18:19 -0400)
Add a event delegation to keep internal links inside the standalone
window.

Fixes 1. of #2800

view/templates/head.tpl

index 70add44c2f72580bc5c5c618d8a58ef2d99f5035..fe14a29dcdd40f5998f4e401293b28a8944e39a6 100644 (file)
 <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]>