Skip to content

Instantly share code, notes, and snippets.

@mike-zarandona
Created October 12, 2014 09:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mike-zarandona/41606f4c7e25b7cff88d to your computer and use it in GitHub Desktop.
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`
<?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