polymer-rails 0.2.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -3
  3. data/app/assets/javascripts/polymer/polymer-micro.html +36 -0
  4. data/app/assets/javascripts/polymer/polymer-mini.html +45 -0
  5. data/app/assets/javascripts/polymer/polymer.html +59 -11
  6. data/app/assets/javascripts/polymer/src/lib/annotations/annotations.html +262 -0
  7. data/app/assets/javascripts/polymer/src/lib/annotations/demo/app-chrome.html +60 -0
  8. data/app/assets/javascripts/polymer/src/lib/array-observe.html +118 -0
  9. data/app/assets/javascripts/polymer/src/lib/array-splice.html +262 -0
  10. data/app/assets/javascripts/polymer/src/lib/async.html +68 -0
  11. data/app/assets/javascripts/polymer/src/lib/base.html +117 -0
  12. data/app/assets/javascripts/polymer/src/lib/bind/accessors.html +223 -0
  13. data/app/assets/javascripts/polymer/src/lib/bind/demo/app-chrome.html +28 -0
  14. data/app/assets/javascripts/polymer/src/lib/bind/demo/app.html +29 -0
  15. data/app/assets/javascripts/polymer/src/lib/bind/demo/src/annotations-bind-demo.html +76 -0
  16. data/app/assets/javascripts/polymer/src/lib/bind/demo/src/bind-demo.html +83 -0
  17. data/app/assets/javascripts/polymer/src/lib/bind/effects.html +80 -0
  18. data/app/assets/javascripts/polymer/src/lib/case-map.html +46 -0
  19. data/app/assets/javascripts/polymer/src/lib/collection.html +179 -0
  20. data/app/assets/javascripts/polymer/src/lib/css-parse.html +131 -0
  21. data/app/assets/javascripts/polymer/src/lib/debounce.html +69 -0
  22. data/app/assets/javascripts/polymer/src/lib/dom-api.html +467 -0
  23. data/app/assets/javascripts/polymer/src/lib/dom-module.html +68 -0
  24. data/app/assets/javascripts/polymer/src/lib/event-api.html +92 -0
  25. data/app/assets/javascripts/polymer/src/lib/expr/focus.html +22 -0
  26. data/app/assets/javascripts/polymer/src/lib/expr/gestures.html +1 -0
  27. data/app/assets/javascripts/polymer/src/lib/expr/log.html +21 -0
  28. data/app/assets/javascripts/polymer/src/lib/expr/sinspect.html +235 -0
  29. data/app/assets/javascripts/polymer/src/lib/expr/style-auditor.html +123 -0
  30. data/app/assets/javascripts/polymer/src/lib/expr/style-protector.html +52 -0
  31. data/app/assets/javascripts/polymer/src/lib/gestures.html +284 -0
  32. data/app/assets/javascripts/polymer/src/lib/lang.html +21 -0
  33. data/app/assets/javascripts/polymer/src/lib/module.html +56 -0
  34. data/app/assets/javascripts/polymer/src/lib/polymer-bootstrap.html +78 -0
  35. data/app/assets/javascripts/polymer/src/lib/resolve-url.html +82 -0
  36. data/app/assets/javascripts/polymer/src/lib/settings.html +52 -0
  37. data/app/assets/javascripts/polymer/src/lib/style-defaults.html +32 -0
  38. data/app/assets/javascripts/polymer/src/lib/style-transformer.html +185 -0
  39. data/app/assets/javascripts/polymer/src/lib/style-util.html +77 -0
  40. data/app/assets/javascripts/polymer/src/lib/template/templatizer.html +132 -0
  41. data/app/assets/javascripts/polymer/src/lib/template/x-array-selector.html +178 -0
  42. data/app/assets/javascripts/polymer/src/lib/template/x-autobind.html +80 -0
  43. data/app/assets/javascripts/polymer/src/lib/template/x-if.html +115 -0
  44. data/app/assets/javascripts/polymer/src/lib/template/x-repeat.html +510 -0
  45. data/app/assets/javascripts/polymer/src/lib/template/x-template.html +39 -0
  46. data/app/assets/javascripts/polymer/src/lib/x-style.html +115 -0
  47. data/app/assets/javascripts/polymer/src/micro/attributes.html +180 -0
  48. data/app/assets/javascripts/polymer/src/micro/constructor.html +74 -0
  49. data/app/assets/javascripts/polymer/src/micro/extends.html +79 -0
  50. data/app/assets/javascripts/polymer/src/micro/mixins.html +40 -0
  51. data/app/assets/javascripts/polymer/src/micro/properties.html +96 -0
  52. data/app/assets/javascripts/polymer/src/micro/tag.html +28 -0
  53. data/app/assets/javascripts/polymer/src/mini/ready.html +180 -0
  54. data/app/assets/javascripts/polymer/src/mini/shadow.html +41 -0
  55. data/app/assets/javascripts/polymer/src/mini/shady.html +365 -0
  56. data/app/assets/javascripts/polymer/src/mini/template.html +56 -0
  57. data/app/assets/javascripts/polymer/src/polymer-lib.html +15 -0
  58. data/app/assets/javascripts/polymer/src/standard/annotations.html +198 -0
  59. data/app/assets/javascripts/polymer/src/standard/configure.html +160 -0
  60. data/app/assets/javascripts/polymer/src/standard/effects.html +215 -0
  61. data/app/assets/javascripts/polymer/src/standard/events.html +127 -0
  62. data/app/assets/javascripts/polymer/src/standard/notify-path.html +260 -0
  63. data/app/assets/javascripts/polymer/src/standard/resolveUrl.html +27 -0
  64. data/app/assets/javascripts/polymer/src/standard/styling.html +157 -0
  65. data/app/assets/javascripts/polymer/src/standard/utils.html +158 -0
  66. data/app/assets/javascripts/polymer/src/standard/x-styling.html +300 -0
  67. data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +2270 -0
  68. data/lib/generators/polymer/component/templates/component.html.erb +3 -3
  69. data/lib/generators/polymer/install/install_generator.rb +1 -1
  70. data/lib/polymer-rails/version.rb +1 -1
  71. metadata +80 -5
  72. data/app/assets/javascripts/polymer/layout.html +0 -286
  73. data/app/assets/javascripts/polymer/polymer.js +0 -14
  74. data/app/assets/javascripts/polymer/webcomponents.js +0 -14
@@ -0,0 +1,117 @@
1
+ <!--
2
+ @license
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
+ <script>
11
+
12
+ Polymer.Base = {
13
+
14
+ // (semi-)pluggable features for Base
15
+ addFeature: function(feature) {
16
+ this.extend(this, feature);
17
+ },
18
+
19
+ registerCallback: function() {
20
+ this.registerFeatures(); // abstract
21
+ this.registered();
22
+ },
23
+
24
+ registered: function() {
25
+ // for overriding
26
+ // `this` context is a prototype, not an instance
27
+ },
28
+
29
+ createdCallback: function() {
30
+ Polymer.telemetry.instanceCount++;
31
+ this.root = this;
32
+ this.beforeCreated();
33
+ this.created();
34
+ this.afterCreated();
35
+ this.initFeatures(); // abstract
36
+ },
37
+
38
+ beforeCreated: function() {
39
+ // for overriding
40
+ },
41
+
42
+ created: function() {
43
+ // for overriding
44
+ },
45
+
46
+ afterCreated: function() {
47
+ // for overriding
48
+ },
49
+
50
+ attachedCallback: function() {
51
+ this.isAttached = true;
52
+ // reserved for canonical behavior
53
+ this.attached();
54
+ },
55
+
56
+ attached: function() {
57
+ // for overriding
58
+ },
59
+
60
+ detachedCallback: function() {
61
+ this.isAttached = false;
62
+ // reserved for canonical behavior
63
+ this.detached();
64
+ },
65
+
66
+ detached: function() {
67
+ // for overriding
68
+ },
69
+
70
+ attributeChangedCallback: function(name) {
71
+ this.setAttributeToProperty(this, name);
72
+ // reserved for canonical behavior
73
+ this.attributeChanged.apply(this, arguments);
74
+ },
75
+
76
+ attributeChanged: function() {
77
+ // for overriding
78
+ },
79
+
80
+ // copy own properties from `api` to `prototype`
81
+ extend: function(prototype, api) {
82
+ if (prototype && api) {
83
+ Object.getOwnPropertyNames(api).forEach(function(n) {
84
+ var pd = Object.getOwnPropertyDescriptor(api, n);
85
+ if (pd) {
86
+ Object.defineProperty(prototype, n, pd);
87
+ }
88
+ });
89
+ }
90
+ return prototype || api;
91
+ }
92
+
93
+ };
94
+
95
+ if (Object.__proto__) {
96
+ Polymer.Base.chainObject = function(object, inherited) {
97
+ if (object && inherited && object !== inherited) {
98
+ object.__proto__ = inherited;
99
+ }
100
+ return object;
101
+ };
102
+ } else {
103
+ Polymer.Base.chainObject = function(object, inherited) {
104
+ if (object && inherited && object !== inherited) {
105
+ var chained = Object.create(inherited);
106
+ object = Polymer.Base.extend(chained, object);
107
+ }
108
+ return object;
109
+ };
110
+ }
111
+
112
+ Polymer.Base = Polymer.Base.chainObject(Polymer.Base, HTMLElement.prototype);
113
+
114
+ // TODO(sjmiles): ad hoc telemetry
115
+ Polymer.telemetry.instanceCount = 0;
116
+
117
+ </script>
@@ -0,0 +1,223 @@
1
+ <!--
2
+ @license
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
+ <script>
11
+
12
+ Polymer.Bind = {
13
+
14
+ // for prototypes (usually)
15
+
16
+ prepareModel: function(model) {
17
+ model._propertyEffects = {};
18
+ model._bindListeners = [];
19
+ // TODO(sjmiles): no mixin function?
20
+ var api = this._modelApi;
21
+ for (var n in api) {
22
+ model[n] = api[n];
23
+ }
24
+ },
25
+
26
+ _modelApi: {
27
+
28
+ _notifyChange: function(property) {
29
+ var eventName = Polymer.CaseMap.camelToDashCase(property) + '-changed';
30
+ // TODO(sjmiles): oops, `fire` doesn't exist at this layer
31
+ this.fire(eventName, {
32
+ value: this[property]
33
+ }, null, false);
34
+ },
35
+
36
+ // TODO(sjmiles): removing _notifyListener from here breaks accessors.html
37
+ // as a standalone lib. This is temporary, as standard/configure.html
38
+ // installs it's own version on Polymer.Base, and we need that to work
39
+ // right now.
40
+ // NOTE: exists as a hook for processing listeners
41
+ /*
42
+ _notifyListener: function(fn, e) {
43
+ // NOTE: pass e.target because e.target can get lost if this function
44
+ // is queued asynchrously
45
+ return fn.call(this, e, e.target);
46
+ },
47
+ */
48
+
49
+ _propertySet: function(property, value, effects) {
50
+ var old = this._data[property];
51
+ if (old !== value) {
52
+ this._data[property] = value;
53
+ if (typeof value == 'object') {
54
+ this._clearPath(property);
55
+ }
56
+ if (effects) {
57
+ this._effectEffects(property, value, effects, old);
58
+ }
59
+ }
60
+ return old;
61
+ },
62
+
63
+ _effectEffects: function(property, value, effects, old) {
64
+ effects.forEach(function(fx) {
65
+ //console.log(fx);
66
+ var fn = Polymer.Bind[fx.kind + 'Effect'];
67
+ if (fn) {
68
+ fn.call(this, property, value, fx.effect, old);
69
+ }
70
+ }, this);
71
+ },
72
+
73
+ _clearPath: function(path) {
74
+ for (var prop in this._data) {
75
+ if (prop.indexOf(path + '.') === 0) {
76
+ this._data[prop] = undefined;
77
+ }
78
+ }
79
+ }
80
+
81
+ },
82
+
83
+ // a prepared model can acquire effects
84
+
85
+ addPropertyEffect: function(model, property, kind, effect) {
86
+ var fx = model._propertyEffects[property];
87
+ if (!fx) {
88
+ fx = model._propertyEffects[property] = [];
89
+ }
90
+ fx.push({
91
+ kind: kind,
92
+ effect: effect
93
+ });
94
+ },
95
+
96
+ createBindings: function(model) {
97
+ //console.group(model.is);
98
+ // map of properties to effects
99
+ var fx$ = model._propertyEffects;
100
+ if (fx$) {
101
+ // for each property with effects
102
+ for (var n in fx$) {
103
+ // array of effects
104
+ var fx = fx$[n];
105
+ // effects have priority
106
+ fx.sort(this._sortPropertyEffects);
107
+ // create accessors
108
+ this._createAccessors(model, n, fx);
109
+ }
110
+ }
111
+ //console.groupEnd();
112
+ },
113
+
114
+ _sortPropertyEffects: (function() {
115
+ // TODO(sjmiles): EFFECT_ORDER buried this way is not ideal,
116
+ // but presumably the sort method is going to be a hot path and not
117
+ // have a `this`. There is also a problematic dependency on effect.kind
118
+ // values here, which are otherwise pluggable.
119
+ var EFFECT_ORDER = {
120
+ 'compute': 0,
121
+ 'annotation': 1,
122
+ 'computedAnnotation': 2,
123
+ 'reflect': 3,
124
+ 'notify': 4,
125
+ 'observer': 5,
126
+ 'function': 6
127
+ };
128
+ return function(a, b) {
129
+ return EFFECT_ORDER[a.kind] - EFFECT_ORDER[b.kind];
130
+ };
131
+ })(),
132
+
133
+ // create accessors that implement effects
134
+
135
+ _createAccessors: function(model, property, effects) {
136
+ var defun = {
137
+ get: function() {
138
+ // TODO(sjmiles): elide delegation for performance, good ROI?
139
+ return this._data[property];
140
+ }
141
+ };
142
+ var setter = function(value) {
143
+ this._propertySet(property, value, effects);
144
+ };
145
+ // ReadOnly properties have a private setter only
146
+ // TODO(kschaaf): Per current Bind factoring, we shouldn't
147
+ // be interrogating the prototype here
148
+ if (model.isReadOnlyProperty && model.isReadOnlyProperty(property)) {
149
+ //model['_' + property + 'Setter'] = setter;
150
+ //model['_set_' + property] = setter;
151
+ model['_set' + this.upper(property)] = setter;
152
+ } else {
153
+ defun.set = setter;
154
+ }
155
+ Object.defineProperty(model, property, defun);
156
+ },
157
+
158
+ upper: function(name) {
159
+ return name[0].toUpperCase() + name.substring(1);
160
+ },
161
+
162
+ _addAnnotatedListener: function(model, index, property, path, event) {
163
+ var fn = this._notedListenerFactory(property, path,
164
+ this._isStructured(path), this._isEventBogus);
165
+ var eventName = event ||
166
+ (Polymer.CaseMap.camelToDashCase(property) + '-changed');
167
+ model._bindListeners.push({
168
+ index: index,
169
+ property: property,
170
+ path: path,
171
+ changedFn: fn,
172
+ event: eventName
173
+ });
174
+ },
175
+
176
+ _isStructured: function(path) {
177
+ return path.indexOf('.') > 0;
178
+ },
179
+
180
+ _isEventBogus: function(e, target) {
181
+ return e.path && e.path[0] !== target;
182
+ },
183
+
184
+ _notedListenerFactory: function(property, path, isStructured, bogusTest) {
185
+ return function(e, target) {
186
+ if (!bogusTest(e, target)) {
187
+ if (e.detail && e.detail.path) {
188
+ this.notifyPath(this._fixPath(path, property, e.detail.path),
189
+ e.detail.value);
190
+ } else {
191
+ var value = target[property];
192
+ if (!isStructured) {
193
+ this[path] = target[property];
194
+ } else {
195
+ // TODO(kschaaf): dirty check avoids null references when the object has gone away
196
+ if (this._data[path] != value) {
197
+ this.setPathValue(path, value);
198
+ }
199
+ }
200
+ }
201
+ }
202
+ };
203
+ },
204
+
205
+ // for instances
206
+
207
+ prepareInstance: function(inst) {
208
+ inst._data = Object.create(null);
209
+ },
210
+
211
+ setupBindListeners: function(inst) {
212
+ inst._bindListeners.forEach(function(info) {
213
+ // Property listeners:
214
+ // <node>.on.<property>-changed: <path]> = e.detail.value
215
+ //console.log('[_setupBindListener]: [%s][%s] listening for [%s][%s-changed]', this.localName, info.path, info.id || info.index, info.property);
216
+ var node = inst._nodes[info.index];
217
+ node.addEventListener(info.event, inst._notifyListener.bind(inst, info.changedFn));
218
+ });
219
+ }
220
+
221
+ };
222
+
223
+ </script>
@@ -0,0 +1,28 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+
5
+ <title>Bind Test</title>
6
+
7
+ <meta charset="utf-8">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
+
10
+ <style>
11
+ pre {
12
+ font-family: sans-serif;
13
+ font-size: 14px;
14
+ }
15
+ </style>
16
+
17
+ <link rel="import" href="src/bind-demo.html">
18
+ <link rel="import" href="src/annotations-bind-demo.html">
19
+
20
+ </head>
21
+ <body>
22
+
23
+ <pre id="bd"></pre>
24
+
25
+ <pre id="abd"></pre>
26
+
27
+ </body>
28
+ </html>
@@ -0,0 +1,29 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+
5
+ <title>Bind Test</title>
6
+
7
+ <meta charset="utf-8">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
+
10
+ <script src="../../../../webcomponentsjs/webcomponents-lite.js"></script>
11
+
12
+ <style>
13
+ pre {
14
+ font-family: sans-serif;
15
+ font-size: 14px;
16
+ }
17
+ </style>
18
+
19
+ <link rel="import" href="src/bind-demo.html">
20
+ <link rel="import" href="src/annotations-bind-demo.html">
21
+
22
+ </head>
23
+ <body>
24
+
25
+ <pre id="bd"></pre>
26
+ <pre id="abd"></pre>
27
+
28
+ </body>
29
+ </html>
@@ -0,0 +1,76 @@
1
+ <link rel="import" href="../../../module.html">
2
+ <link rel="import" href="../../../lang.html">
3
+ <link rel="import" href="../../../annotations/annotations.html">
4
+
5
+ <link rel="import" href="../../bind.html">
6
+ <link rel="import" href="../../bind-effects.html">
7
+ <link rel="import" href="../../bind-annotations.html">
8
+
9
+ <template>
10
+
11
+ <div>annotated #foo span:</div>
12
+ <br>
13
+ <span id="foo" attribute="{{path}}" oneway="[[otherpath]]" style="{{specialStyle}}">{{text}}</span>
14
+
15
+ </template>
16
+
17
+ <script>
18
+
19
+ // TODO(sjmiles): should 'bind-annotations' blend the other two modules
20
+ // somehow so we don't need to include all three here?
21
+ using(['Annotations', 'bind', 'bind-annotations'],
22
+
23
+ function(Annotations, Bind, BindAnnotations) {
24
+
25
+ var out = document.querySelector('#abd');
26
+ out.innerHTML += '<hr><h3>annotations-bind demo</h3><hr>';
27
+
28
+ // phase one: prototyping
29
+
30
+ var prototype = {};
31
+ var template = currentImport.querySelector('template');
32
+ var list = Templabindinate(prototype, template);
33
+
34
+ // phase two: instancing
35
+
36
+ var model = Object.create(prototype);
37
+ var dom = Instancinance(model, template);
38
+ document.body.appendChild(dom);
39
+
40
+ // affect model
41
+
42
+ model.text = 'Hello from Model';
43
+ model.path = 'path';
44
+ model.otherpath = 'other.path';
45
+ model.specialStyle = {backgroundColor: "red"};
46
+
47
+ // effects visible in dom
48
+
49
+ var foo = dom.querySelector('#foo');
50
+ out.innerHTML +=
51
+ 'foo.<b>path</b> = "' + model.path + '"<br>'
52
+ + 'foo.<b>otherpath</b> = "' + model.otherpath + '"<br>'
53
+ + 'foo.<b>specialStyle</b> = "' + JSON.stringify(model.specialStyle)+ '"<br>'
54
+ ;
55
+
56
+ // ad hoc abstractions
57
+
58
+ function Templabindinate(model, template) {
59
+ Bind.prepareModel(model);
60
+ var list = Annotations.parseAnnotations(template);
61
+ BindAnnotations.addEffects(model, list);
62
+ return list;
63
+ }
64
+
65
+ function Instancinance(model, template) {
66
+ Bind.prepareInstance(model);
67
+ Bind.createBindings(model);
68
+ var dom = document.importNode(template.content, true);
69
+ model._nodes = BindAnnotations.marshalAnnotatedNodes(model._nodes, dom,
70
+ Annotations.findAnnotatedNode);
71
+ return dom;
72
+ }
73
+
74
+ });
75
+
76
+ </script>