polymer-paper-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +69 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/core/animation/web-animations.html.erb +1 -0
  5. data/app/assets/components/core/animation/web-animations.js +5666 -0
  6. data/app/assets/components/core/icon/core-icon.css +25 -0
  7. data/app/assets/components/core/icon/core-icon.html.erb +126 -0
  8. data/app/assets/components/core/iconset/core-iconset.html.erb +236 -0
  9. data/app/assets/components/core/input/core-input.css +35 -0
  10. data/app/assets/components/core/input/core-input.html.erb +385 -0
  11. data/app/assets/components/core/list/core-list.css +20 -0
  12. data/app/assets/components/core/list/core-list.html.erb +403 -0
  13. data/app/assets/components/core/media-query/core-media-query.html +86 -0
  14. data/app/assets/components/core/menu/core-menu.css +18 -0
  15. data/app/assets/components/core/menu/core-menu.html.erb +62 -0
  16. data/app/assets/components/core/menu/core-submenu.css +29 -0
  17. data/app/assets/components/core/menu/core-submenu.html.erb +106 -0
  18. data/app/assets/components/core/meta/core-meta.html +143 -0
  19. data/app/assets/components/core/overlay/core-key-helper.html +17 -0
  20. data/app/assets/components/core/overlay/core-overlay-layer.html +112 -0
  21. data/app/assets/components/core/overlay/core-overlay.html.erb +661 -0
  22. data/app/assets/components/core/range/core-range.html +106 -0
  23. data/app/assets/components/core/selection/core-selection.html +148 -0
  24. data/app/assets/components/core/selector/core-selector.html.erb +423 -0
  25. data/app/assets/components/core/style/core-style.html +386 -0
  26. data/app/assets/components/core/transition/core-transition-css.html.erb +76 -0
  27. data/app/assets/components/core/transition/core-transition-overlay.css +46 -0
  28. data/app/assets/components/core/transition/core-transition.html.erb +44 -0
  29. data/app/assets/components/paper-button/paper-button.css +115 -0
  30. data/app/assets/components/paper-button/paper-button.html.erb +210 -0
  31. data/app/assets/components/paper-checkbox/paper-checkbox.css +262 -0
  32. data/app/assets/components/paper-checkbox/paper-checkbox.html.erb +104 -0
  33. data/app/assets/components/paper-dialog/paper-dialog-transition.css +59 -0
  34. data/app/assets/components/paper-dialog/paper-dialog-transition.html.erb +27 -0
  35. data/app/assets/components/paper-dialog/paper-dialog.css +0 -0
  36. data/app/assets/components/paper-dialog/paper-dialog.html.erb +176 -0
  37. data/app/assets/components/paper-fab/paper-fab.css +27 -0
  38. data/app/assets/components/paper-fab/paper-fab.html.erb +55 -0
  39. data/app/assets/components/paper-focusable/paper-focusable.html +144 -0
  40. data/app/assets/components/paper-icon-button/paper-icon-button.css +17 -0
  41. data/app/assets/components/paper-icon-button/paper-icon-button.html.erb +87 -0
  42. data/app/assets/components/paper-input/error-100.png +0 -0
  43. data/app/assets/components/paper-input/error-200.png +0 -0
  44. data/app/assets/components/paper-input/paper-input.html.erb +398 -0
  45. data/app/assets/components/paper-input/paper-input.scss +203 -0
  46. data/app/assets/components/paper-item/paper-item.css +30 -0
  47. data/app/assets/components/paper-item/paper-item.html.erb +103 -0
  48. data/app/assets/components/paper-menu-button/paper-menu-button-overlay.html.erb +86 -0
  49. data/app/assets/components/paper-menu-button/paper-menu-button-transition.css +19 -0
  50. data/app/assets/components/paper-menu-button/paper-menu-button-transition.html.erb +118 -0
  51. data/app/assets/components/paper-menu-button/paper-menu-button.css +86 -0
  52. data/app/assets/components/paper-menu-button/paper-menu-button.html.erb +128 -0
  53. data/app/assets/components/paper-progress/paper-progress.css +35 -0
  54. data/app/assets/components/paper-progress/paper-progress.html.erb +98 -0
  55. data/app/assets/components/paper-radio-button/paper-radio-button.css +98 -0
  56. data/app/assets/components/paper-radio-button/paper-radio-button.html.erb +148 -0
  57. data/app/assets/components/paper-radio-group/paper-radio-group.html.erb +68 -0
  58. data/app/assets/components/paper-ripple/paper-ripple.html +426 -0
  59. data/app/assets/components/paper-shadow/paper-shadow.css +81 -0
  60. data/app/assets/components/paper-shadow/paper-shadow.html.erb +212 -0
  61. data/app/assets/components/paper-slider/paper-slider.css +193 -0
  62. data/app/assets/components/paper-slider/paper-slider.html.erb +310 -0
  63. data/app/assets/components/paper-tabs/paper-tab.css +49 -0
  64. data/app/assets/components/paper-tabs/paper-tab.html.erb +66 -0
  65. data/app/assets/components/paper-tabs/paper-tabs.css +57 -0
  66. data/app/assets/components/paper-tabs/paper-tabs.html.erb +127 -0
  67. data/app/assets/components/paper-toast/paper-toast.css +0 -0
  68. data/app/assets/components/paper-toast/paper-toast.html.erb +258 -0
  69. data/app/assets/components/paper-toggle-button/paper-toggle-button.css +61 -0
  70. data/app/assets/components/paper-toggle-button/paper-toggle-button.html.erb +125 -0
  71. data/lib/polymer-paper-rails/engine.rb +4 -0
  72. data/lib/polymer-paper-rails/version.rb +3 -0
  73. data/lib/polymer-paper-rails.rb +2 -0
  74. metadata +158 -0
@@ -0,0 +1,386 @@
1
+ <!--
2
+ Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6
+ Code distributed by Google as part of the polymer project is also
7
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8
+ -->
9
+ <!--
10
+
11
+ The `core-style` element helps manage styling inside other elements and can
12
+ be used to make themes. The `core-style` element can be either a producer
13
+ or consumer of styling. If it has its `id` property set, it's a producer.
14
+ Elements that are producers should include css styling as their text content.
15
+ If a `core-style` has its `ref` property set, it's a consumer. A `core-style`
16
+ typically sets its `ref` property to the value of the `id` property of the
17
+ `core-style` it wants to use. This allows a single producer to be used in
18
+ multiple places, for example, in many different elements.
19
+
20
+ It's common to place `core-style` producer elements inside HTMLImports.
21
+ Remote stylesheets should be included this way, the @import css mechanism is
22
+ not currently supported.
23
+
24
+ Here's a basic example:
25
+
26
+ <polymer-element name="x-test" noscript>
27
+ <template>
28
+ <core-style ref="x-test"></core-style>
29
+ <content></content>
30
+ </template>
31
+ </polymer-element>
32
+
33
+ The `x-test` element above will be styled by any `core-style` elements that have
34
+ `id` set to `x-test`. These `core-style` producers are separate from the element
35
+ definition, allowing a user of the element to style it independent of the author's
36
+ styling. For example:
37
+
38
+ <core-style id="x-test">
39
+ :host {
40
+ backgound-color: steelblue;
41
+ }
42
+ </core-style>
43
+
44
+ The content of the `x-test` `core-style` producer gets included inside the
45
+ shadowRoot of the `x-test` element. If the content of the `x-test` producer
46
+ `core-style` changes, all consumers of it are automatically kept in sync. This
47
+ allows updating styling on the fly.
48
+
49
+ The `core-style` element also supports bindings and it is the producer
50
+ `core-style` element is the model for its content. Here's an example:
51
+
52
+ <core-style id="x-test">
53
+ :host {
54
+ background-color: {{myColor}};
55
+ }
56
+ </core-style>
57
+ <script>
58
+ document._currentScript.ownerDocument.getElementById('x-test').myColor = 'orange';
59
+ </script>
60
+
61
+ Finally, to facilitate sharing data between `core-style` elements, all
62
+ `core-style` elements have a `g` property which is set to the global
63
+ `CoreStyle.g`. Here's an example:
64
+
65
+ <core-style id="x-test">
66
+ :host {
67
+ background-color: {{g.myColor}};
68
+ }
69
+ </core-style>
70
+ <script>
71
+ CoreStyle.g.myColor = 'tomato';
72
+ </script>
73
+
74
+ Finally, one `core-style` can be nested inside another. The `core-style`
75
+ element has a `list` property which is a map of all the `core-style` producers.
76
+ A `core-style` producer's content is available via its `cssText` property.
77
+ Putting this together:
78
+
79
+ <core-style id="common">
80
+ :host {
81
+ font-family: sans-serif;
82
+ }
83
+ </core-style>
84
+
85
+ <core-style id="x-test">
86
+ {{list.common.cssText}}
87
+
88
+ :host {
89
+ background-color: {{g.myColor}};
90
+ }
91
+ </core-style>
92
+
93
+
94
+ @group Polymer Core Elements
95
+ @element core-style
96
+ @homepage github.io
97
+ -->
98
+
99
+
100
+ <polymer-element name="core-style" hidden>
101
+ <script>
102
+ (function() {
103
+
104
+ window.CoreStyle = window.CoreStyle || {
105
+ g: {},
106
+ list: {},
107
+ refMap: {}
108
+ };
109
+
110
+ Polymer('core-style', {
111
+ /**
112
+ * The `id` property should be set if the `core-style` is a producer
113
+ * of styles. In this case, the `core-style` should have text content
114
+ * that is cssText.
115
+ *
116
+ * @attribute id
117
+ * @type string
118
+ * @default ''
119
+ */
120
+
121
+
122
+ publish: {
123
+ /**
124
+ * The `ref` property should be set if the `core-style` element is a
125
+ * consumer of styles. Set it to the `id` of the desired `core-style`
126
+ * element.
127
+ *
128
+ * @attribute ref
129
+ * @type string
130
+ * @default ''
131
+ */
132
+ ref: ''
133
+ },
134
+
135
+ // static
136
+ g: CoreStyle.g,
137
+ refMap: CoreStyle.refMap,
138
+
139
+ /**
140
+ * The `list` is a map of all `core-style` producers stored by `id`. It
141
+ * should be considered readonly. It's useful for nesting one `core-style`
142
+ * inside another.
143
+ *
144
+ * @attribute list
145
+ * @type object (readonly)
146
+ * @default {map of all `core-style` producers}
147
+ */
148
+ list: CoreStyle.list,
149
+
150
+ // if we have an id, we provide style
151
+ // if we have a ref, we consume/require style
152
+ ready: function() {
153
+ if (this.id) {
154
+ this.provide();
155
+ } else {
156
+ this.registerRef(this.ref);
157
+ if (!window.ShadowDOMPolyfill) {
158
+ this.require();
159
+ }
160
+ }
161
+ },
162
+
163
+ // can't shim until attached if using SD polyfill because need to find host
164
+ attached: function() {
165
+ if (!this.id && window.ShadowDOMPolyfill) {
166
+ this.require();
167
+ }
168
+ },
169
+
170
+ /****** producer stuff *******/
171
+
172
+ provide: function() {
173
+ this.register();
174
+ // we want to do this asap, especially so we can do so before definitions
175
+ // that use this core-style are registered.
176
+ if (this.textContent) {
177
+ this._completeProvide();
178
+ } else {
179
+ this.async(this._completeProvide);
180
+ }
181
+ },
182
+
183
+ register: function() {
184
+ var i = this.list[this.id];
185
+ if (i) {
186
+ if (!Array.isArray(i)) {
187
+ this.list[this.id] = [i];
188
+ }
189
+ this.list[this.id].push(this);
190
+ } else {
191
+ this.list[this.id] = this;
192
+ }
193
+ },
194
+
195
+ // stamp into a shadowRoot so we can monitor dom of the bound output
196
+ _completeProvide: function() {
197
+ this.createShadowRoot();
198
+ this.domObserver = new MutationObserver(this.domModified.bind(this))
199
+ .observe(this.shadowRoot, {subtree: true,
200
+ characterData: true, childList: true});
201
+ this.provideContent();
202
+ },
203
+
204
+ provideContent: function() {
205
+ this.ensureTemplate();
206
+ this.shadowRoot.textContent = '';
207
+ this.shadowRoot.appendChild(this.instanceTemplate(this.template));
208
+ this.cssText = this.shadowRoot.textContent;
209
+ },
210
+
211
+ ensureTemplate: function() {
212
+ if (!this.template) {
213
+ this.template = this.querySelector('template:not([repeat]):not([bind])');
214
+ // move content into the template
215
+ if (!this.template) {
216
+ this.template = document.createElement('template');
217
+ var n = this.firstChild;
218
+ while (n) {
219
+ this.template.content.appendChild(n.cloneNode(true));
220
+ n = n.nextSibling;
221
+ }
222
+ }
223
+ }
224
+ },
225
+
226
+ domModified: function() {
227
+ this.cssText = this.shadowRoot.textContent;
228
+ this.notify();
229
+ },
230
+
231
+ // notify instances that reference this element
232
+ notify: function() {
233
+ var s$ = this.refMap[this.id];
234
+ if (s$) {
235
+ for (var i=0, s; (s=s$[i]); i++) {
236
+ s.require();
237
+ }
238
+ }
239
+ },
240
+
241
+ /****** consumer stuff *******/
242
+
243
+ registerRef: function(ref) {
244
+ //console.log('register', ref);
245
+ this.refMap[this.ref] = this.refMap[this.ref] || [];
246
+ this.refMap[this.ref].push(this);
247
+ },
248
+
249
+ applyRef: function(ref) {
250
+ this.ref = ref;
251
+ this.registerRef(this.ref);
252
+ this.require();
253
+ },
254
+
255
+ require: function() {
256
+ var cssText = this.cssTextForRef(this.ref);
257
+ //console.log('require', this.ref, cssText);
258
+ if (cssText) {
259
+ this.ensureStyleElement();
260
+ // do nothing if cssText has not changed
261
+ if (this.styleElement._cssText === cssText) {
262
+ return;
263
+ }
264
+ this.styleElement._cssText = cssText;
265
+ if (window.ShadowDOMPolyfill) {
266
+ this.styleElement.textContent = cssText;
267
+ cssText = Platform.ShadowCSS.shimStyle(this.styleElement,
268
+ this.getScopeSelector());
269
+ }
270
+ this.styleElement.textContent = cssText;
271
+ }
272
+ },
273
+
274
+ cssTextForRef: function(ref) {
275
+ var s$ = this.byId(ref);
276
+ var cssText = '';
277
+ if (s$) {
278
+ if (Array.isArray(s$)) {
279
+ var p = [];
280
+ for (var i=0, l=s$.length, s; (i<l) && (s=s$[i]); i++) {
281
+ p.push(s.cssText);
282
+ }
283
+ cssText = p.join('\n\n');
284
+ } else {
285
+ cssText = s$.cssText;
286
+ }
287
+ }
288
+ if (s$ && !cssText) {
289
+ console.warn('No styles provided for ref:', ref);
290
+ }
291
+ return cssText;
292
+ },
293
+
294
+ byId: function(id) {
295
+ return this.list[id];
296
+ },
297
+
298
+ ensureStyleElement: function() {
299
+ if (!this.styleElement) {
300
+ this.styleElement = window.ShadowDOMPolyfill ?
301
+ this.makeShimStyle() :
302
+ this.makeRootStyle();
303
+ }
304
+ if (!this.styleElement) {
305
+ console.warn(this.localName, 'could not setup style.');
306
+ }
307
+ },
308
+
309
+ makeRootStyle: function() {
310
+ var style = document.createElement('style');
311
+ this.appendChild(style);
312
+ return style;
313
+ },
314
+
315
+ makeShimStyle: function() {
316
+ var host = this.findHost(this);
317
+ if (host) {
318
+ var name = host.localName;
319
+ var style = document.querySelector('style[' + name + '=' + this.ref +']');
320
+ if (!style) {
321
+ style = document.createElement('style');
322
+ style.setAttribute(name, this.ref);
323
+ document.head.appendChild(style);
324
+ }
325
+ return style;
326
+ }
327
+ },
328
+
329
+ getScopeSelector: function() {
330
+ if (!this._scopeSelector) {
331
+ var selector = '', host = this.findHost(this);
332
+ if (host) {
333
+ var typeExtension = host.hasAttribute('is');
334
+ var name = typeExtension ? host.getAttribute('is') : host.localName;
335
+ selector = Platform.ShadowCSS.makeScopeSelector(name,
336
+ typeExtension);
337
+ }
338
+ this._scopeSelector = selector;
339
+ }
340
+ return this._scopeSelector;
341
+ },
342
+
343
+ findHost: function(node) {
344
+ while (node.parentNode) {
345
+ node = node.parentNode;
346
+ }
347
+ return node.host || wrap(document.documentElement);
348
+ },
349
+
350
+ /* filters! */
351
+ // TODO(dfreedm): add more filters!
352
+
353
+ cycle: function(rgb, amount) {
354
+ if (rgb.match('#')) {
355
+ var o = this.hexToRgb(rgb);
356
+ if (!o) {
357
+ return rgb;
358
+ }
359
+ rgb = 'rgb(' + o.r + ',' + o.b + ',' + o.g + ')';
360
+ }
361
+
362
+ function cycleChannel(v) {
363
+ return Math.abs((Number(v) - amount) % 255);
364
+ }
365
+
366
+ return rgb.replace(/rgb\(([^,]*),([^,]*),([^,]*)\)/, function(m, a, b, c) {
367
+ return 'rgb(' + cycleChannel(a) + ',' + cycleChannel(b) + ', '
368
+ + cycleChannel(c) + ')';
369
+ });
370
+ },
371
+
372
+ hexToRgb: function(hex) {
373
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
374
+ return result ? {
375
+ r: parseInt(result[1], 16),
376
+ g: parseInt(result[2], 16),
377
+ b: parseInt(result[3], 16)
378
+ } : null;
379
+ }
380
+
381
+ });
382
+
383
+
384
+ })();
385
+ </script>
386
+ </polymer-element>
@@ -0,0 +1,76 @@
1
+ <!--
2
+ Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6
+ Code distributed by Google as part of the polymer project is also
7
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8
+ -->
9
+
10
+ <%= html_import_tag "core/transition/core-transition" %>
11
+
12
+ <polymer-element name="core-transition-css" extends="core-transition" attributes="transitionType">
13
+ <template>
14
+ <%= stylesheet_link_tag "core/transition/core-transition-overlay",'no-shim' => true %>
15
+ </template>
16
+ <script>
17
+
18
+ Polymer('core-transition-css', {
19
+
20
+ baseClass: 'core-transition',
21
+ openedClass: 'core-opened',
22
+ closedClass: 'core-closed',
23
+ completeEventName: 'transitionend',
24
+
25
+ registerCallback: function(element) {
26
+ this.transitionStyle = element.templateContent().firstElementChild;
27
+ },
28
+
29
+ // template is just for loading styles, we don't need a shadowRoot
30
+ fetchTemplate: function() {
31
+ return null;
32
+ },
33
+
34
+ go: function(node, state) {
35
+ if (state.opened !== undefined) {
36
+ this.transitionOpened(node, state.opened);
37
+ }
38
+ },
39
+
40
+ setup: function(node) {
41
+ if (!node._hasTransitionStyle) {
42
+ if (!node.shadowRoot) {
43
+ node.createShadowRoot().innerHTML = '<content></content>';
44
+ }
45
+ this.installScopeStyle(this.transitionStyle, 'transition',
46
+ node.shadowRoot);
47
+ node._hasTransitionStyle = true;
48
+ node.classList.add(this.baseClass);
49
+ if (this.transitionType) {
50
+ node.classList.add(this.baseClass + '-' + this.transitionType);
51
+ }
52
+ }
53
+ },
54
+
55
+ transitionOpened: function(node, opened) {
56
+ this.listenOnce(node, this.completeEventName, function() {
57
+ node.classList.toggle(this.revealedClass, opened);
58
+ if (!opened) {
59
+ node.classList.remove(this.closedClass);
60
+ }
61
+ this.complete(node);
62
+ });
63
+ node.classList.toggle(this.openedClass, opened);
64
+ node.classList.toggle(this.closedClass, !opened);
65
+ }
66
+
67
+ });
68
+ </script>
69
+ </polymer-element>
70
+
71
+ <core-transition-css id="core-transition-fade"></core-transition-css>
72
+ <core-transition-css id="core-transition-center" transitionType="center"></core-transition-css>
73
+ <core-transition-css id="core-transition-top" transitionType="top"></core-transition-css>
74
+ <core-transition-css id="core-transition-bottom" transitionType="bottom"></core-transition-css>
75
+ <core-transition-css id="core-transition-left" transitionType="left"></core-transition-css>
76
+ <core-transition-css id="core-transition-right" transitionType="right"></core-transition-css>