g-page: modified to use an external stylesheet

This commit is contained in:
Steve Orvell
2012-11-05 18:30:04 -08:00
parent 1bfc113a79
commit 35c960804c
2 changed files with 23 additions and 12 deletions

10
src/css/g-page.css Normal file
View File

@@ -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;
}

View File

@@ -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>