polymer-neon-rails 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/app/assets/components/iron-flex-layout/README.md +4 -0
- data/app/assets/components/iron-flex-layout/bower.json +21 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/demo/index.html +40 -0
- data/app/assets/components/iron-flex-layout/demo/x-app.html +106 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-meta/README.md +46 -0
- data/app/assets/components/iron-meta/bower.json +28 -0
- data/app/assets/components/iron-meta/demo/index.html +45 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/index.html +27 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-meta/test/basic.html +48 -0
- data/app/assets/components/iron-meta/test/index.html +30 -0
- data/app/assets/components/iron-meta/test/iron-meta.html +186 -0
- data/app/assets/components/iron-resizable-behavior/README.md +16 -0
- data/app/assets/components/iron-resizable-behavior/bower.json +26 -0
- data/app/assets/components/iron-resizable-behavior/demo/index.html +29 -0
- data/app/assets/components/iron-resizable-behavior/demo/src/x-app.html +114 -0
- data/app/assets/components/iron-resizable-behavior/index.html +25 -0
- data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
- data/app/assets/components/iron-resizable-behavior/test/basic.html +263 -0
- data/app/assets/components/iron-resizable-behavior/test/index.html +31 -0
- data/app/assets/components/iron-resizable-behavior/test/test-elements.html +143 -0
- data/app/assets/components/iron-selector/README.md +50 -0
- data/app/assets/components/iron-selector/bower.json +31 -0
- data/app/assets/components/iron-selector/demo/index.html +66 -0
- data/app/assets/components/iron-selector/index.html +28 -0
- data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
- data/app/assets/components/iron-selector/iron-selectable.html +307 -0
- data/app/assets/components/iron-selector/iron-selection.html +115 -0
- data/app/assets/components/iron-selector/iron-selector.html +71 -0
- data/app/assets/components/iron-selector/test/activate-event.html +138 -0
- data/app/assets/components/iron-selector/test/basic.html +150 -0
- data/app/assets/components/iron-selector/test/content-element.html +43 -0
- data/app/assets/components/iron-selector/test/content.html +168 -0
- data/app/assets/components/iron-selector/test/index.html +36 -0
- data/app/assets/components/iron-selector/test/multi.html +135 -0
- data/app/assets/components/iron-selector/test/next-previous.html +134 -0
- data/app/assets/components/iron-selector/test/selected-attribute.html +72 -0
- data/app/assets/components/iron-selector/test/template-repeat.html +110 -0
- data/app/assets/components/neon-animation/README.md +304 -0
- data/app/assets/components/neon-animation/animations/cascaded-animation.html +84 -0
- data/app/assets/components/neon-animation/animations/fade-in-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/fade-out-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/hero-animation.html +83 -0
- data/app/assets/components/neon-animation/animations/opaque-animation.html +46 -0
- data/app/assets/components/neon-animation/animations/ripple-animation.html +92 -0
- data/app/assets/components/neon-animation/animations/scale-down-animation.html +65 -0
- data/app/assets/components/neon-animation/animations/scale-up-animation.html +58 -0
- data/app/assets/components/neon-animation/animations/slide-down-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-from-left-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-from-right-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-left-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-right-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-up-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/transform-animation.html +61 -0
- data/app/assets/components/neon-animation/bower.json +51 -0
- data/app/assets/components/neon-animation/demo/declarative/index.html +108 -0
- data/app/assets/components/neon-animation/demo/doc/basic.html +47 -0
- data/app/assets/components/neon-animation/demo/doc/my-animatable.html +73 -0
- data/app/assets/components/neon-animation/demo/doc/my-dialog.html +97 -0
- data/app/assets/components/neon-animation/demo/doc/types.html +53 -0
- data/app/assets/components/neon-animation/demo/dropdown/animated-dropdown.html +97 -0
- data/app/assets/components/neon-animation/demo/dropdown/index.html +54 -0
- data/app/assets/components/neon-animation/demo/grid/animated-grid.html +166 -0
- data/app/assets/components/neon-animation/demo/grid/fullsize-page-with-card.html +124 -0
- data/app/assets/components/neon-animation/demo/grid/index.html +70 -0
- data/app/assets/components/neon-animation/demo/index.html +6 -0
- data/app/assets/components/neon-animation/demo/list/full-view.html +122 -0
- data/app/assets/components/neon-animation/demo/list/index.html +29 -0
- data/app/assets/components/neon-animation/demo/list/list-demo.html +112 -0
- data/app/assets/components/neon-animation/demo/list/list-view.html +127 -0
- data/app/assets/components/neon-animation/demo/load/animated-grid.html +147 -0
- data/app/assets/components/neon-animation/demo/load/full-page.html +86 -0
- data/app/assets/components/neon-animation/demo/load/index.html +45 -0
- data/app/assets/components/neon-animation/demo/reprojection/animated-grid.html +166 -0
- data/app/assets/components/neon-animation/demo/reprojection/fullsize-page-with-card.html +124 -0
- data/app/assets/components/neon-animation/demo/reprojection/index.html +66 -0
- data/app/assets/components/neon-animation/demo/reprojection/reprojected-pages.html +42 -0
- data/app/assets/components/neon-animation/demo/shared.css +40 -0
- data/app/assets/components/neon-animation/demo/tiles/circles-page.html +110 -0
- data/app/assets/components/neon-animation/demo/tiles/index.html +77 -0
- data/app/assets/components/neon-animation/demo/tiles/squares-page.html +104 -0
- data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
- data/app/assets/components/neon-animation/index.html +30 -0
- data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
- data/app/assets/components/neon-animation/neon-animatable.html +54 -0
- data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
- data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
- data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
- data/app/assets/components/neon-animation/neon-animation.html +17 -0
- data/app/assets/components/neon-animation/neon-animations.html +25 -0
- data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
- data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
- data/app/assets/components/neon-animation/web-animations.html +11 -0
- data/app/assets/components/neon-elements/README.md +19 -0
- data/app/assets/components/neon-elements/bower.json +26 -0
- data/app/assets/components/paper-styles/README.md +3 -0
- data/app/assets/components/paper-styles/bower.json +27 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/demo-pages.html +72 -0
- data/app/assets/components/paper-styles/demo.css +25 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/polymer/LICENSE.txt +27 -0
- data/app/assets/components/polymer/bower.json +26 -0
- data/app/assets/components/polymer/build.log +27 -0
- data/app/assets/components/polymer/polymer-micro.html +523 -0
- data/app/assets/components/polymer/polymer-mini.html +1368 -0
- data/app/assets/components/polymer/polymer.html +3768 -0
- data/app/assets/components/web-animations-js/COPYING +202 -0
- data/app/assets/components/web-animations-js/History.md +108 -0
- data/app/assets/components/web-animations-js/README.md +161 -0
- data/app/assets/components/web-animations-js/bower.json +31 -0
- data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations-next-lite.min.js.map +1 -0
- data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations-next.min.js.map +1 -0
- data/app/assets/components/web-animations-js/web-animations.html +50 -0
- data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations.min.js.gz +0 -0
- data/app/assets/components/web-animations-js/web-animations.min.js.map +1 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/README.md +125 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/bower.json +14 -0
- data/app/assets/components/webcomponentsjs/build.log +33 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-neon-rails.rb +2 -0
- data/lib/polymer-neon-rails/engine.rb +4 -0
- data/lib/polymer-neon-rails/version.rb +3 -0
- metadata +264 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
iron-meta
|
2
|
+
=========
|
3
|
+
|
4
|
+
`iron-meta` is a generic element you can use for sharing information across the DOM tree.
|
5
|
+
It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any
|
6
|
+
instance of iron-meta has access to the shared
|
7
|
+
information. You can use `iron-meta` to share whatever you want (or create an extension
|
8
|
+
[like x-meta] for enhancements).
|
9
|
+
|
10
|
+
The `iron-meta` instances containing your actual data can be loaded in an import,
|
11
|
+
or constructed in any way you see fit. The only requirement is that you create them
|
12
|
+
before you try to access them.
|
13
|
+
|
14
|
+
Examples:
|
15
|
+
|
16
|
+
If I create an instance like this:
|
17
|
+
|
18
|
+
```html
|
19
|
+
<iron-meta key="info" keyUrl="foo/bar"></iron-meta>
|
20
|
+
```
|
21
|
+
|
22
|
+
Note that keyUrl="foo/bar" is the metadata I've defined. I could define more
|
23
|
+
attributes or use child nodes to define additional metadata.
|
24
|
+
|
25
|
+
Now I can access that element (and it's metadata) from any iron-meta instance
|
26
|
+
via the byKey method, e.g.
|
27
|
+
|
28
|
+
```javascript
|
29
|
+
meta.byKey('info').getAttribute('keyUrl').
|
30
|
+
```
|
31
|
+
|
32
|
+
Pure imperative form would be like:
|
33
|
+
|
34
|
+
```javascript
|
35
|
+
document.createElement('iron-meta').byKey('info').getAttribute('keyUrl');
|
36
|
+
```
|
37
|
+
|
38
|
+
Or, in a Polymer element, you can include a meta in your template:
|
39
|
+
|
40
|
+
```html
|
41
|
+
<iron-meta id="meta"></iron-meta>
|
42
|
+
```
|
43
|
+
|
44
|
+
```javascript
|
45
|
+
this.$.meta.byKey('info').getAttribute('keyUrl');
|
46
|
+
```
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"name": "iron-meta",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"keywords": [
|
5
|
+
"web-components",
|
6
|
+
"polymer",
|
7
|
+
"meta"
|
8
|
+
],
|
9
|
+
"license": "http://polymer.github.io/LICENSE.txt",
|
10
|
+
"description": "Useful for sharing information across a DOM tree",
|
11
|
+
"private": true,
|
12
|
+
"authors": [
|
13
|
+
"The Polymer Authors"
|
14
|
+
],
|
15
|
+
"keywords": [
|
16
|
+
"web-components",
|
17
|
+
"polymer"
|
18
|
+
],
|
19
|
+
"dependencies": {
|
20
|
+
"polymer": "Polymer/polymer#^1.0.0"
|
21
|
+
},
|
22
|
+
"devDependencies": {
|
23
|
+
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
|
24
|
+
"test-fixture": "polymerelements/test-fixture#^1.0.0",
|
25
|
+
"web-component-tester": "*",
|
26
|
+
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<!--
|
3
|
+
@license
|
4
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
5
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
6
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
7
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
8
|
+
Code distributed by Google as part of the polymer project is also
|
9
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
10
|
+
-->
|
11
|
+
<html>
|
12
|
+
<head>
|
13
|
+
|
14
|
+
<meta charset="utf-8">
|
15
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
16
|
+
|
17
|
+
<title>iron-meta</title>
|
18
|
+
|
19
|
+
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
20
|
+
|
21
|
+
<link rel="import" href="../iron-meta.html">
|
22
|
+
|
23
|
+
</head>
|
24
|
+
<body>
|
25
|
+
|
26
|
+
<iron-meta key="info" value="foo/bar"></iron-meta>
|
27
|
+
|
28
|
+
The keyUrl stored at key="info" is "<meta-test></meta-test>".
|
29
|
+
|
30
|
+
<script>
|
31
|
+
|
32
|
+
Polymer({
|
33
|
+
|
34
|
+
is: 'meta-test',
|
35
|
+
|
36
|
+
ready: function() {
|
37
|
+
this.textContent = new Polymer.IronMetaQuery({key: 'info'}).value;
|
38
|
+
}
|
39
|
+
|
40
|
+
});
|
41
|
+
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</body>
|
45
|
+
</html>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
|
6
|
+
<g id="background" display="none">
|
7
|
+
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
|
8
|
+
</g>
|
9
|
+
<g id="label">
|
10
|
+
</g>
|
11
|
+
<g id="art">
|
12
|
+
<circle cx="22" cy="85" r="4"/>
|
13
|
+
<circle cx="88" cy="98" r="4"/>
|
14
|
+
<path d="M87.5,100c-3.8-0.3-5.5-2.8-7-5c-1.4-2.1-2.7-3.9-5.5-4.2c-2.8-0.3-4.4,1.3-6.2,3.1c-1.9,1.9-4,4-7.8,3.7
|
15
|
+
c-3.8-0.3-5.5-2.8-7-5c-1.4-2.1-2.7-3.9-5.5-4.2c-2.8-0.3-4.4,1.3-6.2,3.1c-1.9,1.9-4,4-7.8,3.7c-3.8-0.3-5.5-2.8-7-5
|
16
|
+
c-1.4-2.1-2.7-3.9-5.5-4.2l0.2-2c3.8,0.3,5.5,2.8,7,5c1.4,2.1,2.7,3.9,5.5,4.2c2.8,0.3,4.4-1.3,6.2-3.1c1.9-1.9,4-4,7.8-3.7
|
17
|
+
c3.8,0.3,5.5,2.8,7,5c1.4,2.1,2.7,3.9,5.5,4.2c2.8,0.3,4.4-1.3,6.2-3.1c1.9-1.9,4-4,7.8-3.7c3.8,0.3,5.5,2.8,7,5
|
18
|
+
c1.4,2.1,2.7,3.9,5.5,4.2L87.5,100z"/>
|
19
|
+
<circle cx="96" cy="86" r="4"/>
|
20
|
+
<circle cx="162" cy="98" r="4"/>
|
21
|
+
<rect x="95.5" y="91" transform="matrix(0.9839 0.1789 -0.1789 0.9839 18.5382 -21.5923)" width="67.1" height="2"/>
|
22
|
+
<g>
|
23
|
+
<path d="M27,41.5l4.5,13.4l4.9-13.4h5.4v32h-4.4V61l0.4-13.4l-5.4,14.5h-2L25.6,48L26,61v12.5h-4.4v-32H27z"/>
|
24
|
+
<path d="M67.5,58.7H53.4V70h16.4v3.5H49v-32h20.6V45H53.4v10.2h14.2V58.7z"/>
|
25
|
+
<path d="M98.5,45H88.3v28.5h-4.4V45H73.6v-3.5h24.9V45z"/>
|
26
|
+
<path d="M116.2,65.3H105l-2.6,8.2h-4.5l10.9-32h3.8l10.6,32h-4.5L116.2,65.3z M106.2,61.6h8.9l-4.4-14.2L106.2,61.6z"/>
|
27
|
+
</g>
|
28
|
+
<g id="ic_x5F_add_x0D_">
|
29
|
+
</g>
|
30
|
+
</g>
|
31
|
+
<g id="Guides">
|
32
|
+
</g>
|
33
|
+
</svg>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<!--
|
3
|
+
@license
|
4
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
5
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
|
6
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
7
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
8
|
+
Code distributed by Google as part of the polymer project is also
|
9
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
|
10
|
+
-->
|
11
|
+
<html>
|
12
|
+
<head>
|
13
|
+
|
14
|
+
<meta charset="utf-8">
|
15
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
16
|
+
<title>iron-meta</title>
|
17
|
+
|
18
|
+
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
|
19
|
+
<link rel="import" href="../iron-component-page/iron-component-page.html">
|
20
|
+
|
21
|
+
</head>
|
22
|
+
<body>
|
23
|
+
|
24
|
+
<iron-component-page></iron-component-page>
|
25
|
+
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,352 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
|
11
|
+
<link rel="import" href="../polymer/polymer.html">
|
12
|
+
|
13
|
+
<!--
|
14
|
+
`iron-meta` is a generic element you can use for sharing information across the DOM tree.
|
15
|
+
It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any
|
16
|
+
instance of iron-meta has access to the shared
|
17
|
+
information. You can use `iron-meta` to share whatever you want (or create an extension
|
18
|
+
[like x-meta] for enhancements).
|
19
|
+
|
20
|
+
The `iron-meta` instances containing your actual data can be loaded in an import,
|
21
|
+
or constructed in any way you see fit. The only requirement is that you create them
|
22
|
+
before you try to access them.
|
23
|
+
|
24
|
+
Examples:
|
25
|
+
|
26
|
+
If I create an instance like this:
|
27
|
+
|
28
|
+
<iron-meta key="info" keyUrl="foo/bar"></iron-meta>
|
29
|
+
|
30
|
+
Note that keyUrl="foo/bar" is the metadata I've defined. I could define more
|
31
|
+
attributes or use child nodes to define additional metadata.
|
32
|
+
|
33
|
+
Now I can access that element (and it's metadata) from any iron-meta instance
|
34
|
+
via the byKey method, e.g.
|
35
|
+
|
36
|
+
meta.byKey('info').getAttribute('keyUrl').
|
37
|
+
|
38
|
+
Pure imperative form would be like:
|
39
|
+
|
40
|
+
document.createElement('iron-meta').byKey('info').getAttribute('keyUrl');
|
41
|
+
|
42
|
+
Or, in a Polymer element, you can include a meta in your template:
|
43
|
+
|
44
|
+
<iron-meta id="meta"></iron-meta>
|
45
|
+
...
|
46
|
+
this.$.meta.byKey('info').getAttribute('keyUrl');
|
47
|
+
|
48
|
+
@group Iron Elements
|
49
|
+
@demo demo/index.html
|
50
|
+
@hero hero.svg
|
51
|
+
@element iron-meta
|
52
|
+
-->
|
53
|
+
|
54
|
+
<script>
|
55
|
+
|
56
|
+
(function() {
|
57
|
+
|
58
|
+
// monostate data
|
59
|
+
var metaDatas = {};
|
60
|
+
var metaArrays = {};
|
61
|
+
|
62
|
+
Polymer.IronMeta = Polymer({
|
63
|
+
|
64
|
+
is: 'iron-meta',
|
65
|
+
|
66
|
+
properties: {
|
67
|
+
|
68
|
+
/**
|
69
|
+
* The type of meta-data. All meta-data of the same type is stored
|
70
|
+
* together.
|
71
|
+
*
|
72
|
+
* @attribute type
|
73
|
+
* @type String
|
74
|
+
* @default 'default'
|
75
|
+
*/
|
76
|
+
type: {
|
77
|
+
type: String,
|
78
|
+
value: 'default',
|
79
|
+
observer: '_typeChanged'
|
80
|
+
},
|
81
|
+
|
82
|
+
/**
|
83
|
+
* The key used to store `value` under the `type` namespace.
|
84
|
+
*
|
85
|
+
* @attribute key
|
86
|
+
* @type String
|
87
|
+
* @default ''
|
88
|
+
*/
|
89
|
+
key: {
|
90
|
+
type: String,
|
91
|
+
observer: '_keyChanged'
|
92
|
+
},
|
93
|
+
|
94
|
+
/**
|
95
|
+
* The meta-data to store or retrieve.
|
96
|
+
*
|
97
|
+
* @attribute value
|
98
|
+
* @type *
|
99
|
+
* @default this
|
100
|
+
*/
|
101
|
+
value: {
|
102
|
+
type: Object,
|
103
|
+
notify: true,
|
104
|
+
observer: '_valueChanged'
|
105
|
+
},
|
106
|
+
|
107
|
+
/**
|
108
|
+
* If true, `value` is set to the iron-meta instance itself.
|
109
|
+
*
|
110
|
+
* @attribute self
|
111
|
+
* @type Boolean
|
112
|
+
* @default false
|
113
|
+
*/
|
114
|
+
self: {
|
115
|
+
type: Boolean,
|
116
|
+
observer: '_selfChanged'
|
117
|
+
},
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Array of all meta-data values for the given type.
|
121
|
+
*
|
122
|
+
* @property list
|
123
|
+
* @type Array
|
124
|
+
*/
|
125
|
+
list: {
|
126
|
+
type: Array,
|
127
|
+
notify: true
|
128
|
+
}
|
129
|
+
|
130
|
+
},
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Only runs if someone invokes the factory/constructor directly
|
134
|
+
* e.g. `new Polymer.IronMeta()`
|
135
|
+
*/
|
136
|
+
factoryImpl: function(config) {
|
137
|
+
if (config) {
|
138
|
+
for (var n in config) {
|
139
|
+
switch(n) {
|
140
|
+
case 'type':
|
141
|
+
case 'key':
|
142
|
+
case 'value':
|
143
|
+
this[n] = config[n];
|
144
|
+
break;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
},
|
149
|
+
|
150
|
+
created: function() {
|
151
|
+
// TODO(sjmiles): good for debugging?
|
152
|
+
this._metaDatas = metaDatas;
|
153
|
+
this._metaArrays = metaArrays;
|
154
|
+
},
|
155
|
+
|
156
|
+
_keyChanged: function(key, old) {
|
157
|
+
this._resetRegistration(old);
|
158
|
+
},
|
159
|
+
|
160
|
+
_valueChanged: function(value) {
|
161
|
+
this._resetRegistration(this.key);
|
162
|
+
},
|
163
|
+
|
164
|
+
_selfChanged: function(self) {
|
165
|
+
if (self) {
|
166
|
+
this.value = this;
|
167
|
+
}
|
168
|
+
},
|
169
|
+
|
170
|
+
_typeChanged: function(type) {
|
171
|
+
this._unregisterKey(this.key);
|
172
|
+
if (!metaDatas[type]) {
|
173
|
+
metaDatas[type] = {};
|
174
|
+
}
|
175
|
+
this._metaData = metaDatas[type];
|
176
|
+
if (!metaArrays[type]) {
|
177
|
+
metaArrays[type] = [];
|
178
|
+
}
|
179
|
+
this.list = metaArrays[type];
|
180
|
+
this._registerKeyValue(this.key, this.value);
|
181
|
+
},
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Retrieves meta data value by key.
|
185
|
+
*
|
186
|
+
* @method byKey
|
187
|
+
* @param {String} key The key of the meta-data to be returned.
|
188
|
+
* @returns *
|
189
|
+
*/
|
190
|
+
byKey: function(key) {
|
191
|
+
return this._metaData && this._metaData[key];
|
192
|
+
},
|
193
|
+
|
194
|
+
_resetRegistration: function(oldKey) {
|
195
|
+
this._unregisterKey(oldKey);
|
196
|
+
this._registerKeyValue(this.key, this.value);
|
197
|
+
},
|
198
|
+
|
199
|
+
_unregisterKey: function(key) {
|
200
|
+
this._unregister(key, this._metaData, this.list);
|
201
|
+
},
|
202
|
+
|
203
|
+
_registerKeyValue: function(key, value) {
|
204
|
+
this._register(key, value, this._metaData, this.list);
|
205
|
+
},
|
206
|
+
|
207
|
+
_register: function(key, value, data, list) {
|
208
|
+
if (key && data && value !== undefined) {
|
209
|
+
data[key] = value;
|
210
|
+
list.push(value);
|
211
|
+
}
|
212
|
+
},
|
213
|
+
|
214
|
+
_unregister: function(key, data, list) {
|
215
|
+
if (key && data) {
|
216
|
+
if (key in data) {
|
217
|
+
var value = data[key];
|
218
|
+
delete data[key];
|
219
|
+
this.arrayDelete(list, value);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
});
|
225
|
+
|
226
|
+
/**
|
227
|
+
`iron-meta-query` can be used to access infomation stored in `iron-meta`.
|
228
|
+
|
229
|
+
Examples:
|
230
|
+
|
231
|
+
If I create an instance like this:
|
232
|
+
|
233
|
+
<iron-meta key="info" value="foo/bar"></iron-meta>
|
234
|
+
|
235
|
+
Note that keyUrl="foo/bar" is the metadata I've defined. I could define more
|
236
|
+
attributes or use child nodes to define additional metadata.
|
237
|
+
|
238
|
+
Now I can access that element (and it's metadata) from any `iron-meta-query` instance:
|
239
|
+
|
240
|
+
var value = new Polymer.IronMetaQuery({key: 'info'}).value;
|
241
|
+
|
242
|
+
@group Polymer Iron Elements
|
243
|
+
@element iron-meta-query
|
244
|
+
*/
|
245
|
+
Polymer.IronMetaQuery = Polymer({
|
246
|
+
|
247
|
+
is: 'iron-meta-query',
|
248
|
+
|
249
|
+
properties: {
|
250
|
+
|
251
|
+
/**
|
252
|
+
* The type of meta-data. All meta-data of the same type is stored
|
253
|
+
* together.
|
254
|
+
*
|
255
|
+
* @attribute type
|
256
|
+
* @type String
|
257
|
+
* @default 'default'
|
258
|
+
*/
|
259
|
+
type: {
|
260
|
+
type: String,
|
261
|
+
value: 'default',
|
262
|
+
observer: '_typeChanged'
|
263
|
+
},
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Specifies a key to use for retrieving `value` from the `type`
|
267
|
+
* namespace.
|
268
|
+
*
|
269
|
+
* @attribute key
|
270
|
+
* @type String
|
271
|
+
*/
|
272
|
+
key: {
|
273
|
+
type: String,
|
274
|
+
observer: '_keyChanged'
|
275
|
+
},
|
276
|
+
|
277
|
+
/**
|
278
|
+
* The meta-data to store or retrieve.
|
279
|
+
*
|
280
|
+
* @attribute value
|
281
|
+
* @type *
|
282
|
+
* @default this
|
283
|
+
*/
|
284
|
+
value: {
|
285
|
+
type: Object,
|
286
|
+
notify: true,
|
287
|
+
readOnly: true
|
288
|
+
},
|
289
|
+
|
290
|
+
/**
|
291
|
+
* Array of all meta-data values for the given type.
|
292
|
+
*
|
293
|
+
* @property list
|
294
|
+
* @type Array
|
295
|
+
*/
|
296
|
+
list: {
|
297
|
+
type: Array,
|
298
|
+
notify: true
|
299
|
+
}
|
300
|
+
|
301
|
+
},
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Actually a factory method, not a true constructor. Only runs if
|
305
|
+
* someone invokes it directly (via `new Polymer.IronMeta()`);
|
306
|
+
*/
|
307
|
+
constructor: function(config) {
|
308
|
+
if (config) {
|
309
|
+
for (var n in config) {
|
310
|
+
switch(n) {
|
311
|
+
case 'type':
|
312
|
+
case 'key':
|
313
|
+
this[n] = config[n];
|
314
|
+
break;
|
315
|
+
}
|
316
|
+
}
|
317
|
+
}
|
318
|
+
},
|
319
|
+
|
320
|
+
created: function() {
|
321
|
+
// TODO(sjmiles): good for debugging?
|
322
|
+
this._metaDatas = metaDatas;
|
323
|
+
this._metaArrays = metaArrays;
|
324
|
+
},
|
325
|
+
|
326
|
+
_keyChanged: function(key) {
|
327
|
+
this._setValue(this._metaData && this._metaData[key]);
|
328
|
+
},
|
329
|
+
|
330
|
+
_typeChanged: function(type) {
|
331
|
+
this._metaData = metaDatas[type];
|
332
|
+
this.list = metaArrays[type];
|
333
|
+
if (this.key) {
|
334
|
+
this._keyChanged(this.key);
|
335
|
+
}
|
336
|
+
},
|
337
|
+
|
338
|
+
/**
|
339
|
+
* Retrieves meta data value by key.
|
340
|
+
*
|
341
|
+
* @method byKey
|
342
|
+
* @param {String} key The key of the meta-data to be returned.
|
343
|
+
* @returns *
|
344
|
+
*/
|
345
|
+
byKey: function(key) {
|
346
|
+
return this._metaData && this._metaData[key];
|
347
|
+
}
|
348
|
+
|
349
|
+
});
|
350
|
+
|
351
|
+
})();
|
352
|
+
</script>
|