Added Polymer

This commit is contained in:
Thaum
2014-11-26 10:18:35 +00:00
parent 5eea4714b2
commit 3408ba9e8d
1210 changed files with 394645 additions and 47 deletions

View File

@@ -0,0 +1,23 @@
{
"name": "sampler-scaffold",
"private": true,
"dependencies": {
"core-drawer-panel": "Polymer/core-drawer-panel#^0.5.0",
"core-header-panel": "Polymer/core-header-panel#^0.5.0",
"core-icon-button": "Polymer/core-icon-button#^0.5.0",
"core-item": "Polymer/core-item#^0.5.0",
"core-menu": "Polymer/core-menu#^0.5.0",
"core-toolbar": "Polymer/core-toolbar#^0.5.0"
},
"version": "0.5.1",
"homepage": "https://github.com/Polymer/sampler-scaffold",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "0e24e1c606ad13a10e618477e2ac964ab999c55f"
},
"_source": "git://github.com/Polymer/sampler-scaffold.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/sampler-scaffold"
}

View File

@@ -0,0 +1,4 @@
sampler-scaffold
================
See the [component page](http://polymer.github.io/sampler-scaffold) for more information.

View File

@@ -0,0 +1,13 @@
{
"name": "sampler-scaffold",
"private": true,
"dependencies": {
"core-drawer-panel": "Polymer/core-drawer-panel#^0.5.0",
"core-header-panel": "Polymer/core-header-panel#^0.5.0",
"core-icon-button": "Polymer/core-icon-button#^0.5.0",
"core-item": "Polymer/core-item#^0.5.0",
"core-menu": "Polymer/core-menu#^0.5.0",
"core-toolbar": "Polymer/core-toolbar#^0.5.0"
},
"version": "0.5.1"
}

View File

@@ -0,0 +1,54 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
<title>sampler-scaffold</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="sampler-scaffold.html">
<link rel="import" href="../core-item/core-item.html">
<style>
body {
font-family: 'Helvetica Neue', Helvetica, Arial;
margin: 0;
}
section {
padding: 40px;
min-height: 300px;
}
</style>
</head>
<body unresolved>
<sampler-scaffold label="HTML Input Elements">
<core-item label="String" url="demos/string.html"></core-item>
<core-item label="Checkbox" url="demos/checkbox.html"></core-item>
<core-item label="Radio" url="demos/radio.html"></core-item>
<core-item label="Range" url="demos/range.html"></core-item>
<core-item label="Color" url="demos/color.html"></core-item>
</sampler-scaffold>
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
</head>
<body>
<input type="checkbox">
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
</head>
<body>
<input type="color">
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
</head>
<body>
<input type="radio">
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
</head>
<body>
<input type="range">
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
</head>
<body>
<input>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>

View File

@@ -0,0 +1,158 @@
/*
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
#drawerPanel, [drawer] {
background-color: #eee;
}
[drawer] {
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
[main] {
height: 100%;
}
core-toolbar {
background-color: #5264ae;
color: #fff;
font-size: 20px;
font-weight: 400;
}
core-toolbar.medium-tall {
height: 144px;
}
core-toolbar::shadow #bottomBar {
height: 80px;
}
.main-label {
padding: 0 0 20px 60px;
}
/* menu */
core-menu#menu {
padding: 8px 0;
margin: 0;
}
/* menu item */
polyfill-next-selector { content: 'core-menu#menu core-item'; }
::content core-item, ::content core-submenu::shadow core-item {
height: 56px;
padding-left: 60px;
font-size: 15px;
color: #444;
font-weight: normal !important;
}
polyfill-next-selector { content: 'core-menu#menu core-item.core-selected'; }
::content core-item.core-selected {
background-color: #dedede;
}
/* card */
#card {
display: block;
margin: 64px 120px 60px 5px;
background-color: #fff;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
border-radius: 2px;
overflow: hidden;
}
#card[hidden] {
display: none;
}
#card.move-up {
transition: -webkit-transform 0.38s cubic-bezier(0.4, 0.0, 0.2, 1);
transition: transform 0.38s cubic-bezier(0.4, 0.0, 0.2, 1);
}
polyfill-next-selector { content: '.sourceButton';}
::content .sourceButton {
position: absolute;
z-index: 1;
}
polyfill-next-selector { content: '.sourceButton:not(.fallback)';}
::content .sourceButton:not(.fallback) {
background-color: #fcfcfc;
color: #666464;
bottom: -28px;
right: 24px;
}
polyfill-next-selector { content: '.sourceButton.fallback';}
::content .sourceButton.fallback {
right: 24px;
top: 13px;
}
polyfill-next-selector { content: '#drawerPanel[narrow] .sourceButton:not(.fallback)';}
#drawerPanel[narrow] ::content .sourceButton:not(.fallback) {
right: 8px;
}
polyfill-next-selector { content: '#drawerPanel:not([narrow]) .menuButton';}
#drawerPanel:not([narrow]) ::content .menuButton {
display: none;
}
.element-label {
height: 80px;
line-height: 80px;
padding-left: 24px;
background-color: #fff;
letter-spacing: 0.05em;
font-size: 24px;
font-weight: 400;
color: #5265a2;
}
#frame {
display: block;
width: 100%;
min-height: 600px;
border: none;
}
/* narrow layout */
#drawerPanel[narrow] [main] {
background-color: #fff;
}
#drawerPanel[narrow] #card {
margin: 0;
box-shadow: none;
position: absolute;
top: 0px;
right: 0;
bottom: 0;
left: 0;
}
#drawerPanel[narrow] #frame {
position: absolute;
min-height: 100%;
}
#drawerPanel[narrow] #frameContainer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: auto;
}

View File

@@ -0,0 +1,224 @@
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!--
`sampler-scaffold` provides a responsive layout for elements sampler.
Exampler:
<sampler-scaffold label="HTML Input Elements">
<core-item label="String" url="demos/string.html"></core-item>
<core-item label="Checkbox" url="demos/checkbox.html"></core-item>
<core-item label="Radio" url="demos/radio.html"></core-item>
<core-item label="Range" url="demos/range.html"></core-item>
<core-item label="Color" url="demos/color.html"></core-item>
</sampler-scaffold>
Use `label` to set the sampler label and `responsiveWidth` to change the layout
of the scaffold.
@element sampler-scaffold
@homepage github.io
-->
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<polymer-element name="sampler-scaffold" attributes="label responsiveWidth">
<template>
<link rel="stylesheet" href="sampler-scaffold.css">
<core-drawer-panel id="drawerPanel" narrow="{{narrow}}" drawerWidth="320px" responsiveWidth="{{responsiveWidth}}">
<core-header-panel id="mainHeaderPanel" main mode="{{narrow ? 'waterfall' : 'cover'}}" shadow>
<core-toolbar class="{{ {'medium-tall' : !narrow} | tokenList }}">
<content select=".menuButton" on-tap="{{togglePanel}}">
<core-icon-button class="menuButton fallback" icon="menu"></core-icon-button>
</content>
<div hidden?="{{!narrow}}">{{item.label}}</div>
<content select=".sourceButton" on-tap="{{viewSourceAction}}">
<core-icon-button class="sourceButton fallback" icon="launch"></core-icon-button>
</content>
</core-toolbar>
<div id="card" on-transitionend="{{cardTransitionDone}}" hidden?="{{!item}}">
<div class="element-label" hidden?="{{narrow}}">{{item.label}}</div>
<div id="frameContainer">
<iframe id="frame" on-load="{{frameLoaded}}"></iframe>
</div>
</div>
</core-header-panel>
<core-header-panel drawer>
<core-toolbar class="{{ {'medium-tall' : !narrow} | tokenList }}">
<div class="bottom main-label fit">{{label}}</div>
</core-toolbar>
<core-menu id="menu" on-core-select="{{menuSelect}}">
<content></content>
</core-menu>
</core-header-panel>
</core-drawer-panel>
</template>
<script>
Polymer('sampler-scaffold', {
/**
* When the browser window size is smaller than the `responsiveWidth`,
* `sampler-scaffold` changes to a narrow layout. In narrow layout,
* the drawer will be stacked on top of the main panel.
*
* @attribute responsiveWidth
* @type string
*/
responsiveWidth: '860px',
/**
* Sampler label.
*
* @attribute label
* @type string
*/
ready: function() {
this.boundResizeFrame = this.resizeFrame.bind(this);
window.addEventListener('resize', this.updateFrameHeight.bind(this));
window.addEventListener('hashchange', this.parseLocationHash.bind(this));
},
domReady: function() {
this.async(function() {
this.parseLocationHash();
}, null, 300);
},
parseLocationHash: function() {
var route = window.location.hash.slice(1);
for (var i = 0, item; item = this.$.menu.items[i]; i++) {
if (item.getAttribute('tag') === route) {
this.$.menu.selected = i;
return;
}
}
this.$.menu.selected = this.$.menu.selected || 0;
},
menuSelect: function(e, detail) {
if (detail.isSelected) {
this.item = detail.item;
if (this.item.children.length) {
this.item.selected = 0;
}
this.item.tag = this.item.getAttribute('tag');
var url = this.item.getAttribute('url');
this.$.frame.contentWindow.location.replace(url);
window.location.hash = this.item.tag;
if (this.narrow) {
this.$.drawerPanel.closeDrawer();
} else {
this.animateCard();
}
}
},
animateCard: function() {
this.$.card.classList.remove('move-up');
this.$.card.style.display = 'none';
this.async(function() {
this.$.card.style.display = 'block';
this.moveCard(this.$.mainHeaderPanel.offsetHeight);
this.async(function() {
this.$.card.classList.add('move-up');
this.moveCard(null);
}, null, 300);
});
},
moveCard: function(y) {
var s = this.$.card.style;
s.webkitTransform = s.transform =
y ? 'translate3d(0, ' + y + 'px,0)' : '';
},
cardTransitionDone: function() {
if (this.$.card.classList.contains('move-up')) {
this.$.card.classList.remove('move-up');
this.updateFrameHeight();
}
},
togglePanel: function() {
this.$.drawerPanel.togglePanel();
},
frameLoaded: function() {
if (!this.item) {
return;
}
this.$.frame.contentWindow.addEventListener('polymer-ready', function() {
setTimeout(this.updateFrameHeight.bind(this), 100);
this.$.frame.contentWindow.addEventListener('core-resize',
this.boundResizeFrame, false);
}.bind(this));
},
resizeFrame: function() {
this.job('resizeFrame', function() {
this.updateFrameHeight();
});
},
updateFrameHeight: function() {
var frame = this.$.frame;
var doc = frame.contentDocument;
if (doc) {
var docElt = doc.documentElement;
// TODO(ffu); expose scroll info from header-panel
var pos = this.$.mainHeaderPanel.$.mainContainer.scrollTop;
frame.style.height = 'auto';
frame.style.height = docElt.scrollHeight + 'px';
if (doc.body) {
var s = doc.body.style;
s.overflow = 'hidden';
// to avoid the 'blinking bug'
// https://code.google.com/p/chromium/issues/detail?id=332024
s.webkitTransform = s.transform = 'translateZ(0)';
}
this.$.mainHeaderPanel.$.mainContainer.scrollTop = pos;
}
},
viewSourceAction: function() {
window.open('view-source:' + this.$.frame.contentWindow.location.href,
this.item.tag);
}
});
</script>
</polymer-element>