Skip to content

Instantly share code, notes, and snippets.

@i8degrees
Created May 10, 2017 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i8degrees/27b34dfbf7fdfcd7862a2b118fb35ce4 to your computer and use it in GitHub Desktop.
Save i8degrees/27b34dfbf7fdfcd7862a2b118fb35ce4 to your computer and use it in GitHub Desktop.
//- partials/_safari-web-app.pug:jeff
//-
//- https://gist.github.com/kylebarrow/1042026
//- http://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window
script().
'use strict';
var script = document.createElement('script');
script.innerHTML = `(function(standalone) {
if(!standalone) {
return;
}
document.addEventListener('click', function(evt) {
var element = evt.target,
href = '';
while(!/^(a|html)$/i.test(element.nodeName)) {
element = element.parentNode;
}
if(element.getAttribute) {
href = element.getAttribute('href');
if('' !== href && '#' !== href && null !== href && (!element.protocol || element.protocol !== 'tel:')) {
evt.preventDefault();
window.location = element.href;
}
}
}, false);
}(window.navigator.standalone));`
document.head.appendChild(script);
//- HTML5 doctype
doctype html
html(lang='en')
head
append meta
meta(name='apple-mobile-web-app-capable', content='yes')
meta(name='apple-mobile-web-app-status-bar-style', content='black-translucent')
meta(name='apple-mobile-web-app-title', content='Naughty Girl | naughty.im')
include partials/_safari-web-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment