Refactor browser check.

This commit is contained in:
Lars Jung 2015-05-16 21:36:05 +02:00
parent 8d3611e30c
commit 0a843a0b1f
5 changed files with 38 additions and 30 deletions

View file

@ -2,28 +2,25 @@ block init
<?php header('Content-type: text/html;charset=utf-8'); ?>
doctype html
<!--[if lt IE 10]><html class='no-js no-browser' lang='en'><![endif]-->
<!--[if gt IE 9]><!--><html class='no-js browser' lang='en'><!--<![endif]-->
html(class='no-js', lang='en')
head
meta(charset='utf-8')
meta(http-equiv='x-ua-compatible', content='ie=edge')
title #{title}
meta(name='description', content='#{title}')
meta(name='viewport', content='width=device-width, initial-scale=1')
link(rel='shortcut icon', href!='<?= $public_href; ?>images/favicon/favicon-16-32.ico')
link(rel='apple-touch-icon-precomposed', type='image/png', href!='<?= $public_href; ?>images/favicon/favicon-152.png')
link(rel='stylesheet', href!='<?= $public_href; ?>css/styles.css')
script(src!='<?= $public_href; ?>js/scripts.js', data-module='#{module}')
<?= $x_head_tags; ?>
head
meta(charset='utf-8')
meta(http-equiv='x-ua-compatible', content='ie=edge')
title #{title}
meta(name='description', content='#{title}')
meta(name='viewport', content='width=device-width, initial-scale=1')
link(rel='shortcut icon', href!='<?= $public_href; ?>images/favicon/favicon-16-32.ico')
link(rel='apple-touch-icon-precomposed', type='image/png', href!='<?= $public_href; ?>images/favicon/favicon-152.png')
link(rel='stylesheet', href!='<?= $public_href; ?>css/styles.css')
script(src!='<?= $public_href; ?>js/scripts.js', data-module='#{module}')
<?= $x_head_tags; ?>
body#root(class='#{module}')
body#root(class='#{module}')
div#fallback-hints
span.noJsMsg Works best with JavaScript enabled!
span.noBrowserMsg Works best in #[a(href='http://browsehappy.com') modern browsers]!
span.backlink #[a(href='#{pkg.homepage}', title='#{pkg.name} v#{pkg.version} - #{pkg.description}') powered by #{pkg.name}]
div#fallback-hints
span.noJsMsg Works best with JavaScript enabled!
span.noBrowserMsg Works best in #[a(href='http://browsehappy.com') modern browsers]!
span.backlink #[a(href='#{pkg.homepage}', title='#{pkg.name} v#{pkg.version} - #{pkg.description}') powered by #{pkg.name}]
block body
</html>
block body

View file

@ -88,6 +88,7 @@
}
.noJsMsg, .noBrowserMsg {
display: none;
margin: 0 16px;
color: @col-error;
}
@ -104,10 +105,10 @@ html.no-js, html.no-browser {
}
}
html.js .noJsMsg {
display: none;
html.no-js .noJsMsg {
display: inline !important;
}
html.browser .noBrowserMsg {
display: none;
html.no-browser .noBrowserMsg {
display: inline !important;
}

View file

@ -1,6 +1,7 @@
#sidebar {
display: none;
overflow: auto;
overflow-x: hidden;
overflow-y: auto;
flex: 0 0 auto;
order: 0;
background: @col-back-panel;

View file

@ -1,9 +1,5 @@
modulejs.define('boot', ['$', 'core/server'], function ($, server) {
if ($('html').hasClass('no-browser')) {
return;
}
var module = $('script[data-module]').data('module');
var data = {action: 'get', setup: true, options: true, types: true};

View file

@ -1,3 +1,14 @@
(function () {
if (function () {
var div = document.createElement('div');
div.innerHTML = '<!--[if lt IE 10]><br><![endif]-->';
return div.getElementsByTagName('br').length;
}()) {
document.documentElement.className = 'js no-browser';
return;
}
// @include "lib/modernizr-*.js"
// @include "lib/jquery-*.js"
// @include "lib/jquery.*.js"
@ -20,3 +31,5 @@
modulejs.require('boot');
}());
}());