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
This commit is contained in:
Hypolite Petovan 2016-10-01 18:19:43 -04:00
parent 82dcc3fe79
commit f302f66dcd

View file

@ -19,6 +19,10 @@
<link rel="apple-touch-icon" href="{{$touch_icon}}"/>
<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"