Skip to content

Commit

Permalink
Merge pull request #35 from sorvell/master
Browse files Browse the repository at this point in the history
g-page: use external stylesheet
  • Loading branch information
frankiefu committed Nov 6, 2012
2 parents 73d5ef5 + 251f742 commit a4126f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
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

0 comments on commit a4126f7

Please sign in to comment.