polymer-gold-rails 1.0.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +36 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/gold-cc-cvc-input/README.md +24 -0
  5. data/app/assets/components/gold-cc-cvc-input/bower.json +39 -0
  6. data/app/assets/components/gold-cc-cvc-input/cvc_hint.png +0 -0
  7. data/app/assets/components/gold-cc-cvc-input/cvc_hint_amex.png +0 -0
  8. data/app/assets/components/gold-cc-cvc-input/demo/index.html +54 -0
  9. data/app/assets/components/gold-cc-cvc-input/gold-cc-cvc-input.html +195 -0
  10. data/app/assets/components/gold-cc-cvc-input/hero.svg +36 -0
  11. data/app/assets/components/gold-cc-cvc-input/index.html +26 -0
  12. data/app/assets/components/gold-cc-cvc-input/test/basic.html +125 -0
  13. data/app/assets/components/gold-cc-cvc-input/test/index.html +25 -0
  14. data/app/assets/components/gold-cc-expiration-input/README.md +10 -0
  15. data/app/assets/components/gold-cc-expiration-input/bower.json +40 -0
  16. data/app/assets/components/gold-cc-expiration-input/date-input.html +157 -0
  17. data/app/assets/components/gold-cc-expiration-input/date-validator.html +38 -0
  18. data/app/assets/components/gold-cc-expiration-input/demo/index.html +53 -0
  19. data/app/assets/components/gold-cc-expiration-input/gold-cc-expiration-input.html +131 -0
  20. data/app/assets/components/gold-cc-expiration-input/hero.svg +58 -0
  21. data/app/assets/components/gold-cc-expiration-input/index.html +28 -0
  22. data/app/assets/components/gold-cc-expiration-input/test/basic.html +126 -0
  23. data/app/assets/components/gold-cc-expiration-input/test/index.html +25 -0
  24. data/app/assets/components/gold-cc-input/README.md +9 -0
  25. data/app/assets/components/gold-cc-input/bower.json +39 -0
  26. data/app/assets/components/gold-cc-input/cc-validator.js +192 -0
  27. data/app/assets/components/gold-cc-input/demo/index.html +48 -0
  28. data/app/assets/components/gold-cc-input/gold-cc-input.html +215 -0
  29. data/app/assets/components/gold-cc-input/hero.svg +52 -0
  30. data/app/assets/components/gold-cc-input/images/amex.png +0 -0
  31. data/app/assets/components/gold-cc-input/images/diners_club.png +0 -0
  32. data/app/assets/components/gold-cc-input/images/discover.png +0 -0
  33. data/app/assets/components/gold-cc-input/images/jcb.png +0 -0
  34. data/app/assets/components/gold-cc-input/images/mastercard.png +0 -0
  35. data/app/assets/components/gold-cc-input/images/visa.png +0 -0
  36. data/app/assets/components/gold-cc-input/index.html +28 -0
  37. data/app/assets/components/gold-cc-input/test/basic.html +136 -0
  38. data/app/assets/components/gold-cc-input/test/index.html +25 -0
  39. data/app/assets/components/gold-elements/README.md +12 -0
  40. data/app/assets/components/gold-elements/bower.json +42 -0
  41. data/app/assets/components/gold-elements/demo/complex-form.html +127 -0
  42. data/app/assets/components/gold-elements/demo/index.html +94 -0
  43. data/app/assets/components/gold-elements/demo/item-card.html +59 -0
  44. data/app/assets/components/gold-elements/demo/simple-form.css +55 -0
  45. data/app/assets/components/gold-elements/demo/simple-form.html +93 -0
  46. data/app/assets/components/gold-elements/screenshot.png +0 -0
  47. data/app/assets/components/gold-email-input/README.md +8 -0
  48. data/app/assets/components/gold-email-input/bower.json +40 -0
  49. data/app/assets/components/gold-email-input/demo/index.html +46 -0
  50. data/app/assets/components/gold-email-input/email-validator.html +31 -0
  51. data/app/assets/components/gold-email-input/gold-email-input.html +108 -0
  52. data/app/assets/components/gold-email-input/hero.svg +59 -0
  53. data/app/assets/components/gold-email-input/index.html +28 -0
  54. data/app/assets/components/gold-email-input/test/basic.html +97 -0
  55. data/app/assets/components/gold-email-input/test/index.html +25 -0
  56. data/app/assets/components/gold-phone-input/README.md +13 -0
  57. data/app/assets/components/gold-phone-input/bower.json +39 -0
  58. data/app/assets/components/gold-phone-input/demo/index.html +53 -0
  59. data/app/assets/components/gold-phone-input/gold-phone-input.html +197 -0
  60. data/app/assets/components/gold-phone-input/hero.svg +63 -0
  61. data/app/assets/components/gold-phone-input/index.html +28 -0
  62. data/app/assets/components/gold-phone-input/test/basic.html +117 -0
  63. data/app/assets/components/gold-phone-input/test/index.html +25 -0
  64. data/app/assets/components/gold-zip-input/README.md +8 -0
  65. data/app/assets/components/gold-zip-input/bower.json +40 -0
  66. data/app/assets/components/gold-zip-input/demo/index.html +54 -0
  67. data/app/assets/components/gold-zip-input/gold-zip-input.html +113 -0
  68. data/app/assets/components/gold-zip-input/hero.svg +43 -0
  69. data/app/assets/components/gold-zip-input/index.html +28 -0
  70. data/app/assets/components/gold-zip-input/test/basic.html +116 -0
  71. data/app/assets/components/gold-zip-input/test/index.html +25 -0
  72. data/app/assets/components/gold-zip-input/zip-validator.html +32 -0
  73. data/app/assets/components/iron-autogrow-textarea/README.md +24 -0
  74. data/app/assets/components/iron-autogrow-textarea/bower.json +37 -0
  75. data/app/assets/components/iron-autogrow-textarea/demo/index.html +81 -0
  76. data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
  77. data/app/assets/components/iron-autogrow-textarea/index.html +30 -0
  78. data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
  79. data/app/assets/components/iron-autogrow-textarea/test/basic.html +94 -0
  80. data/app/assets/components/iron-autogrow-textarea/test/index.html +25 -0
  81. data/app/assets/components/iron-flex-layout/README.md +4 -0
  82. data/app/assets/components/iron-flex-layout/bower.json +21 -0
  83. data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
  84. data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
  85. data/app/assets/components/iron-flex-layout/demo/index.html +40 -0
  86. data/app/assets/components/iron-flex-layout/demo/x-app.html +106 -0
  87. data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
  88. data/app/assets/components/iron-form-element-behavior/README.md +2 -0
  89. data/app/assets/components/iron-form-element-behavior/bower.json +27 -0
  90. data/app/assets/components/iron-form-element-behavior/demo/index.html +53 -0
  91. data/app/assets/components/iron-form-element-behavior/demo/simple-element.html +27 -0
  92. data/app/assets/components/iron-form-element-behavior/demo/simple-form.html +42 -0
  93. data/app/assets/components/iron-form-element-behavior/index.html +30 -0
  94. data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
  95. data/app/assets/components/iron-icon/README.md +56 -0
  96. data/app/assets/components/iron-icon/bower.json +29 -0
  97. data/app/assets/components/iron-icon/demo/index.html +28 -0
  98. data/app/assets/components/iron-icon/demo/location.png +0 -0
  99. data/app/assets/components/iron-icon/hero.svg +19 -0
  100. data/app/assets/components/iron-icon/index.html +26 -0
  101. data/app/assets/components/iron-icon/iron-icon.html +187 -0
  102. data/app/assets/components/iron-icon/test/index.html +31 -0
  103. data/app/assets/components/iron-icon/test/iron-icon.html +120 -0
  104. data/app/assets/components/iron-input/README.md +16 -0
  105. data/app/assets/components/iron-input/bower.json +36 -0
  106. data/app/assets/components/iron-input/demo/index.html +87 -0
  107. data/app/assets/components/iron-input/hero.svg +19 -0
  108. data/app/assets/components/iron-input/index.html +30 -0
  109. data/app/assets/components/iron-input/iron-input.html +235 -0
  110. data/app/assets/components/iron-input/test/index.html +24 -0
  111. data/app/assets/components/iron-input/test/iron-input.html +139 -0
  112. data/app/assets/components/iron-input/test/letters-only.html +30 -0
  113. data/app/assets/components/iron-meta/README.md +46 -0
  114. data/app/assets/components/iron-meta/bower.json +28 -0
  115. data/app/assets/components/iron-meta/demo/index.html +45 -0
  116. data/app/assets/components/iron-meta/hero.svg +33 -0
  117. data/app/assets/components/iron-meta/index.html +27 -0
  118. data/app/assets/components/iron-meta/iron-meta.html +352 -0
  119. data/app/assets/components/iron-meta/test/basic.html +48 -0
  120. data/app/assets/components/iron-meta/test/index.html +30 -0
  121. data/app/assets/components/iron-meta/test/iron-meta.html +186 -0
  122. data/app/assets/components/iron-validatable-behavior/README.md +3 -0
  123. data/app/assets/components/iron-validatable-behavior/bower.json +35 -0
  124. data/app/assets/components/iron-validatable-behavior/demo/cats-only.html +46 -0
  125. data/app/assets/components/iron-validatable-behavior/demo/index.html +71 -0
  126. data/app/assets/components/iron-validatable-behavior/demo/validatable-input.html +46 -0
  127. data/app/assets/components/iron-validatable-behavior/index.html +30 -0
  128. data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +101 -0
  129. data/app/assets/components/iron-validatable-behavior/test/index.html +35 -0
  130. data/app/assets/components/iron-validatable-behavior/test/iron-validatable-behavior.html +52 -0
  131. data/app/assets/components/iron-validatable-behavior/test/test-validatable.html +28 -0
  132. data/app/assets/components/iron-validator-behavior/README.md +4 -0
  133. data/app/assets/components/iron-validator-behavior/bower.json +34 -0
  134. data/app/assets/components/iron-validator-behavior/demo/cats-only.html +46 -0
  135. data/app/assets/components/iron-validator-behavior/demo/index.html +144 -0
  136. data/app/assets/components/iron-validator-behavior/index.html +30 -0
  137. data/app/assets/components/iron-validator-behavior/iron-validator-behavior.html +61 -0
  138. data/app/assets/components/iron-validator-behavior/test/index.html +34 -0
  139. data/app/assets/components/iron-validator-behavior/test/iron-validator-behavior.html +47 -0
  140. data/app/assets/components/iron-validator-behavior/test/simple-validator.html +26 -0
  141. data/app/assets/components/paper-input/README.md +5 -0
  142. data/app/assets/components/paper-input/all-imports.html +12 -0
  143. data/app/assets/components/paper-input/bower.json +44 -0
  144. data/app/assets/components/paper-input/demo/index.html +96 -0
  145. data/app/assets/components/paper-input/demo/ssn-input.html +94 -0
  146. data/app/assets/components/paper-input/demo/ssn-validator.html +31 -0
  147. data/app/assets/components/paper-input/hero.svg +19 -0
  148. data/app/assets/components/paper-input/index.html +28 -0
  149. data/app/assets/components/paper-input/paper-input-addon-behavior.html +47 -0
  150. data/app/assets/components/paper-input/paper-input-behavior.html +317 -0
  151. data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
  152. data/app/assets/components/paper-input/paper-input-container.html +495 -0
  153. data/app/assets/components/paper-input/paper-input-error.html +99 -0
  154. data/app/assets/components/paper-input/paper-input.html +126 -0
  155. data/app/assets/components/paper-input/paper-textarea.html +106 -0
  156. data/app/assets/components/paper-input/test/index.html +28 -0
  157. data/app/assets/components/paper-input/test/letters-only.html +30 -0
  158. data/app/assets/components/paper-input/test/paper-input-char-counter.html +112 -0
  159. data/app/assets/components/paper-input/test/paper-input-container.html +237 -0
  160. data/app/assets/components/paper-input/test/paper-input-error.html +60 -0
  161. data/app/assets/components/paper-input/test/paper-input.html +213 -0
  162. data/app/assets/components/paper-input/test/paper-textarea.html +169 -0
  163. data/app/assets/components/paper-styles/README.md +3 -0
  164. data/app/assets/components/paper-styles/bower.json +27 -0
  165. data/app/assets/components/paper-styles/classes/global.html +96 -0
  166. data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
  167. data/app/assets/components/paper-styles/classes/shadow.html +39 -0
  168. data/app/assets/components/paper-styles/classes/typography.html +171 -0
  169. data/app/assets/components/paper-styles/color.html +333 -0
  170. data/app/assets/components/paper-styles/default-theme.html +39 -0
  171. data/app/assets/components/paper-styles/demo-pages.html +72 -0
  172. data/app/assets/components/paper-styles/demo.css +25 -0
  173. data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
  174. data/app/assets/components/paper-styles/paper-styles.html +17 -0
  175. data/app/assets/components/paper-styles/shadow.html +61 -0
  176. data/app/assets/components/paper-styles/typography.html +240 -0
  177. data/app/assets/components/polymer/LICENSE.txt +27 -0
  178. data/app/assets/components/polymer/bower.json +26 -0
  179. data/app/assets/components/polymer/build.log +27 -0
  180. data/app/assets/components/polymer/polymer-micro.html +523 -0
  181. data/app/assets/components/polymer/polymer-mini.html +1368 -0
  182. data/app/assets/components/polymer/polymer.html +3768 -0
  183. data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
  184. data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
  185. data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
  186. data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
  187. data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
  188. data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
  189. data/app/assets/components/webcomponentsjs/README.md +125 -0
  190. data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
  191. data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
  192. data/app/assets/components/webcomponentsjs/bower.json +14 -0
  193. data/app/assets/components/webcomponentsjs/build.log +33 -0
  194. data/app/assets/components/webcomponentsjs/package.json +31 -0
  195. data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
  196. data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
  197. data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
  198. data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
  199. data/lib/polymer-gold-rails.rb +2 -0
  200. data/lib/polymer-gold-rails/enigne.rb +4 -0
  201. data/lib/polymer-gold-rails/version.rb +3 -0
  202. metadata +312 -0
@@ -0,0 +1,24 @@
1
+ <!doctype html>
2
+ <!--
3
+ Copyright (c) 2014 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
+ <html>
11
+ <head>
12
+ <meta charset="UTF-8">
13
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
14
+ <title>iron-input ests</title>
15
+ <script src="../../web-component-tester/browser.js"></script>
16
+ </head>
17
+ <body>
18
+ <script>
19
+ WCT.loadSuites([
20
+ 'iron-input.html',
21
+ ]);
22
+ </script>
23
+ </body>
24
+ </html>
@@ -0,0 +1,139 @@
1
+ <!doctype html>
2
+ <!--
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
+ <html>
11
+ <head>
12
+
13
+ <title>iron-input tests</title>
14
+
15
+ <meta charset="utf-8">
16
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
17
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
18
+
19
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
20
+
21
+ <script src="../../web-component-tester/browser.js"></script>
22
+ <script src="../../test-fixture/test-fixture-mocha.js"></script>
23
+
24
+ <link rel="import" href="../../test-fixture/test-fixture.html">
25
+ <link rel="import" href="../iron-input.html">
26
+ <link rel="import" href="letters-only.html">
27
+
28
+ </head>
29
+ <body>
30
+
31
+ <test-fixture id="basic">
32
+ <template>
33
+ <input is="iron-input">
34
+ </template>
35
+ </test-fixture>
36
+
37
+ <test-fixture id="has-value">
38
+ <template>
39
+ <input is="iron-input" value="foobar">
40
+ </template>
41
+ </test-fixture>
42
+
43
+ <test-fixture id="has-bind-value">
44
+ <template>
45
+ <input is="iron-input" bind-value="foobar">
46
+ </template>
47
+ </test-fixture>
48
+
49
+ <test-fixture id="prevent-invalid-input">
50
+ <template>
51
+ <input is="iron-input" prevent-invalid-input pattern="[0-9]">
52
+ </template>
53
+ </test-fixture>
54
+
55
+ <test-fixture id="prevent-invalid-input-has-value">
56
+ <template>
57
+ <input is="iron-input" prevent-invalid-input pattern="[0-9]*" value="foobar">
58
+ </template>
59
+ </test-fixture>
60
+
61
+ <test-fixture id="prevent-invalid-input-has-bind-value">
62
+ <template>
63
+ <input is="iron-input" prevent-invalid-input pattern="[0-9]*" bind-value="foobar">
64
+ </template>
65
+ </test-fixture>
66
+
67
+ <test-fixture id="has-validator">
68
+ <template>
69
+ <letters-only></letters-only>
70
+ <input is="iron-input" validator="letters-only" pattern="[0-9]*">
71
+ </template>
72
+ </test-fixture>
73
+
74
+ <template is="dom-bind" id="bind-to-object">
75
+ <input is="iron-input" id="input" bind-value="{{foo}}">
76
+ </template>
77
+
78
+ <script>
79
+
80
+ suite('basic', function() {
81
+
82
+ test('setting bindValue sets value', function() {
83
+ var input = fixture('basic');
84
+ input.bindValue = 'foobar';
85
+ assert.equal(input.value, input.bindValue, 'value equals to bindValue');
86
+ });
87
+
88
+ test('changing the input triggers an event', function(done) {
89
+ var input = fixture('basic');
90
+
91
+ input.addEventListener('bind-value-changed', function(value) {
92
+ assert.equal(input.value, input.bindValue, 'value equals to bindValue');
93
+ done();
94
+ });
95
+
96
+ input.value = "foo";
97
+ input._onInput();
98
+ });
99
+
100
+ test('default value sets bindValue', function() {
101
+ var input = fixture('has-value');
102
+ assert.equal(input.bindValue, input.value, 'bindValue equals value');
103
+ });
104
+
105
+ test('default bindValue sets value', function() {
106
+ var input = fixture('has-bind-value');
107
+ assert.equal(input.value, input.bindValue, 'value equals to bindValue');
108
+ });
109
+
110
+ test('set bindValue to undefined', function() {
111
+ var scope = document.getElementById('bind-to-object');
112
+ scope.foo = undefined;
113
+ assert.ok(!scope.$.input.bindValue, 'bindValue is falsy');
114
+ assert.ok(!scope.$.input.value, 'value is falsy');
115
+ });
116
+
117
+ test('validator used instead of constraints api if provided', function() {
118
+ var input = fixture('has-validator')[1];
119
+ input.value = '123';
120
+ input.validate();
121
+ assert.isTrue(input.invalid, 'input is invalid');
122
+ });
123
+
124
+ test('prevent invalid input works in _onInput', function() {
125
+ var input = fixture('prevent-invalid-input');
126
+ input.value = '123';
127
+ input._onInput();
128
+ assert.equal(input.bindValue, '123');
129
+
130
+ input.value = '123foo';
131
+ input._onInput();
132
+ assert.equal(input.bindValue, '123');
133
+ });
134
+ });
135
+
136
+ </script>
137
+
138
+ </body>
139
+ </html>
@@ -0,0 +1,30 @@
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
+ <link rel="import" href="../../iron-validator-behavior/iron-validator-behavior.html">
13
+
14
+ <script>
15
+
16
+ Polymer({
17
+
18
+ is: 'letters-only',
19
+
20
+ behaviors: [
21
+ Polymer.IronValidatorBehavior
22
+ ],
23
+
24
+ validate: function(value) {
25
+ return !value || value.match(/^[a-zA-Z]*$/) !== null;
26
+ }
27
+
28
+ });
29
+
30
+ </script>
@@ -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>