-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
132 lines (107 loc) · 4.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>RWD and Web Components</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<!-- 1. Load platform support before any code that touches the DOM. -->
<script src="vendor/bower/webcomponentsjs/webcomponents.min.js"></script>
<!-- 2. Load the component using an HTML Import -->
<!--Doesn't work: <link media="screen and (max-width: 767px)" rel="import" href="components/components320/mobile-navigation.html">
<link media="screen and (min-width: 768px)" rel="import" href="components/components768/main-navigation.html">-->
<script>
function matchComponent () {
// Set Media Queries
var isDesktop = window.matchMedia('(min-width: 640px)');
var isMobile = window.matchMedia('(max-width: 640px)');
// Create link and settings
var link = document.createElement('link');
link.rel = 'import';
// Create Nav Elements
var navLink = link;
navLink.id = 'navLink';
var linkTarget = document.getElementById('navLink');
var navDesktopElement = document.createElement('main-navigation');
var navMobileElement = document.createElement('mobile-navigation');
navDesktopElement.id = 'NavElem';
navMobileElement.id = 'NavElem';
var navTarget = document.getElementById('NavElem');
if (isMobile.matches) {
navTarget.parentNode.removeChild(navTarget);
document.querySelector('.nav').appendChild(navMobileElement);
navLink.href = 'components/mobile-navigation.html';
if (document.contains(linkTarget)) {
linkTarget.parentNode.removeChild(linkTarget);
}
document.head.appendChild(navLink);
} else {
navTarget.parentNode.removeChild(navTarget);
document.querySelector('.nav').appendChild(navDesktopElement);
navLink.href = 'components/main-navigation.html';
if (document.contains(linkTarget)) {
linkTarget.parentNode.removeChild(linkTarget);
}
document.head.appendChild(navLink);
}
}
// Init
function initRwdComponents() {
var myEfficientFn = debounce(function() {
matchComponent();
}, 100);
window.addEventListener('load', matchComponent);
// Triggering resize just once (http://davidwalsh.name/javascript-debounce-function)
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
// Resize Listener
window.addEventListener('resize', myEfficientFn);
}
initRwdComponents();
</script>
<style type="text/css">
/* Above-The-Fold-Styles go here */
</style>
<!-- If IE8 should be supported, anyway -->
<!--[if lt IE 9]>
<script src="vendor/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<header class="header" role="banner"></header>
<nav class="nav" role="navigation">
<main-navigation id="NavElem"></main-navigation>
</nav>
<main role="main">
<h1>Lorem ipsum dolor.</h1>
</main>
<aside class="aside" role="complementary"></aside>
<footer class="footer" role="contentinfo"></footer>
<!-- Get customized modernizr from http://modernizr.com/download/ -->
<script src="vendor/modernizr.custom.67687.js"></script>
<!-- adjust jQuery version for googleapis file -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="vendor/bower/jquery/dist/jquery.min.js"><\/script>')</script>
<script src="js/app.js"></script>
<!--<script src="js-min/app.pkgd.js"></script>-->
<!-- Load Stylesheets asynchronous (lend from https://css-tricks.com/authoring-critical-fold-css/) -->
<script>function loadCSS(e){var n=window.document.createElement("link"),t=window.document.getElementsByTagName("head")[0];n.rel="stylesheet",n.href=e,n.media="only x",t.parentNode.insertBefore(n,t),setTimeout(function(){n.media="all"},0)}loadCSS("css/app.css");/*loadCSS('css-min/app.css');*/</script>
<noscript>
<link rel="stylesheet" href="css/app.css">
<!--<link rel="stylesheet" href="css-min/app.css">-->
</noscript>
</body>
</html>