Created
October 12, 2014 09:11
-
-
Save mike-zarandona/41606f4c7e25b7cff88d to your computer and use it in GitHub Desktop.
Two `<meta/>` tags and a `<script/>` tag to allow iOS users to use the "Add to Home Screen" function in Mobile Safari. This is convenient in maximizing screen real estate when composing in `/admin`. This is a modification to `/admin/themes/ascent/layouts/default.php`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$current_user = Auth::getCurrentMember(); | |
$name = $current_user->get('name'); | |
?><!doctype html> | |
<html lang="<?php echo Config::getCurrentLanguage(); ?>"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> | |
<title>Statamic Control Panel</title> | |
<link rel="stylesheet" href="<?php echo Path::tidy(Config::getSiteRoot().'/'.$app->config['theme_path']) ?>css/ascent.min.css"> | |
<link rel="shortcut icon" href="<?php print Path::tidy(Config::getSiteRoot().'/'.$app->config['theme_path'])?>img/favicon.ico" /> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black"> | |
<script> | |
var transliterate = <?php echo json_encode(Config::get('custom_transliteration', array())); ?>; | |
</script> | |
<script> | |
var content_type = "<?php echo Config::getContentType(); ?>"; | |
</script> | |
<script type="text/javascript" src="<?php echo Path::tidy(Config::getSiteRoot().'/'.$app->config['theme_path'])?>js/ascent.min.js?v=1.8.2"></script> | |
<?php echo Hook::run('control_panel', 'add_to_head', 'cumulative') ?> | |
<script> | |
// http://stanhub.com/how-to-prevent-ios-standalone-mode-web-apps-from-opening-links-in-safari/ | |
if(("standalone" in window.navigator) && window.navigator.standalone){ | |
var noddy, remotes = false; | |
document.addEventListener('click', function(event) { | |
noddy = event.target; | |
while(noddy.nodeName !== "A" && noddy.nodeName !== "HTML") { | |
noddy = noddy.parentNode; | |
} | |
if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 || remotes)) { | |
event.preventDefault(); | |
document.location.href = noddy.href; | |
} | |
},false); | |
} | |
</script> | |
</head> | |
<body id="<?php echo $route; ?>"> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lines 12 + 13 were added to enable the web app (https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW1)
Line 22 was added to keep links inside the mobile webapp (http://stanhub.com/how-to-prevent-ios-standalone-mode-web-apps-from-opening-links-in-safari/)