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,28 @@
{
"name": "core-label",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1"
},
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"version": "0.5.1",
"homepage": "https://github.com/Polymer/core-label",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "d68be9825ed55a5101cb23ae015306fcf270d818"
},
"_source": "git://github.com/Polymer/core-label.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/core-label"
}

View File

@@ -0,0 +1,18 @@
{
"name": "core-label",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1"
},
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"version": "0.5.1"
}

View File

@@ -0,0 +1,124 @@
<!--
@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
-->
<!--
`<core-label>` provides a version of the `<label>` element that works with Custom Elements as well as native elements.
All text in the `core-label` will be applied to the target element as a screen-reader accessible description.
There are two ways to use `core-label` to target an element:
1. place an element inside core-label with the `for` attribute:
<core-label>
Context for the Button
<paper-button for>button</paper-button>
</core-label>
2. Set the `for` attribute on the `core-label` element to point to a target element in the same scope with a query
string:
<core-label for=".foo">
Context for the button witht the "foo" class"
</core-label>
<paper-button class="foo">Far away button</paper-button>
All taps on the `core-label` will be forwarded to the "target" element.
@group Core Elements
@element core-label
@homepage github.io
-->
<link rel="import" href="../polymer/polymer.html">
<!-- Native <label> has cursor: default -->
<style>
html /deep/ core-label {
cursor: default;
}
</style>
<polymer-element name="core-label">
<script>
(function() {
var ID = 0;
function generate(node) {
if (!node.id) {
node.id = 'core-label-' + ID++;
}
return node.id;
}
Polymer('core-label', {
/**
* A query selector string for a "target" element not nested in the `<core-label>`
*
* @attribute for
* @type string
* @default ''
*/
publish: {
'for': {reflect: true, value: ''}
},
eventDelegates: {
'tap': 'tapHandler'
},
created: function() {
generate(this);
this._forElement = null;
},
ready: function() {
if (!this.for) {
this._forElement = this.querySelector('[for]');
this._tie();
}
},
tapHandler: function(ev) {
if (!this._forElement) {
return;
}
if (ev.target === this._forElement) {
return;
}
this._forElement.focus();
this._forElement.click();
this.fire('tap', null, this._forElement);
},
_tie: function() {
if (this._forElement) {
this._forElement.setAttribute('aria-labelledby', this.id);
}
},
_findScope: function() {
var n = this.parentNode;
while(n && n.parentNode) {
n = n.parentNode;
}
return n;
},
forChanged: function(oldFor, newFor) {
if (this._forElement) {
this._forElement.removeAttribute('aria-labelledby');
}
var scope = this._findScope();
if (!scope) {
return;
}
this._forElement = scope.querySelector(newFor);
if (this._forElement) {
this._tie();
}
}
});
})();
</script>
</polymer-element>

View File

@@ -0,0 +1,147 @@
<!DOCTYPE html>
<!--
@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
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Core Label</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="core-label.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../paper-slider/paper-slider.html">
<link rel="import" href="../paper-button/paper-button.html">
</head>
<body>
<label>regular label<input type="checkbox"></label>
<br>
<label>regular label 2<input></label>
<br>
<label>
a
<input>
b
</label>
<br>
<label for="native">
hi
</label>
<button id="native">hello</button>
<br>
<label>
a
<button>b</button>
c
</label>
<hr>
<core-label>
label next to checkbox
<input for type="checkbox">
something
</core-label>
<br>
<core-label for="#quux">
label for checkbox
</core-label>
<input id="quux" type="checkbox">
<br>
<core-label for="#foo">
<img src="http://placehold.it/200x200" alt="200x200 placeholder image">
image (with alt attribute) label
</core-label>
<input id="foo" type="checkbox">
<br>
<core-label for=".bar">
label for a class .bar
</core-label>
<input class="bar" type="checkbox">
<br>
<core-label>
input label
<input for>
</core-label>
<br>
<core-label>
paper checkbox
<paper-checkbox for></paper-checkbox>
</core-label>
<br>
<core-label>
paper slider
<paper-slider min="0" max="100" value="50" for></paper-slider>
</core-label>
<br>
<core-label>
input type range
<input type="range" for>
</core-label>
<br>
<core-label>
a
<input type="text" for>
b
</core-label>
<br>
<core-label>
c
<button for>hi</button>
d
</core-label>
<br>
<core-label>
label this button
<paper-button for>labelled by parent</paper-button>
</core-label>
<br>
<core-label for=".two">
Hi!
</core-label>
<button class="one">sup</button>
<button class="two">whazzup</button>
</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>