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.
- checksums.yaml +7 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/app/assets/components/gold-cc-cvc-input/README.md +24 -0
- data/app/assets/components/gold-cc-cvc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint_amex.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/demo/index.html +54 -0
- data/app/assets/components/gold-cc-cvc-input/gold-cc-cvc-input.html +195 -0
- data/app/assets/components/gold-cc-cvc-input/hero.svg +36 -0
- data/app/assets/components/gold-cc-cvc-input/index.html +26 -0
- data/app/assets/components/gold-cc-cvc-input/test/basic.html +125 -0
- data/app/assets/components/gold-cc-cvc-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-expiration-input/README.md +10 -0
- data/app/assets/components/gold-cc-expiration-input/bower.json +40 -0
- data/app/assets/components/gold-cc-expiration-input/date-input.html +157 -0
- data/app/assets/components/gold-cc-expiration-input/date-validator.html +38 -0
- data/app/assets/components/gold-cc-expiration-input/demo/index.html +53 -0
- data/app/assets/components/gold-cc-expiration-input/gold-cc-expiration-input.html +131 -0
- data/app/assets/components/gold-cc-expiration-input/hero.svg +58 -0
- data/app/assets/components/gold-cc-expiration-input/index.html +28 -0
- data/app/assets/components/gold-cc-expiration-input/test/basic.html +126 -0
- data/app/assets/components/gold-cc-expiration-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-input/README.md +9 -0
- data/app/assets/components/gold-cc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-input/cc-validator.js +192 -0
- data/app/assets/components/gold-cc-input/demo/index.html +48 -0
- data/app/assets/components/gold-cc-input/gold-cc-input.html +215 -0
- data/app/assets/components/gold-cc-input/hero.svg +52 -0
- data/app/assets/components/gold-cc-input/images/amex.png +0 -0
- data/app/assets/components/gold-cc-input/images/diners_club.png +0 -0
- data/app/assets/components/gold-cc-input/images/discover.png +0 -0
- data/app/assets/components/gold-cc-input/images/jcb.png +0 -0
- data/app/assets/components/gold-cc-input/images/mastercard.png +0 -0
- data/app/assets/components/gold-cc-input/images/visa.png +0 -0
- data/app/assets/components/gold-cc-input/index.html +28 -0
- data/app/assets/components/gold-cc-input/test/basic.html +136 -0
- data/app/assets/components/gold-cc-input/test/index.html +25 -0
- data/app/assets/components/gold-elements/README.md +12 -0
- data/app/assets/components/gold-elements/bower.json +42 -0
- data/app/assets/components/gold-elements/demo/complex-form.html +127 -0
- data/app/assets/components/gold-elements/demo/index.html +94 -0
- data/app/assets/components/gold-elements/demo/item-card.html +59 -0
- data/app/assets/components/gold-elements/demo/simple-form.css +55 -0
- data/app/assets/components/gold-elements/demo/simple-form.html +93 -0
- data/app/assets/components/gold-elements/screenshot.png +0 -0
- data/app/assets/components/gold-email-input/README.md +8 -0
- data/app/assets/components/gold-email-input/bower.json +40 -0
- data/app/assets/components/gold-email-input/demo/index.html +46 -0
- data/app/assets/components/gold-email-input/email-validator.html +31 -0
- data/app/assets/components/gold-email-input/gold-email-input.html +108 -0
- data/app/assets/components/gold-email-input/hero.svg +59 -0
- data/app/assets/components/gold-email-input/index.html +28 -0
- data/app/assets/components/gold-email-input/test/basic.html +97 -0
- data/app/assets/components/gold-email-input/test/index.html +25 -0
- data/app/assets/components/gold-phone-input/README.md +13 -0
- data/app/assets/components/gold-phone-input/bower.json +39 -0
- data/app/assets/components/gold-phone-input/demo/index.html +53 -0
- data/app/assets/components/gold-phone-input/gold-phone-input.html +197 -0
- data/app/assets/components/gold-phone-input/hero.svg +63 -0
- data/app/assets/components/gold-phone-input/index.html +28 -0
- data/app/assets/components/gold-phone-input/test/basic.html +117 -0
- data/app/assets/components/gold-phone-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/README.md +8 -0
- data/app/assets/components/gold-zip-input/bower.json +40 -0
- data/app/assets/components/gold-zip-input/demo/index.html +54 -0
- data/app/assets/components/gold-zip-input/gold-zip-input.html +113 -0
- data/app/assets/components/gold-zip-input/hero.svg +43 -0
- data/app/assets/components/gold-zip-input/index.html +28 -0
- data/app/assets/components/gold-zip-input/test/basic.html +116 -0
- data/app/assets/components/gold-zip-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/zip-validator.html +32 -0
- data/app/assets/components/iron-autogrow-textarea/README.md +24 -0
- data/app/assets/components/iron-autogrow-textarea/bower.json +37 -0
- data/app/assets/components/iron-autogrow-textarea/demo/index.html +81 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/index.html +30 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-autogrow-textarea/test/basic.html +94 -0
- data/app/assets/components/iron-autogrow-textarea/test/index.html +25 -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-form-element-behavior/README.md +2 -0
- data/app/assets/components/iron-form-element-behavior/bower.json +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/index.html +53 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-element.html +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-form.html +42 -0
- data/app/assets/components/iron-form-element-behavior/index.html +30 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/README.md +56 -0
- data/app/assets/components/iron-icon/bower.json +29 -0
- data/app/assets/components/iron-icon/demo/index.html +28 -0
- data/app/assets/components/iron-icon/demo/location.png +0 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/index.html +26 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icon/test/index.html +31 -0
- data/app/assets/components/iron-icon/test/iron-icon.html +120 -0
- data/app/assets/components/iron-input/README.md +16 -0
- data/app/assets/components/iron-input/bower.json +36 -0
- data/app/assets/components/iron-input/demo/index.html +87 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/index.html +30 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-input/test/index.html +24 -0
- data/app/assets/components/iron-input/test/iron-input.html +139 -0
- data/app/assets/components/iron-input/test/letters-only.html +30 -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-validatable-behavior/README.md +3 -0
- data/app/assets/components/iron-validatable-behavior/bower.json +35 -0
- data/app/assets/components/iron-validatable-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validatable-behavior/demo/index.html +71 -0
- data/app/assets/components/iron-validatable-behavior/demo/validatable-input.html +46 -0
- data/app/assets/components/iron-validatable-behavior/index.html +30 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +101 -0
- data/app/assets/components/iron-validatable-behavior/test/index.html +35 -0
- data/app/assets/components/iron-validatable-behavior/test/iron-validatable-behavior.html +52 -0
- data/app/assets/components/iron-validatable-behavior/test/test-validatable.html +28 -0
- data/app/assets/components/iron-validator-behavior/README.md +4 -0
- data/app/assets/components/iron-validator-behavior/bower.json +34 -0
- data/app/assets/components/iron-validator-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validator-behavior/demo/index.html +144 -0
- data/app/assets/components/iron-validator-behavior/index.html +30 -0
- data/app/assets/components/iron-validator-behavior/iron-validator-behavior.html +61 -0
- data/app/assets/components/iron-validator-behavior/test/index.html +34 -0
- data/app/assets/components/iron-validator-behavior/test/iron-validator-behavior.html +47 -0
- data/app/assets/components/iron-validator-behavior/test/simple-validator.html +26 -0
- data/app/assets/components/paper-input/README.md +5 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/bower.json +44 -0
- data/app/assets/components/paper-input/demo/index.html +96 -0
- data/app/assets/components/paper-input/demo/ssn-input.html +94 -0
- data/app/assets/components/paper-input/demo/ssn-validator.html +31 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/index.html +28 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +47 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +317 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +106 -0
- data/app/assets/components/paper-input/test/index.html +28 -0
- data/app/assets/components/paper-input/test/letters-only.html +30 -0
- data/app/assets/components/paper-input/test/paper-input-char-counter.html +112 -0
- data/app/assets/components/paper-input/test/paper-input-container.html +237 -0
- data/app/assets/components/paper-input/test/paper-input-error.html +60 -0
- data/app/assets/components/paper-input/test/paper-input.html +213 -0
- data/app/assets/components/paper-input/test/paper-textarea.html +169 -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/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-gold-rails.rb +2 -0
- data/lib/polymer-gold-rails/enigne.rb +4 -0
- data/lib/polymer-gold-rails/version.rb +3 -0
- metadata +312 -0
@@ -0,0 +1,3768 @@
|
|
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
|
+
@license
|
11
|
+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
12
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
13
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
14
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
15
|
+
Code distributed by Google as part of the polymer project is also
|
16
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
17
|
+
--><link rel="import" href="polymer-mini.html">
|
18
|
+
|
19
|
+
<script>Polymer.nar = [];
|
20
|
+
Polymer.Annotations = {
|
21
|
+
parseAnnotations: function (template) {
|
22
|
+
var list = [];
|
23
|
+
var content = template._content || template.content;
|
24
|
+
this._parseNodeAnnotations(content, list);
|
25
|
+
return list;
|
26
|
+
},
|
27
|
+
_parseNodeAnnotations: function (node, list) {
|
28
|
+
return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, list) : this._parseElementAnnotations(node, list);
|
29
|
+
},
|
30
|
+
_testEscape: function (value) {
|
31
|
+
var escape = value.slice(0, 2);
|
32
|
+
if (escape === '{{' || escape === '[[') {
|
33
|
+
return escape;
|
34
|
+
}
|
35
|
+
},
|
36
|
+
_parseTextNodeAnnotation: function (node, list) {
|
37
|
+
var v = node.textContent;
|
38
|
+
var escape = this._testEscape(v);
|
39
|
+
if (escape) {
|
40
|
+
node.textContent = ' ';
|
41
|
+
var annote = {
|
42
|
+
bindings: [{
|
43
|
+
kind: 'text',
|
44
|
+
mode: escape[0],
|
45
|
+
value: v.slice(2, -2).trim()
|
46
|
+
}]
|
47
|
+
};
|
48
|
+
list.push(annote);
|
49
|
+
return annote;
|
50
|
+
}
|
51
|
+
},
|
52
|
+
_parseElementAnnotations: function (element, list) {
|
53
|
+
var annote = {
|
54
|
+
bindings: [],
|
55
|
+
events: []
|
56
|
+
};
|
57
|
+
this._parseChildNodesAnnotations(element, annote, list);
|
58
|
+
if (element.attributes) {
|
59
|
+
this._parseNodeAttributeAnnotations(element, annote, list);
|
60
|
+
if (this.prepElement) {
|
61
|
+
this.prepElement(element);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
if (annote.bindings.length || annote.events.length || annote.id) {
|
65
|
+
list.push(annote);
|
66
|
+
}
|
67
|
+
return annote;
|
68
|
+
},
|
69
|
+
_parseChildNodesAnnotations: function (root, annote, list, callback) {
|
70
|
+
if (root.firstChild) {
|
71
|
+
for (var i = 0, node = root.firstChild; node; node = node.nextSibling, i++) {
|
72
|
+
if (node.localName === 'template' && !node.hasAttribute('preserve-content')) {
|
73
|
+
this._parseTemplate(node, i, list, annote);
|
74
|
+
}
|
75
|
+
var childAnnotation = this._parseNodeAnnotations(node, list, callback);
|
76
|
+
if (childAnnotation) {
|
77
|
+
childAnnotation.parent = annote;
|
78
|
+
childAnnotation.index = i;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
},
|
83
|
+
_parseTemplate: function (node, index, list, parent) {
|
84
|
+
var content = document.createDocumentFragment();
|
85
|
+
content._notes = this.parseAnnotations(node);
|
86
|
+
content.appendChild(node.content);
|
87
|
+
list.push({
|
88
|
+
bindings: Polymer.nar,
|
89
|
+
events: Polymer.nar,
|
90
|
+
templateContent: content,
|
91
|
+
parent: parent,
|
92
|
+
index: index
|
93
|
+
});
|
94
|
+
},
|
95
|
+
_parseNodeAttributeAnnotations: function (node, annotation) {
|
96
|
+
for (var i = node.attributes.length - 1, a; a = node.attributes[i]; i--) {
|
97
|
+
var n = a.name, v = a.value;
|
98
|
+
if (n === 'id' && !this._testEscape(v)) {
|
99
|
+
annotation.id = v;
|
100
|
+
} else if (n.slice(0, 3) === 'on-') {
|
101
|
+
node.removeAttribute(n);
|
102
|
+
annotation.events.push({
|
103
|
+
name: n.slice(3),
|
104
|
+
value: v
|
105
|
+
});
|
106
|
+
} else {
|
107
|
+
var b = this._parseNodeAttributeAnnotation(node, n, v);
|
108
|
+
if (b) {
|
109
|
+
annotation.bindings.push(b);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
},
|
114
|
+
_parseNodeAttributeAnnotation: function (node, n, v) {
|
115
|
+
var escape = this._testEscape(v);
|
116
|
+
if (escape) {
|
117
|
+
var customEvent;
|
118
|
+
var name = n;
|
119
|
+
var mode = escape[0];
|
120
|
+
v = v.slice(2, -2).trim();
|
121
|
+
var not = false;
|
122
|
+
if (v[0] == '!') {
|
123
|
+
v = v.substring(1);
|
124
|
+
not = true;
|
125
|
+
}
|
126
|
+
var kind = 'property';
|
127
|
+
if (n[n.length - 1] == '$') {
|
128
|
+
name = n.slice(0, -1);
|
129
|
+
kind = 'attribute';
|
130
|
+
}
|
131
|
+
var notifyEvent, colon;
|
132
|
+
if (mode == '{' && (colon = v.indexOf('::')) > 0) {
|
133
|
+
notifyEvent = v.substring(colon + 2);
|
134
|
+
v = v.substring(0, colon);
|
135
|
+
customEvent = true;
|
136
|
+
}
|
137
|
+
if (node.localName == 'input' && n == 'value') {
|
138
|
+
node.setAttribute(n, '');
|
139
|
+
}
|
140
|
+
node.removeAttribute(n);
|
141
|
+
if (kind === 'property') {
|
142
|
+
name = Polymer.CaseMap.dashToCamelCase(name);
|
143
|
+
}
|
144
|
+
return {
|
145
|
+
kind: kind,
|
146
|
+
mode: mode,
|
147
|
+
name: name,
|
148
|
+
value: v,
|
149
|
+
negate: not,
|
150
|
+
event: notifyEvent,
|
151
|
+
customEvent: customEvent
|
152
|
+
};
|
153
|
+
}
|
154
|
+
},
|
155
|
+
_localSubTree: function (node, host) {
|
156
|
+
return node === host ? node.childNodes : node._lightChildren || node.childNodes;
|
157
|
+
},
|
158
|
+
findAnnotatedNode: function (root, annote) {
|
159
|
+
var parent = annote.parent && Polymer.Annotations.findAnnotatedNode(root, annote.parent);
|
160
|
+
return !parent ? root : Polymer.Annotations._localSubTree(parent, root)[annote.index];
|
161
|
+
}
|
162
|
+
};
|
163
|
+
(function () {
|
164
|
+
function resolveCss(cssText, ownerDocument) {
|
165
|
+
return cssText.replace(CSS_URL_RX, function (m, pre, url, post) {
|
166
|
+
return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + post;
|
167
|
+
});
|
168
|
+
}
|
169
|
+
function resolveAttrs(element, ownerDocument) {
|
170
|
+
for (var name in URL_ATTRS) {
|
171
|
+
var a$ = URL_ATTRS[name];
|
172
|
+
for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) {
|
173
|
+
if (name === '*' || element.localName === name) {
|
174
|
+
at = element.attributes[a];
|
175
|
+
v = at && at.value;
|
176
|
+
if (v && v.search(BINDING_RX) < 0) {
|
177
|
+
at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
function resolve(url, ownerDocument) {
|
184
|
+
var resolver = getUrlResolver(ownerDocument);
|
185
|
+
resolver.href = url;
|
186
|
+
return resolver.href || url;
|
187
|
+
}
|
188
|
+
var tempDoc;
|
189
|
+
var tempDocBase;
|
190
|
+
function resolveUrl(url, baseUri) {
|
191
|
+
if (!tempDoc) {
|
192
|
+
tempDoc = document.implementation.createHTMLDocument('temp');
|
193
|
+
tempDocBase = tempDoc.createElement('base');
|
194
|
+
tempDoc.head.appendChild(tempDocBase);
|
195
|
+
}
|
196
|
+
tempDocBase.href = baseUri;
|
197
|
+
return resolve(url, tempDoc);
|
198
|
+
}
|
199
|
+
function getUrlResolver(ownerDocument) {
|
200
|
+
return ownerDocument.__urlResolver || (ownerDocument.__urlResolver = ownerDocument.createElement('a'));
|
201
|
+
}
|
202
|
+
var CSS_URL_RX = /(url\()([^)]*)(\))/g;
|
203
|
+
var URL_ATTRS = {
|
204
|
+
'*': [
|
205
|
+
'href',
|
206
|
+
'src',
|
207
|
+
'style',
|
208
|
+
'url'
|
209
|
+
],
|
210
|
+
form: ['action']
|
211
|
+
};
|
212
|
+
var BINDING_RX = /\{\{|\[\[/;
|
213
|
+
Polymer.ResolveUrl = {
|
214
|
+
resolveCss: resolveCss,
|
215
|
+
resolveAttrs: resolveAttrs,
|
216
|
+
resolveUrl: resolveUrl
|
217
|
+
};
|
218
|
+
}());
|
219
|
+
Polymer.Base._addFeature({
|
220
|
+
_prepAnnotations: function () {
|
221
|
+
if (!this._template) {
|
222
|
+
this._notes = [];
|
223
|
+
} else {
|
224
|
+
Polymer.Annotations.prepElement = this._prepElement.bind(this);
|
225
|
+
this._notes = Polymer.Annotations.parseAnnotations(this._template);
|
226
|
+
this._processAnnotations(this._notes);
|
227
|
+
Polymer.Annotations.prepElement = null;
|
228
|
+
}
|
229
|
+
},
|
230
|
+
_processAnnotations: function (notes) {
|
231
|
+
for (var i = 0; i < notes.length; i++) {
|
232
|
+
var note = notes[i];
|
233
|
+
for (var j = 0; j < note.bindings.length; j++) {
|
234
|
+
var b = note.bindings[j];
|
235
|
+
b.signature = this._parseMethod(b.value);
|
236
|
+
if (!b.signature) {
|
237
|
+
b.model = this._modelForPath(b.value);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
if (note.templateContent) {
|
241
|
+
this._processAnnotations(note.templateContent._notes);
|
242
|
+
var pp = note.templateContent._parentProps = this._discoverTemplateParentProps(note.templateContent._notes);
|
243
|
+
var bindings = [];
|
244
|
+
for (var prop in pp) {
|
245
|
+
bindings.push({
|
246
|
+
index: note.index,
|
247
|
+
kind: 'property',
|
248
|
+
mode: '{',
|
249
|
+
name: '_parent_' + prop,
|
250
|
+
model: prop,
|
251
|
+
value: prop
|
252
|
+
});
|
253
|
+
}
|
254
|
+
note.bindings = note.bindings.concat(bindings);
|
255
|
+
}
|
256
|
+
}
|
257
|
+
},
|
258
|
+
_discoverTemplateParentProps: function (notes) {
|
259
|
+
var pp = {};
|
260
|
+
notes.forEach(function (n) {
|
261
|
+
n.bindings.forEach(function (b) {
|
262
|
+
if (b.signature) {
|
263
|
+
var args = b.signature.args;
|
264
|
+
for (var k = 0; k < args.length; k++) {
|
265
|
+
pp[args[k].model] = true;
|
266
|
+
}
|
267
|
+
} else {
|
268
|
+
pp[b.model] = true;
|
269
|
+
}
|
270
|
+
});
|
271
|
+
if (n.templateContent) {
|
272
|
+
var tpp = n.templateContent._parentProps;
|
273
|
+
Polymer.Base.mixin(pp, tpp);
|
274
|
+
}
|
275
|
+
});
|
276
|
+
return pp;
|
277
|
+
},
|
278
|
+
_prepElement: function (element) {
|
279
|
+
Polymer.ResolveUrl.resolveAttrs(element, this._template.ownerDocument);
|
280
|
+
},
|
281
|
+
_findAnnotatedNode: Polymer.Annotations.findAnnotatedNode,
|
282
|
+
_marshalAnnotationReferences: function () {
|
283
|
+
if (this._template) {
|
284
|
+
this._marshalIdNodes();
|
285
|
+
this._marshalAnnotatedNodes();
|
286
|
+
this._marshalAnnotatedListeners();
|
287
|
+
}
|
288
|
+
},
|
289
|
+
_configureAnnotationReferences: function () {
|
290
|
+
this._configureTemplateContent();
|
291
|
+
},
|
292
|
+
_configureTemplateContent: function () {
|
293
|
+
this._notes.forEach(function (note, i) {
|
294
|
+
if (note.templateContent) {
|
295
|
+
this._nodes[i]._content = note.templateContent;
|
296
|
+
}
|
297
|
+
}, this);
|
298
|
+
},
|
299
|
+
_marshalIdNodes: function () {
|
300
|
+
this.$ = {};
|
301
|
+
this._notes.forEach(function (a) {
|
302
|
+
if (a.id) {
|
303
|
+
this.$[a.id] = this._findAnnotatedNode(this.root, a);
|
304
|
+
}
|
305
|
+
}, this);
|
306
|
+
},
|
307
|
+
_marshalAnnotatedNodes: function () {
|
308
|
+
if (this._nodes) {
|
309
|
+
this._nodes = this._nodes.map(function (a) {
|
310
|
+
return this._findAnnotatedNode(this.root, a);
|
311
|
+
}, this);
|
312
|
+
}
|
313
|
+
},
|
314
|
+
_marshalAnnotatedListeners: function () {
|
315
|
+
this._notes.forEach(function (a) {
|
316
|
+
if (a.events && a.events.length) {
|
317
|
+
var node = this._findAnnotatedNode(this.root, a);
|
318
|
+
a.events.forEach(function (e) {
|
319
|
+
this.listen(node, e.name, e.value);
|
320
|
+
}, this);
|
321
|
+
}
|
322
|
+
}, this);
|
323
|
+
}
|
324
|
+
});
|
325
|
+
Polymer.Base._addFeature({
|
326
|
+
listeners: {},
|
327
|
+
_listenListeners: function (listeners) {
|
328
|
+
var node, name, key;
|
329
|
+
for (key in listeners) {
|
330
|
+
if (key.indexOf('.') < 0) {
|
331
|
+
node = this;
|
332
|
+
name = key;
|
333
|
+
} else {
|
334
|
+
name = key.split('.');
|
335
|
+
node = this.$[name[0]];
|
336
|
+
name = name[1];
|
337
|
+
}
|
338
|
+
this.listen(node, name, listeners[key]);
|
339
|
+
}
|
340
|
+
},
|
341
|
+
listen: function (node, eventName, methodName) {
|
342
|
+
this._listen(node, eventName, this._createEventHandler(node, eventName, methodName));
|
343
|
+
},
|
344
|
+
_createEventHandler: function (node, eventName, methodName) {
|
345
|
+
var host = this;
|
346
|
+
return function (e) {
|
347
|
+
if (host[methodName]) {
|
348
|
+
host[methodName](e, e.detail);
|
349
|
+
} else {
|
350
|
+
host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined'));
|
351
|
+
}
|
352
|
+
};
|
353
|
+
},
|
354
|
+
_listen: function (node, eventName, handler) {
|
355
|
+
node.addEventListener(eventName, handler);
|
356
|
+
}
|
357
|
+
});
|
358
|
+
(function () {
|
359
|
+
'use strict';
|
360
|
+
var HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
|
361
|
+
var GESTURE_KEY = '__polymerGestures';
|
362
|
+
var HANDLED_OBJ = '__polymerGesturesHandled';
|
363
|
+
var TOUCH_ACTION = '__polymerGesturesTouchAction';
|
364
|
+
var TAP_DISTANCE = 25;
|
365
|
+
var TRACK_DISTANCE = 5;
|
366
|
+
var TRACK_LENGTH = 2;
|
367
|
+
var MOUSE_TIMEOUT = 2500;
|
368
|
+
var MOUSE_EVENTS = [
|
369
|
+
'mousedown',
|
370
|
+
'mousemove',
|
371
|
+
'mouseup',
|
372
|
+
'click'
|
373
|
+
];
|
374
|
+
var mouseCanceller = function (mouseEvent) {
|
375
|
+
mouseEvent[HANDLED_OBJ] = { skip: true };
|
376
|
+
if (mouseEvent.type === 'click') {
|
377
|
+
var path = Polymer.dom(mouseEvent).path;
|
378
|
+
for (var i = 0; i < path.length; i++) {
|
379
|
+
if (path[i] === POINTERSTATE.mouse.target) {
|
380
|
+
return;
|
381
|
+
}
|
382
|
+
}
|
383
|
+
mouseEvent.preventDefault();
|
384
|
+
mouseEvent.stopPropagation();
|
385
|
+
}
|
386
|
+
};
|
387
|
+
function setupTeardownMouseCanceller(setup) {
|
388
|
+
for (var i = 0, en; i < MOUSE_EVENTS.length; i++) {
|
389
|
+
en = MOUSE_EVENTS[i];
|
390
|
+
if (setup) {
|
391
|
+
document.addEventListener(en, mouseCanceller, true);
|
392
|
+
} else {
|
393
|
+
document.removeEventListener(en, mouseCanceller, true);
|
394
|
+
}
|
395
|
+
}
|
396
|
+
}
|
397
|
+
function ignoreMouse() {
|
398
|
+
if (!POINTERSTATE.mouse.mouseIgnoreJob) {
|
399
|
+
setupTeardownMouseCanceller(true);
|
400
|
+
}
|
401
|
+
var unset = function () {
|
402
|
+
setupTeardownMouseCanceller();
|
403
|
+
POINTERSTATE.mouse.target = null;
|
404
|
+
POINTERSTATE.mouse.mouseIgnoreJob = null;
|
405
|
+
};
|
406
|
+
POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT);
|
407
|
+
}
|
408
|
+
var POINTERSTATE = {
|
409
|
+
tapPrevented: false,
|
410
|
+
mouse: {
|
411
|
+
target: null,
|
412
|
+
mouseIgnoreJob: null
|
413
|
+
},
|
414
|
+
touch: {
|
415
|
+
x: 0,
|
416
|
+
y: 0,
|
417
|
+
id: -1,
|
418
|
+
scrollDecided: false
|
419
|
+
}
|
420
|
+
};
|
421
|
+
function firstTouchAction(ev) {
|
422
|
+
var path = Polymer.dom(ev).path;
|
423
|
+
var ta = 'auto';
|
424
|
+
for (var i = 0, n; i < path.length; i++) {
|
425
|
+
n = path[i];
|
426
|
+
if (n[TOUCH_ACTION]) {
|
427
|
+
ta = n[TOUCH_ACTION];
|
428
|
+
break;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
return ta;
|
432
|
+
}
|
433
|
+
var Gestures = {
|
434
|
+
gestures: {},
|
435
|
+
recognizers: [],
|
436
|
+
deepTargetFind: function (x, y) {
|
437
|
+
var node = document.elementFromPoint(x, y);
|
438
|
+
var next = node;
|
439
|
+
while (next && next.shadowRoot) {
|
440
|
+
next = next.shadowRoot.elementFromPoint(x, y);
|
441
|
+
if (next) {
|
442
|
+
node = next;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
return node;
|
446
|
+
},
|
447
|
+
handleNative: function (ev) {
|
448
|
+
var handled;
|
449
|
+
var type = ev.type;
|
450
|
+
var node = ev.currentTarget;
|
451
|
+
var gobj = node[GESTURE_KEY];
|
452
|
+
var gs = gobj[type];
|
453
|
+
if (!gs) {
|
454
|
+
return;
|
455
|
+
}
|
456
|
+
if (!ev[HANDLED_OBJ]) {
|
457
|
+
ev[HANDLED_OBJ] = {};
|
458
|
+
if (type.slice(0, 5) === 'touch') {
|
459
|
+
var t = ev.changedTouches[0];
|
460
|
+
if (type === 'touchstart') {
|
461
|
+
if (ev.touches.length === 1) {
|
462
|
+
POINTERSTATE.touch.id = t.identifier;
|
463
|
+
}
|
464
|
+
}
|
465
|
+
if (POINTERSTATE.touch.id !== t.identifier) {
|
466
|
+
return;
|
467
|
+
}
|
468
|
+
if (!HAS_NATIVE_TA) {
|
469
|
+
if (type === 'touchstart' || type === 'touchmove') {
|
470
|
+
Gestures.handleTouchAction(ev);
|
471
|
+
}
|
472
|
+
}
|
473
|
+
if (type === 'touchend') {
|
474
|
+
POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
|
475
|
+
ignoreMouse(true);
|
476
|
+
}
|
477
|
+
}
|
478
|
+
}
|
479
|
+
handled = ev[HANDLED_OBJ];
|
480
|
+
if (handled.skip) {
|
481
|
+
return;
|
482
|
+
}
|
483
|
+
var recognizers = Gestures.recognizers;
|
484
|
+
for (var i = 0, r; i < recognizers.length; i++) {
|
485
|
+
r = recognizers[i];
|
486
|
+
if (gs[r.name] && !handled[r.name]) {
|
487
|
+
handled[r.name] = true;
|
488
|
+
r[type](ev);
|
489
|
+
}
|
490
|
+
}
|
491
|
+
},
|
492
|
+
handleTouchAction: function (ev) {
|
493
|
+
var t = ev.changedTouches[0];
|
494
|
+
var type = ev.type;
|
495
|
+
if (type === 'touchstart') {
|
496
|
+
POINTERSTATE.touch.x = t.clientX;
|
497
|
+
POINTERSTATE.touch.y = t.clientY;
|
498
|
+
POINTERSTATE.touch.scrollDecided = false;
|
499
|
+
} else if (type === 'touchmove') {
|
500
|
+
if (POINTERSTATE.touch.scrollDecided) {
|
501
|
+
return;
|
502
|
+
}
|
503
|
+
POINTERSTATE.touch.scrollDecided = true;
|
504
|
+
var ta = firstTouchAction(ev);
|
505
|
+
var prevent = false;
|
506
|
+
var dx = Math.abs(POINTERSTATE.touch.x - t.clientX);
|
507
|
+
var dy = Math.abs(POINTERSTATE.touch.y - t.clientY);
|
508
|
+
if (!ev.cancelable) {
|
509
|
+
} else if (ta === 'none') {
|
510
|
+
prevent = true;
|
511
|
+
} else if (ta === 'pan-x') {
|
512
|
+
prevent = dy > dx;
|
513
|
+
} else if (ta === 'pan-y') {
|
514
|
+
prevent = dx > dy;
|
515
|
+
}
|
516
|
+
if (prevent) {
|
517
|
+
ev.preventDefault();
|
518
|
+
}
|
519
|
+
}
|
520
|
+
},
|
521
|
+
add: function (node, evType, handler) {
|
522
|
+
var recognizer = this.gestures[evType];
|
523
|
+
var deps = recognizer.deps;
|
524
|
+
var name = recognizer.name;
|
525
|
+
var gobj = node[GESTURE_KEY];
|
526
|
+
if (!gobj) {
|
527
|
+
node[GESTURE_KEY] = gobj = {};
|
528
|
+
}
|
529
|
+
for (var i = 0, dep, gd; i < deps.length; i++) {
|
530
|
+
dep = deps[i];
|
531
|
+
gd = gobj[dep];
|
532
|
+
if (!gd) {
|
533
|
+
gobj[dep] = gd = {};
|
534
|
+
node.addEventListener(dep, this.handleNative);
|
535
|
+
}
|
536
|
+
gd[name] = (gd[name] || 0) + 1;
|
537
|
+
}
|
538
|
+
node.addEventListener(evType, handler);
|
539
|
+
if (recognizer.touchAction) {
|
540
|
+
this.setTouchAction(node, recognizer.touchAction);
|
541
|
+
}
|
542
|
+
},
|
543
|
+
register: function (recog) {
|
544
|
+
this.recognizers.push(recog);
|
545
|
+
for (var i = 0; i < recog.emits.length; i++) {
|
546
|
+
this.gestures[recog.emits[i]] = recog;
|
547
|
+
}
|
548
|
+
},
|
549
|
+
setTouchAction: function (node, value) {
|
550
|
+
if (HAS_NATIVE_TA) {
|
551
|
+
node.style.touchAction = value;
|
552
|
+
}
|
553
|
+
node[TOUCH_ACTION] = value;
|
554
|
+
},
|
555
|
+
fire: function (target, type, detail) {
|
556
|
+
var ev = new CustomEvent(type, {
|
557
|
+
detail: detail,
|
558
|
+
bubbles: true,
|
559
|
+
cancelable: true
|
560
|
+
});
|
561
|
+
target.dispatchEvent(ev);
|
562
|
+
}
|
563
|
+
};
|
564
|
+
Gestures.register({
|
565
|
+
name: 'downup',
|
566
|
+
deps: [
|
567
|
+
'mousedown',
|
568
|
+
'touchstart',
|
569
|
+
'touchend'
|
570
|
+
],
|
571
|
+
emits: [
|
572
|
+
'down',
|
573
|
+
'up'
|
574
|
+
],
|
575
|
+
mousedown: function (e) {
|
576
|
+
var t = e.currentTarget;
|
577
|
+
var self = this;
|
578
|
+
var upfn = function upfn(e) {
|
579
|
+
self.fire('up', t, e);
|
580
|
+
document.removeEventListener('mouseup', upfn);
|
581
|
+
};
|
582
|
+
document.addEventListener('mouseup', upfn);
|
583
|
+
this.fire('down', t, e);
|
584
|
+
},
|
585
|
+
touchstart: function (e) {
|
586
|
+
this.fire('down', e.currentTarget, e.changedTouches[0]);
|
587
|
+
},
|
588
|
+
touchend: function (e) {
|
589
|
+
this.fire('up', e.currentTarget, e.changedTouches[0]);
|
590
|
+
},
|
591
|
+
fire: function (type, target, event) {
|
592
|
+
Gestures.fire(target, type, {
|
593
|
+
x: event.clientX,
|
594
|
+
y: event.clientY,
|
595
|
+
sourceEvent: event
|
596
|
+
});
|
597
|
+
}
|
598
|
+
});
|
599
|
+
Gestures.register({
|
600
|
+
name: 'track',
|
601
|
+
touchAction: 'none',
|
602
|
+
deps: [
|
603
|
+
'mousedown',
|
604
|
+
'touchstart',
|
605
|
+
'touchmove',
|
606
|
+
'touchend'
|
607
|
+
],
|
608
|
+
emits: ['track'],
|
609
|
+
info: {
|
610
|
+
x: 0,
|
611
|
+
y: 0,
|
612
|
+
state: 'start',
|
613
|
+
started: false,
|
614
|
+
moves: [],
|
615
|
+
addMove: function (move) {
|
616
|
+
if (this.moves.length > TRACK_LENGTH) {
|
617
|
+
this.moves.shift();
|
618
|
+
}
|
619
|
+
this.moves.push(move);
|
620
|
+
}
|
621
|
+
},
|
622
|
+
clearInfo: function () {
|
623
|
+
this.info.state = 'start';
|
624
|
+
this.info.started = false;
|
625
|
+
this.info.moves = [];
|
626
|
+
this.info.x = 0;
|
627
|
+
this.info.y = 0;
|
628
|
+
},
|
629
|
+
hasMovedEnough: function (x, y) {
|
630
|
+
if (this.info.started) {
|
631
|
+
return true;
|
632
|
+
}
|
633
|
+
var dx = Math.abs(this.info.x - x);
|
634
|
+
var dy = Math.abs(this.info.y - y);
|
635
|
+
return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
|
636
|
+
},
|
637
|
+
mousedown: function (e) {
|
638
|
+
var t = e.currentTarget;
|
639
|
+
var self = this;
|
640
|
+
var movefn = function movefn(e) {
|
641
|
+
var x = e.clientX, y = e.clientY;
|
642
|
+
if (self.hasMovedEnough(x, y)) {
|
643
|
+
self.info.state = self.info.started ? e.type === 'mouseup' ? 'end' : 'track' : 'start';
|
644
|
+
self.info.addMove({
|
645
|
+
x: x,
|
646
|
+
y: y
|
647
|
+
});
|
648
|
+
self.fire(t, e);
|
649
|
+
e.preventDefault();
|
650
|
+
self.info.started = true;
|
651
|
+
}
|
652
|
+
};
|
653
|
+
var upfn = function upfn(e) {
|
654
|
+
if (self.info.started) {
|
655
|
+
POINTERSTATE.tapPrevented = true;
|
656
|
+
movefn(e);
|
657
|
+
}
|
658
|
+
self.clearInfo();
|
659
|
+
document.removeEventListener('mousemove', movefn);
|
660
|
+
document.removeEventListener('mouseup', upfn);
|
661
|
+
};
|
662
|
+
document.addEventListener('mousemove', movefn);
|
663
|
+
document.addEventListener('mouseup', upfn);
|
664
|
+
this.info.x = e.clientX;
|
665
|
+
this.info.y = e.clientY;
|
666
|
+
},
|
667
|
+
touchstart: function (e) {
|
668
|
+
var ct = e.changedTouches[0];
|
669
|
+
this.info.x = ct.clientX;
|
670
|
+
this.info.y = ct.clientY;
|
671
|
+
},
|
672
|
+
touchmove: function (e) {
|
673
|
+
var t = e.currentTarget;
|
674
|
+
var ct = e.changedTouches[0];
|
675
|
+
var x = ct.clientX, y = ct.clientY;
|
676
|
+
if (this.hasMovedEnough(x, y)) {
|
677
|
+
this.info.addMove({
|
678
|
+
x: x,
|
679
|
+
y: y
|
680
|
+
});
|
681
|
+
this.fire(t, ct);
|
682
|
+
this.info.state = 'track';
|
683
|
+
this.info.started = true;
|
684
|
+
}
|
685
|
+
},
|
686
|
+
touchend: function (e) {
|
687
|
+
var t = e.currentTarget;
|
688
|
+
var ct = e.changedTouches[0];
|
689
|
+
if (this.info.started) {
|
690
|
+
POINTERSTATE.tapPrevented = true;
|
691
|
+
this.info.state = 'end';
|
692
|
+
this.info.addMove({
|
693
|
+
x: ct.clientX,
|
694
|
+
y: ct.clientY
|
695
|
+
});
|
696
|
+
this.fire(t, ct);
|
697
|
+
}
|
698
|
+
this.clearInfo();
|
699
|
+
},
|
700
|
+
fire: function (target, touch) {
|
701
|
+
var secondlast = this.info.moves[this.info.moves.length - 2];
|
702
|
+
var lastmove = this.info.moves[this.info.moves.length - 1];
|
703
|
+
var dx = lastmove.x - this.info.x;
|
704
|
+
var dy = lastmove.y - this.info.y;
|
705
|
+
var ddx, ddy = 0;
|
706
|
+
if (secondlast) {
|
707
|
+
ddx = lastmove.x - secondlast.x;
|
708
|
+
ddy = lastmove.y - secondlast.y;
|
709
|
+
}
|
710
|
+
return Gestures.fire(target, 'track', {
|
711
|
+
state: this.info.state,
|
712
|
+
x: touch.clientX,
|
713
|
+
y: touch.clientY,
|
714
|
+
dx: dx,
|
715
|
+
dy: dy,
|
716
|
+
ddx: ddx,
|
717
|
+
ddy: ddy,
|
718
|
+
sourceEvent: touch,
|
719
|
+
hover: function () {
|
720
|
+
return Gestures.deepTargetFind(touch.clientX, touch.clientY);
|
721
|
+
}
|
722
|
+
});
|
723
|
+
}
|
724
|
+
});
|
725
|
+
Gestures.register({
|
726
|
+
name: 'tap',
|
727
|
+
deps: [
|
728
|
+
'mousedown',
|
729
|
+
'click',
|
730
|
+
'touchstart',
|
731
|
+
'touchend'
|
732
|
+
],
|
733
|
+
emits: ['tap'],
|
734
|
+
start: {
|
735
|
+
x: NaN,
|
736
|
+
y: NaN
|
737
|
+
},
|
738
|
+
reset: function () {
|
739
|
+
this.start.x = NaN;
|
740
|
+
this.start.y = NaN;
|
741
|
+
},
|
742
|
+
save: function (e) {
|
743
|
+
this.start.x = e.clientX;
|
744
|
+
this.start.y = e.clientY;
|
745
|
+
},
|
746
|
+
mousedown: function (e) {
|
747
|
+
POINTERSTATE.tapPrevented = false;
|
748
|
+
this.save(e);
|
749
|
+
},
|
750
|
+
click: function (e) {
|
751
|
+
this.forward(e);
|
752
|
+
},
|
753
|
+
touchstart: function (e) {
|
754
|
+
POINTERSTATE.tapPrevented = false;
|
755
|
+
this.save(e.changedTouches[0]);
|
756
|
+
},
|
757
|
+
touchend: function (e) {
|
758
|
+
this.forward(e.changedTouches[0]);
|
759
|
+
},
|
760
|
+
forward: function (e) {
|
761
|
+
var dx = Math.abs(e.clientX - this.start.x);
|
762
|
+
var dy = Math.abs(e.clientY - this.start.y);
|
763
|
+
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) {
|
764
|
+
if (!POINTERSTATE.tapPrevented) {
|
765
|
+
Gestures.fire(e.target, 'tap', {
|
766
|
+
x: e.clientX,
|
767
|
+
y: e.clientY,
|
768
|
+
sourceEvent: e
|
769
|
+
});
|
770
|
+
}
|
771
|
+
}
|
772
|
+
this.reset();
|
773
|
+
}
|
774
|
+
});
|
775
|
+
var DIRECTION_MAP = {
|
776
|
+
x: 'pan-x',
|
777
|
+
y: 'pan-y',
|
778
|
+
none: 'none',
|
779
|
+
all: 'auto'
|
780
|
+
};
|
781
|
+
Polymer.Base._addFeature({
|
782
|
+
_listen: function (node, eventName, handler) {
|
783
|
+
if (Gestures.gestures[eventName]) {
|
784
|
+
Gestures.add(node, eventName, handler);
|
785
|
+
} else {
|
786
|
+
node.addEventListener(eventName, handler);
|
787
|
+
}
|
788
|
+
},
|
789
|
+
setScrollDirection: function (direction, node) {
|
790
|
+
node = node || this;
|
791
|
+
Gestures.setTouchAction(node, DIRECTION_MAP[direction] || 'auto');
|
792
|
+
}
|
793
|
+
});
|
794
|
+
Polymer.Gestures = Gestures;
|
795
|
+
}());
|
796
|
+
Polymer.Async = function () {
|
797
|
+
var currVal = 0;
|
798
|
+
var lastVal = 0;
|
799
|
+
var callbacks = [];
|
800
|
+
var twiddle = document.createTextNode('');
|
801
|
+
function runAsync(callback, waitTime) {
|
802
|
+
if (waitTime > 0) {
|
803
|
+
return ~setTimeout(callback, waitTime);
|
804
|
+
} else {
|
805
|
+
twiddle.textContent = currVal++;
|
806
|
+
callbacks.push(callback);
|
807
|
+
return currVal - 1;
|
808
|
+
}
|
809
|
+
}
|
810
|
+
function cancelAsync(handle) {
|
811
|
+
if (handle < 0) {
|
812
|
+
clearTimeout(~handle);
|
813
|
+
} else {
|
814
|
+
var idx = handle - lastVal;
|
815
|
+
if (idx >= 0) {
|
816
|
+
if (!callbacks[idx]) {
|
817
|
+
throw 'invalid async handle: ' + handle;
|
818
|
+
}
|
819
|
+
callbacks[idx] = null;
|
820
|
+
}
|
821
|
+
}
|
822
|
+
}
|
823
|
+
function atEndOfMicrotask() {
|
824
|
+
var len = callbacks.length;
|
825
|
+
for (var i = 0; i < len; i++) {
|
826
|
+
var cb = callbacks[i];
|
827
|
+
if (cb) {
|
828
|
+
cb();
|
829
|
+
}
|
830
|
+
}
|
831
|
+
callbacks.splice(0, len);
|
832
|
+
lastVal += len;
|
833
|
+
}
|
834
|
+
new (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask).observe(twiddle, { characterData: true });
|
835
|
+
return {
|
836
|
+
run: runAsync,
|
837
|
+
cancel: cancelAsync
|
838
|
+
};
|
839
|
+
}();
|
840
|
+
Polymer.Debounce = function () {
|
841
|
+
var Async = Polymer.Async;
|
842
|
+
var Debouncer = function (context) {
|
843
|
+
this.context = context;
|
844
|
+
this.boundComplete = this.complete.bind(this);
|
845
|
+
};
|
846
|
+
Debouncer.prototype = {
|
847
|
+
go: function (callback, wait) {
|
848
|
+
var h;
|
849
|
+
this.finish = function () {
|
850
|
+
Async.cancel(h);
|
851
|
+
};
|
852
|
+
h = Async.run(this.boundComplete, wait);
|
853
|
+
this.callback = callback;
|
854
|
+
},
|
855
|
+
stop: function () {
|
856
|
+
if (this.finish) {
|
857
|
+
this.finish();
|
858
|
+
this.finish = null;
|
859
|
+
}
|
860
|
+
},
|
861
|
+
complete: function () {
|
862
|
+
if (this.finish) {
|
863
|
+
this.stop();
|
864
|
+
this.callback.call(this.context);
|
865
|
+
}
|
866
|
+
}
|
867
|
+
};
|
868
|
+
function debounce(debouncer, callback, wait) {
|
869
|
+
if (debouncer) {
|
870
|
+
debouncer.stop();
|
871
|
+
} else {
|
872
|
+
debouncer = new Debouncer(this);
|
873
|
+
}
|
874
|
+
debouncer.go(callback, wait);
|
875
|
+
return debouncer;
|
876
|
+
}
|
877
|
+
return debounce;
|
878
|
+
}();
|
879
|
+
Polymer.Base._addFeature({
|
880
|
+
$$: function (slctr) {
|
881
|
+
return Polymer.dom(this.root).querySelector(slctr);
|
882
|
+
},
|
883
|
+
toggleClass: function (name, bool, node) {
|
884
|
+
node = node || this;
|
885
|
+
if (arguments.length == 1) {
|
886
|
+
bool = !node.classList.contains(name);
|
887
|
+
}
|
888
|
+
if (bool) {
|
889
|
+
Polymer.dom(node).classList.add(name);
|
890
|
+
} else {
|
891
|
+
Polymer.dom(node).classList.remove(name);
|
892
|
+
}
|
893
|
+
},
|
894
|
+
toggleAttribute: function (name, bool, node) {
|
895
|
+
node = node || this;
|
896
|
+
if (arguments.length == 1) {
|
897
|
+
bool = !node.hasAttribute(name);
|
898
|
+
}
|
899
|
+
if (bool) {
|
900
|
+
Polymer.dom(node).setAttribute(name, '');
|
901
|
+
} else {
|
902
|
+
Polymer.dom(node).removeAttribute(name);
|
903
|
+
}
|
904
|
+
},
|
905
|
+
classFollows: function (name, toElement, fromElement) {
|
906
|
+
if (fromElement) {
|
907
|
+
Polymer.dom(fromElement).classList.remove(name);
|
908
|
+
}
|
909
|
+
if (toElement) {
|
910
|
+
Polymer.dom(toElement).classList.add(name);
|
911
|
+
}
|
912
|
+
},
|
913
|
+
attributeFollows: function (name, toElement, fromElement) {
|
914
|
+
if (fromElement) {
|
915
|
+
Polymer.dom(fromElement).removeAttribute(name);
|
916
|
+
}
|
917
|
+
if (toElement) {
|
918
|
+
Polymer.dom(toElement).setAttribute(name, '');
|
919
|
+
}
|
920
|
+
},
|
921
|
+
getContentChildNodes: function (slctr) {
|
922
|
+
return Polymer.dom(Polymer.dom(this.root).querySelector(slctr || 'content')).getDistributedNodes();
|
923
|
+
},
|
924
|
+
getContentChildren: function (slctr) {
|
925
|
+
return this.getContentChildNodes(slctr).filter(function (n) {
|
926
|
+
return n.nodeType === Node.ELEMENT_NODE;
|
927
|
+
});
|
928
|
+
},
|
929
|
+
fire: function (type, detail, options) {
|
930
|
+
options = options || Polymer.nob;
|
931
|
+
var node = options.node || this;
|
932
|
+
var detail = detail === null || detail === undefined ? Polymer.nob : detail;
|
933
|
+
var bubbles = options.bubbles === undefined ? true : options.bubbles;
|
934
|
+
var event = new CustomEvent(type, {
|
935
|
+
bubbles: Boolean(bubbles),
|
936
|
+
cancelable: Boolean(options.cancelable),
|
937
|
+
detail: detail
|
938
|
+
});
|
939
|
+
node.dispatchEvent(event);
|
940
|
+
return event;
|
941
|
+
},
|
942
|
+
async: function (callback, waitTime) {
|
943
|
+
return Polymer.Async.run(callback.bind(this), waitTime);
|
944
|
+
},
|
945
|
+
cancelAsync: function (handle) {
|
946
|
+
Polymer.Async.cancel(handle);
|
947
|
+
},
|
948
|
+
arrayDelete: function (path, item) {
|
949
|
+
var index;
|
950
|
+
if (Array.isArray(path)) {
|
951
|
+
index = path.indexOf(item);
|
952
|
+
if (index >= 0) {
|
953
|
+
return path.splice(index, 1);
|
954
|
+
}
|
955
|
+
} else {
|
956
|
+
var arr = this.get(path);
|
957
|
+
index = arr.indexOf(item);
|
958
|
+
if (index >= 0) {
|
959
|
+
return this.splice(path, index, 1);
|
960
|
+
}
|
961
|
+
}
|
962
|
+
},
|
963
|
+
transform: function (transform, node) {
|
964
|
+
node = node || this;
|
965
|
+
node.style.webkitTransform = transform;
|
966
|
+
node.style.transform = transform;
|
967
|
+
},
|
968
|
+
translate3d: function (x, y, z, node) {
|
969
|
+
node = node || this;
|
970
|
+
this.transform('translate3d(' + x + ',' + y + ',' + z + ')', node);
|
971
|
+
},
|
972
|
+
importHref: function (href, onload, onerror) {
|
973
|
+
var l = document.createElement('link');
|
974
|
+
l.rel = 'import';
|
975
|
+
l.href = href;
|
976
|
+
if (onload) {
|
977
|
+
l.onload = onload.bind(this);
|
978
|
+
}
|
979
|
+
if (onerror) {
|
980
|
+
l.onerror = onerror.bind(this);
|
981
|
+
}
|
982
|
+
document.head.appendChild(l);
|
983
|
+
return l;
|
984
|
+
},
|
985
|
+
create: function (tag, props) {
|
986
|
+
var elt = document.createElement(tag);
|
987
|
+
if (props) {
|
988
|
+
for (var n in props) {
|
989
|
+
elt[n] = props[n];
|
990
|
+
}
|
991
|
+
}
|
992
|
+
return elt;
|
993
|
+
},
|
994
|
+
mixin: function (target, source) {
|
995
|
+
for (var i in source) {
|
996
|
+
target[i] = source[i];
|
997
|
+
}
|
998
|
+
}
|
999
|
+
});
|
1000
|
+
Polymer.Bind = {
|
1001
|
+
prepareModel: function (model) {
|
1002
|
+
model._propertyEffects = {};
|
1003
|
+
model._bindListeners = [];
|
1004
|
+
var api = this._modelApi;
|
1005
|
+
for (var n in api) {
|
1006
|
+
model[n] = api[n];
|
1007
|
+
}
|
1008
|
+
},
|
1009
|
+
_modelApi: {
|
1010
|
+
_notifyChange: function (property) {
|
1011
|
+
var eventName = Polymer.CaseMap.camelToDashCase(property) + '-changed';
|
1012
|
+
this.fire(eventName, { value: this[property] }, { bubbles: false });
|
1013
|
+
},
|
1014
|
+
_propertySet: function (property, value, effects) {
|
1015
|
+
var old = this.__data__[property];
|
1016
|
+
if (old !== value) {
|
1017
|
+
this.__data__[property] = value;
|
1018
|
+
if (typeof value == 'object') {
|
1019
|
+
this._clearPath(property);
|
1020
|
+
}
|
1021
|
+
if (this._propertyChanged) {
|
1022
|
+
this._propertyChanged(property, value, old);
|
1023
|
+
}
|
1024
|
+
if (effects) {
|
1025
|
+
this._effectEffects(property, value, effects, old);
|
1026
|
+
}
|
1027
|
+
}
|
1028
|
+
return old;
|
1029
|
+
},
|
1030
|
+
_effectEffects: function (property, value, effects, old) {
|
1031
|
+
effects.forEach(function (fx) {
|
1032
|
+
var fn = Polymer.Bind['_' + fx.kind + 'Effect'];
|
1033
|
+
if (fn) {
|
1034
|
+
fn.call(this, property, value, fx.effect, old);
|
1035
|
+
}
|
1036
|
+
}, this);
|
1037
|
+
},
|
1038
|
+
_clearPath: function (path) {
|
1039
|
+
for (var prop in this.__data__) {
|
1040
|
+
if (prop.indexOf(path + '.') === 0) {
|
1041
|
+
this.__data__[prop] = undefined;
|
1042
|
+
}
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
},
|
1046
|
+
ensurePropertyEffects: function (model, property) {
|
1047
|
+
var fx = model._propertyEffects[property];
|
1048
|
+
if (!fx) {
|
1049
|
+
fx = model._propertyEffects[property] = [];
|
1050
|
+
}
|
1051
|
+
return fx;
|
1052
|
+
},
|
1053
|
+
addPropertyEffect: function (model, property, kind, effect) {
|
1054
|
+
var fx = this.ensurePropertyEffects(model, property);
|
1055
|
+
fx.push({
|
1056
|
+
kind: kind,
|
1057
|
+
effect: effect
|
1058
|
+
});
|
1059
|
+
},
|
1060
|
+
createBindings: function (model) {
|
1061
|
+
var fx$ = model._propertyEffects;
|
1062
|
+
if (fx$) {
|
1063
|
+
for (var n in fx$) {
|
1064
|
+
var fx = fx$[n];
|
1065
|
+
fx.sort(this._sortPropertyEffects);
|
1066
|
+
this._createAccessors(model, n, fx);
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
},
|
1070
|
+
_sortPropertyEffects: function () {
|
1071
|
+
var EFFECT_ORDER = {
|
1072
|
+
'compute': 0,
|
1073
|
+
'annotation': 1,
|
1074
|
+
'computedAnnotation': 2,
|
1075
|
+
'reflect': 3,
|
1076
|
+
'notify': 4,
|
1077
|
+
'observer': 5,
|
1078
|
+
'complexObserver': 6,
|
1079
|
+
'function': 7
|
1080
|
+
};
|
1081
|
+
return function (a, b) {
|
1082
|
+
return EFFECT_ORDER[a.kind] - EFFECT_ORDER[b.kind];
|
1083
|
+
};
|
1084
|
+
}(),
|
1085
|
+
_createAccessors: function (model, property, effects) {
|
1086
|
+
var defun = {
|
1087
|
+
get: function () {
|
1088
|
+
return this.__data__[property];
|
1089
|
+
}
|
1090
|
+
};
|
1091
|
+
var setter = function (value) {
|
1092
|
+
this._propertySet(property, value, effects);
|
1093
|
+
};
|
1094
|
+
if (model.getPropertyInfo && model.getPropertyInfo(property).readOnly) {
|
1095
|
+
model['_set' + this.upper(property)] = setter;
|
1096
|
+
} else {
|
1097
|
+
defun.set = setter;
|
1098
|
+
}
|
1099
|
+
Object.defineProperty(model, property, defun);
|
1100
|
+
},
|
1101
|
+
upper: function (name) {
|
1102
|
+
return name[0].toUpperCase() + name.substring(1);
|
1103
|
+
},
|
1104
|
+
_addAnnotatedListener: function (model, index, property, path, event) {
|
1105
|
+
var fn = this._notedListenerFactory(property, path, this._isStructured(path), this._isEventBogus);
|
1106
|
+
var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed';
|
1107
|
+
model._bindListeners.push({
|
1108
|
+
index: index,
|
1109
|
+
property: property,
|
1110
|
+
path: path,
|
1111
|
+
changedFn: fn,
|
1112
|
+
event: eventName
|
1113
|
+
});
|
1114
|
+
},
|
1115
|
+
_isStructured: function (path) {
|
1116
|
+
return path.indexOf('.') > 0;
|
1117
|
+
},
|
1118
|
+
_isEventBogus: function (e, target) {
|
1119
|
+
return e.path && e.path[0] !== target;
|
1120
|
+
},
|
1121
|
+
_notedListenerFactory: function (property, path, isStructured, bogusTest) {
|
1122
|
+
return function (e, target) {
|
1123
|
+
if (!bogusTest(e, target)) {
|
1124
|
+
if (e.detail && e.detail.path) {
|
1125
|
+
this.notifyPath(this._fixPath(path, property, e.detail.path), e.detail.value);
|
1126
|
+
} else {
|
1127
|
+
var value = target[property];
|
1128
|
+
if (!isStructured) {
|
1129
|
+
this[path] = target[property];
|
1130
|
+
} else {
|
1131
|
+
if (this.__data__[path] != value) {
|
1132
|
+
this.set(path, value);
|
1133
|
+
}
|
1134
|
+
}
|
1135
|
+
}
|
1136
|
+
}
|
1137
|
+
};
|
1138
|
+
},
|
1139
|
+
prepareInstance: function (inst) {
|
1140
|
+
inst.__data__ = Object.create(null);
|
1141
|
+
},
|
1142
|
+
setupBindListeners: function (inst) {
|
1143
|
+
inst._bindListeners.forEach(function (info) {
|
1144
|
+
var node = inst._nodes[info.index];
|
1145
|
+
node.addEventListener(info.event, inst._notifyListener.bind(inst, info.changedFn));
|
1146
|
+
});
|
1147
|
+
}
|
1148
|
+
};
|
1149
|
+
Polymer.Base.extend(Polymer.Bind, {
|
1150
|
+
_shouldAddListener: function (effect) {
|
1151
|
+
return effect.name && effect.mode === '{' && !effect.negate && effect.kind != 'attribute';
|
1152
|
+
},
|
1153
|
+
_annotationEffect: function (source, value, effect) {
|
1154
|
+
if (source != effect.value) {
|
1155
|
+
value = this.get(effect.value);
|
1156
|
+
this.__data__[effect.value] = value;
|
1157
|
+
}
|
1158
|
+
var calc = effect.negate ? !value : value;
|
1159
|
+
if (!effect.customEvent || this._nodes[effect.index][effect.name] !== calc) {
|
1160
|
+
return this._applyEffectValue(calc, effect);
|
1161
|
+
}
|
1162
|
+
},
|
1163
|
+
_reflectEffect: function (source) {
|
1164
|
+
this.reflectPropertyToAttribute(source);
|
1165
|
+
},
|
1166
|
+
_notifyEffect: function (source) {
|
1167
|
+
this._notifyChange(source);
|
1168
|
+
},
|
1169
|
+
_functionEffect: function (source, value, fn, old) {
|
1170
|
+
fn.call(this, source, value, old);
|
1171
|
+
},
|
1172
|
+
_observerEffect: function (source, value, effect, old) {
|
1173
|
+
var fn = this[effect.method];
|
1174
|
+
if (fn) {
|
1175
|
+
fn.call(this, value, old);
|
1176
|
+
} else {
|
1177
|
+
this._warn(this._logf('_observerEffect', 'observer method `' + effect.method + '` not defined'));
|
1178
|
+
}
|
1179
|
+
},
|
1180
|
+
_complexObserverEffect: function (source, value, effect) {
|
1181
|
+
var fn = this[effect.method];
|
1182
|
+
if (fn) {
|
1183
|
+
var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
|
1184
|
+
if (args) {
|
1185
|
+
fn.apply(this, args);
|
1186
|
+
}
|
1187
|
+
} else {
|
1188
|
+
this._warn(this._logf('_complexObserverEffect', 'observer method `' + effect.method + '` not defined'));
|
1189
|
+
}
|
1190
|
+
},
|
1191
|
+
_computeEffect: function (source, value, effect) {
|
1192
|
+
var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
|
1193
|
+
if (args) {
|
1194
|
+
var fn = this[effect.method];
|
1195
|
+
if (fn) {
|
1196
|
+
this[effect.property] = fn.apply(this, args);
|
1197
|
+
} else {
|
1198
|
+
this._warn(this._logf('_computeEffect', 'compute method `' + effect.method + '` not defined'));
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
},
|
1202
|
+
_annotatedComputationEffect: function (source, value, effect) {
|
1203
|
+
var computedHost = this._rootDataHost || this;
|
1204
|
+
var fn = computedHost[effect.method];
|
1205
|
+
if (fn) {
|
1206
|
+
var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
|
1207
|
+
if (args) {
|
1208
|
+
var computedvalue = fn.apply(computedHost, args);
|
1209
|
+
if (effect.negate) {
|
1210
|
+
computedvalue = !computedvalue;
|
1211
|
+
}
|
1212
|
+
this._applyEffectValue(computedvalue, effect);
|
1213
|
+
}
|
1214
|
+
} else {
|
1215
|
+
computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute method `' + effect.method + '` not defined'));
|
1216
|
+
}
|
1217
|
+
},
|
1218
|
+
_marshalArgs: function (model, effect, path, value) {
|
1219
|
+
var values = [];
|
1220
|
+
var args = effect.args;
|
1221
|
+
for (var i = 0, l = args.length; i < l; i++) {
|
1222
|
+
var arg = args[i];
|
1223
|
+
var name = arg.name;
|
1224
|
+
var v;
|
1225
|
+
if (arg.literal) {
|
1226
|
+
v = arg.value;
|
1227
|
+
} else if (arg.structured) {
|
1228
|
+
v = Polymer.Base.get(name, model);
|
1229
|
+
} else {
|
1230
|
+
v = model[name];
|
1231
|
+
}
|
1232
|
+
if (args.length > 1 && v === undefined) {
|
1233
|
+
return;
|
1234
|
+
}
|
1235
|
+
if (arg.wildcard) {
|
1236
|
+
var baseChanged = name.indexOf(path + '.') === 0;
|
1237
|
+
var matches = effect.trigger.name.indexOf(name) === 0 && !baseChanged;
|
1238
|
+
values[i] = {
|
1239
|
+
path: matches ? path : name,
|
1240
|
+
value: matches ? value : v,
|
1241
|
+
base: v
|
1242
|
+
};
|
1243
|
+
} else {
|
1244
|
+
values[i] = v;
|
1245
|
+
}
|
1246
|
+
}
|
1247
|
+
return values;
|
1248
|
+
}
|
1249
|
+
});
|
1250
|
+
Polymer.Base._addFeature({
|
1251
|
+
_addPropertyEffect: function (property, kind, effect) {
|
1252
|
+
Polymer.Bind.addPropertyEffect(this, property, kind, effect);
|
1253
|
+
},
|
1254
|
+
_prepEffects: function () {
|
1255
|
+
Polymer.Bind.prepareModel(this);
|
1256
|
+
this._addAnnotationEffects(this._notes);
|
1257
|
+
},
|
1258
|
+
_prepBindings: function () {
|
1259
|
+
Polymer.Bind.createBindings(this);
|
1260
|
+
},
|
1261
|
+
_addPropertyEffects: function (properties) {
|
1262
|
+
if (properties) {
|
1263
|
+
for (var p in properties) {
|
1264
|
+
var prop = properties[p];
|
1265
|
+
if (prop.observer) {
|
1266
|
+
this._addObserverEffect(p, prop.observer);
|
1267
|
+
}
|
1268
|
+
if (prop.computed) {
|
1269
|
+
this._addComputedEffect(p, prop.computed);
|
1270
|
+
}
|
1271
|
+
if (prop.notify) {
|
1272
|
+
this._addPropertyEffect(p, 'notify');
|
1273
|
+
}
|
1274
|
+
if (prop.reflectToAttribute) {
|
1275
|
+
this._addPropertyEffect(p, 'reflect');
|
1276
|
+
}
|
1277
|
+
if (prop.readOnly) {
|
1278
|
+
Polymer.Bind.ensurePropertyEffects(this, p);
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
}
|
1282
|
+
},
|
1283
|
+
_addComputedEffect: function (name, expression) {
|
1284
|
+
var sig = this._parseMethod(expression);
|
1285
|
+
sig.args.forEach(function (arg) {
|
1286
|
+
this._addPropertyEffect(arg.model, 'compute', {
|
1287
|
+
method: sig.method,
|
1288
|
+
args: sig.args,
|
1289
|
+
trigger: arg,
|
1290
|
+
property: name
|
1291
|
+
});
|
1292
|
+
}, this);
|
1293
|
+
},
|
1294
|
+
_addObserverEffect: function (property, observer) {
|
1295
|
+
this._addPropertyEffect(property, 'observer', {
|
1296
|
+
method: observer,
|
1297
|
+
property: property
|
1298
|
+
});
|
1299
|
+
},
|
1300
|
+
_addComplexObserverEffects: function (observers) {
|
1301
|
+
if (observers) {
|
1302
|
+
observers.forEach(function (observer) {
|
1303
|
+
this._addComplexObserverEffect(observer);
|
1304
|
+
}, this);
|
1305
|
+
}
|
1306
|
+
},
|
1307
|
+
_addComplexObserverEffect: function (observer) {
|
1308
|
+
var sig = this._parseMethod(observer);
|
1309
|
+
sig.args.forEach(function (arg) {
|
1310
|
+
this._addPropertyEffect(arg.model, 'complexObserver', {
|
1311
|
+
method: sig.method,
|
1312
|
+
args: sig.args,
|
1313
|
+
trigger: arg
|
1314
|
+
});
|
1315
|
+
}, this);
|
1316
|
+
},
|
1317
|
+
_addAnnotationEffects: function (notes) {
|
1318
|
+
this._nodes = [];
|
1319
|
+
notes.forEach(function (note) {
|
1320
|
+
var index = this._nodes.push(note) - 1;
|
1321
|
+
note.bindings.forEach(function (binding) {
|
1322
|
+
this._addAnnotationEffect(binding, index);
|
1323
|
+
}, this);
|
1324
|
+
}, this);
|
1325
|
+
},
|
1326
|
+
_addAnnotationEffect: function (note, index) {
|
1327
|
+
if (Polymer.Bind._shouldAddListener(note)) {
|
1328
|
+
Polymer.Bind._addAnnotatedListener(this, index, note.name, note.value, note.event);
|
1329
|
+
}
|
1330
|
+
if (note.signature) {
|
1331
|
+
this._addAnnotatedComputationEffect(note, index);
|
1332
|
+
} else {
|
1333
|
+
note.index = index;
|
1334
|
+
this._addPropertyEffect(note.model, 'annotation', note);
|
1335
|
+
}
|
1336
|
+
},
|
1337
|
+
_addAnnotatedComputationEffect: function (note, index) {
|
1338
|
+
var sig = note.signature;
|
1339
|
+
if (sig.static) {
|
1340
|
+
this.__addAnnotatedComputationEffect('__static__', index, note, sig, null);
|
1341
|
+
} else {
|
1342
|
+
sig.args.forEach(function (arg) {
|
1343
|
+
if (!arg.literal) {
|
1344
|
+
this.__addAnnotatedComputationEffect(arg.model, index, note, sig, arg);
|
1345
|
+
}
|
1346
|
+
}, this);
|
1347
|
+
}
|
1348
|
+
},
|
1349
|
+
__addAnnotatedComputationEffect: function (property, index, note, sig, trigger) {
|
1350
|
+
this._addPropertyEffect(property, 'annotatedComputation', {
|
1351
|
+
index: index,
|
1352
|
+
kind: note.kind,
|
1353
|
+
property: note.name,
|
1354
|
+
negate: note.negate,
|
1355
|
+
method: sig.method,
|
1356
|
+
args: sig.args,
|
1357
|
+
trigger: trigger
|
1358
|
+
});
|
1359
|
+
},
|
1360
|
+
_parseMethod: function (expression) {
|
1361
|
+
var m = expression.match(/(\w*)\((.*)\)/);
|
1362
|
+
if (m) {
|
1363
|
+
var sig = {
|
1364
|
+
method: m[1],
|
1365
|
+
static: true
|
1366
|
+
};
|
1367
|
+
if (m[2].trim()) {
|
1368
|
+
var args = m[2].replace(/\\,/g, ',').split(',');
|
1369
|
+
return this._parseArgs(args, sig);
|
1370
|
+
} else {
|
1371
|
+
sig.args = Polymer.nar;
|
1372
|
+
return sig;
|
1373
|
+
}
|
1374
|
+
}
|
1375
|
+
},
|
1376
|
+
_parseArgs: function (argList, sig) {
|
1377
|
+
sig.args = argList.map(function (rawArg) {
|
1378
|
+
var arg = this._parseArg(rawArg);
|
1379
|
+
if (!arg.literal) {
|
1380
|
+
sig.static = false;
|
1381
|
+
}
|
1382
|
+
return arg;
|
1383
|
+
}, this);
|
1384
|
+
return sig;
|
1385
|
+
},
|
1386
|
+
_parseArg: function (rawArg) {
|
1387
|
+
var arg = rawArg.trim().replace(/,/g, ',').replace(/\\(.)/g, '$1');
|
1388
|
+
var a = {
|
1389
|
+
name: arg,
|
1390
|
+
model: this._modelForPath(arg)
|
1391
|
+
};
|
1392
|
+
var fc = arg[0];
|
1393
|
+
if (fc >= '0' && fc <= '9') {
|
1394
|
+
fc = '#';
|
1395
|
+
}
|
1396
|
+
switch (fc) {
|
1397
|
+
case '\'':
|
1398
|
+
case '"':
|
1399
|
+
a.value = arg.slice(1, -1);
|
1400
|
+
a.literal = true;
|
1401
|
+
break;
|
1402
|
+
case '#':
|
1403
|
+
a.value = Number(arg);
|
1404
|
+
a.literal = true;
|
1405
|
+
break;
|
1406
|
+
}
|
1407
|
+
if (!a.literal) {
|
1408
|
+
a.structured = arg.indexOf('.') > 0;
|
1409
|
+
if (a.structured) {
|
1410
|
+
a.wildcard = arg.slice(-2) == '.*';
|
1411
|
+
if (a.wildcard) {
|
1412
|
+
a.name = arg.slice(0, -2);
|
1413
|
+
}
|
1414
|
+
}
|
1415
|
+
}
|
1416
|
+
return a;
|
1417
|
+
},
|
1418
|
+
_marshalInstanceEffects: function () {
|
1419
|
+
Polymer.Bind.prepareInstance(this);
|
1420
|
+
Polymer.Bind.setupBindListeners(this);
|
1421
|
+
},
|
1422
|
+
_applyEffectValue: function (value, info) {
|
1423
|
+
var node = this._nodes[info.index];
|
1424
|
+
var property = info.property || info.name || 'textContent';
|
1425
|
+
if (info.kind == 'attribute') {
|
1426
|
+
this.serializeValueToAttribute(value, property, node);
|
1427
|
+
} else {
|
1428
|
+
if (property === 'className') {
|
1429
|
+
value = this._scopeElementClass(node, value);
|
1430
|
+
}
|
1431
|
+
if (property === 'textContent' || node.localName == 'input' && property == 'value') {
|
1432
|
+
value = value == undefined ? '' : value;
|
1433
|
+
}
|
1434
|
+
return node[property] = value;
|
1435
|
+
}
|
1436
|
+
},
|
1437
|
+
_executeStaticEffects: function () {
|
1438
|
+
if (this._propertyEffects.__static__) {
|
1439
|
+
this._effectEffects('__static__', null, this._propertyEffects.__static__);
|
1440
|
+
}
|
1441
|
+
}
|
1442
|
+
});
|
1443
|
+
Polymer.Base._addFeature({
|
1444
|
+
_setupConfigure: function (initialConfig) {
|
1445
|
+
this._config = initialConfig || {};
|
1446
|
+
this._handlers = [];
|
1447
|
+
},
|
1448
|
+
_marshalAttributes: function () {
|
1449
|
+
this._takeAttributesToModel(this._config);
|
1450
|
+
},
|
1451
|
+
_configValue: function (name, value) {
|
1452
|
+
this._config[name] = value;
|
1453
|
+
},
|
1454
|
+
_beforeClientsReady: function () {
|
1455
|
+
this._configure();
|
1456
|
+
},
|
1457
|
+
_configure: function () {
|
1458
|
+
this._configureAnnotationReferences();
|
1459
|
+
var config = {};
|
1460
|
+
this.behaviors.forEach(function (b) {
|
1461
|
+
this._configureProperties(b.properties, config);
|
1462
|
+
}, this);
|
1463
|
+
this._configureProperties(this.properties, config);
|
1464
|
+
this._mixinConfigure(config, this._config);
|
1465
|
+
this._config = config;
|
1466
|
+
this._distributeConfig(this._config);
|
1467
|
+
},
|
1468
|
+
_configureProperties: function (properties, config) {
|
1469
|
+
for (var i in properties) {
|
1470
|
+
var c = properties[i];
|
1471
|
+
if (c.value !== undefined) {
|
1472
|
+
var value = c.value;
|
1473
|
+
if (typeof value == 'function') {
|
1474
|
+
value = value.call(this, this._config);
|
1475
|
+
}
|
1476
|
+
config[i] = value;
|
1477
|
+
}
|
1478
|
+
}
|
1479
|
+
},
|
1480
|
+
_mixinConfigure: function (a, b) {
|
1481
|
+
for (var prop in b) {
|
1482
|
+
if (!this.getPropertyInfo(prop).readOnly) {
|
1483
|
+
a[prop] = b[prop];
|
1484
|
+
}
|
1485
|
+
}
|
1486
|
+
},
|
1487
|
+
_distributeConfig: function (config) {
|
1488
|
+
var fx$ = this._propertyEffects;
|
1489
|
+
if (fx$) {
|
1490
|
+
for (var p in config) {
|
1491
|
+
var fx = fx$[p];
|
1492
|
+
if (fx) {
|
1493
|
+
for (var i = 0, l = fx.length, x; i < l && (x = fx[i]); i++) {
|
1494
|
+
if (x.kind === 'annotation') {
|
1495
|
+
var node = this._nodes[x.effect.index];
|
1496
|
+
if (node._configValue) {
|
1497
|
+
var value = p === x.effect.value ? config[p] : this.get(x.effect.value, config);
|
1498
|
+
node._configValue(x.effect.name, value);
|
1499
|
+
}
|
1500
|
+
}
|
1501
|
+
}
|
1502
|
+
}
|
1503
|
+
}
|
1504
|
+
}
|
1505
|
+
},
|
1506
|
+
_afterClientsReady: function () {
|
1507
|
+
this._executeStaticEffects();
|
1508
|
+
this._applyConfig(this._config);
|
1509
|
+
this._flushHandlers();
|
1510
|
+
},
|
1511
|
+
_applyConfig: function (config) {
|
1512
|
+
for (var n in config) {
|
1513
|
+
if (this[n] === undefined) {
|
1514
|
+
var effects = this._propertyEffects[n];
|
1515
|
+
if (effects) {
|
1516
|
+
this._propertySet(n, config[n], effects);
|
1517
|
+
} else {
|
1518
|
+
this[n] = config[n];
|
1519
|
+
}
|
1520
|
+
}
|
1521
|
+
}
|
1522
|
+
},
|
1523
|
+
_notifyListener: function (fn, e) {
|
1524
|
+
if (!this._clientsReadied) {
|
1525
|
+
this._queueHandler([
|
1526
|
+
fn,
|
1527
|
+
e,
|
1528
|
+
e.target
|
1529
|
+
]);
|
1530
|
+
} else {
|
1531
|
+
return fn.call(this, e, e.target);
|
1532
|
+
}
|
1533
|
+
},
|
1534
|
+
_queueHandler: function (args) {
|
1535
|
+
this._handlers.push(args);
|
1536
|
+
},
|
1537
|
+
_flushHandlers: function () {
|
1538
|
+
var h$ = this._handlers;
|
1539
|
+
for (var i = 0, l = h$.length, h; i < l && (h = h$[i]); i++) {
|
1540
|
+
h[0].call(this, h[1], h[2]);
|
1541
|
+
}
|
1542
|
+
}
|
1543
|
+
});
|
1544
|
+
(function () {
|
1545
|
+
'use strict';
|
1546
|
+
Polymer.Base._addFeature({
|
1547
|
+
notifyPath: function (path, value, fromAbove) {
|
1548
|
+
var old = this._propertySet(path, value);
|
1549
|
+
if (old !== value) {
|
1550
|
+
this._pathEffector(path, value);
|
1551
|
+
if (!fromAbove) {
|
1552
|
+
this._notifyPath(path, value);
|
1553
|
+
}
|
1554
|
+
}
|
1555
|
+
},
|
1556
|
+
_getPathParts: function (path) {
|
1557
|
+
if (Array.isArray(path)) {
|
1558
|
+
var parts = [];
|
1559
|
+
for (var i = 0; i < path.length; i++) {
|
1560
|
+
var args = path[i].toString().split('.');
|
1561
|
+
for (var j = 0; j < args.length; j++) {
|
1562
|
+
parts.push(args[j]);
|
1563
|
+
}
|
1564
|
+
}
|
1565
|
+
return parts;
|
1566
|
+
} else {
|
1567
|
+
return path.toString().split('.');
|
1568
|
+
}
|
1569
|
+
},
|
1570
|
+
set: function (path, value, root) {
|
1571
|
+
var prop = root || this;
|
1572
|
+
var parts = this._getPathParts(path);
|
1573
|
+
var array;
|
1574
|
+
var last = parts[parts.length - 1];
|
1575
|
+
if (parts.length > 1) {
|
1576
|
+
for (var i = 0; i < parts.length - 1; i++) {
|
1577
|
+
prop = prop[parts[i]];
|
1578
|
+
if (array) {
|
1579
|
+
parts[i] = Polymer.Collection.get(array).getKey(prop);
|
1580
|
+
}
|
1581
|
+
if (!prop) {
|
1582
|
+
return;
|
1583
|
+
}
|
1584
|
+
array = Array.isArray(prop) ? prop : null;
|
1585
|
+
}
|
1586
|
+
prop[last] = value;
|
1587
|
+
if (!root) {
|
1588
|
+
this.notifyPath(parts.join('.'), value);
|
1589
|
+
}
|
1590
|
+
} else {
|
1591
|
+
prop[path] = value;
|
1592
|
+
}
|
1593
|
+
},
|
1594
|
+
get: function (path, root) {
|
1595
|
+
var prop = root || this;
|
1596
|
+
var parts = this._getPathParts(path);
|
1597
|
+
var last = parts.pop();
|
1598
|
+
while (parts.length) {
|
1599
|
+
prop = prop[parts.shift()];
|
1600
|
+
if (!prop) {
|
1601
|
+
return;
|
1602
|
+
}
|
1603
|
+
}
|
1604
|
+
return prop[last];
|
1605
|
+
},
|
1606
|
+
_pathEffector: function (path, value) {
|
1607
|
+
var model = this._modelForPath(path);
|
1608
|
+
var fx$ = this._propertyEffects[model];
|
1609
|
+
if (fx$) {
|
1610
|
+
fx$.forEach(function (fx) {
|
1611
|
+
var fxFn = this['_' + fx.kind + 'PathEffect'];
|
1612
|
+
if (fxFn) {
|
1613
|
+
fxFn.call(this, path, value, fx.effect);
|
1614
|
+
}
|
1615
|
+
}, this);
|
1616
|
+
}
|
1617
|
+
if (this._boundPaths) {
|
1618
|
+
this._notifyBoundPaths(path, value);
|
1619
|
+
}
|
1620
|
+
},
|
1621
|
+
_annotationPathEffect: function (path, value, effect) {
|
1622
|
+
if (effect.value === path || effect.value.indexOf(path + '.') === 0) {
|
1623
|
+
Polymer.Bind._annotationEffect.call(this, path, value, effect);
|
1624
|
+
} else if (path.indexOf(effect.value + '.') === 0 && !effect.negate) {
|
1625
|
+
var node = this._nodes[effect.index];
|
1626
|
+
if (node && node.notifyPath) {
|
1627
|
+
var p = this._fixPath(effect.name, effect.value, path);
|
1628
|
+
node.notifyPath(p, value, true);
|
1629
|
+
}
|
1630
|
+
}
|
1631
|
+
},
|
1632
|
+
_complexObserverPathEffect: function (path, value, effect) {
|
1633
|
+
if (this._pathMatchesEffect(path, effect)) {
|
1634
|
+
Polymer.Bind._complexObserverEffect.call(this, path, value, effect);
|
1635
|
+
}
|
1636
|
+
},
|
1637
|
+
_computePathEffect: function (path, value, effect) {
|
1638
|
+
if (this._pathMatchesEffect(path, effect)) {
|
1639
|
+
Polymer.Bind._computeEffect.call(this, path, value, effect);
|
1640
|
+
}
|
1641
|
+
},
|
1642
|
+
_annotatedComputationPathEffect: function (path, value, effect) {
|
1643
|
+
if (this._pathMatchesEffect(path, effect)) {
|
1644
|
+
Polymer.Bind._annotatedComputationEffect.call(this, path, value, effect);
|
1645
|
+
}
|
1646
|
+
},
|
1647
|
+
_pathMatchesEffect: function (path, effect) {
|
1648
|
+
var effectArg = effect.trigger.name;
|
1649
|
+
return effectArg == path || effectArg.indexOf(path + '.') === 0 || effect.trigger.wildcard && path.indexOf(effectArg) === 0;
|
1650
|
+
},
|
1651
|
+
linkPaths: function (to, from) {
|
1652
|
+
this._boundPaths = this._boundPaths || {};
|
1653
|
+
if (from) {
|
1654
|
+
this._boundPaths[to] = from;
|
1655
|
+
} else {
|
1656
|
+
this.unbindPath(to);
|
1657
|
+
}
|
1658
|
+
},
|
1659
|
+
unlinkPaths: function (path) {
|
1660
|
+
if (this._boundPaths) {
|
1661
|
+
delete this._boundPaths[path];
|
1662
|
+
}
|
1663
|
+
},
|
1664
|
+
_notifyBoundPaths: function (path, value) {
|
1665
|
+
var from, to;
|
1666
|
+
for (var a in this._boundPaths) {
|
1667
|
+
var b = this._boundPaths[a];
|
1668
|
+
if (path.indexOf(a + '.') == 0) {
|
1669
|
+
from = a;
|
1670
|
+
to = b;
|
1671
|
+
break;
|
1672
|
+
}
|
1673
|
+
if (path.indexOf(b + '.') == 0) {
|
1674
|
+
from = b;
|
1675
|
+
to = a;
|
1676
|
+
break;
|
1677
|
+
}
|
1678
|
+
}
|
1679
|
+
if (from && to) {
|
1680
|
+
var p = this._fixPath(to, from, path);
|
1681
|
+
this.notifyPath(p, value);
|
1682
|
+
}
|
1683
|
+
},
|
1684
|
+
_fixPath: function (property, root, path) {
|
1685
|
+
return property + path.slice(root.length);
|
1686
|
+
},
|
1687
|
+
_notifyPath: function (path, value) {
|
1688
|
+
var rootName = this._modelForPath(path);
|
1689
|
+
var dashCaseName = Polymer.CaseMap.camelToDashCase(rootName);
|
1690
|
+
var eventName = dashCaseName + this._EVENT_CHANGED;
|
1691
|
+
this.fire(eventName, {
|
1692
|
+
path: path,
|
1693
|
+
value: value
|
1694
|
+
}, { bubbles: false });
|
1695
|
+
},
|
1696
|
+
_modelForPath: function (path) {
|
1697
|
+
var dot = path.indexOf('.');
|
1698
|
+
return dot < 0 ? path : path.slice(0, dot);
|
1699
|
+
},
|
1700
|
+
_EVENT_CHANGED: '-changed',
|
1701
|
+
_notifySplice: function (array, path, index, added, removed) {
|
1702
|
+
var splices = [{
|
1703
|
+
index: index,
|
1704
|
+
addedCount: added,
|
1705
|
+
removed: removed,
|
1706
|
+
object: array,
|
1707
|
+
type: 'splice'
|
1708
|
+
}];
|
1709
|
+
var change = {
|
1710
|
+
keySplices: Polymer.Collection.get(array).applySplices(splices),
|
1711
|
+
indexSplices: splices
|
1712
|
+
};
|
1713
|
+
this.set(path + '.splices', change);
|
1714
|
+
if (added != removed.length) {
|
1715
|
+
this.notifyPath(path + '.length', array.length);
|
1716
|
+
}
|
1717
|
+
change.keySplices = null;
|
1718
|
+
change.indexSplices = null;
|
1719
|
+
},
|
1720
|
+
push: function (path) {
|
1721
|
+
var array = this.get(path);
|
1722
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
1723
|
+
var len = array.length;
|
1724
|
+
var ret = array.push.apply(array, args);
|
1725
|
+
this._notifySplice(array, path, len, args.length, []);
|
1726
|
+
return ret;
|
1727
|
+
},
|
1728
|
+
pop: function (path) {
|
1729
|
+
var array = this.get(path);
|
1730
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
1731
|
+
var rem = array.slice(-1);
|
1732
|
+
var ret = array.pop.apply(array, args);
|
1733
|
+
this._notifySplice(array, path, array.length, 0, rem);
|
1734
|
+
return ret;
|
1735
|
+
},
|
1736
|
+
splice: function (path, start, deleteCount) {
|
1737
|
+
var array = this.get(path);
|
1738
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
1739
|
+
var rem = array.slice(start, start + deleteCount);
|
1740
|
+
var ret = array.splice.apply(array, args);
|
1741
|
+
this._notifySplice(array, path, start, args.length - 2, rem);
|
1742
|
+
return ret;
|
1743
|
+
},
|
1744
|
+
shift: function (path) {
|
1745
|
+
var array = this.get(path);
|
1746
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
1747
|
+
var ret = array.shift.apply(array, args);
|
1748
|
+
this._notifySplice(array, path, 0, 0, [ret]);
|
1749
|
+
return ret;
|
1750
|
+
},
|
1751
|
+
unshift: function (path) {
|
1752
|
+
var array = this.get(path);
|
1753
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
1754
|
+
var ret = array.unshift.apply(array, args);
|
1755
|
+
this._notifySplice(array, path, 0, args.length, []);
|
1756
|
+
return ret;
|
1757
|
+
}
|
1758
|
+
});
|
1759
|
+
}());
|
1760
|
+
Polymer.Base._addFeature({
|
1761
|
+
resolveUrl: function (url) {
|
1762
|
+
var module = Polymer.DomModule.import(this.is);
|
1763
|
+
var root = '';
|
1764
|
+
if (module) {
|
1765
|
+
var assetPath = module.getAttribute('assetpath') || '';
|
1766
|
+
root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI);
|
1767
|
+
}
|
1768
|
+
return Polymer.ResolveUrl.resolveUrl(url, root);
|
1769
|
+
}
|
1770
|
+
});
|
1771
|
+
Polymer.CssParse = function () {
|
1772
|
+
var api = {
|
1773
|
+
parse: function (text) {
|
1774
|
+
text = this._clean(text);
|
1775
|
+
return this._parseCss(this._lex(text), text);
|
1776
|
+
},
|
1777
|
+
_clean: function (cssText) {
|
1778
|
+
return cssText.replace(rx.comments, '').replace(rx.port, '');
|
1779
|
+
},
|
1780
|
+
_lex: function (text) {
|
1781
|
+
var root = {
|
1782
|
+
start: 0,
|
1783
|
+
end: text.length
|
1784
|
+
};
|
1785
|
+
var n = root;
|
1786
|
+
for (var i = 0, s = 0, l = text.length; i < l; i++) {
|
1787
|
+
switch (text[i]) {
|
1788
|
+
case this.OPEN_BRACE:
|
1789
|
+
if (!n.rules) {
|
1790
|
+
n.rules = [];
|
1791
|
+
}
|
1792
|
+
var p = n;
|
1793
|
+
var previous = p.rules[p.rules.length - 1];
|
1794
|
+
n = {
|
1795
|
+
start: i + 1,
|
1796
|
+
parent: p,
|
1797
|
+
previous: previous
|
1798
|
+
};
|
1799
|
+
p.rules.push(n);
|
1800
|
+
break;
|
1801
|
+
case this.CLOSE_BRACE:
|
1802
|
+
n.end = i + 1;
|
1803
|
+
n = n.parent || root;
|
1804
|
+
break;
|
1805
|
+
}
|
1806
|
+
}
|
1807
|
+
return root;
|
1808
|
+
},
|
1809
|
+
_parseCss: function (node, text) {
|
1810
|
+
var t = text.substring(node.start, node.end - 1);
|
1811
|
+
node.parsedCssText = node.cssText = t.trim();
|
1812
|
+
if (node.parent) {
|
1813
|
+
var ss = node.previous ? node.previous.end : node.parent.start;
|
1814
|
+
t = text.substring(ss, node.start - 1);
|
1815
|
+
t = t.substring(t.lastIndexOf(';') + 1);
|
1816
|
+
var s = node.parsedSelector = node.selector = t.trim();
|
1817
|
+
node.atRule = s.indexOf(AT_START) === 0;
|
1818
|
+
if (node.atRule) {
|
1819
|
+
if (s.indexOf(MEDIA_START) === 0) {
|
1820
|
+
node.type = this.types.MEDIA_RULE;
|
1821
|
+
} else if (s.match(rx.keyframesRule)) {
|
1822
|
+
node.type = this.types.KEYFRAMES_RULE;
|
1823
|
+
}
|
1824
|
+
} else {
|
1825
|
+
if (s.indexOf(VAR_START) === 0) {
|
1826
|
+
node.type = this.types.MIXIN_RULE;
|
1827
|
+
} else {
|
1828
|
+
node.type = this.types.STYLE_RULE;
|
1829
|
+
}
|
1830
|
+
}
|
1831
|
+
}
|
1832
|
+
var r$ = node.rules;
|
1833
|
+
if (r$) {
|
1834
|
+
for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
|
1835
|
+
this._parseCss(r, text);
|
1836
|
+
}
|
1837
|
+
}
|
1838
|
+
return node;
|
1839
|
+
},
|
1840
|
+
stringify: function (node, preserveProperties, text) {
|
1841
|
+
text = text || '';
|
1842
|
+
var cssText = '';
|
1843
|
+
if (node.cssText || node.rules) {
|
1844
|
+
var r$ = node.rules;
|
1845
|
+
if (r$ && (preserveProperties || !hasMixinRules(r$))) {
|
1846
|
+
for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
|
1847
|
+
cssText = this.stringify(r, preserveProperties, cssText);
|
1848
|
+
}
|
1849
|
+
} else {
|
1850
|
+
cssText = preserveProperties ? node.cssText : removeCustomProps(node.cssText);
|
1851
|
+
cssText = cssText.trim();
|
1852
|
+
if (cssText) {
|
1853
|
+
cssText = ' ' + cssText + '\n';
|
1854
|
+
}
|
1855
|
+
}
|
1856
|
+
}
|
1857
|
+
if (cssText) {
|
1858
|
+
if (node.selector) {
|
1859
|
+
text += node.selector + ' ' + this.OPEN_BRACE + '\n';
|
1860
|
+
}
|
1861
|
+
text += cssText;
|
1862
|
+
if (node.selector) {
|
1863
|
+
text += this.CLOSE_BRACE + '\n\n';
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
return text;
|
1867
|
+
},
|
1868
|
+
types: {
|
1869
|
+
STYLE_RULE: 1,
|
1870
|
+
KEYFRAMES_RULE: 7,
|
1871
|
+
MEDIA_RULE: 4,
|
1872
|
+
MIXIN_RULE: 1000
|
1873
|
+
},
|
1874
|
+
OPEN_BRACE: '{',
|
1875
|
+
CLOSE_BRACE: '}'
|
1876
|
+
};
|
1877
|
+
function hasMixinRules(rules) {
|
1878
|
+
return rules[0].selector.indexOf(VAR_START) >= 0;
|
1879
|
+
}
|
1880
|
+
function removeCustomProps(cssText) {
|
1881
|
+
return cssText.replace(rx.customProp, '').replace(rx.mixinProp, '').replace(rx.mixinApply, '').replace(rx.varApply, '');
|
1882
|
+
}
|
1883
|
+
var VAR_START = '--';
|
1884
|
+
var MEDIA_START = '@media';
|
1885
|
+
var AT_START = '@';
|
1886
|
+
var rx = {
|
1887
|
+
comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
|
1888
|
+
port: /@import[^;]*;/gim,
|
1889
|
+
customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?;/gim,
|
1890
|
+
mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?};?/gim,
|
1891
|
+
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*;/gim,
|
1892
|
+
varApply: /[^;:]*?:[^;]*var[^;]*;/gim,
|
1893
|
+
keyframesRule: /^@[^\s]*keyframes/
|
1894
|
+
};
|
1895
|
+
return api;
|
1896
|
+
}();
|
1897
|
+
Polymer.StyleUtil = function () {
|
1898
|
+
return {
|
1899
|
+
MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css]',
|
1900
|
+
toCssText: function (rules, callback, preserveProperties) {
|
1901
|
+
if (typeof rules === 'string') {
|
1902
|
+
rules = this.parser.parse(rules);
|
1903
|
+
}
|
1904
|
+
if (callback) {
|
1905
|
+
this.forEachStyleRule(rules, callback);
|
1906
|
+
}
|
1907
|
+
return this.parser.stringify(rules, preserveProperties);
|
1908
|
+
},
|
1909
|
+
forRulesInStyles: function (styles, callback) {
|
1910
|
+
for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
|
1911
|
+
this.forEachStyleRule(this.rulesForStyle(s), callback);
|
1912
|
+
}
|
1913
|
+
},
|
1914
|
+
rulesForStyle: function (style) {
|
1915
|
+
if (!style.__cssRules) {
|
1916
|
+
style.__cssRules = this.parser.parse(style.textContent);
|
1917
|
+
}
|
1918
|
+
return style.__cssRules;
|
1919
|
+
},
|
1920
|
+
clearStyleRules: function (style) {
|
1921
|
+
style.__cssRules = null;
|
1922
|
+
},
|
1923
|
+
forEachStyleRule: function (node, callback) {
|
1924
|
+
var s = node.selector;
|
1925
|
+
var skipRules = false;
|
1926
|
+
if (node.type === this.ruleTypes.STYLE_RULE) {
|
1927
|
+
callback(node);
|
1928
|
+
} else if (node.type === this.ruleTypes.KEYFRAMES_RULE || node.type === this.ruleTypes.MIXIN_RULE) {
|
1929
|
+
skipRules = true;
|
1930
|
+
}
|
1931
|
+
var r$ = node.rules;
|
1932
|
+
if (r$ && !skipRules) {
|
1933
|
+
for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
|
1934
|
+
this.forEachStyleRule(r, callback);
|
1935
|
+
}
|
1936
|
+
}
|
1937
|
+
},
|
1938
|
+
applyCss: function (cssText, moniker, target, afterNode) {
|
1939
|
+
var style = document.createElement('style');
|
1940
|
+
if (moniker) {
|
1941
|
+
style.setAttribute('scope', moniker);
|
1942
|
+
}
|
1943
|
+
style.textContent = cssText;
|
1944
|
+
target = target || document.head;
|
1945
|
+
if (!afterNode) {
|
1946
|
+
var n$ = target.querySelectorAll('style[scope]');
|
1947
|
+
afterNode = n$[n$.length - 1];
|
1948
|
+
}
|
1949
|
+
target.insertBefore(style, afterNode && afterNode.nextSibling || target.firstChild);
|
1950
|
+
return style;
|
1951
|
+
},
|
1952
|
+
cssFromModule: function (moduleId) {
|
1953
|
+
var m = Polymer.DomModule.import(moduleId);
|
1954
|
+
if (m && !m._cssText) {
|
1955
|
+
var cssText = '';
|
1956
|
+
var e$ = Array.prototype.slice.call(m.querySelectorAll(this.MODULE_STYLES_SELECTOR));
|
1957
|
+
for (var i = 0, e; i < e$.length; i++) {
|
1958
|
+
e = e$[i];
|
1959
|
+
if (e.localName === 'style') {
|
1960
|
+
e = e.__appliedElement || e;
|
1961
|
+
e.parentNode.removeChild(e);
|
1962
|
+
} else {
|
1963
|
+
e = e.import && e.import.body;
|
1964
|
+
}
|
1965
|
+
if (e) {
|
1966
|
+
cssText += Polymer.ResolveUrl.resolveCss(e.textContent, e.ownerDocument);
|
1967
|
+
}
|
1968
|
+
}
|
1969
|
+
m._cssText = cssText;
|
1970
|
+
}
|
1971
|
+
return m && m._cssText || '';
|
1972
|
+
},
|
1973
|
+
parser: Polymer.CssParse,
|
1974
|
+
ruleTypes: Polymer.CssParse.types
|
1975
|
+
};
|
1976
|
+
}();
|
1977
|
+
Polymer.StyleTransformer = function () {
|
1978
|
+
var nativeShadow = Polymer.Settings.useNativeShadow;
|
1979
|
+
var styleUtil = Polymer.StyleUtil;
|
1980
|
+
var api = {
|
1981
|
+
dom: function (node, scope, useAttr, shouldRemoveScope) {
|
1982
|
+
this._transformDom(node, scope || '', useAttr, shouldRemoveScope);
|
1983
|
+
},
|
1984
|
+
_transformDom: function (node, selector, useAttr, shouldRemoveScope) {
|
1985
|
+
if (node.setAttribute) {
|
1986
|
+
this.element(node, selector, useAttr, shouldRemoveScope);
|
1987
|
+
}
|
1988
|
+
var c$ = Polymer.dom(node).childNodes;
|
1989
|
+
for (var i = 0; i < c$.length; i++) {
|
1990
|
+
this._transformDom(c$[i], selector, useAttr, shouldRemoveScope);
|
1991
|
+
}
|
1992
|
+
},
|
1993
|
+
element: function (element, scope, useAttr, shouldRemoveScope) {
|
1994
|
+
if (useAttr) {
|
1995
|
+
if (shouldRemoveScope) {
|
1996
|
+
element.removeAttribute(SCOPE_NAME);
|
1997
|
+
} else {
|
1998
|
+
element.setAttribute(SCOPE_NAME, scope);
|
1999
|
+
}
|
2000
|
+
} else {
|
2001
|
+
if (scope) {
|
2002
|
+
if (element.classList) {
|
2003
|
+
if (shouldRemoveScope) {
|
2004
|
+
element.classList.remove(SCOPE_NAME);
|
2005
|
+
element.classList.remove(scope);
|
2006
|
+
} else {
|
2007
|
+
element.classList.add(SCOPE_NAME);
|
2008
|
+
element.classList.add(scope);
|
2009
|
+
}
|
2010
|
+
} else if (element.getAttribute) {
|
2011
|
+
var c = element.getAttribute(CLASS);
|
2012
|
+
if (shouldRemoveScope) {
|
2013
|
+
if (c) {
|
2014
|
+
element.setAttribute(CLASS, c.replace(SCOPE_NAME, '').replace(scope, ''));
|
2015
|
+
}
|
2016
|
+
} else {
|
2017
|
+
element.setAttribute(CLASS, c + (c ? ' ' : '') + SCOPE_NAME + ' ' + scope);
|
2018
|
+
}
|
2019
|
+
}
|
2020
|
+
}
|
2021
|
+
}
|
2022
|
+
},
|
2023
|
+
elementStyles: function (element, callback) {
|
2024
|
+
var styles = element._styles;
|
2025
|
+
var cssText = '';
|
2026
|
+
for (var i = 0, l = styles.length, s, text; i < l && (s = styles[i]); i++) {
|
2027
|
+
var rules = styleUtil.rulesForStyle(s);
|
2028
|
+
cssText += nativeShadow ? styleUtil.toCssText(rules, callback) : this.css(rules, element.is, element.extends, callback, element._scopeCssViaAttr) + '\n\n';
|
2029
|
+
}
|
2030
|
+
return cssText.trim();
|
2031
|
+
},
|
2032
|
+
css: function (rules, scope, ext, callback, useAttr) {
|
2033
|
+
var hostScope = this._calcHostScope(scope, ext);
|
2034
|
+
scope = this._calcElementScope(scope, useAttr);
|
2035
|
+
var self = this;
|
2036
|
+
return styleUtil.toCssText(rules, function (rule) {
|
2037
|
+
if (!rule.isScoped) {
|
2038
|
+
self.rule(rule, scope, hostScope);
|
2039
|
+
rule.isScoped = true;
|
2040
|
+
}
|
2041
|
+
if (callback) {
|
2042
|
+
callback(rule, scope, hostScope);
|
2043
|
+
}
|
2044
|
+
});
|
2045
|
+
},
|
2046
|
+
_calcElementScope: function (scope, useAttr) {
|
2047
|
+
if (scope) {
|
2048
|
+
return useAttr ? CSS_ATTR_PREFIX + scope + CSS_ATTR_SUFFIX : CSS_CLASS_PREFIX + scope;
|
2049
|
+
} else {
|
2050
|
+
return '';
|
2051
|
+
}
|
2052
|
+
},
|
2053
|
+
_calcHostScope: function (scope, ext) {
|
2054
|
+
return ext ? '[is=' + scope + ']' : scope;
|
2055
|
+
},
|
2056
|
+
rule: function (rule, scope, hostScope) {
|
2057
|
+
this._transformRule(rule, this._transformComplexSelector, scope, hostScope);
|
2058
|
+
},
|
2059
|
+
_transformRule: function (rule, transformer, scope, hostScope) {
|
2060
|
+
var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
|
2061
|
+
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
|
2062
|
+
p$[i] = transformer.call(this, p, scope, hostScope);
|
2063
|
+
}
|
2064
|
+
rule.selector = p$.join(COMPLEX_SELECTOR_SEP);
|
2065
|
+
},
|
2066
|
+
_transformComplexSelector: function (selector, scope, hostScope) {
|
2067
|
+
var stop = false;
|
2068
|
+
var self = this;
|
2069
|
+
selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
|
2070
|
+
if (!stop) {
|
2071
|
+
var o = self._transformCompoundSelector(s, c, scope, hostScope);
|
2072
|
+
if (o.stop) {
|
2073
|
+
stop = true;
|
2074
|
+
}
|
2075
|
+
c = o.combinator;
|
2076
|
+
s = o.value;
|
2077
|
+
}
|
2078
|
+
return c + s;
|
2079
|
+
});
|
2080
|
+
return selector;
|
2081
|
+
},
|
2082
|
+
_transformCompoundSelector: function (selector, combinator, scope, hostScope) {
|
2083
|
+
var jumpIndex = selector.search(SCOPE_JUMP);
|
2084
|
+
if (selector.indexOf(HOST) >= 0) {
|
2085
|
+
selector = selector.replace(HOST_PAREN, function (m, host, paren) {
|
2086
|
+
return hostScope + paren;
|
2087
|
+
});
|
2088
|
+
selector = selector.replace(HOST, hostScope);
|
2089
|
+
} else if (jumpIndex !== 0) {
|
2090
|
+
selector = scope ? this._transformSimpleSelector(selector, scope) : selector;
|
2091
|
+
}
|
2092
|
+
if (selector.indexOf(CONTENT) >= 0) {
|
2093
|
+
combinator = '';
|
2094
|
+
}
|
2095
|
+
var stop;
|
2096
|
+
if (jumpIndex >= 0) {
|
2097
|
+
selector = selector.replace(SCOPE_JUMP, ' ');
|
2098
|
+
stop = true;
|
2099
|
+
}
|
2100
|
+
return {
|
2101
|
+
value: selector,
|
2102
|
+
combinator: combinator,
|
2103
|
+
stop: stop
|
2104
|
+
};
|
2105
|
+
},
|
2106
|
+
_transformSimpleSelector: function (selector, scope) {
|
2107
|
+
var p$ = selector.split(PSEUDO_PREFIX);
|
2108
|
+
p$[0] += scope;
|
2109
|
+
return p$.join(PSEUDO_PREFIX);
|
2110
|
+
},
|
2111
|
+
rootRule: function (rule) {
|
2112
|
+
this._transformRule(rule, this._transformRootSelector);
|
2113
|
+
},
|
2114
|
+
_transformRootSelector: function (selector) {
|
2115
|
+
return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector) : selector.trim() + SCOPE_ROOT_SELECTOR;
|
2116
|
+
},
|
2117
|
+
SCOPE_NAME: 'style-scope'
|
2118
|
+
};
|
2119
|
+
var SCOPE_NAME = api.SCOPE_NAME;
|
2120
|
+
var SCOPE_ROOT_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')';
|
2121
|
+
var COMPLEX_SELECTOR_SEP = ',';
|
2122
|
+
var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g;
|
2123
|
+
var HOST = ':host';
|
2124
|
+
var HOST_PAREN = /(\:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
|
2125
|
+
var CONTENT = '::content';
|
2126
|
+
var SCOPE_JUMP = /\:\:content|\:\:shadow|\/deep\//;
|
2127
|
+
var CSS_CLASS_PREFIX = '.';
|
2128
|
+
var CSS_ATTR_PREFIX = '[' + SCOPE_NAME + '~=';
|
2129
|
+
var CSS_ATTR_SUFFIX = ']';
|
2130
|
+
var PSEUDO_PREFIX = ':';
|
2131
|
+
var CLASS = 'class';
|
2132
|
+
return api;
|
2133
|
+
}();
|
2134
|
+
Polymer.StyleExtends = function () {
|
2135
|
+
var styleUtil = Polymer.StyleUtil;
|
2136
|
+
return {
|
2137
|
+
hasExtends: function (cssText) {
|
2138
|
+
return Boolean(cssText.match(this.rx.EXTEND));
|
2139
|
+
},
|
2140
|
+
transform: function (style) {
|
2141
|
+
var rules = styleUtil.rulesForStyle(style);
|
2142
|
+
var self = this;
|
2143
|
+
styleUtil.forEachStyleRule(rules, function (rule) {
|
2144
|
+
var map = self._mapRule(rule);
|
2145
|
+
if (rule.parent) {
|
2146
|
+
var m;
|
2147
|
+
while (m = self.rx.EXTEND.exec(rule.cssText)) {
|
2148
|
+
var extend = m[1];
|
2149
|
+
var extendor = self._findExtendor(extend, rule);
|
2150
|
+
if (extendor) {
|
2151
|
+
self._extendRule(rule, extendor);
|
2152
|
+
}
|
2153
|
+
}
|
2154
|
+
}
|
2155
|
+
rule.cssText = rule.cssText.replace(self.rx.EXTEND, '');
|
2156
|
+
});
|
2157
|
+
return styleUtil.toCssText(rules, function (rule) {
|
2158
|
+
if (rule.selector.match(self.rx.STRIP)) {
|
2159
|
+
rule.cssText = '';
|
2160
|
+
}
|
2161
|
+
}, true);
|
2162
|
+
},
|
2163
|
+
_mapRule: function (rule) {
|
2164
|
+
if (rule.parent) {
|
2165
|
+
var map = rule.parent.map || (rule.parent.map = {});
|
2166
|
+
var parts = rule.selector.split(',');
|
2167
|
+
for (var i = 0, p; i < parts.length; i++) {
|
2168
|
+
p = parts[i];
|
2169
|
+
map[p.trim()] = rule;
|
2170
|
+
}
|
2171
|
+
return map;
|
2172
|
+
}
|
2173
|
+
},
|
2174
|
+
_findExtendor: function (extend, rule) {
|
2175
|
+
return rule.parent && rule.parent.map && rule.parent.map[extend] || this._findExtendor(extend, rule.parent);
|
2176
|
+
},
|
2177
|
+
_extendRule: function (target, source) {
|
2178
|
+
if (target.parent !== source.parent) {
|
2179
|
+
this._cloneAndAddRuleToParent(source, target.parent);
|
2180
|
+
}
|
2181
|
+
target.extends = target.extends || (target.extends = []);
|
2182
|
+
target.extends.push(source);
|
2183
|
+
source.selector = source.selector.replace(this.rx.STRIP, '');
|
2184
|
+
source.selector = (source.selector && source.selector + ',\n') + target.selector;
|
2185
|
+
if (source.extends) {
|
2186
|
+
source.extends.forEach(function (e) {
|
2187
|
+
this._extendRule(target, e);
|
2188
|
+
}, this);
|
2189
|
+
}
|
2190
|
+
},
|
2191
|
+
_cloneAndAddRuleToParent: function (rule, parent) {
|
2192
|
+
rule = Object.create(rule);
|
2193
|
+
rule.parent = parent;
|
2194
|
+
if (rule.extends) {
|
2195
|
+
rule.extends = rule.extends.slice();
|
2196
|
+
}
|
2197
|
+
parent.rules.push(rule);
|
2198
|
+
},
|
2199
|
+
rx: {
|
2200
|
+
EXTEND: /@extends\(([^)]*)\)\s*?;/gim,
|
2201
|
+
STRIP: /%[^,]*$/
|
2202
|
+
}
|
2203
|
+
};
|
2204
|
+
}();
|
2205
|
+
(function () {
|
2206
|
+
var prepElement = Polymer.Base._prepElement;
|
2207
|
+
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2208
|
+
var styleUtil = Polymer.StyleUtil;
|
2209
|
+
var styleTransformer = Polymer.StyleTransformer;
|
2210
|
+
var styleExtends = Polymer.StyleExtends;
|
2211
|
+
Polymer.Base._addFeature({
|
2212
|
+
_prepElement: function (element) {
|
2213
|
+
if (this._encapsulateStyle) {
|
2214
|
+
styleTransformer.element(element, this.is, this._scopeCssViaAttr);
|
2215
|
+
}
|
2216
|
+
prepElement.call(this, element);
|
2217
|
+
},
|
2218
|
+
_prepStyles: function () {
|
2219
|
+
if (this._encapsulateStyle === undefined) {
|
2220
|
+
this._encapsulateStyle = !nativeShadow && Boolean(this._template);
|
2221
|
+
}
|
2222
|
+
this._styles = this._collectStyles();
|
2223
|
+
var cssText = styleTransformer.elementStyles(this);
|
2224
|
+
if (cssText && this._template) {
|
2225
|
+
var style = styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : null);
|
2226
|
+
if (!nativeShadow) {
|
2227
|
+
this._scopeStyle = style;
|
2228
|
+
}
|
2229
|
+
}
|
2230
|
+
},
|
2231
|
+
_collectStyles: function () {
|
2232
|
+
var styles = [];
|
2233
|
+
var cssText = '', m$ = this.styleModules;
|
2234
|
+
if (m$) {
|
2235
|
+
for (var i = 0, l = m$.length, m; i < l && (m = m$[i]); i++) {
|
2236
|
+
cssText += styleUtil.cssFromModule(m);
|
2237
|
+
}
|
2238
|
+
}
|
2239
|
+
cssText += styleUtil.cssFromModule(this.is);
|
2240
|
+
if (cssText) {
|
2241
|
+
var style = document.createElement('style');
|
2242
|
+
style.textContent = cssText;
|
2243
|
+
if (styleExtends.hasExtends(style.textContent)) {
|
2244
|
+
cssText = styleExtends.transform(style);
|
2245
|
+
}
|
2246
|
+
styles.push(style);
|
2247
|
+
}
|
2248
|
+
return styles;
|
2249
|
+
},
|
2250
|
+
_elementAdd: function (node) {
|
2251
|
+
if (this._encapsulateStyle) {
|
2252
|
+
if (node.__styleScoped) {
|
2253
|
+
node.__styleScoped = false;
|
2254
|
+
} else {
|
2255
|
+
styleTransformer.dom(node, this.is, this._scopeCssViaAttr);
|
2256
|
+
}
|
2257
|
+
}
|
2258
|
+
},
|
2259
|
+
_elementRemove: function (node) {
|
2260
|
+
if (this._encapsulateStyle) {
|
2261
|
+
styleTransformer.dom(node, this.is, this._scopeCssViaAttr, true);
|
2262
|
+
}
|
2263
|
+
},
|
2264
|
+
scopeSubtree: function (container, shouldObserve) {
|
2265
|
+
if (nativeShadow) {
|
2266
|
+
return;
|
2267
|
+
}
|
2268
|
+
var self = this;
|
2269
|
+
var scopify = function (node) {
|
2270
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
2271
|
+
node.className = self._scopeElementClass(node, node.className);
|
2272
|
+
var n$ = node.querySelectorAll('*');
|
2273
|
+
Array.prototype.forEach.call(n$, function (n) {
|
2274
|
+
n.className = self._scopeElementClass(n, n.className);
|
2275
|
+
});
|
2276
|
+
}
|
2277
|
+
};
|
2278
|
+
scopify(container);
|
2279
|
+
if (shouldObserve) {
|
2280
|
+
var mo = new MutationObserver(function (mxns) {
|
2281
|
+
mxns.forEach(function (m) {
|
2282
|
+
if (m.addedNodes) {
|
2283
|
+
for (var i = 0; i < m.addedNodes.length; i++) {
|
2284
|
+
scopify(m.addedNodes[i]);
|
2285
|
+
}
|
2286
|
+
}
|
2287
|
+
});
|
2288
|
+
});
|
2289
|
+
mo.observe(container, {
|
2290
|
+
childList: true,
|
2291
|
+
subtree: true
|
2292
|
+
});
|
2293
|
+
return mo;
|
2294
|
+
}
|
2295
|
+
}
|
2296
|
+
});
|
2297
|
+
}());
|
2298
|
+
Polymer.StyleProperties = function () {
|
2299
|
+
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2300
|
+
var matchesSelector = Polymer.DomApi.matchesSelector;
|
2301
|
+
var styleUtil = Polymer.StyleUtil;
|
2302
|
+
var styleTransformer = Polymer.StyleTransformer;
|
2303
|
+
return {
|
2304
|
+
decorateStyles: function (styles) {
|
2305
|
+
var self = this, props = {};
|
2306
|
+
styleUtil.forRulesInStyles(styles, function (rule) {
|
2307
|
+
self.decorateRule(rule);
|
2308
|
+
self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);
|
2309
|
+
});
|
2310
|
+
var names = [];
|
2311
|
+
for (var i in props) {
|
2312
|
+
names.push(i);
|
2313
|
+
}
|
2314
|
+
return names;
|
2315
|
+
},
|
2316
|
+
decorateRule: function (rule) {
|
2317
|
+
if (rule.propertyInfo) {
|
2318
|
+
return rule.propertyInfo;
|
2319
|
+
}
|
2320
|
+
var info = {}, properties = {};
|
2321
|
+
var hasProperties = this.collectProperties(rule, properties);
|
2322
|
+
if (hasProperties) {
|
2323
|
+
info.properties = properties;
|
2324
|
+
rule.rules = null;
|
2325
|
+
}
|
2326
|
+
info.cssText = this.collectCssText(rule);
|
2327
|
+
rule.propertyInfo = info;
|
2328
|
+
return info;
|
2329
|
+
},
|
2330
|
+
collectProperties: function (rule, properties) {
|
2331
|
+
var info = rule.propertyInfo;
|
2332
|
+
if (info) {
|
2333
|
+
if (info.properties) {
|
2334
|
+
Polymer.Base.mixin(properties, info.properties);
|
2335
|
+
return true;
|
2336
|
+
}
|
2337
|
+
} else {
|
2338
|
+
var m, rx = this.rx.VAR_ASSIGN;
|
2339
|
+
var cssText = rule.parsedCssText;
|
2340
|
+
var any;
|
2341
|
+
while (m = rx.exec(cssText)) {
|
2342
|
+
properties[m[1]] = (m[2] || m[3]).trim();
|
2343
|
+
any = true;
|
2344
|
+
}
|
2345
|
+
return any;
|
2346
|
+
}
|
2347
|
+
},
|
2348
|
+
collectCssText: function (rule) {
|
2349
|
+
var customCssText = '';
|
2350
|
+
var cssText = rule.parsedCssText;
|
2351
|
+
cssText = cssText.replace(this.rx.BRACKETED, '').replace(this.rx.VAR_ASSIGN, '');
|
2352
|
+
var parts = cssText.split(';');
|
2353
|
+
for (var i = 0, p; i < parts.length; i++) {
|
2354
|
+
p = parts[i];
|
2355
|
+
if (p.match(this.rx.MIXIN_MATCH) || p.match(this.rx.VAR_MATCH)) {
|
2356
|
+
customCssText += p + ';\n';
|
2357
|
+
}
|
2358
|
+
}
|
2359
|
+
return customCssText;
|
2360
|
+
},
|
2361
|
+
collectPropertiesInCssText: function (cssText, props) {
|
2362
|
+
var m;
|
2363
|
+
while (m = this.rx.VAR_CAPTURE.exec(cssText)) {
|
2364
|
+
props[m[1]] = true;
|
2365
|
+
}
|
2366
|
+
},
|
2367
|
+
reify: function (props) {
|
2368
|
+
var names = Object.getOwnPropertyNames(props);
|
2369
|
+
for (var i = 0, n; i < names.length; i++) {
|
2370
|
+
n = names[i];
|
2371
|
+
props[n] = this.valueForProperty(props[n], props);
|
2372
|
+
}
|
2373
|
+
},
|
2374
|
+
valueForProperty: function (property, props) {
|
2375
|
+
if (property) {
|
2376
|
+
if (property.indexOf(';') >= 0) {
|
2377
|
+
property = this.valueForProperties(property, props);
|
2378
|
+
} else {
|
2379
|
+
var self = this;
|
2380
|
+
var fn = function (all, prefix, value, fallback) {
|
2381
|
+
var propertyValue = self.valueForProperty(props[value], props) || (props[fallback] ? self.valueForProperty(props[fallback], props) : fallback);
|
2382
|
+
return prefix + (propertyValue || '');
|
2383
|
+
};
|
2384
|
+
property = property.replace(this.rx.VAR_MATCH, fn);
|
2385
|
+
}
|
2386
|
+
}
|
2387
|
+
return property && property.trim() || '';
|
2388
|
+
},
|
2389
|
+
valueForProperties: function (property, props) {
|
2390
|
+
var parts = property.split(';');
|
2391
|
+
for (var i = 0, p, m; i < parts.length && (p = parts[i]); i++) {
|
2392
|
+
m = p.match(this.rx.MIXIN_MATCH);
|
2393
|
+
if (m) {
|
2394
|
+
p = this.valueForProperty(props[m[1]], props);
|
2395
|
+
} else {
|
2396
|
+
var pp = p.split(':');
|
2397
|
+
if (pp[1]) {
|
2398
|
+
pp[1] = pp[1].trim();
|
2399
|
+
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
|
2400
|
+
}
|
2401
|
+
p = pp.join(':');
|
2402
|
+
}
|
2403
|
+
parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || '';
|
2404
|
+
}
|
2405
|
+
return parts.join(';');
|
2406
|
+
},
|
2407
|
+
applyProperties: function (rule, props) {
|
2408
|
+
var output = '';
|
2409
|
+
if (!rule.propertyInfo) {
|
2410
|
+
this.decorateRule(rule);
|
2411
|
+
}
|
2412
|
+
if (rule.propertyInfo.cssText) {
|
2413
|
+
output = this.valueForProperties(rule.propertyInfo.cssText, props);
|
2414
|
+
}
|
2415
|
+
rule.cssText = output;
|
2416
|
+
},
|
2417
|
+
propertyDataFromStyles: function (styles, element) {
|
2418
|
+
var props = {}, self = this;
|
2419
|
+
var o = [], i = 0;
|
2420
|
+
styleUtil.forRulesInStyles(styles, function (rule) {
|
2421
|
+
if (!rule.propertyInfo) {
|
2422
|
+
self.decorateRule(rule);
|
2423
|
+
}
|
2424
|
+
if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.selector)) {
|
2425
|
+
self.collectProperties(rule, props);
|
2426
|
+
addToBitMask(i, o);
|
2427
|
+
}
|
2428
|
+
i++;
|
2429
|
+
});
|
2430
|
+
return {
|
2431
|
+
properties: props,
|
2432
|
+
key: o
|
2433
|
+
};
|
2434
|
+
},
|
2435
|
+
scopePropertiesFromStyles: function (styles) {
|
2436
|
+
if (!styles._scopeStyleProperties) {
|
2437
|
+
styles._scopeStyleProperties = this.selectedPropertiesFromStyles(styles, this.SCOPE_SELECTORS);
|
2438
|
+
}
|
2439
|
+
return styles._scopeStyleProperties;
|
2440
|
+
},
|
2441
|
+
hostPropertiesFromStyles: function (styles) {
|
2442
|
+
if (!styles._hostStyleProperties) {
|
2443
|
+
styles._hostStyleProperties = this.selectedPropertiesFromStyles(styles, this.HOST_SELECTORS);
|
2444
|
+
}
|
2445
|
+
return styles._hostStyleProperties;
|
2446
|
+
},
|
2447
|
+
selectedPropertiesFromStyles: function (styles, selectors) {
|
2448
|
+
var props = {}, self = this;
|
2449
|
+
styleUtil.forRulesInStyles(styles, function (rule) {
|
2450
|
+
if (!rule.propertyInfo) {
|
2451
|
+
self.decorateRule(rule);
|
2452
|
+
}
|
2453
|
+
for (var i = 0; i < selectors.length; i++) {
|
2454
|
+
if (rule.parsedSelector === selectors[i]) {
|
2455
|
+
self.collectProperties(rule, props);
|
2456
|
+
return;
|
2457
|
+
}
|
2458
|
+
}
|
2459
|
+
});
|
2460
|
+
return props;
|
2461
|
+
},
|
2462
|
+
transformStyles: function (element, properties, scopeSelector) {
|
2463
|
+
var self = this;
|
2464
|
+
var hostRx = new RegExp(this.rx.HOST_PREFIX + element.is + this.rx.HOST_SUFFIX);
|
2465
|
+
return styleTransformer.elementStyles(element, function (rule) {
|
2466
|
+
self.applyProperties(rule, properties);
|
2467
|
+
if (rule.cssText && !nativeShadow) {
|
2468
|
+
self._scopeSelector(rule, hostRx, element.is, element._scopeCssViaAttr, scopeSelector);
|
2469
|
+
}
|
2470
|
+
});
|
2471
|
+
},
|
2472
|
+
_scopeSelector: function (rule, hostRx, is, viaAttr, scopeId) {
|
2473
|
+
rule.transformedSelector = rule.transformedSelector || rule.selector;
|
2474
|
+
var selector = rule.transformedSelector;
|
2475
|
+
var scope = viaAttr ? '[' + styleTransformer.SCOPE_NAME + '~=' + scopeId + ']' : '.' + scopeId;
|
2476
|
+
var parts = selector.split(',');
|
2477
|
+
for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) {
|
2478
|
+
parts[i] = p.match(hostRx) ? p.replace(is, is + scope) : scope + ' ' + p;
|
2479
|
+
}
|
2480
|
+
rule.selector = parts.join(',');
|
2481
|
+
},
|
2482
|
+
applyElementScopeSelector: function (element, selector, old, viaAttr) {
|
2483
|
+
var c = viaAttr ? element.getAttribute(styleTransformer.SCOPE_NAME) : element.className;
|
2484
|
+
v = old ? c.replace(old, selector) : (c ? c + ' ' : '') + this.XSCOPE_NAME + ' ' + selector;
|
2485
|
+
if (c !== v) {
|
2486
|
+
if (viaAttr) {
|
2487
|
+
element.setAttribute(styleTransformer.SCOPE_NAME, v);
|
2488
|
+
} else {
|
2489
|
+
element.className = v;
|
2490
|
+
}
|
2491
|
+
}
|
2492
|
+
},
|
2493
|
+
applyElementStyle: function (element, properties, selector, style) {
|
2494
|
+
var cssText = style ? style.textContent || '' : this.transformStyles(element, properties, selector);
|
2495
|
+
var s = element._customStyle;
|
2496
|
+
if (s && !nativeShadow && s !== style) {
|
2497
|
+
s._useCount--;
|
2498
|
+
if (s._useCount <= 0) {
|
2499
|
+
s.parentNode.removeChild(s);
|
2500
|
+
}
|
2501
|
+
}
|
2502
|
+
if (nativeShadow || (!style || !style.parentNode)) {
|
2503
|
+
if (nativeShadow && element._customStyle) {
|
2504
|
+
element._customStyle.textContent = cssText;
|
2505
|
+
style = element._customStyle;
|
2506
|
+
} else if (cssText) {
|
2507
|
+
style = styleUtil.applyCss(cssText, selector, nativeShadow ? element.root : null, element._scopeStyle);
|
2508
|
+
}
|
2509
|
+
}
|
2510
|
+
if (style) {
|
2511
|
+
style._useCount = style._useCount || 0;
|
2512
|
+
if (element._customStyle != style) {
|
2513
|
+
style._useCount++;
|
2514
|
+
}
|
2515
|
+
element._customStyle = style;
|
2516
|
+
}
|
2517
|
+
return style;
|
2518
|
+
},
|
2519
|
+
rx: {
|
2520
|
+
VAR_ASSIGN: /(?:^|;\s*)(--[^\:;]*?):\s*?(?:([^;{]*?)|{([^}]*)})(?=;)/gim,
|
2521
|
+
MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\);?/im,
|
2522
|
+
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gim,
|
2523
|
+
VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gim,
|
2524
|
+
BRACKETED: /\{[^}]*\}/g,
|
2525
|
+
HOST_PREFIX: '(?:^|[^.])',
|
2526
|
+
HOST_SUFFIX: '($|[.:[\\s>+~])'
|
2527
|
+
},
|
2528
|
+
HOST_SELECTORS: [':host'],
|
2529
|
+
SCOPE_SELECTORS: [':root'],
|
2530
|
+
XSCOPE_NAME: 'x-scope'
|
2531
|
+
};
|
2532
|
+
function addToBitMask(n, bits) {
|
2533
|
+
var o = parseInt(n / 32);
|
2534
|
+
var v = 1 << n % 32;
|
2535
|
+
bits[o] = (bits[o] || 0) | v;
|
2536
|
+
}
|
2537
|
+
}();
|
2538
|
+
Polymer.StyleDefaults = function () {
|
2539
|
+
var styleProperties = Polymer.StyleProperties;
|
2540
|
+
var styleUtil = Polymer.StyleUtil;
|
2541
|
+
var style = document.createElement('style');
|
2542
|
+
var api = {
|
2543
|
+
style: style,
|
2544
|
+
_styles: [style],
|
2545
|
+
_properties: null,
|
2546
|
+
applyCss: function (cssText) {
|
2547
|
+
this.style.textContent += cssText;
|
2548
|
+
styleUtil.clearStyleRules(this.style);
|
2549
|
+
this._properties = null;
|
2550
|
+
},
|
2551
|
+
get _styleProperties() {
|
2552
|
+
if (!this._properties) {
|
2553
|
+
styleProperties.decorateStyles(this._styles);
|
2554
|
+
this._styles._scopeStyleProperties = null;
|
2555
|
+
this._properties = styleProperties.scopePropertiesFromStyles(this._styles);
|
2556
|
+
}
|
2557
|
+
return this._properties;
|
2558
|
+
},
|
2559
|
+
_needsStyleProperties: function () {
|
2560
|
+
},
|
2561
|
+
_computeStyleProperties: function () {
|
2562
|
+
return this._styleProperties;
|
2563
|
+
}
|
2564
|
+
};
|
2565
|
+
return api;
|
2566
|
+
}();
|
2567
|
+
(function () {
|
2568
|
+
Polymer.StyleCache = function () {
|
2569
|
+
this.cache = {};
|
2570
|
+
};
|
2571
|
+
Polymer.StyleCache.prototype = {
|
2572
|
+
MAX: 100,
|
2573
|
+
store: function (is, data, keyValues, keyStyles) {
|
2574
|
+
data.keyValues = keyValues;
|
2575
|
+
data.styles = keyStyles;
|
2576
|
+
var s$ = this.cache[is] = this.cache[is] || [];
|
2577
|
+
s$.push(data);
|
2578
|
+
if (s$.length > this.MAX) {
|
2579
|
+
s$.shift();
|
2580
|
+
}
|
2581
|
+
},
|
2582
|
+
retrieve: function (is, keyValues, keyStyles) {
|
2583
|
+
var cache = this.cache[is];
|
2584
|
+
if (cache) {
|
2585
|
+
for (var i = cache.length - 1, data; i >= 0; i--) {
|
2586
|
+
data = cache[i];
|
2587
|
+
if (keyStyles === data.styles && this._objectsEqual(keyValues, data.keyValues)) {
|
2588
|
+
return data;
|
2589
|
+
}
|
2590
|
+
}
|
2591
|
+
}
|
2592
|
+
},
|
2593
|
+
clear: function () {
|
2594
|
+
this.cache = {};
|
2595
|
+
},
|
2596
|
+
_objectsEqual: function (target, source) {
|
2597
|
+
for (var i in target) {
|
2598
|
+
if (target[i] !== source[i]) {
|
2599
|
+
return false;
|
2600
|
+
}
|
2601
|
+
}
|
2602
|
+
if (Array.isArray(target)) {
|
2603
|
+
return target.length === source.length;
|
2604
|
+
}
|
2605
|
+
return true;
|
2606
|
+
}
|
2607
|
+
};
|
2608
|
+
}());
|
2609
|
+
(function () {
|
2610
|
+
var serializeValueToAttribute = Polymer.Base.serializeValueToAttribute;
|
2611
|
+
var propertyUtils = Polymer.StyleProperties;
|
2612
|
+
var styleTransformer = Polymer.StyleTransformer;
|
2613
|
+
var styleUtil = Polymer.StyleUtil;
|
2614
|
+
var styleDefaults = Polymer.StyleDefaults;
|
2615
|
+
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2616
|
+
Polymer.Base._addFeature({
|
2617
|
+
_prepStyleProperties: function () {
|
2618
|
+
this._ownStylePropertyNames = this._styles ? propertyUtils.decorateStyles(this._styles) : [];
|
2619
|
+
},
|
2620
|
+
_setupStyleProperties: function () {
|
2621
|
+
this.customStyle = {};
|
2622
|
+
},
|
2623
|
+
_needsStyleProperties: function () {
|
2624
|
+
return Boolean(this._ownStylePropertyNames && this._ownStylePropertyNames.length);
|
2625
|
+
},
|
2626
|
+
_beforeAttached: function () {
|
2627
|
+
if (!this._scopeSelector && this._needsStyleProperties()) {
|
2628
|
+
this._updateStyleProperties();
|
2629
|
+
}
|
2630
|
+
},
|
2631
|
+
_updateStyleProperties: function () {
|
2632
|
+
var info, scope = this.domHost || styleDefaults;
|
2633
|
+
if (!scope._styleCache) {
|
2634
|
+
scope._styleCache = new Polymer.StyleCache();
|
2635
|
+
}
|
2636
|
+
var scopeData = propertyUtils.propertyDataFromStyles(scope._styles, this);
|
2637
|
+
info = scope._styleCache.retrieve(this.is, scopeData.key, this._styles);
|
2638
|
+
var scopeCached = Boolean(info);
|
2639
|
+
if (scopeCached) {
|
2640
|
+
this._styleProperties = info._styleProperties;
|
2641
|
+
} else {
|
2642
|
+
this._computeStyleProperties(scopeData.properties);
|
2643
|
+
}
|
2644
|
+
this._computeOwnStyleProperties();
|
2645
|
+
if (!scopeCached) {
|
2646
|
+
info = styleCache.retrieve(this.is, this._ownStyleProperties, this._styles);
|
2647
|
+
}
|
2648
|
+
var globalCached = Boolean(info) && !scopeCached;
|
2649
|
+
style = this._applyStyleProperties(info);
|
2650
|
+
if (!scopeCached) {
|
2651
|
+
var cacheableStyle = style;
|
2652
|
+
if (nativeShadow) {
|
2653
|
+
cacheableStyle = style.cloneNode ? style.cloneNode(true) : Object.create(style || null);
|
2654
|
+
}
|
2655
|
+
info = {
|
2656
|
+
style: cacheableStyle,
|
2657
|
+
_scopeSelector: this._scopeSelector,
|
2658
|
+
_styleProperties: this._styleProperties
|
2659
|
+
};
|
2660
|
+
scope._styleCache.store(this.is, info, scopeData.key, this._styles);
|
2661
|
+
if (!globalCached) {
|
2662
|
+
styleCache.store(this.is, Object.create(info), this._ownStyleProperties, this._styles);
|
2663
|
+
}
|
2664
|
+
}
|
2665
|
+
},
|
2666
|
+
_computeStyleProperties: function (scopeProps) {
|
2667
|
+
var scope = this.domHost || styleDefaults;
|
2668
|
+
if (!scope._styleProperties) {
|
2669
|
+
scope._computeStyleProperties();
|
2670
|
+
}
|
2671
|
+
var props = Object.create(scope._styleProperties);
|
2672
|
+
this.mixin(props, propertyUtils.hostPropertiesFromStyles(this._styles));
|
2673
|
+
scopeProps = scopeProps || propertyUtils.propertyDataFromStyles(scope._styles, this).properties;
|
2674
|
+
this.mixin(props, scopeProps);
|
2675
|
+
this.mixin(props, propertyUtils.scopePropertiesFromStyles(this._styles));
|
2676
|
+
this.mixin(props, this.customStyle);
|
2677
|
+
propertyUtils.reify(props);
|
2678
|
+
this._styleProperties = props;
|
2679
|
+
},
|
2680
|
+
_computeOwnStyleProperties: function () {
|
2681
|
+
var props = {};
|
2682
|
+
for (var i = 0, n; i < this._ownStylePropertyNames.length; i++) {
|
2683
|
+
n = this._ownStylePropertyNames[i];
|
2684
|
+
props[n] = this._styleProperties[n];
|
2685
|
+
}
|
2686
|
+
this._ownStyleProperties = props;
|
2687
|
+
},
|
2688
|
+
_scopeCount: 0,
|
2689
|
+
_applyStyleProperties: function (info) {
|
2690
|
+
var oldScopeSelector = this._scopeSelector;
|
2691
|
+
this._scopeSelector = info ? info._scopeSelector : this.is + '-' + this.__proto__._scopeCount++;
|
2692
|
+
style = propertyUtils.applyElementStyle(this, this._styleProperties, this._scopeSelector, info && info.style);
|
2693
|
+
if ((style || oldScopeSelector) && !nativeShadow) {
|
2694
|
+
propertyUtils.applyElementScopeSelector(this, this._scopeSelector, oldScopeSelector, this._scopeCssViaAttr);
|
2695
|
+
}
|
2696
|
+
return style || {};
|
2697
|
+
},
|
2698
|
+
serializeValueToAttribute: function (value, attribute, node) {
|
2699
|
+
node = node || this;
|
2700
|
+
if (attribute === 'class') {
|
2701
|
+
var host = node === this ? this.domHost || this.dataHost : this;
|
2702
|
+
if (host) {
|
2703
|
+
value = host._scopeElementClass(node, value);
|
2704
|
+
}
|
2705
|
+
}
|
2706
|
+
node = Polymer.dom(node);
|
2707
|
+
serializeValueToAttribute.call(this, value, attribute, node);
|
2708
|
+
},
|
2709
|
+
_scopeElementClass: function (element, selector) {
|
2710
|
+
if (!nativeShadow && !this._scopeCssViaAttr) {
|
2711
|
+
selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is + (element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' + element._scopeSelector : '');
|
2712
|
+
}
|
2713
|
+
return selector;
|
2714
|
+
},
|
2715
|
+
updateStyles: function () {
|
2716
|
+
if (this.isAttached) {
|
2717
|
+
if (this._needsStyleProperties()) {
|
2718
|
+
this._updateStyleProperties();
|
2719
|
+
} else {
|
2720
|
+
this._styleProperties = null;
|
2721
|
+
}
|
2722
|
+
if (this._styleCache) {
|
2723
|
+
this._styleCache.clear();
|
2724
|
+
}
|
2725
|
+
this._updateRootStyles();
|
2726
|
+
}
|
2727
|
+
},
|
2728
|
+
_updateRootStyles: function (root) {
|
2729
|
+
root = root || this.root;
|
2730
|
+
var c$ = Polymer.dom(root)._query(function (e) {
|
2731
|
+
return e.shadyRoot || e.shadowRoot;
|
2732
|
+
});
|
2733
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
2734
|
+
if (c.updateStyles) {
|
2735
|
+
c.updateStyles();
|
2736
|
+
}
|
2737
|
+
}
|
2738
|
+
}
|
2739
|
+
});
|
2740
|
+
Polymer.updateStyles = function () {
|
2741
|
+
styleDefaults._styleCache.clear();
|
2742
|
+
Polymer.Base._updateRootStyles(document);
|
2743
|
+
};
|
2744
|
+
var styleCache = new Polymer.StyleCache();
|
2745
|
+
Polymer.customStyleCache = styleCache;
|
2746
|
+
var SCOPE_NAME = styleTransformer.SCOPE_NAME;
|
2747
|
+
var XSCOPE_NAME = propertyUtils.XSCOPE_NAME;
|
2748
|
+
}());
|
2749
|
+
Polymer.Base._addFeature({
|
2750
|
+
_registerFeatures: function () {
|
2751
|
+
this._prepIs();
|
2752
|
+
this._prepAttributes();
|
2753
|
+
this._prepExtends();
|
2754
|
+
this._prepConstructor();
|
2755
|
+
this._prepTemplate();
|
2756
|
+
this._prepStyles();
|
2757
|
+
this._prepStyleProperties();
|
2758
|
+
this._prepAnnotations();
|
2759
|
+
this._prepEffects();
|
2760
|
+
this._prepBehaviors();
|
2761
|
+
this._prepBindings();
|
2762
|
+
this._prepShady();
|
2763
|
+
},
|
2764
|
+
_prepBehavior: function (b) {
|
2765
|
+
this._addPropertyEffects(b.properties);
|
2766
|
+
this._addComplexObserverEffects(b.observers);
|
2767
|
+
this._addHostAttributes(b.hostAttributes);
|
2768
|
+
},
|
2769
|
+
_initFeatures: function () {
|
2770
|
+
this._poolContent();
|
2771
|
+
this._setupConfigure();
|
2772
|
+
this._setupStyleProperties();
|
2773
|
+
this._pushHost();
|
2774
|
+
this._stampTemplate();
|
2775
|
+
this._popHost();
|
2776
|
+
this._marshalAnnotationReferences();
|
2777
|
+
this._marshalHostAttributes();
|
2778
|
+
this._setupDebouncers();
|
2779
|
+
this._marshalInstanceEffects();
|
2780
|
+
this._marshalBehaviors();
|
2781
|
+
this._marshalAttributes();
|
2782
|
+
this._tryReady();
|
2783
|
+
},
|
2784
|
+
_marshalBehavior: function (b) {
|
2785
|
+
this._listenListeners(b.listeners);
|
2786
|
+
}
|
2787
|
+
});
|
2788
|
+
(function () {
|
2789
|
+
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2790
|
+
var propertyUtils = Polymer.StyleProperties;
|
2791
|
+
var styleUtil = Polymer.StyleUtil;
|
2792
|
+
var styleDefaults = Polymer.StyleDefaults;
|
2793
|
+
Polymer({
|
2794
|
+
is: 'custom-style',
|
2795
|
+
extends: 'style',
|
2796
|
+
created: function () {
|
2797
|
+
this._appliesToDocument = this.parentNode.localName !== 'dom-module';
|
2798
|
+
if (this._appliesToDocument) {
|
2799
|
+
var e = this.__appliedElement || this;
|
2800
|
+
var rules = styleUtil.rulesForStyle(e);
|
2801
|
+
propertyUtils.decorateStyles([e]);
|
2802
|
+
this._rulesToDefaultProperties(rules);
|
2803
|
+
this.async(this._applyStyle);
|
2804
|
+
}
|
2805
|
+
},
|
2806
|
+
_applyStyle: function () {
|
2807
|
+
var e = this.__appliedElement || this;
|
2808
|
+
this._computeStyleProperties();
|
2809
|
+
var props = this._styleProperties;
|
2810
|
+
var self = this;
|
2811
|
+
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) {
|
2812
|
+
if (rule.selector === ':root') {
|
2813
|
+
rule.selector = 'body';
|
2814
|
+
}
|
2815
|
+
var css = rule.cssText = rule.parsedCssText;
|
2816
|
+
if (rule.propertyInfo && rule.propertyInfo.cssText) {
|
2817
|
+
css = css.replace(propertyUtils.rx.VAR_ASSIGN, '');
|
2818
|
+
rule.cssText = propertyUtils.valueForProperties(css, props);
|
2819
|
+
}
|
2820
|
+
if (!nativeShadow) {
|
2821
|
+
Polymer.StyleTransformer.rootRule(rule);
|
2822
|
+
}
|
2823
|
+
});
|
2824
|
+
},
|
2825
|
+
_rulesToDefaultProperties: function (rules) {
|
2826
|
+
styleUtil.forEachStyleRule(rules, function (rule) {
|
2827
|
+
if (!rule.propertyInfo.properties) {
|
2828
|
+
rule.cssText = '';
|
2829
|
+
}
|
2830
|
+
});
|
2831
|
+
var cssText = styleUtil.parser.stringify(rules, true);
|
2832
|
+
if (cssText) {
|
2833
|
+
styleDefaults.applyCss(cssText);
|
2834
|
+
}
|
2835
|
+
}
|
2836
|
+
});
|
2837
|
+
}());
|
2838
|
+
Polymer.Templatizer = {
|
2839
|
+
properties: { _hideTemplateChildren: { observer: '_showHideChildren' } },
|
2840
|
+
_templatizerStatic: {
|
2841
|
+
count: 0,
|
2842
|
+
callbacks: {},
|
2843
|
+
debouncer: null
|
2844
|
+
},
|
2845
|
+
_instanceProps: Polymer.nob,
|
2846
|
+
created: function () {
|
2847
|
+
this._templatizerId = this._templatizerStatic.count++;
|
2848
|
+
},
|
2849
|
+
templatize: function (template) {
|
2850
|
+
if (!template._content) {
|
2851
|
+
template._content = template.content;
|
2852
|
+
}
|
2853
|
+
if (template._content._ctor) {
|
2854
|
+
this.ctor = template._content._ctor;
|
2855
|
+
this._prepParentProperties(this.ctor.prototype, template);
|
2856
|
+
return;
|
2857
|
+
}
|
2858
|
+
var archetype = Object.create(Polymer.Base);
|
2859
|
+
this._customPrepAnnotations(archetype, template);
|
2860
|
+
archetype._prepEffects();
|
2861
|
+
this._customPrepEffects(archetype);
|
2862
|
+
archetype._prepBehaviors();
|
2863
|
+
archetype._prepBindings();
|
2864
|
+
this._prepParentProperties(archetype, template);
|
2865
|
+
archetype._notifyPath = this._notifyPathImpl;
|
2866
|
+
archetype._scopeElementClass = this._scopeElementClassImpl;
|
2867
|
+
archetype.listen = this._listenImpl;
|
2868
|
+
var _constructor = this._constructorImpl;
|
2869
|
+
var ctor = function TemplateInstance(model, host) {
|
2870
|
+
_constructor.call(this, model, host);
|
2871
|
+
};
|
2872
|
+
ctor.prototype = archetype;
|
2873
|
+
archetype.constructor = ctor;
|
2874
|
+
template._content._ctor = ctor;
|
2875
|
+
this.ctor = ctor;
|
2876
|
+
},
|
2877
|
+
_getRootDataHost: function () {
|
2878
|
+
return this.dataHost && this.dataHost._rootDataHost || this.dataHost;
|
2879
|
+
},
|
2880
|
+
_showHideChildren: function (hidden) {
|
2881
|
+
},
|
2882
|
+
_debounceTemplate: function (fn) {
|
2883
|
+
this._templatizerStatic.callbacks[this._templatizerId] = fn.bind(this);
|
2884
|
+
this._templatizerStatic.debouncer = Polymer.Debounce(this._templatizerStatic.debouncer, this._flushTemplates.bind(this, true));
|
2885
|
+
},
|
2886
|
+
_flushTemplates: function (debouncerExpired) {
|
2887
|
+
var db = this._templatizerStatic.debouncer;
|
2888
|
+
while (debouncerExpired || db && db.finish) {
|
2889
|
+
db.stop();
|
2890
|
+
var cbs = this._templatizerStatic.callbacks;
|
2891
|
+
this._templatizerStatic.callbacks = {};
|
2892
|
+
for (var id in cbs) {
|
2893
|
+
cbs[id]();
|
2894
|
+
}
|
2895
|
+
debouncerExpired = false;
|
2896
|
+
}
|
2897
|
+
},
|
2898
|
+
_customPrepEffects: function (archetype) {
|
2899
|
+
var parentProps = archetype._parentProps;
|
2900
|
+
for (var prop in parentProps) {
|
2901
|
+
archetype._addPropertyEffect(prop, 'function', this._createHostPropEffector(prop));
|
2902
|
+
}
|
2903
|
+
},
|
2904
|
+
_customPrepAnnotations: function (archetype, template) {
|
2905
|
+
archetype._template = template;
|
2906
|
+
var c = template._content;
|
2907
|
+
if (!c._notes) {
|
2908
|
+
var rootDataHost = archetype._rootDataHost;
|
2909
|
+
if (rootDataHost) {
|
2910
|
+
Polymer.Annotations.prepElement = rootDataHost._prepElement.bind(rootDataHost);
|
2911
|
+
}
|
2912
|
+
c._notes = Polymer.Annotations.parseAnnotations(template);
|
2913
|
+
Polymer.Annotations.prepElement = null;
|
2914
|
+
this._processAnnotations(c._notes);
|
2915
|
+
}
|
2916
|
+
archetype._notes = c._notes;
|
2917
|
+
archetype._parentProps = c._parentProps;
|
2918
|
+
},
|
2919
|
+
_prepParentProperties: function (archetype, template) {
|
2920
|
+
var parentProps = this._parentProps = archetype._parentProps;
|
2921
|
+
if (this._forwardParentProp && parentProps) {
|
2922
|
+
var proto = archetype._parentPropProto;
|
2923
|
+
var prop;
|
2924
|
+
if (!proto) {
|
2925
|
+
for (prop in this._instanceProps) {
|
2926
|
+
delete parentProps[prop];
|
2927
|
+
}
|
2928
|
+
proto = archetype._parentPropProto = Object.create(null);
|
2929
|
+
if (template != this) {
|
2930
|
+
Polymer.Bind.prepareModel(proto);
|
2931
|
+
}
|
2932
|
+
for (prop in parentProps) {
|
2933
|
+
var parentProp = '_parent_' + prop;
|
2934
|
+
var effects = [
|
2935
|
+
{
|
2936
|
+
kind: 'function',
|
2937
|
+
effect: this._createForwardPropEffector(prop)
|
2938
|
+
},
|
2939
|
+
{ kind: 'notify' }
|
2940
|
+
];
|
2941
|
+
Polymer.Bind._createAccessors(proto, parentProp, effects);
|
2942
|
+
}
|
2943
|
+
}
|
2944
|
+
if (template != this) {
|
2945
|
+
Polymer.Bind.prepareInstance(template);
|
2946
|
+
template._forwardParentProp = this._forwardParentProp.bind(this);
|
2947
|
+
}
|
2948
|
+
this._extendTemplate(template, proto);
|
2949
|
+
}
|
2950
|
+
},
|
2951
|
+
_createForwardPropEffector: function (prop) {
|
2952
|
+
return function (source, value) {
|
2953
|
+
this._forwardParentProp(prop, value);
|
2954
|
+
};
|
2955
|
+
},
|
2956
|
+
_createHostPropEffector: function (prop) {
|
2957
|
+
return function (source, value) {
|
2958
|
+
this.dataHost['_parent_' + prop] = value;
|
2959
|
+
};
|
2960
|
+
},
|
2961
|
+
_extendTemplate: function (template, proto) {
|
2962
|
+
Object.getOwnPropertyNames(proto).forEach(function (n) {
|
2963
|
+
var val = template[n];
|
2964
|
+
var pd = Object.getOwnPropertyDescriptor(proto, n);
|
2965
|
+
Object.defineProperty(template, n, pd);
|
2966
|
+
if (val !== undefined) {
|
2967
|
+
template._propertySet(n, val);
|
2968
|
+
}
|
2969
|
+
});
|
2970
|
+
},
|
2971
|
+
_forwardInstancePath: function (inst, path, value) {
|
2972
|
+
},
|
2973
|
+
_notifyPathImpl: function (path, value) {
|
2974
|
+
var dataHost = this.dataHost;
|
2975
|
+
var dot = path.indexOf('.');
|
2976
|
+
var root = dot < 0 ? path : path.slice(0, dot);
|
2977
|
+
dataHost._forwardInstancePath.call(dataHost, this, path, value);
|
2978
|
+
if (root in dataHost._parentProps) {
|
2979
|
+
dataHost.notifyPath('_parent_' + path, value);
|
2980
|
+
}
|
2981
|
+
},
|
2982
|
+
_pathEffector: function (path, value, fromAbove) {
|
2983
|
+
if (this._forwardParentPath) {
|
2984
|
+
if (path.indexOf('_parent_') === 0) {
|
2985
|
+
this._forwardParentPath(path.substring(8), value);
|
2986
|
+
}
|
2987
|
+
}
|
2988
|
+
Polymer.Base._pathEffector.apply(this, arguments);
|
2989
|
+
},
|
2990
|
+
_constructorImpl: function (model, host) {
|
2991
|
+
this._rootDataHost = host._getRootDataHost();
|
2992
|
+
this._setupConfigure(model);
|
2993
|
+
this._pushHost(host);
|
2994
|
+
this.root = this.instanceTemplate(this._template);
|
2995
|
+
this.root.__styleScoped = true;
|
2996
|
+
this._popHost();
|
2997
|
+
this._marshalAnnotatedNodes();
|
2998
|
+
this._marshalInstanceEffects();
|
2999
|
+
this._marshalAnnotatedListeners();
|
3000
|
+
var children = [];
|
3001
|
+
for (var n = this.root.firstChild; n; n = n.nextSibling) {
|
3002
|
+
children.push(n);
|
3003
|
+
n._templateInstance = this;
|
3004
|
+
}
|
3005
|
+
this._children = children;
|
3006
|
+
this._tryReady();
|
3007
|
+
},
|
3008
|
+
_listenImpl: function (node, eventName, methodName) {
|
3009
|
+
var model = this;
|
3010
|
+
var host = this._rootDataHost;
|
3011
|
+
var handler = host._createEventHandler(node, eventName, methodName);
|
3012
|
+
var decorated = function (e) {
|
3013
|
+
e.model = model;
|
3014
|
+
handler(e);
|
3015
|
+
};
|
3016
|
+
host._listen(node, eventName, decorated);
|
3017
|
+
},
|
3018
|
+
_scopeElementClassImpl: function (node, value) {
|
3019
|
+
var host = this._rootDataHost;
|
3020
|
+
if (host) {
|
3021
|
+
return host._scopeElementClass(node, value);
|
3022
|
+
}
|
3023
|
+
},
|
3024
|
+
stamp: function (model) {
|
3025
|
+
model = model || {};
|
3026
|
+
if (this._parentProps) {
|
3027
|
+
for (var prop in this._parentProps) {
|
3028
|
+
model[prop] = this['_parent_' + prop];
|
3029
|
+
}
|
3030
|
+
}
|
3031
|
+
return new this.ctor(model, this);
|
3032
|
+
}
|
3033
|
+
};
|
3034
|
+
Polymer({
|
3035
|
+
is: 'dom-template',
|
3036
|
+
extends: 'template',
|
3037
|
+
behaviors: [Polymer.Templatizer],
|
3038
|
+
ready: function () {
|
3039
|
+
this.templatize(this);
|
3040
|
+
}
|
3041
|
+
});
|
3042
|
+
Polymer._collections = new WeakMap();
|
3043
|
+
Polymer.Collection = function (userArray) {
|
3044
|
+
Polymer._collections.set(userArray, this);
|
3045
|
+
this.userArray = userArray;
|
3046
|
+
this.store = userArray.slice();
|
3047
|
+
this.initMap();
|
3048
|
+
};
|
3049
|
+
Polymer.Collection.prototype = {
|
3050
|
+
constructor: Polymer.Collection,
|
3051
|
+
initMap: function () {
|
3052
|
+
var omap = this.omap = new WeakMap();
|
3053
|
+
var pmap = this.pmap = {};
|
3054
|
+
var s = this.store;
|
3055
|
+
for (var i = 0; i < s.length; i++) {
|
3056
|
+
var item = s[i];
|
3057
|
+
if (item && typeof item == 'object') {
|
3058
|
+
omap.set(item, i);
|
3059
|
+
} else {
|
3060
|
+
pmap[item] = i;
|
3061
|
+
}
|
3062
|
+
}
|
3063
|
+
},
|
3064
|
+
add: function (item) {
|
3065
|
+
var key = this.store.push(item) - 1;
|
3066
|
+
if (item && typeof item == 'object') {
|
3067
|
+
this.omap.set(item, key);
|
3068
|
+
} else {
|
3069
|
+
this.pmap[item] = key;
|
3070
|
+
}
|
3071
|
+
return key;
|
3072
|
+
},
|
3073
|
+
removeKey: function (key) {
|
3074
|
+
this._removeFromMap(this.store[key]);
|
3075
|
+
delete this.store[key];
|
3076
|
+
},
|
3077
|
+
_removeFromMap: function (item) {
|
3078
|
+
if (typeof item == 'object') {
|
3079
|
+
this.omap.delete(item);
|
3080
|
+
} else {
|
3081
|
+
delete this.pmap[item];
|
3082
|
+
}
|
3083
|
+
},
|
3084
|
+
remove: function (item) {
|
3085
|
+
var key = this.getKey(item);
|
3086
|
+
this.removeKey(key);
|
3087
|
+
return key;
|
3088
|
+
},
|
3089
|
+
getKey: function (item) {
|
3090
|
+
if (typeof item == 'object') {
|
3091
|
+
return this.omap.get(item);
|
3092
|
+
} else {
|
3093
|
+
return this.pmap[item];
|
3094
|
+
}
|
3095
|
+
},
|
3096
|
+
getKeys: function () {
|
3097
|
+
return Object.keys(this.store);
|
3098
|
+
},
|
3099
|
+
setItem: function (key, value) {
|
3100
|
+
this.store[key] = value;
|
3101
|
+
},
|
3102
|
+
getItem: function (key) {
|
3103
|
+
return this.store[key];
|
3104
|
+
},
|
3105
|
+
getItems: function () {
|
3106
|
+
var items = [], store = this.store;
|
3107
|
+
for (var key in store) {
|
3108
|
+
items.push(store[key]);
|
3109
|
+
}
|
3110
|
+
return items;
|
3111
|
+
},
|
3112
|
+
applySplices: function (splices) {
|
3113
|
+
var keySplices = [];
|
3114
|
+
for (var i = 0; i < splices.length; i++) {
|
3115
|
+
var j, o, key, s = splices[i];
|
3116
|
+
var removed = [];
|
3117
|
+
for (j = 0; j < s.removed.length; j++) {
|
3118
|
+
o = s.removed[j];
|
3119
|
+
key = this.remove(o);
|
3120
|
+
removed.push(key);
|
3121
|
+
}
|
3122
|
+
var added = [];
|
3123
|
+
for (j = 0; j < s.addedCount; j++) {
|
3124
|
+
o = this.userArray[s.index + j];
|
3125
|
+
key = this.add(o);
|
3126
|
+
added.push(key);
|
3127
|
+
}
|
3128
|
+
keySplices.push({
|
3129
|
+
index: s.index,
|
3130
|
+
removed: removed,
|
3131
|
+
removedItems: s.removed,
|
3132
|
+
added: added
|
3133
|
+
});
|
3134
|
+
}
|
3135
|
+
return keySplices;
|
3136
|
+
}
|
3137
|
+
};
|
3138
|
+
Polymer.Collection.get = function (userArray) {
|
3139
|
+
return Polymer._collections.get(userArray) || new Polymer.Collection(userArray);
|
3140
|
+
};
|
3141
|
+
Polymer({
|
3142
|
+
is: 'dom-repeat',
|
3143
|
+
extends: 'template',
|
3144
|
+
properties: {
|
3145
|
+
items: { type: Array },
|
3146
|
+
as: {
|
3147
|
+
type: String,
|
3148
|
+
value: 'item'
|
3149
|
+
},
|
3150
|
+
indexAs: {
|
3151
|
+
type: String,
|
3152
|
+
value: 'index'
|
3153
|
+
},
|
3154
|
+
sort: {
|
3155
|
+
type: Function,
|
3156
|
+
observer: '_sortChanged'
|
3157
|
+
},
|
3158
|
+
filter: {
|
3159
|
+
type: Function,
|
3160
|
+
observer: '_filterChanged'
|
3161
|
+
},
|
3162
|
+
observe: {
|
3163
|
+
type: String,
|
3164
|
+
observer: '_observeChanged'
|
3165
|
+
},
|
3166
|
+
delay: Number
|
3167
|
+
},
|
3168
|
+
behaviors: [Polymer.Templatizer],
|
3169
|
+
observers: ['_itemsChanged(items.*)'],
|
3170
|
+
detached: function () {
|
3171
|
+
if (this.rows) {
|
3172
|
+
for (var i = 0; i < this.rows.length; i++) {
|
3173
|
+
this._detachRow(i);
|
3174
|
+
}
|
3175
|
+
}
|
3176
|
+
},
|
3177
|
+
attached: function () {
|
3178
|
+
if (this.rows) {
|
3179
|
+
var parentNode = Polymer.dom(this).parentNode;
|
3180
|
+
for (var i = 0; i < this.rows.length; i++) {
|
3181
|
+
Polymer.dom(parentNode).insertBefore(this.rows[i].root, this);
|
3182
|
+
}
|
3183
|
+
}
|
3184
|
+
},
|
3185
|
+
ready: function () {
|
3186
|
+
this._instanceProps = { __key__: true };
|
3187
|
+
this._instanceProps[this.as] = true;
|
3188
|
+
this._instanceProps[this.indexAs] = true;
|
3189
|
+
if (!this.ctor) {
|
3190
|
+
this.templatize(this);
|
3191
|
+
}
|
3192
|
+
},
|
3193
|
+
_sortChanged: function () {
|
3194
|
+
var dataHost = this._getRootDataHost();
|
3195
|
+
var sort = this.sort;
|
3196
|
+
this._sortFn = sort && (typeof sort == 'function' ? sort : function () {
|
3197
|
+
return dataHost[sort].apply(dataHost, arguments);
|
3198
|
+
});
|
3199
|
+
this._fullRefresh = true;
|
3200
|
+
if (this.items) {
|
3201
|
+
this._debounceTemplate(this._render);
|
3202
|
+
}
|
3203
|
+
},
|
3204
|
+
_filterChanged: function () {
|
3205
|
+
var dataHost = this._getRootDataHost();
|
3206
|
+
var filter = this.filter;
|
3207
|
+
this._filterFn = filter && (typeof filter == 'function' ? filter : function () {
|
3208
|
+
return dataHost[filter].apply(dataHost, arguments);
|
3209
|
+
});
|
3210
|
+
this._fullRefresh = true;
|
3211
|
+
if (this.items) {
|
3212
|
+
this._debounceTemplate(this._render);
|
3213
|
+
}
|
3214
|
+
},
|
3215
|
+
_observeChanged: function () {
|
3216
|
+
this._observePaths = this.observe && this.observe.replace('.*', '.').split(' ');
|
3217
|
+
},
|
3218
|
+
_itemsChanged: function (change) {
|
3219
|
+
if (change.path == 'items') {
|
3220
|
+
if (Array.isArray(this.items)) {
|
3221
|
+
this.collection = Polymer.Collection.get(this.items);
|
3222
|
+
} else if (!this.items) {
|
3223
|
+
this.collection = null;
|
3224
|
+
} else {
|
3225
|
+
this._error(this._logf('dom-repeat', 'expected array for `items`,' + ' found', this.items));
|
3226
|
+
}
|
3227
|
+
this._splices = [];
|
3228
|
+
this._fullRefresh = true;
|
3229
|
+
this._debounceTemplate(this._render);
|
3230
|
+
} else if (change.path == 'items.splices') {
|
3231
|
+
this._splices = this._splices.concat(change.value.keySplices);
|
3232
|
+
this._debounceTemplate(this._render);
|
3233
|
+
} else {
|
3234
|
+
var subpath = change.path.slice(6);
|
3235
|
+
this._forwardItemPath(subpath, change.value);
|
3236
|
+
this._checkObservedPaths(subpath);
|
3237
|
+
}
|
3238
|
+
},
|
3239
|
+
_checkObservedPaths: function (path) {
|
3240
|
+
if (this._observePaths) {
|
3241
|
+
path = path.substring(path.indexOf('.') + 1);
|
3242
|
+
var paths = this._observePaths;
|
3243
|
+
for (var i = 0; i < paths.length; i++) {
|
3244
|
+
if (path.indexOf(paths[i]) === 0) {
|
3245
|
+
this._fullRefresh = true;
|
3246
|
+
if (this.delay) {
|
3247
|
+
this.debounce('render', this._render, this.delay);
|
3248
|
+
} else {
|
3249
|
+
this._debounceTemplate(this._render);
|
3250
|
+
}
|
3251
|
+
return;
|
3252
|
+
}
|
3253
|
+
}
|
3254
|
+
}
|
3255
|
+
},
|
3256
|
+
render: function () {
|
3257
|
+
this._fullRefresh = true;
|
3258
|
+
this.debounce('render', this._render);
|
3259
|
+
this._flushTemplates();
|
3260
|
+
},
|
3261
|
+
_render: function () {
|
3262
|
+
var c = this.collection;
|
3263
|
+
if (!this._fullRefresh) {
|
3264
|
+
if (this._sortFn) {
|
3265
|
+
this._applySplicesViewSort(this._splices);
|
3266
|
+
} else {
|
3267
|
+
if (this._filterFn) {
|
3268
|
+
this._fullRefresh = true;
|
3269
|
+
} else {
|
3270
|
+
this._applySplicesArraySort(this._splices);
|
3271
|
+
}
|
3272
|
+
}
|
3273
|
+
}
|
3274
|
+
if (this._fullRefresh) {
|
3275
|
+
this._sortAndFilter();
|
3276
|
+
this._fullRefresh = false;
|
3277
|
+
}
|
3278
|
+
this._splices = [];
|
3279
|
+
var rowForKey = this._rowForKey = {};
|
3280
|
+
var keys = this._orderedKeys;
|
3281
|
+
this.rows = this.rows || [];
|
3282
|
+
for (var i = 0; i < keys.length; i++) {
|
3283
|
+
var key = keys[i];
|
3284
|
+
var item = c.getItem(key);
|
3285
|
+
var row = this.rows[i];
|
3286
|
+
rowForKey[key] = i;
|
3287
|
+
if (!row) {
|
3288
|
+
this.rows.push(row = this._insertRow(i, null, item));
|
3289
|
+
}
|
3290
|
+
row[this.as] = item;
|
3291
|
+
row.__key__ = key;
|
3292
|
+
row[this.indexAs] = i;
|
3293
|
+
}
|
3294
|
+
for (; i < this.rows.length; i++) {
|
3295
|
+
this._detachRow(i);
|
3296
|
+
}
|
3297
|
+
this.rows.splice(keys.length, this.rows.length - keys.length);
|
3298
|
+
this.fire('dom-change');
|
3299
|
+
},
|
3300
|
+
_sortAndFilter: function () {
|
3301
|
+
var c = this.collection;
|
3302
|
+
if (!this._sortFn) {
|
3303
|
+
this._orderedKeys = [];
|
3304
|
+
var items = this.items;
|
3305
|
+
if (items) {
|
3306
|
+
for (var i = 0; i < items.length; i++) {
|
3307
|
+
this._orderedKeys.push(c.getKey(items[i]));
|
3308
|
+
}
|
3309
|
+
}
|
3310
|
+
} else {
|
3311
|
+
this._orderedKeys = c ? c.getKeys() : [];
|
3312
|
+
}
|
3313
|
+
if (this._filterFn) {
|
3314
|
+
this._orderedKeys = this._orderedKeys.filter(function (a) {
|
3315
|
+
return this._filterFn(c.getItem(a));
|
3316
|
+
}, this);
|
3317
|
+
}
|
3318
|
+
if (this._sortFn) {
|
3319
|
+
this._orderedKeys.sort(function (a, b) {
|
3320
|
+
return this._sortFn(c.getItem(a), c.getItem(b));
|
3321
|
+
}.bind(this));
|
3322
|
+
}
|
3323
|
+
},
|
3324
|
+
_keySort: function (a, b) {
|
3325
|
+
return this.collection.getKey(a) - this.collection.getKey(b);
|
3326
|
+
},
|
3327
|
+
_applySplicesViewSort: function (splices) {
|
3328
|
+
var c = this.collection;
|
3329
|
+
var keys = this._orderedKeys;
|
3330
|
+
var rows = this.rows;
|
3331
|
+
var removedRows = [];
|
3332
|
+
var addedKeys = [];
|
3333
|
+
var pool = [];
|
3334
|
+
var sortFn = this._sortFn || this._keySort.bind(this);
|
3335
|
+
splices.forEach(function (s) {
|
3336
|
+
for (var i = 0; i < s.removed.length; i++) {
|
3337
|
+
var idx = this._rowForKey[s.removed[i]];
|
3338
|
+
if (idx != null) {
|
3339
|
+
removedRows.push(idx);
|
3340
|
+
}
|
3341
|
+
}
|
3342
|
+
for (var i = 0; i < s.added.length; i++) {
|
3343
|
+
addedKeys.push(s.added[i]);
|
3344
|
+
}
|
3345
|
+
}, this);
|
3346
|
+
if (removedRows.length) {
|
3347
|
+
removedRows.sort();
|
3348
|
+
for (var i = removedRows.length - 1; i >= 0; i--) {
|
3349
|
+
var idx = removedRows[i];
|
3350
|
+
pool.push(this._detachRow(idx));
|
3351
|
+
rows.splice(idx, 1);
|
3352
|
+
keys.splice(idx, 1);
|
3353
|
+
}
|
3354
|
+
}
|
3355
|
+
if (addedKeys.length) {
|
3356
|
+
if (this._filterFn) {
|
3357
|
+
addedKeys = addedKeys.filter(function (a) {
|
3358
|
+
return this._filterFn(c.getItem(a));
|
3359
|
+
}, this);
|
3360
|
+
}
|
3361
|
+
addedKeys.sort(function (a, b) {
|
3362
|
+
return this._sortFn(c.getItem(a), c.getItem(b));
|
3363
|
+
}.bind(this));
|
3364
|
+
var start = 0;
|
3365
|
+
for (var i = 0; i < addedKeys.length; i++) {
|
3366
|
+
start = this._insertRowIntoViewSort(start, addedKeys[i], pool);
|
3367
|
+
}
|
3368
|
+
}
|
3369
|
+
},
|
3370
|
+
_insertRowIntoViewSort: function (start, key, pool) {
|
3371
|
+
var c = this.collection;
|
3372
|
+
var item = c.getItem(key);
|
3373
|
+
var end = this.rows.length - 1;
|
3374
|
+
var idx = -1;
|
3375
|
+
var sortFn = this._sortFn || this._keySort.bind(this);
|
3376
|
+
while (start <= end) {
|
3377
|
+
var mid = start + end >> 1;
|
3378
|
+
var midKey = this._orderedKeys[mid];
|
3379
|
+
var cmp = sortFn(c.getItem(midKey), item);
|
3380
|
+
if (cmp < 0) {
|
3381
|
+
start = mid + 1;
|
3382
|
+
} else if (cmp > 0) {
|
3383
|
+
end = mid - 1;
|
3384
|
+
} else {
|
3385
|
+
idx = mid;
|
3386
|
+
break;
|
3387
|
+
}
|
3388
|
+
}
|
3389
|
+
if (idx < 0) {
|
3390
|
+
idx = end + 1;
|
3391
|
+
}
|
3392
|
+
this._orderedKeys.splice(idx, 0, key);
|
3393
|
+
this.rows.splice(idx, 0, this._insertRow(idx, pool, c.getItem(key)));
|
3394
|
+
return idx;
|
3395
|
+
},
|
3396
|
+
_applySplicesArraySort: function (splices) {
|
3397
|
+
var keys = this._orderedKeys;
|
3398
|
+
var pool = [];
|
3399
|
+
splices.forEach(function (s) {
|
3400
|
+
for (var i = 0; i < s.removed.length; i++) {
|
3401
|
+
pool.push(this._detachRow(s.index + i));
|
3402
|
+
}
|
3403
|
+
this.rows.splice(s.index, s.removed.length);
|
3404
|
+
}, this);
|
3405
|
+
var c = this.collection;
|
3406
|
+
splices.forEach(function (s) {
|
3407
|
+
var args = [
|
3408
|
+
s.index,
|
3409
|
+
s.removed.length
|
3410
|
+
].concat(s.added);
|
3411
|
+
keys.splice.apply(keys, args);
|
3412
|
+
for (var i = 0; i < s.added.length; i++) {
|
3413
|
+
var item = c.getItem(s.added[i]);
|
3414
|
+
var row = this._insertRow(s.index + i, pool, item);
|
3415
|
+
this.rows.splice(s.index + i, 0, row);
|
3416
|
+
}
|
3417
|
+
}, this);
|
3418
|
+
},
|
3419
|
+
_detachRow: function (idx) {
|
3420
|
+
var row = this.rows[idx];
|
3421
|
+
var parentNode = Polymer.dom(this).parentNode;
|
3422
|
+
for (var i = 0; i < row._children.length; i++) {
|
3423
|
+
var el = row._children[i];
|
3424
|
+
Polymer.dom(row.root).appendChild(el);
|
3425
|
+
}
|
3426
|
+
return row;
|
3427
|
+
},
|
3428
|
+
_insertRow: function (idx, pool, item) {
|
3429
|
+
var row = pool && pool.pop() || this._generateRow(idx, item);
|
3430
|
+
var beforeRow = this.rows[idx];
|
3431
|
+
var beforeNode = beforeRow ? beforeRow._children[0] : this;
|
3432
|
+
var parentNode = Polymer.dom(this).parentNode;
|
3433
|
+
Polymer.dom(parentNode).insertBefore(row.root, beforeNode);
|
3434
|
+
return row;
|
3435
|
+
},
|
3436
|
+
_generateRow: function (idx, item) {
|
3437
|
+
var model = { __key__: this.collection.getKey(item) };
|
3438
|
+
model[this.as] = item;
|
3439
|
+
model[this.indexAs] = idx;
|
3440
|
+
var row = this.stamp(model);
|
3441
|
+
return row;
|
3442
|
+
},
|
3443
|
+
_showHideChildren: function (hidden) {
|
3444
|
+
if (this.rows) {
|
3445
|
+
for (var i = 0; i < this.rows.length; i++) {
|
3446
|
+
var c$ = this.rows[i]._children;
|
3447
|
+
for (var j = 0; j < c$.length; j++) {
|
3448
|
+
var c = c$[j];
|
3449
|
+
if (c.style) {
|
3450
|
+
c.style.display = hidden ? 'none' : '';
|
3451
|
+
}
|
3452
|
+
c._hideTemplateChildren = hidden;
|
3453
|
+
}
|
3454
|
+
}
|
3455
|
+
}
|
3456
|
+
},
|
3457
|
+
_forwardInstancePath: function (row, path, value) {
|
3458
|
+
if (path.indexOf(this.as + '.') === 0) {
|
3459
|
+
this.notifyPath('items.' + row.__key__ + '.' + path.slice(this.as.length + 1), value);
|
3460
|
+
return true;
|
3461
|
+
}
|
3462
|
+
},
|
3463
|
+
_forwardParentProp: function (prop, value) {
|
3464
|
+
if (this.rows) {
|
3465
|
+
this.rows.forEach(function (row) {
|
3466
|
+
row[prop] = value;
|
3467
|
+
}, this);
|
3468
|
+
}
|
3469
|
+
},
|
3470
|
+
_forwardParentPath: function (path, value) {
|
3471
|
+
if (this.rows) {
|
3472
|
+
this.rows.forEach(function (row) {
|
3473
|
+
row.notifyPath(path, value, true);
|
3474
|
+
}, this);
|
3475
|
+
}
|
3476
|
+
},
|
3477
|
+
_forwardItemPath: function (path, value) {
|
3478
|
+
if (this._rowForKey) {
|
3479
|
+
var dot = path.indexOf('.');
|
3480
|
+
var key = path.substring(0, dot < 0 ? path.length : dot);
|
3481
|
+
var idx = this._rowForKey[key];
|
3482
|
+
var row = this.rows[idx];
|
3483
|
+
if (row) {
|
3484
|
+
if (dot >= 0) {
|
3485
|
+
path = this.as + '.' + path.substring(dot + 1);
|
3486
|
+
row.notifyPath(path, value, true);
|
3487
|
+
} else {
|
3488
|
+
row[this.as] = value;
|
3489
|
+
}
|
3490
|
+
}
|
3491
|
+
}
|
3492
|
+
},
|
3493
|
+
modelForElement: function (el) {
|
3494
|
+
var model;
|
3495
|
+
while (el) {
|
3496
|
+
if (model = el._templateInstance) {
|
3497
|
+
if (model.dataHost != this) {
|
3498
|
+
el = model.dataHost;
|
3499
|
+
} else {
|
3500
|
+
return model;
|
3501
|
+
}
|
3502
|
+
} else {
|
3503
|
+
el = el.parentNode;
|
3504
|
+
}
|
3505
|
+
}
|
3506
|
+
},
|
3507
|
+
itemForElement: function (el) {
|
3508
|
+
var instance = this.modelForElement(el);
|
3509
|
+
return instance && instance[this.as];
|
3510
|
+
},
|
3511
|
+
keyForElement: function (el) {
|
3512
|
+
var instance = this.modelForElement(el);
|
3513
|
+
return instance && instance.__key__;
|
3514
|
+
},
|
3515
|
+
indexForElement: function (el) {
|
3516
|
+
var instance = this.modelForElement(el);
|
3517
|
+
return instance && instance[this.indexAs];
|
3518
|
+
}
|
3519
|
+
});
|
3520
|
+
Polymer({
|
3521
|
+
is: 'array-selector',
|
3522
|
+
properties: {
|
3523
|
+
items: {
|
3524
|
+
type: Array,
|
3525
|
+
observer: '_itemsChanged'
|
3526
|
+
},
|
3527
|
+
selected: {
|
3528
|
+
type: Object,
|
3529
|
+
notify: true
|
3530
|
+
},
|
3531
|
+
toggle: Boolean,
|
3532
|
+
multi: Boolean
|
3533
|
+
},
|
3534
|
+
_itemsChanged: function () {
|
3535
|
+
if (Array.isArray(this.selected)) {
|
3536
|
+
for (var i = 0; i < this.selected.length; i++) {
|
3537
|
+
this.unlinkPaths('selected.' + i);
|
3538
|
+
}
|
3539
|
+
} else {
|
3540
|
+
this.unlinkPaths('selected');
|
3541
|
+
}
|
3542
|
+
if (this.multi) {
|
3543
|
+
this.selected = [];
|
3544
|
+
} else {
|
3545
|
+
this.selected = null;
|
3546
|
+
}
|
3547
|
+
},
|
3548
|
+
deselect: function (item) {
|
3549
|
+
if (this.multi) {
|
3550
|
+
var scol = Polymer.Collection.get(this.selected);
|
3551
|
+
var sidx = this.selected.indexOf(item);
|
3552
|
+
if (sidx >= 0) {
|
3553
|
+
var skey = scol.getKey(item);
|
3554
|
+
this.splice('selected', sidx, 1);
|
3555
|
+
this.unlinkPaths('selected.' + skey);
|
3556
|
+
return true;
|
3557
|
+
}
|
3558
|
+
} else {
|
3559
|
+
this.selected = null;
|
3560
|
+
this.unlinkPaths('selected');
|
3561
|
+
}
|
3562
|
+
},
|
3563
|
+
select: function (item) {
|
3564
|
+
var icol = Polymer.Collection.get(this.items);
|
3565
|
+
var key = icol.getKey(item);
|
3566
|
+
if (this.multi) {
|
3567
|
+
var scol = Polymer.Collection.get(this.selected);
|
3568
|
+
var skey = scol.getKey(item);
|
3569
|
+
if (skey >= 0) {
|
3570
|
+
this.deselect(item);
|
3571
|
+
} else if (this.toggle) {
|
3572
|
+
this.push('selected', item);
|
3573
|
+
this.async(function () {
|
3574
|
+
skey = scol.getKey(item);
|
3575
|
+
this.linkPaths('selected.' + skey, 'items.' + key);
|
3576
|
+
});
|
3577
|
+
}
|
3578
|
+
} else {
|
3579
|
+
if (this.toggle && item == this.selected) {
|
3580
|
+
this.deselect();
|
3581
|
+
} else {
|
3582
|
+
this.linkPaths('selected', 'items.' + key);
|
3583
|
+
this.selected = item;
|
3584
|
+
}
|
3585
|
+
}
|
3586
|
+
}
|
3587
|
+
});
|
3588
|
+
Polymer({
|
3589
|
+
is: 'dom-if',
|
3590
|
+
extends: 'template',
|
3591
|
+
properties: {
|
3592
|
+
'if': {
|
3593
|
+
type: Boolean,
|
3594
|
+
value: false
|
3595
|
+
},
|
3596
|
+
restamp: {
|
3597
|
+
type: Boolean,
|
3598
|
+
value: false
|
3599
|
+
}
|
3600
|
+
},
|
3601
|
+
behaviors: [Polymer.Templatizer],
|
3602
|
+
observers: ['_queueRender(if, restamp)'],
|
3603
|
+
_queueRender: function () {
|
3604
|
+
this._debounceTemplate(this._render);
|
3605
|
+
},
|
3606
|
+
detached: function () {
|
3607
|
+
this._teardownInstance();
|
3608
|
+
},
|
3609
|
+
attached: function () {
|
3610
|
+
if (this.if && this.ctor) {
|
3611
|
+
this.async(this._ensureInstance);
|
3612
|
+
}
|
3613
|
+
},
|
3614
|
+
render: function () {
|
3615
|
+
this._flushTemplates();
|
3616
|
+
},
|
3617
|
+
_render: function () {
|
3618
|
+
if (this.if) {
|
3619
|
+
if (!this.ctor) {
|
3620
|
+
this._wrapTextNodes(this._content || this.content);
|
3621
|
+
this.templatize(this);
|
3622
|
+
}
|
3623
|
+
this._ensureInstance();
|
3624
|
+
this._showHideChildren();
|
3625
|
+
} else if (this.restamp) {
|
3626
|
+
this._teardownInstance();
|
3627
|
+
}
|
3628
|
+
if (!this.restamp && this._instance) {
|
3629
|
+
this._showHideChildren();
|
3630
|
+
}
|
3631
|
+
if (this.if != this._lastIf) {
|
3632
|
+
this.fire('dom-change');
|
3633
|
+
this._lastIf = this.if;
|
3634
|
+
}
|
3635
|
+
},
|
3636
|
+
_ensureInstance: function () {
|
3637
|
+
if (!this._instance) {
|
3638
|
+
this._instance = this.stamp();
|
3639
|
+
var root = this._instance.root;
|
3640
|
+
var parent = Polymer.dom(Polymer.dom(this).parentNode);
|
3641
|
+
parent.insertBefore(root, this);
|
3642
|
+
}
|
3643
|
+
},
|
3644
|
+
_teardownInstance: function () {
|
3645
|
+
if (this._instance) {
|
3646
|
+
var c = this._instance._children;
|
3647
|
+
if (c) {
|
3648
|
+
var parent = Polymer.dom(Polymer.dom(c[0]).parentNode);
|
3649
|
+
c.forEach(function (n) {
|
3650
|
+
parent.removeChild(n);
|
3651
|
+
});
|
3652
|
+
}
|
3653
|
+
this._instance = null;
|
3654
|
+
}
|
3655
|
+
},
|
3656
|
+
_wrapTextNodes: function (root) {
|
3657
|
+
for (var n = root.firstChild; n; n = n.nextSibling) {
|
3658
|
+
if (n.nodeType === Node.TEXT_NODE) {
|
3659
|
+
var s = document.createElement('span');
|
3660
|
+
root.insertBefore(s, n);
|
3661
|
+
s.appendChild(n);
|
3662
|
+
n = s;
|
3663
|
+
}
|
3664
|
+
}
|
3665
|
+
},
|
3666
|
+
_showHideChildren: function () {
|
3667
|
+
var hidden = this._hideTemplateChildren || !this.if;
|
3668
|
+
if (this._instance) {
|
3669
|
+
var c$ = this._instance._children;
|
3670
|
+
for (var i = 0; i < c$.length; i++) {
|
3671
|
+
var c = c$[i];
|
3672
|
+
c.style.display = hidden ? 'none' : '';
|
3673
|
+
c._hideTemplateChildren = hidden;
|
3674
|
+
}
|
3675
|
+
}
|
3676
|
+
},
|
3677
|
+
_forwardParentProp: function (prop, value) {
|
3678
|
+
if (this._instance) {
|
3679
|
+
this._instance[prop] = value;
|
3680
|
+
}
|
3681
|
+
},
|
3682
|
+
_forwardParentPath: function (path, value) {
|
3683
|
+
if (this._instance) {
|
3684
|
+
this._instance.notifyPath(path, value, true);
|
3685
|
+
}
|
3686
|
+
}
|
3687
|
+
});
|
3688
|
+
Polymer.ImportStatus = {
|
3689
|
+
_ready: false,
|
3690
|
+
_callbacks: [],
|
3691
|
+
whenLoaded: function (cb) {
|
3692
|
+
if (this._ready) {
|
3693
|
+
cb();
|
3694
|
+
} else {
|
3695
|
+
this._callbacks.push(cb);
|
3696
|
+
}
|
3697
|
+
},
|
3698
|
+
_importsLoaded: function () {
|
3699
|
+
this._ready = true;
|
3700
|
+
this._callbacks.forEach(function (cb) {
|
3701
|
+
cb();
|
3702
|
+
});
|
3703
|
+
this._callbacks = [];
|
3704
|
+
}
|
3705
|
+
};
|
3706
|
+
window.addEventListener('load', function () {
|
3707
|
+
Polymer.ImportStatus._importsLoaded();
|
3708
|
+
});
|
3709
|
+
if (window.HTMLImports) {
|
3710
|
+
HTMLImports.whenReady(function () {
|
3711
|
+
Polymer.ImportStatus._importsLoaded();
|
3712
|
+
});
|
3713
|
+
}
|
3714
|
+
Polymer({
|
3715
|
+
is: 'dom-bind',
|
3716
|
+
extends: 'template',
|
3717
|
+
created: function () {
|
3718
|
+
Polymer.ImportStatus.whenLoaded(this._readySelf.bind(this));
|
3719
|
+
},
|
3720
|
+
_registerFeatures: function () {
|
3721
|
+
this._prepExtends();
|
3722
|
+
this._prepConstructor();
|
3723
|
+
},
|
3724
|
+
_insertChildren: function () {
|
3725
|
+
var parentDom = Polymer.dom(Polymer.dom(this).parentNode);
|
3726
|
+
parentDom.insertBefore(this.root, this);
|
3727
|
+
},
|
3728
|
+
_removeChildren: function () {
|
3729
|
+
if (this._children) {
|
3730
|
+
for (var i = 0; i < this._children.length; i++) {
|
3731
|
+
this.root.appendChild(this._children[i]);
|
3732
|
+
}
|
3733
|
+
}
|
3734
|
+
},
|
3735
|
+
_initFeatures: function () {
|
3736
|
+
},
|
3737
|
+
_scopeElementClass: function (element, selector) {
|
3738
|
+
if (this.dataHost) {
|
3739
|
+
return this.dataHost._scopeElementClass(element, selector);
|
3740
|
+
} else {
|
3741
|
+
return selector;
|
3742
|
+
}
|
3743
|
+
},
|
3744
|
+
_prepConfigure: function () {
|
3745
|
+
var config = {};
|
3746
|
+
for (var prop in this._propertyEffects) {
|
3747
|
+
config[prop] = this[prop];
|
3748
|
+
}
|
3749
|
+
this._setupConfigure = this._setupConfigure.bind(this, config);
|
3750
|
+
},
|
3751
|
+
attached: function () {
|
3752
|
+
if (!this._children) {
|
3753
|
+
this._template = this;
|
3754
|
+
this._prepAnnotations();
|
3755
|
+
this._prepEffects();
|
3756
|
+
this._prepBehaviors();
|
3757
|
+
this._prepConfigure();
|
3758
|
+
this._prepBindings();
|
3759
|
+
Polymer.Base._initFeatures.call(this);
|
3760
|
+
this._children = Array.prototype.slice.call(this.root.childNodes);
|
3761
|
+
}
|
3762
|
+
this._insertChildren();
|
3763
|
+
this.fire('dom-change');
|
3764
|
+
},
|
3765
|
+
detached: function () {
|
3766
|
+
this._removeChildren();
|
3767
|
+
}
|
3768
|
+
});</script>
|