Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g-page: use external stylesheet #35

Merged
merged 2 commits into from
Nov 6, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/css/g-page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright 2012 The Toolkitchen Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
html, body {
height: 100%;
margin: 0;
font-family: 'Helvetica Nue', 'Helvetica', Arial, 'open sans' sans-serif;
}
25 changes: 13 additions & 12 deletions src/g-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
* license that can be found in the LICENSE file.
*/
-->
<element name="g-page">
<element name="g-page" attributes="nofit">
<link rel="components" href="g-component.html">
<link rel="stylesheet" href="css/g-page.css" />
<template>
<content></content>
</template>
<script>
this.component({
shadowRootCreated: function() {
this.makeFittable();
shadowRootCreated: function(inRoot) {
this.makeFittable(inRoot);
},
prototype: {
makeFittable: function() {
var sheet = document.querySelector('style[fittable]');
makeFittable: function(inRoot) {
var sheet = document.querySelector('style[g-page]');
if (!sheet) {
sheet = document.createElement('style');
sheet.setAttribute('fittable', '');
sheet.textContent = 'html, body { ' +
'height: 100%;' +
'margin: 0;' +
'}';
sheet = inRoot.querySelector('style');
sheet.setAttribute('g-page', '');
sheet.removeAttribute('scoped');
document.head.appendChild(sheet);
}
if (!this.nofit) {
sheet.textContent += '\n' + this.tagName.toLowerCase() + ' {height: 100%;}\n';
}
}

}
});
</script>
Expand Down