polymer-rails 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polymer/polymer-micro.html +49 -12
- data/app/assets/javascripts/polymer/polymer-mini.html +50 -11
- data/app/assets/javascripts/polymer/polymer.html +282 -125
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +77 -23
- data/app/assets/javascripts/webcomponentsjs/webcomponents.js +30 -52
- data/lib/polymer-rails.rb +11 -1
- data/lib/polymer-rails/processors/components_processor.rb +1 -9
- data/lib/polymer-rails/processors/components_processor_v2.rb +16 -0
- data/lib/polymer-rails/processors/components_processor_v3.rb +33 -0
- data/lib/polymer-rails/railtie.rb +19 -2
- data/lib/polymer-rails/version.rb +1 -1
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39009e09a451db6b696b64d747b85eabe02ae38b
|
4
|
+
data.tar.gz: 2f05a0e70596c06e796cd2070940e691a4d38293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec975c0220275695ad07be0c423d728e2d1971780e5c7150c7974d934eb9fd15725f10b1d06df29c0e64ed0b41ec6db58294a48eb5c79527afe8a165d067b4de
|
7
|
+
data.tar.gz: 22fe13f96a2eecfe72ab794a012656eb3d65cfa5653830edb82135a51dcbf86ad81eb767629cc426dcd28ef14fc6cbd8859dc88ae3420c6b0d91bc9848f73987
|
@@ -95,6 +95,38 @@ get: function () {
|
|
95
95
|
return (document._currentScript || document.currentScript).ownerDocument;
|
96
96
|
}
|
97
97
|
});
|
98
|
+
Polymer.RenderStatus = {
|
99
|
+
_ready: false,
|
100
|
+
_callbacks: [],
|
101
|
+
whenReady: function (cb) {
|
102
|
+
if (this._ready) {
|
103
|
+
cb();
|
104
|
+
} else {
|
105
|
+
this._callbacks.push(cb);
|
106
|
+
}
|
107
|
+
},
|
108
|
+
_makeReady: function () {
|
109
|
+
this._ready = true;
|
110
|
+
this._callbacks.forEach(function (cb) {
|
111
|
+
cb();
|
112
|
+
});
|
113
|
+
this._callbacks = [];
|
114
|
+
},
|
115
|
+
_catchFirstRender: function () {
|
116
|
+
requestAnimationFrame(function () {
|
117
|
+
Polymer.RenderStatus._makeReady();
|
118
|
+
});
|
119
|
+
}
|
120
|
+
};
|
121
|
+
if (window.HTMLImports) {
|
122
|
+
HTMLImports.whenReady(function () {
|
123
|
+
Polymer.RenderStatus._catchFirstRender();
|
124
|
+
});
|
125
|
+
} else {
|
126
|
+
Polymer.RenderStatus._catchFirstRender();
|
127
|
+
}
|
128
|
+
Polymer.ImportStatus = Polymer.RenderStatus;
|
129
|
+
Polymer.ImportStatus.whenLoaded = Polymer.ImportStatus.whenReady;
|
98
130
|
Polymer.Base = {
|
99
131
|
__isPolymerInstance__: true,
|
100
132
|
_addFeature: function (feature) {
|
@@ -111,17 +143,22 @@ this._doBehavior('created');
|
|
111
143
|
this._initFeatures();
|
112
144
|
},
|
113
145
|
attachedCallback: function () {
|
146
|
+
Polymer.RenderStatus.whenReady(function () {
|
114
147
|
this.isAttached = true;
|
115
148
|
this._doBehavior('attached');
|
149
|
+
}.bind(this));
|
116
150
|
},
|
117
151
|
detachedCallback: function () {
|
118
152
|
this.isAttached = false;
|
119
153
|
this._doBehavior('detached');
|
120
154
|
},
|
121
155
|
attributeChangedCallback: function (name) {
|
122
|
-
this.
|
156
|
+
this._attributeChangedImpl(name);
|
123
157
|
this._doBehavior('attributeChanged', arguments);
|
124
158
|
},
|
159
|
+
_attributeChangedImpl: function (name) {
|
160
|
+
this._setAttributeToProperty(this, name);
|
161
|
+
},
|
125
162
|
extend: function (prototype, api) {
|
126
163
|
if (prototype && api) {
|
127
164
|
Object.getOwnPropertyNames(api).forEach(function (n) {
|
@@ -179,6 +216,7 @@ return Boolean(obj && obj.__isPolymerInstance__);
|
|
179
216
|
Polymer.telemetry.instanceCount = 0;
|
180
217
|
(function () {
|
181
218
|
var modules = {};
|
219
|
+
var lcModules = {};
|
182
220
|
var DomModule = function () {
|
183
221
|
return document.createElement('dom-module');
|
184
222
|
};
|
@@ -193,10 +231,11 @@ var id = id || this.id || this.getAttribute('name') || this.getAttribute('is');
|
|
193
231
|
if (id) {
|
194
232
|
this.id = id;
|
195
233
|
modules[id] = this;
|
234
|
+
lcModules[id.toLowerCase()] = this;
|
196
235
|
}
|
197
236
|
},
|
198
237
|
import: function (id, selector) {
|
199
|
-
var m = modules[id];
|
238
|
+
var m = modules[id] || lcModules[id.toLowerCase()];
|
200
239
|
if (!m) {
|
201
240
|
forceDocumentUpgrade();
|
202
241
|
m = modules[id];
|
@@ -208,19 +247,14 @@ return m;
|
|
208
247
|
}
|
209
248
|
});
|
210
249
|
var cePolyfill = window.CustomElements && !CustomElements.useNative;
|
211
|
-
if (cePolyfill) {
|
212
|
-
var ready = CustomElements.ready;
|
213
|
-
CustomElements.ready = true;
|
214
|
-
}
|
215
250
|
document.registerElement('dom-module', DomModule);
|
216
|
-
if (cePolyfill) {
|
217
|
-
CustomElements.ready = ready;
|
218
|
-
}
|
219
251
|
function forceDocumentUpgrade() {
|
220
252
|
if (cePolyfill) {
|
221
253
|
var script = document._currentScript || document.currentScript;
|
222
|
-
|
223
|
-
|
254
|
+
var doc = script && script.ownerDocument;
|
255
|
+
if (doc && !doc.__customElementsForceUpgraded) {
|
256
|
+
doc.__customElementsForceUpgraded = true;
|
257
|
+
CustomElements.upgradeAll(doc);
|
224
258
|
}
|
225
259
|
}
|
226
260
|
}
|
@@ -234,6 +268,9 @@ var id = module.id || module.getAttribute('name') || module.getAttribute('is');
|
|
234
268
|
this.is = id;
|
235
269
|
}
|
236
270
|
}
|
271
|
+
if (this.is) {
|
272
|
+
this.is = this.is.toLowerCase();
|
273
|
+
}
|
237
274
|
}
|
238
275
|
});
|
239
276
|
Polymer.Base._addFeature({
|
@@ -521,7 +558,7 @@ debouncer.stop();
|
|
521
558
|
}
|
522
559
|
}
|
523
560
|
});
|
524
|
-
Polymer.version = '1.0
|
561
|
+
Polymer.version = '1.1.0';
|
525
562
|
Polymer.Base._addFeature({
|
526
563
|
_registerFeatures: function () {
|
527
564
|
this._prepIs();
|
@@ -14,6 +14,10 @@ this._template = this._template || Polymer.DomModule.import(this.is, 'template')
|
|
14
14
|
if (this._template && this._template.hasAttribute('is')) {
|
15
15
|
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
|
16
16
|
}
|
17
|
+
if (this._template && !this._template.content && HTMLTemplateElement.bootstrap) {
|
18
|
+
HTMLTemplateElement.decorate(this._template);
|
19
|
+
HTMLTemplateElement.bootstrap(this._template.content);
|
20
|
+
}
|
17
21
|
},
|
18
22
|
_stampTemplate: function () {
|
19
23
|
if (this._template) {
|
@@ -434,6 +438,14 @@ if (this.patch) {
|
|
434
438
|
this.patch();
|
435
439
|
}
|
436
440
|
};
|
441
|
+
if (window.wrap && Settings.useShadow && !Settings.useNativeShadow) {
|
442
|
+
DomApi = function (node) {
|
443
|
+
this.node = wrap(node);
|
444
|
+
if (this.patch) {
|
445
|
+
this.patch();
|
446
|
+
}
|
447
|
+
};
|
448
|
+
}
|
437
449
|
DomApi.prototype = {
|
438
450
|
flush: function () {
|
439
451
|
Polymer.dom.flush();
|
@@ -446,11 +458,14 @@ Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent));
|
|
446
458
|
},
|
447
459
|
appendChild: function (node) {
|
448
460
|
var handled;
|
461
|
+
this._ensureContentLogicalInfo(node);
|
449
462
|
this._removeNodeFromHost(node, true);
|
450
463
|
if (this._nodeIsInLogicalTree(this.node)) {
|
451
464
|
this._addLogicalInfo(node, this.node);
|
452
465
|
this._addNodeToHost(node);
|
453
466
|
handled = this._maybeDistribute(node, this.node);
|
467
|
+
} else {
|
468
|
+
this._addNodeToHost(node);
|
454
469
|
}
|
455
470
|
if (!handled && !this._tryRemoveUndistributedNode(node)) {
|
456
471
|
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
@@ -464,9 +479,9 @@ if (!ref_node) {
|
|
464
479
|
return this.appendChild(node);
|
465
480
|
}
|
466
481
|
var handled;
|
482
|
+
this._ensureContentLogicalInfo(node);
|
467
483
|
this._removeNodeFromHost(node, true);
|
468
484
|
if (this._nodeIsInLogicalTree(this.node)) {
|
469
|
-
saveLightChildrenIfNeeded(this.node);
|
470
485
|
var children = this.childNodes;
|
471
486
|
var index = children.indexOf(ref_node);
|
472
487
|
if (index < 0) {
|
@@ -475,6 +490,8 @@ throw Error('The ref_node to be inserted before is not a child ' + 'of this node
|
|
475
490
|
this._addLogicalInfo(node, this.node, index);
|
476
491
|
this._addNodeToHost(node);
|
477
492
|
handled = this._maybeDistribute(node, this.node);
|
493
|
+
} else {
|
494
|
+
this._addNodeToHost(node);
|
478
495
|
}
|
479
496
|
if (!handled && !this._tryRemoveUndistributedNode(node)) {
|
480
497
|
ref_node = ref_node.localName === CONTENT ? this._firstComposedNode(ref_node) : ref_node;
|
@@ -492,6 +509,8 @@ var handled;
|
|
492
509
|
if (this._nodeIsInLogicalTree(this.node)) {
|
493
510
|
this._removeNodeFromHost(node);
|
494
511
|
handled = this._maybeDistribute(node, this.node);
|
512
|
+
} else {
|
513
|
+
this._removeNodeFromHost(node);
|
495
514
|
}
|
496
515
|
if (!handled) {
|
497
516
|
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
@@ -507,6 +526,9 @@ this.insertBefore(node, ref_node);
|
|
507
526
|
this.removeChild(ref_node);
|
508
527
|
return node;
|
509
528
|
},
|
529
|
+
_hasCachedOwnerRoot: function (node) {
|
530
|
+
return Boolean(node._ownerShadyRoot !== undefined);
|
531
|
+
},
|
510
532
|
getOwnerRoot: function () {
|
511
533
|
return this._ownerShadyRootForNode(this.node);
|
512
534
|
},
|
@@ -557,10 +579,27 @@ return true;
|
|
557
579
|
}
|
558
580
|
},
|
559
581
|
_updateInsertionPoints: function (host) {
|
560
|
-
host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
582
|
+
var i$ = host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
583
|
+
for (var i = 0, c; i < i$.length; i++) {
|
584
|
+
c = i$[i];
|
585
|
+
saveLightChildrenIfNeeded(c);
|
586
|
+
saveLightChildrenIfNeeded(factory(c).parentNode);
|
587
|
+
}
|
561
588
|
},
|
562
589
|
_nodeIsInLogicalTree: function (node) {
|
563
|
-
return Boolean(node._lightParent !== undefined || node._isShadyRoot ||
|
590
|
+
return Boolean(node._lightParent !== undefined || node._isShadyRoot || node.shadyRoot);
|
591
|
+
},
|
592
|
+
_ensureContentLogicalInfo: function (node) {
|
593
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
594
|
+
saveLightChildrenIfNeeded(this.node);
|
595
|
+
var c$ = Array.prototype.slice.call(node.childNodes);
|
596
|
+
for (var i = 0, n; i < c$.length && (n = c$[i]); i++) {
|
597
|
+
this._ensureContentLogicalInfo(n);
|
598
|
+
}
|
599
|
+
} else if (node.localName === CONTENT) {
|
600
|
+
saveLightChildrenIfNeeded(this.node);
|
601
|
+
saveLightChildrenIfNeeded(node);
|
602
|
+
}
|
564
603
|
},
|
565
604
|
_parentNeedsDistribution: function (parent) {
|
566
605
|
return parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot);
|
@@ -614,14 +653,12 @@ node = factory(node).parentNode;
|
|
614
653
|
}
|
615
654
|
},
|
616
655
|
_addNodeToHost: function (node) {
|
617
|
-
var
|
618
|
-
var root = this._ownerShadyRootForNode(checkNode);
|
656
|
+
var root = this.getOwnerRoot();
|
619
657
|
if (root) {
|
620
658
|
root.host._elementAdd(node);
|
621
659
|
}
|
622
660
|
},
|
623
661
|
_addLogicalInfo: function (node, container, index) {
|
624
|
-
saveLightChildrenIfNeeded(container);
|
625
662
|
var children = factory(container).childNodes;
|
626
663
|
index = index === undefined ? children.length : index;
|
627
664
|
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
@@ -645,8 +682,7 @@ children.splice(index, 1);
|
|
645
682
|
node._lightParent = null;
|
646
683
|
},
|
647
684
|
_removeOwnerShadyRoot: function (node) {
|
648
|
-
|
649
|
-
if (hasCachedRoot) {
|
685
|
+
if (this._hasCachedOwnerRoot(node)) {
|
650
686
|
var c$ = factory(node).childNodes;
|
651
687
|
for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) {
|
652
688
|
this._removeOwnerShadyRoot(n);
|
@@ -1149,8 +1185,13 @@ this.shadyRoot = this.root;
|
|
1149
1185
|
this.shadyRoot._distributionClean = false;
|
1150
1186
|
this.shadyRoot._isShadyRoot = true;
|
1151
1187
|
this.shadyRoot._dirtyRoots = [];
|
1152
|
-
this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
|
1188
|
+
var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
|
1153
1189
|
saveLightChildrenIfNeeded(this.shadyRoot);
|
1190
|
+
for (var i = 0, c; i < i$.length; i++) {
|
1191
|
+
c = i$[i];
|
1192
|
+
saveLightChildrenIfNeeded(c);
|
1193
|
+
saveLightChildrenIfNeeded(c.parentNode);
|
1194
|
+
}
|
1154
1195
|
this.shadyRoot.host = this;
|
1155
1196
|
},
|
1156
1197
|
get domHost() {
|
@@ -1385,14 +1426,12 @@ if (newChildParent !== parentNode) {
|
|
1385
1426
|
removeFromComposedParent(newChildParent, newChild);
|
1386
1427
|
}
|
1387
1428
|
remove(newChild);
|
1388
|
-
saveLightChildrenIfNeeded(parentNode);
|
1389
1429
|
nativeInsertBefore.call(parentNode, newChild, refChild || null);
|
1390
1430
|
newChild._composedParent = parentNode;
|
1391
1431
|
}
|
1392
1432
|
function remove(node) {
|
1393
1433
|
var parentNode = getComposedParent(node);
|
1394
1434
|
if (parentNode) {
|
1395
|
-
saveLightChildrenIfNeeded(parentNode);
|
1396
1435
|
node._composedParent = null;
|
1397
1436
|
nativeRemoveChild.call(parentNode, node);
|
1398
1437
|
}
|
@@ -424,6 +424,19 @@ var MOUSE_EVENTS = [
|
|
424
424
|
'mouseup',
|
425
425
|
'click'
|
426
426
|
];
|
427
|
+
var MOUSE_WHICH_TO_BUTTONS = [
|
428
|
+
0,
|
429
|
+
1,
|
430
|
+
4,
|
431
|
+
2
|
432
|
+
];
|
433
|
+
var MOUSE_HAS_BUTTONS = function () {
|
434
|
+
try {
|
435
|
+
return new MouseEvent('test', { buttons: 1 }).buttons === 1;
|
436
|
+
} catch (e) {
|
437
|
+
return false;
|
438
|
+
}
|
439
|
+
}();
|
427
440
|
var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
|
428
441
|
var mouseCanceller = function (mouseEvent) {
|
429
442
|
mouseEvent[HANDLED_OBJ] = { skip: true };
|
@@ -462,6 +475,34 @@ POINTERSTATE.mouse.mouseIgnoreJob = null;
|
|
462
475
|
};
|
463
476
|
POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT);
|
464
477
|
}
|
478
|
+
function hasLeftMouseButton(ev) {
|
479
|
+
var type = ev.type;
|
480
|
+
if (MOUSE_EVENTS.indexOf(type) === -1) {
|
481
|
+
return false;
|
482
|
+
}
|
483
|
+
if (type === 'mousemove') {
|
484
|
+
var buttons = ev.buttons === undefined ? 1 : ev.buttons;
|
485
|
+
if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
|
486
|
+
buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0;
|
487
|
+
}
|
488
|
+
return Boolean(buttons & 1);
|
489
|
+
} else {
|
490
|
+
var button = ev.button === undefined ? 0 : ev.button;
|
491
|
+
return button === 0;
|
492
|
+
}
|
493
|
+
}
|
494
|
+
function isSyntheticClick(ev) {
|
495
|
+
if (ev.type === 'click') {
|
496
|
+
if (ev.detail === 0) {
|
497
|
+
return true;
|
498
|
+
}
|
499
|
+
var t = Gestures.findOriginalTarget(ev);
|
500
|
+
var bcr = t.getBoundingClientRect();
|
501
|
+
var x = ev.pageX, y = ev.pageY;
|
502
|
+
return !(x >= bcr.left && x <= bcr.right && (y >= bcr.top && y <= bcr.bottom));
|
503
|
+
}
|
504
|
+
return false;
|
505
|
+
}
|
465
506
|
var POINTERSTATE = {
|
466
507
|
mouse: {
|
467
508
|
target: null,
|
@@ -486,6 +527,16 @@ break;
|
|
486
527
|
}
|
487
528
|
return ta;
|
488
529
|
}
|
530
|
+
function trackDocument(stateObj, movefn, upfn) {
|
531
|
+
stateObj.movefn = movefn;
|
532
|
+
stateObj.upfn = upfn;
|
533
|
+
document.addEventListener('mousemove', movefn);
|
534
|
+
document.addEventListener('mouseup', upfn);
|
535
|
+
}
|
536
|
+
function untrackDocument(stateObj) {
|
537
|
+
document.removeEventListener('mousemove', stateObj.movefn);
|
538
|
+
document.removeEventListener('mouseup', stateObj.upfn);
|
539
|
+
}
|
489
540
|
var Gestures = {
|
490
541
|
gestures: {},
|
491
542
|
recognizers: [],
|
@@ -691,18 +742,48 @@ deps: [
|
|
691
742
|
'touchstart',
|
692
743
|
'touchend'
|
693
744
|
],
|
745
|
+
flow: {
|
746
|
+
start: [
|
747
|
+
'mousedown',
|
748
|
+
'touchstart'
|
749
|
+
],
|
750
|
+
end: [
|
751
|
+
'mouseup',
|
752
|
+
'touchend'
|
753
|
+
]
|
754
|
+
},
|
694
755
|
emits: [
|
695
756
|
'down',
|
696
757
|
'up'
|
697
758
|
],
|
759
|
+
info: {
|
760
|
+
movefn: function () {
|
761
|
+
},
|
762
|
+
upfn: function () {
|
763
|
+
}
|
764
|
+
},
|
765
|
+
reset: function () {
|
766
|
+
untrackDocument(this.info);
|
767
|
+
},
|
698
768
|
mousedown: function (e) {
|
769
|
+
if (!hasLeftMouseButton(e)) {
|
770
|
+
return;
|
771
|
+
}
|
699
772
|
var t = Gestures.findOriginalTarget(e);
|
700
773
|
var self = this;
|
774
|
+
var movefn = function movefn(e) {
|
775
|
+
if (!hasLeftMouseButton(e)) {
|
776
|
+
self.fire('up', t, e);
|
777
|
+
untrackDocument(self.info);
|
778
|
+
}
|
779
|
+
};
|
701
780
|
var upfn = function upfn(e) {
|
781
|
+
if (hasLeftMouseButton(e)) {
|
702
782
|
self.fire('up', t, e);
|
703
|
-
|
783
|
+
}
|
784
|
+
untrackDocument(self.info);
|
704
785
|
};
|
705
|
-
|
786
|
+
trackDocument(this.info, movefn, upfn);
|
706
787
|
this.fire('down', t, e);
|
707
788
|
},
|
708
789
|
touchstart: function (e) {
|
@@ -753,6 +834,10 @@ this.moves.shift();
|
|
753
834
|
}
|
754
835
|
this.moves.push(move);
|
755
836
|
},
|
837
|
+
movefn: function () {
|
838
|
+
},
|
839
|
+
upfn: function () {
|
840
|
+
},
|
756
841
|
prevent: false
|
757
842
|
},
|
758
843
|
reset: function () {
|
@@ -762,6 +847,7 @@ this.info.moves = [];
|
|
762
847
|
this.info.x = 0;
|
763
848
|
this.info.y = 0;
|
764
849
|
this.info.prevent = false;
|
850
|
+
untrackDocument(this.info);
|
765
851
|
},
|
766
852
|
hasMovedEnough: function (x, y) {
|
767
853
|
if (this.info.prevent) {
|
@@ -775,6 +861,9 @@ var dy = Math.abs(this.info.y - y);
|
|
775
861
|
return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
|
776
862
|
},
|
777
863
|
mousedown: function (e) {
|
864
|
+
if (!hasLeftMouseButton(e)) {
|
865
|
+
return;
|
866
|
+
}
|
778
867
|
var t = Gestures.findOriginalTarget(e);
|
779
868
|
var self = this;
|
780
869
|
var movefn = function movefn(e) {
|
@@ -785,6 +874,10 @@ self.info.addMove({
|
|
785
874
|
x: x,
|
786
875
|
y: y
|
787
876
|
});
|
877
|
+
if (!hasLeftMouseButton(e)) {
|
878
|
+
self.info.state = 'end';
|
879
|
+
untrackDocument(self.info);
|
880
|
+
}
|
788
881
|
self.fire(t, e);
|
789
882
|
self.info.started = true;
|
790
883
|
}
|
@@ -794,11 +887,9 @@ if (self.info.started) {
|
|
794
887
|
Gestures.prevent('tap');
|
795
888
|
movefn(e);
|
796
889
|
}
|
797
|
-
|
798
|
-
document.removeEventListener('mouseup', upfn);
|
890
|
+
untrackDocument(self.info);
|
799
891
|
};
|
800
|
-
|
801
|
-
document.addEventListener('mouseup', upfn);
|
892
|
+
trackDocument(this.info, movefn, upfn);
|
802
893
|
this.info.x = e.clientX;
|
803
894
|
this.info.y = e.clientY;
|
804
895
|
},
|
@@ -893,10 +984,14 @@ this.info.x = e.clientX;
|
|
893
984
|
this.info.y = e.clientY;
|
894
985
|
},
|
895
986
|
mousedown: function (e) {
|
987
|
+
if (hasLeftMouseButton(e)) {
|
896
988
|
this.save(e);
|
989
|
+
}
|
897
990
|
},
|
898
991
|
click: function (e) {
|
992
|
+
if (hasLeftMouseButton(e)) {
|
899
993
|
this.forward(e);
|
994
|
+
}
|
900
995
|
},
|
901
996
|
touchstart: function (e) {
|
902
997
|
this.save(e.changedTouches[0]);
|
@@ -908,7 +1003,7 @@ forward: function (e) {
|
|
908
1003
|
var dx = Math.abs(e.clientX - this.info.x);
|
909
1004
|
var dy = Math.abs(e.clientY - this.info.y);
|
910
1005
|
var t = Gestures.findOriginalTarget(e);
|
911
|
-
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) {
|
1006
|
+
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE || isSyntheticClick(e)) {
|
912
1007
|
if (!this.info.prevent) {
|
913
1008
|
Gestures.fire(t, 'tap', {
|
914
1009
|
x: e.clientX,
|
@@ -1529,7 +1624,7 @@ trigger: trigger
|
|
1529
1624
|
});
|
1530
1625
|
},
|
1531
1626
|
_parseMethod: function (expression) {
|
1532
|
-
var m = expression.match(/(
|
1627
|
+
var m = expression.match(/([^\s]+)\((.*)\)/);
|
1533
1628
|
if (m) {
|
1534
1629
|
var sig = {
|
1535
1630
|
method: m[1],
|
@@ -1624,6 +1719,10 @@ this._handlers = [];
|
|
1624
1719
|
_marshalAttributes: function () {
|
1625
1720
|
this._takeAttributesToModel(this._config);
|
1626
1721
|
},
|
1722
|
+
_attributeChangedImpl: function (name) {
|
1723
|
+
var model = this._clientsReadied ? this : this._config;
|
1724
|
+
this._setAttributeToProperty(model, name);
|
1725
|
+
},
|
1627
1726
|
_configValue: function (name, value) {
|
1628
1727
|
this._config[name] = value;
|
1629
1728
|
},
|
@@ -1903,36 +2002,56 @@ var array = this.get(path);
|
|
1903
2002
|
var args = Array.prototype.slice.call(arguments, 1);
|
1904
2003
|
var len = array.length;
|
1905
2004
|
var ret = array.push.apply(array, args);
|
2005
|
+
if (args.length) {
|
1906
2006
|
this._notifySplice(array, path, len, args.length, []);
|
2007
|
+
}
|
1907
2008
|
return ret;
|
1908
2009
|
},
|
1909
2010
|
pop: function (path) {
|
1910
2011
|
var array = this.get(path);
|
2012
|
+
var hadLength = Boolean(array.length);
|
1911
2013
|
var args = Array.prototype.slice.call(arguments, 1);
|
1912
|
-
var rem = array.slice(-1);
|
1913
2014
|
var ret = array.pop.apply(array, args);
|
1914
|
-
|
2015
|
+
if (hadLength) {
|
2016
|
+
this._notifySplice(array, path, array.length, 0, [ret]);
|
2017
|
+
}
|
1915
2018
|
return ret;
|
1916
2019
|
},
|
1917
2020
|
splice: function (path, start, deleteCount) {
|
1918
2021
|
var array = this.get(path);
|
2022
|
+
if (start < 0) {
|
2023
|
+
start = array.length - Math.floor(-start);
|
2024
|
+
} else {
|
2025
|
+
start = Math.floor(start);
|
2026
|
+
}
|
2027
|
+
if (!start) {
|
2028
|
+
start = 0;
|
2029
|
+
}
|
1919
2030
|
var args = Array.prototype.slice.call(arguments, 1);
|
1920
2031
|
var ret = array.splice.apply(array, args);
|
1921
|
-
|
2032
|
+
var addedCount = Math.max(args.length - 2, 0);
|
2033
|
+
if (addedCount || ret.length) {
|
2034
|
+
this._notifySplice(array, path, start, addedCount, ret);
|
2035
|
+
}
|
1922
2036
|
return ret;
|
1923
2037
|
},
|
1924
2038
|
shift: function (path) {
|
1925
2039
|
var array = this.get(path);
|
2040
|
+
var hadLength = Boolean(array.length);
|
1926
2041
|
var args = Array.prototype.slice.call(arguments, 1);
|
1927
2042
|
var ret = array.shift.apply(array, args);
|
2043
|
+
if (hadLength) {
|
1928
2044
|
this._notifySplice(array, path, 0, 0, [ret]);
|
2045
|
+
}
|
1929
2046
|
return ret;
|
1930
2047
|
},
|
1931
2048
|
unshift: function (path) {
|
1932
2049
|
var array = this.get(path);
|
1933
2050
|
var args = Array.prototype.slice.call(arguments, 1);
|
1934
2051
|
var ret = array.unshift.apply(array, args);
|
2052
|
+
if (args.length) {
|
1935
2053
|
this._notifySplice(array, path, 0, args.length, []);
|
2054
|
+
}
|
1936
2055
|
return ret;
|
1937
2056
|
}
|
1938
2057
|
});
|
@@ -1955,7 +2074,7 @@ text = this._clean(text);
|
|
1955
2074
|
return this._parseCss(this._lex(text), text);
|
1956
2075
|
},
|
1957
2076
|
_clean: function (cssText) {
|
1958
|
-
return cssText.replace(
|
2077
|
+
return cssText.replace(this._rx.comments, '').replace(this._rx.port, '');
|
1959
2078
|
},
|
1960
2079
|
_lex: function (text) {
|
1961
2080
|
var root = {
|
@@ -1994,15 +2113,15 @@ var ss = node.previous ? node.previous.end : node.parent.start;
|
|
1994
2113
|
t = text.substring(ss, node.start - 1);
|
1995
2114
|
t = t.substring(t.lastIndexOf(';') + 1);
|
1996
2115
|
var s = node.parsedSelector = node.selector = t.trim();
|
1997
|
-
node.atRule = s.indexOf(AT_START) === 0;
|
2116
|
+
node.atRule = s.indexOf(this.AT_START) === 0;
|
1998
2117
|
if (node.atRule) {
|
1999
|
-
if (s.indexOf(MEDIA_START) === 0) {
|
2118
|
+
if (s.indexOf(this.MEDIA_START) === 0) {
|
2000
2119
|
node.type = this.types.MEDIA_RULE;
|
2001
|
-
} else if (s.match(
|
2120
|
+
} else if (s.match(this._rx.keyframesRule)) {
|
2002
2121
|
node.type = this.types.KEYFRAMES_RULE;
|
2003
2122
|
}
|
2004
2123
|
} else {
|
2005
|
-
if (s.indexOf(VAR_START) === 0) {
|
2124
|
+
if (s.indexOf(this.VAR_START) === 0) {
|
2006
2125
|
node.type = this.types.MIXIN_RULE;
|
2007
2126
|
} else {
|
2008
2127
|
node.type = this.types.STYLE_RULE;
|
@@ -2022,12 +2141,12 @@ text = text || '';
|
|
2022
2141
|
var cssText = '';
|
2023
2142
|
if (node.cssText || node.rules) {
|
2024
2143
|
var r$ = node.rules;
|
2025
|
-
if (r$ && (preserveProperties || !
|
2144
|
+
if (r$ && (preserveProperties || !this._hasMixinRules(r$))) {
|
2026
2145
|
for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
|
2027
2146
|
cssText = this.stringify(r, preserveProperties, cssText);
|
2028
2147
|
}
|
2029
2148
|
} else {
|
2030
|
-
cssText = preserveProperties ? node.cssText : removeCustomProps(node.cssText);
|
2149
|
+
cssText = preserveProperties ? node.cssText : this.removeCustomProps(node.cssText);
|
2031
2150
|
cssText = cssText.trim();
|
2032
2151
|
if (cssText) {
|
2033
2152
|
cssText = ' ' + cssText + '\n';
|
@@ -2045,6 +2164,19 @@ text += this.CLOSE_BRACE + '\n\n';
|
|
2045
2164
|
}
|
2046
2165
|
return text;
|
2047
2166
|
},
|
2167
|
+
_hasMixinRules: function (rules) {
|
2168
|
+
return rules[0].selector.indexOf(this.VAR_START) >= 0;
|
2169
|
+
},
|
2170
|
+
removeCustomProps: function (cssText) {
|
2171
|
+
cssText = this.removeCustomPropAssignment(cssText);
|
2172
|
+
return this.removeCustomPropApply(cssText);
|
2173
|
+
},
|
2174
|
+
removeCustomPropAssignment: function (cssText) {
|
2175
|
+
return cssText.replace(this._rx.customProp, '').replace(this._rx.mixinProp, '');
|
2176
|
+
},
|
2177
|
+
removeCustomPropApply: function (cssText) {
|
2178
|
+
return cssText.replace(this._rx.mixinApply, '').replace(this._rx.varApply, '');
|
2179
|
+
},
|
2048
2180
|
types: {
|
2049
2181
|
STYLE_RULE: 1,
|
2050
2182
|
KEYFRAMES_RULE: 7,
|
@@ -2052,31 +2184,26 @@ MEDIA_RULE: 4,
|
|
2052
2184
|
MIXIN_RULE: 1000
|
2053
2185
|
},
|
2054
2186
|
OPEN_BRACE: '{',
|
2055
|
-
CLOSE_BRACE: '}'
|
2056
|
-
|
2057
|
-
|
2058
|
-
return rules[0].selector.indexOf(VAR_START) >= 0;
|
2059
|
-
}
|
2060
|
-
function removeCustomProps(cssText) {
|
2061
|
-
return cssText.replace(rx.customProp, '').replace(rx.mixinProp, '').replace(rx.mixinApply, '').replace(rx.varApply, '');
|
2062
|
-
}
|
2063
|
-
var VAR_START = '--';
|
2064
|
-
var MEDIA_START = '@media';
|
2065
|
-
var AT_START = '@';
|
2066
|
-
var rx = {
|
2067
|
-
comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
|
2187
|
+
CLOSE_BRACE: '}',
|
2188
|
+
_rx: {
|
2189
|
+
comments: /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,
|
2068
2190
|
port: /@import[^;]*;/gim,
|
2069
2191
|
customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
|
2070
2192
|
mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim,
|
2071
2193
|
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
|
2072
2194
|
varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim,
|
2073
2195
|
keyframesRule: /^@[^\s]*keyframes/
|
2196
|
+
},
|
2197
|
+
VAR_START: '--',
|
2198
|
+
MEDIA_START: '@media',
|
2199
|
+
AT_START: '@'
|
2074
2200
|
};
|
2075
2201
|
return api;
|
2076
2202
|
}();
|
2077
2203
|
Polymer.StyleUtil = function () {
|
2078
2204
|
return {
|
2079
|
-
MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css]',
|
2205
|
+
MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css], template',
|
2206
|
+
INCLUDE_ATTR: 'include',
|
2080
2207
|
toCssText: function (rules, callback, preserveProperties) {
|
2081
2208
|
if (typeof rules === 'string') {
|
2082
2209
|
rules = this.parser.parse(rules);
|
@@ -2103,7 +2230,7 @@ clearStyleRules: function (style) {
|
|
2103
2230
|
style.__cssRules = null;
|
2104
2231
|
},
|
2105
2232
|
forEachStyleRule: function (node, callback) {
|
2106
|
-
var s = node.
|
2233
|
+
var s = node.parsedSelector;
|
2107
2234
|
var skipRules = false;
|
2108
2235
|
if (node.type === this.ruleTypes.STYLE_RULE) {
|
2109
2236
|
callback(node);
|
@@ -2131,27 +2258,52 @@ afterNode = n$[n$.length - 1];
|
|
2131
2258
|
target.insertBefore(style, afterNode && afterNode.nextSibling || target.firstChild);
|
2132
2259
|
return style;
|
2133
2260
|
},
|
2261
|
+
cssFromModules: function (moduleIds) {
|
2262
|
+
var modules = moduleIds.trim().split(' ');
|
2263
|
+
var cssText = '';
|
2264
|
+
for (var i = 0; i < modules.length; i++) {
|
2265
|
+
cssText += this.cssFromModule(modules[i]);
|
2266
|
+
}
|
2267
|
+
return cssText;
|
2268
|
+
},
|
2134
2269
|
cssFromModule: function (moduleId) {
|
2135
2270
|
var m = Polymer.DomModule.import(moduleId);
|
2136
2271
|
if (m && !m._cssText) {
|
2272
|
+
m._cssText = this._cssFromElement(m);
|
2273
|
+
}
|
2274
|
+
return m && m._cssText || '';
|
2275
|
+
},
|
2276
|
+
_cssFromElement: function (element) {
|
2137
2277
|
var cssText = '';
|
2138
|
-
var
|
2139
|
-
|
2278
|
+
var content = element.content || element;
|
2279
|
+
var sourceDoc = element.ownerDocument;
|
2280
|
+
var e$ = Array.prototype.slice.call(content.querySelectorAll(this.MODULE_STYLES_SELECTOR));
|
2281
|
+
for (var i = 0, e, resolveDoc, addModule; i < e$.length; i++) {
|
2140
2282
|
e = e$[i];
|
2283
|
+
resolveDoc = sourceDoc;
|
2284
|
+
addModule = null;
|
2285
|
+
if (e.localName === 'template') {
|
2286
|
+
cssText += this._cssFromElement(e);
|
2287
|
+
} else {
|
2141
2288
|
if (e.localName === 'style') {
|
2289
|
+
addModule = e.getAttribute(this.INCLUDE_ATTR);
|
2142
2290
|
e = e.__appliedElement || e;
|
2143
2291
|
e.parentNode.removeChild(e);
|
2144
2292
|
} else {
|
2145
2293
|
e = e.import && e.import.body;
|
2294
|
+
resolveDoc = e.ownerDocument;
|
2146
2295
|
}
|
2147
2296
|
if (e) {
|
2148
|
-
cssText +=
|
2297
|
+
cssText += this.resolveCss(e.textContent, resolveDoc);
|
2149
2298
|
}
|
2150
2299
|
}
|
2151
|
-
|
2300
|
+
if (addModule) {
|
2301
|
+
cssText += this.cssFromModules(addModule);
|
2152
2302
|
}
|
2153
|
-
|
2303
|
+
}
|
2304
|
+
return cssText;
|
2154
2305
|
},
|
2306
|
+
resolveCss: Polymer.ResolveUrl.resolveCss,
|
2155
2307
|
parser: Polymer.CssParse,
|
2156
2308
|
ruleTypes: Polymer.CssParse.types
|
2157
2309
|
};
|
@@ -2243,7 +2395,7 @@ var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
|
|
2243
2395
|
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
|
2244
2396
|
p$[i] = transformer.call(this, p, scope, hostScope);
|
2245
2397
|
}
|
2246
|
-
rule.selector = p$.join(COMPLEX_SELECTOR_SEP);
|
2398
|
+
rule.selector = rule.transformedSelector = p$.join(COMPLEX_SELECTOR_SEP);
|
2247
2399
|
},
|
2248
2400
|
_transformComplexSelector: function (selector, scope, hostScope) {
|
2249
2401
|
var stop = false;
|
@@ -2598,7 +2750,8 @@ return property && property.trim() || '';
|
|
2598
2750
|
},
|
2599
2751
|
valueForProperties: function (property, props) {
|
2600
2752
|
var parts = property.split(';');
|
2601
|
-
for (var i = 0, p, m; i < parts.length
|
2753
|
+
for (var i = 0, p, m; i < parts.length; i++) {
|
2754
|
+
if (p = parts[i]) {
|
2602
2755
|
m = p.match(this.rx.MIXIN_MATCH);
|
2603
2756
|
if (m) {
|
2604
2757
|
p = this.valueForProperty(props[m[1]], props);
|
@@ -2612,6 +2765,7 @@ p = pp.join(':');
|
|
2612
2765
|
}
|
2613
2766
|
parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || '';
|
2614
2767
|
}
|
2768
|
+
}
|
2615
2769
|
return parts.join(';');
|
2616
2770
|
},
|
2617
2771
|
applyProperties: function (rule, props) {
|
@@ -2631,7 +2785,7 @@ styleUtil.forRulesInStyles(styles, function (rule) {
|
|
2631
2785
|
if (!rule.propertyInfo) {
|
2632
2786
|
self.decorateRule(rule);
|
2633
2787
|
}
|
2634
|
-
if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.
|
2788
|
+
if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.transformedSelector || rule.parsedSelector)) {
|
2635
2789
|
self.collectProperties(rule, props);
|
2636
2790
|
addToBitMask(i, o);
|
2637
2791
|
}
|
@@ -3029,9 +3183,9 @@ this._pushHost();
|
|
3029
3183
|
this._stampTemplate();
|
3030
3184
|
this._popHost();
|
3031
3185
|
this._marshalAnnotationReferences();
|
3032
|
-
this._marshalHostAttributes();
|
3033
3186
|
this._setupDebouncers();
|
3034
3187
|
this._marshalInstanceEffects();
|
3188
|
+
this._marshalHostAttributes();
|
3035
3189
|
this._marshalBehaviors();
|
3036
3190
|
this._marshalAttributes();
|
3037
3191
|
this._tryReady();
|
@@ -3044,12 +3198,14 @@ this._listenListeners(b.listeners);
|
|
3044
3198
|
var nativeShadow = Polymer.Settings.useNativeShadow;
|
3045
3199
|
var propertyUtils = Polymer.StyleProperties;
|
3046
3200
|
var styleUtil = Polymer.StyleUtil;
|
3201
|
+
var cssParse = Polymer.CssParse;
|
3047
3202
|
var styleDefaults = Polymer.StyleDefaults;
|
3048
3203
|
var styleTransformer = Polymer.StyleTransformer;
|
3049
3204
|
Polymer({
|
3050
3205
|
is: 'custom-style',
|
3051
3206
|
extends: 'style',
|
3052
|
-
|
3207
|
+
properties: { include: String },
|
3208
|
+
ready: function () {
|
3053
3209
|
this._tryApply();
|
3054
3210
|
},
|
3055
3211
|
attached: function () {
|
@@ -3061,7 +3217,7 @@ if (this.parentNode && this.parentNode.localName !== 'dom-module') {
|
|
3061
3217
|
this._appliesToDocument = true;
|
3062
3218
|
var e = this.__appliedElement || this;
|
3063
3219
|
styleDefaults.addStyle(e);
|
3064
|
-
if (e.textContent) {
|
3220
|
+
if (e.textContent || this.include) {
|
3065
3221
|
this._apply();
|
3066
3222
|
} else {
|
3067
3223
|
var observer = new MutationObserver(function () {
|
@@ -3075,13 +3231,16 @@ observer.observe(e, { childList: true });
|
|
3075
3231
|
},
|
3076
3232
|
_apply: function () {
|
3077
3233
|
var e = this.__appliedElement || this;
|
3234
|
+
if (this.include) {
|
3235
|
+
e.textContent += styleUtil.cssFromModules(this.include);
|
3236
|
+
}
|
3078
3237
|
this._computeStyleProperties();
|
3079
3238
|
var props = this._styleProperties;
|
3080
3239
|
var self = this;
|
3081
3240
|
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) {
|
3082
3241
|
var css = rule.cssText = rule.parsedCssText;
|
3083
3242
|
if (rule.propertyInfo && rule.propertyInfo.cssText) {
|
3084
|
-
css =
|
3243
|
+
css = cssParse.removeCustomPropAssignment(css);
|
3085
3244
|
rule.cssText = propertyUtils.valueForProperties(css, props);
|
3086
3245
|
}
|
3087
3246
|
styleTransformer.documentRule(rule);
|
@@ -3129,10 +3288,24 @@ _showHideChildrenImpl: function (hide) {
|
|
3129
3288
|
var c = this._children;
|
3130
3289
|
for (var i = 0; i < c.length; i++) {
|
3131
3290
|
var n = c[i];
|
3132
|
-
if (n.
|
3133
|
-
n.
|
3134
|
-
|
3291
|
+
if (Boolean(hide) != Boolean(n.__hideTemplateChildren__)) {
|
3292
|
+
if (n.nodeType === Node.TEXT_NODE) {
|
3293
|
+
if (hide) {
|
3294
|
+
n.__polymerTextContent__ = n.textContent;
|
3295
|
+
n.textContent = '';
|
3296
|
+
} else {
|
3297
|
+
n.textContent = n.__polymerTextContent__;
|
3135
3298
|
}
|
3299
|
+
} else if (n.style) {
|
3300
|
+
if (hide) {
|
3301
|
+
n.__polymerDisplay__ = n.style.display;
|
3302
|
+
n.style.display = 'none';
|
3303
|
+
} else {
|
3304
|
+
n.style.display = n.__polymerDisplay__;
|
3305
|
+
}
|
3306
|
+
}
|
3307
|
+
}
|
3308
|
+
n.__hideTemplateChildren__ = hide;
|
3136
3309
|
}
|
3137
3310
|
},
|
3138
3311
|
_debounceTemplate: function (fn) {
|
@@ -3398,29 +3571,36 @@ items.push(store[key]);
|
|
3398
3571
|
return items;
|
3399
3572
|
},
|
3400
3573
|
_applySplices: function (splices) {
|
3401
|
-
var
|
3402
|
-
|
3403
|
-
|
3574
|
+
var keyMap = {}, key, i;
|
3575
|
+
splices.forEach(function (s) {
|
3576
|
+
s.addedKeys = [];
|
3577
|
+
for (i = 0; i < s.removed.length; i++) {
|
3578
|
+
key = this.getKey(s.removed[i]);
|
3579
|
+
keyMap[key] = keyMap[key] ? null : -1;
|
3580
|
+
}
|
3581
|
+
for (i = 0; i < s.addedCount; i++) {
|
3582
|
+
var item = this.userArray[s.index + i];
|
3583
|
+
key = this.getKey(item);
|
3584
|
+
key = key === undefined ? this.add(item) : key;
|
3585
|
+
keyMap[key] = keyMap[key] ? null : 1;
|
3586
|
+
s.addedKeys.push(key);
|
3587
|
+
}
|
3588
|
+
}, this);
|
3404
3589
|
var removed = [];
|
3405
|
-
|
3406
|
-
|
3407
|
-
key
|
3590
|
+
var added = [];
|
3591
|
+
for (var key in keyMap) {
|
3592
|
+
if (keyMap[key] < 0) {
|
3593
|
+
this.removeKey(key);
|
3408
3594
|
removed.push(key);
|
3409
3595
|
}
|
3410
|
-
|
3411
|
-
for (j = 0; j < s.addedCount; j++) {
|
3412
|
-
o = this.userArray[s.index + j];
|
3413
|
-
key = this.add(o);
|
3596
|
+
if (keyMap[key] > 0) {
|
3414
3597
|
added.push(key);
|
3415
3598
|
}
|
3416
|
-
|
3417
|
-
|
3599
|
+
}
|
3600
|
+
return [{
|
3418
3601
|
removed: removed,
|
3419
|
-
removedItems: s.removed,
|
3420
3602
|
added: added
|
3421
|
-
}
|
3422
|
-
}
|
3423
|
-
return keySplices;
|
3603
|
+
}];
|
3424
3604
|
}
|
3425
3605
|
};
|
3426
3606
|
Polymer.Collection.get = function (userArray) {
|
@@ -3515,11 +3695,13 @@ this.collection = null;
|
|
3515
3695
|
} else {
|
3516
3696
|
this._error(this._logf('dom-repeat', 'expected array for `items`,' + ' found', this.items));
|
3517
3697
|
}
|
3518
|
-
this.
|
3698
|
+
this._keySplices = [];
|
3699
|
+
this._indexSplices = [];
|
3519
3700
|
this._needFullRefresh = true;
|
3520
3701
|
this._debounceTemplate(this._render);
|
3521
3702
|
} else if (change.path == 'items.splices') {
|
3522
|
-
this.
|
3703
|
+
this._keySplices = this._keySplices.concat(change.value.keySplices);
|
3704
|
+
this._indexSplices = this._indexSplices.concat(change.value.indexSplices);
|
3523
3705
|
this._debounceTemplate(this._render);
|
3524
3706
|
} else {
|
3525
3707
|
var subpath = change.path.slice(6);
|
@@ -3556,16 +3738,17 @@ this._applyFullRefresh();
|
|
3556
3738
|
this._needFullRefresh = false;
|
3557
3739
|
} else {
|
3558
3740
|
if (this._sortFn) {
|
3559
|
-
this._applySplicesUserSort(this.
|
3741
|
+
this._applySplicesUserSort(this._keySplices);
|
3560
3742
|
} else {
|
3561
3743
|
if (this._filterFn) {
|
3562
3744
|
this._applyFullRefresh();
|
3563
3745
|
} else {
|
3564
|
-
this._applySplicesArrayOrder(this.
|
3746
|
+
this._applySplicesArrayOrder(this._indexSplices);
|
3565
3747
|
}
|
3566
3748
|
}
|
3567
3749
|
}
|
3568
|
-
this.
|
3750
|
+
this._keySplices = [];
|
3751
|
+
this._indexSplices = [];
|
3569
3752
|
var keyToIdx = this._keyToInstIdx = {};
|
3570
3753
|
for (var i = 0; i < this._instances.length; i++) {
|
3571
3754
|
var inst = this._instances[i];
|
@@ -3703,10 +3886,10 @@ pool.push(inst);
|
|
3703
3886
|
}
|
3704
3887
|
}
|
3705
3888
|
this._instances.splice(s.index, s.removed.length);
|
3706
|
-
for (var i = 0; i < s.
|
3889
|
+
for (var i = 0; i < s.addedKeys.length; i++) {
|
3707
3890
|
var inst = {
|
3708
3891
|
isPlaceholder: true,
|
3709
|
-
key: s.
|
3892
|
+
key: s.addedKeys[i]
|
3710
3893
|
};
|
3711
3894
|
this._instances.splice(s.index + i, 0, inst);
|
3712
3895
|
}
|
@@ -3815,16 +3998,23 @@ is: 'array-selector',
|
|
3815
3998
|
properties: {
|
3816
3999
|
items: {
|
3817
4000
|
type: Array,
|
3818
|
-
observer: '
|
4001
|
+
observer: 'clearSelection'
|
4002
|
+
},
|
4003
|
+
multi: {
|
4004
|
+
type: Boolean,
|
4005
|
+
value: false,
|
4006
|
+
observer: 'clearSelection'
|
3819
4007
|
},
|
3820
4008
|
selected: {
|
3821
4009
|
type: Object,
|
3822
4010
|
notify: true
|
3823
4011
|
},
|
3824
|
-
toggle:
|
3825
|
-
|
4012
|
+
toggle: {
|
4013
|
+
type: Boolean,
|
4014
|
+
value: false
|
4015
|
+
}
|
3826
4016
|
},
|
3827
|
-
|
4017
|
+
clearSelection: function () {
|
3828
4018
|
if (Array.isArray(this.selected)) {
|
3829
4019
|
for (var i = 0; i < this.selected.length; i++) {
|
3830
4020
|
this.unlinkPaths('selected.' + i);
|
@@ -3833,20 +4023,28 @@ this.unlinkPaths('selected.' + i);
|
|
3833
4023
|
this.unlinkPaths('selected');
|
3834
4024
|
}
|
3835
4025
|
if (this.multi) {
|
4026
|
+
if (!this.selected || this.selected.length) {
|
3836
4027
|
this.selected = [];
|
4028
|
+
this._selectedColl = Polymer.Collection.get(this.selected);
|
4029
|
+
}
|
3837
4030
|
} else {
|
3838
4031
|
this.selected = null;
|
4032
|
+
this._selectedColl = null;
|
4033
|
+
}
|
4034
|
+
},
|
4035
|
+
isSelected: function (item) {
|
4036
|
+
if (this.multi) {
|
4037
|
+
return this._selectedColl.getKey(item) !== undefined;
|
4038
|
+
} else {
|
4039
|
+
return this.selected == item;
|
3839
4040
|
}
|
3840
4041
|
},
|
3841
4042
|
deselect: function (item) {
|
3842
4043
|
if (this.multi) {
|
3843
|
-
|
3844
|
-
var
|
3845
|
-
|
3846
|
-
var skey = scol.getKey(item);
|
3847
|
-
this.splice('selected', sidx, 1);
|
4044
|
+
if (this.isSelected(item)) {
|
4045
|
+
var skey = this._selectedColl.getKey(item);
|
4046
|
+
this.arrayDelete('selected', item);
|
3848
4047
|
this.unlinkPaths('selected.' + skey);
|
3849
|
-
return true;
|
3850
4048
|
}
|
3851
4049
|
} else {
|
3852
4050
|
this.selected = null;
|
@@ -3857,18 +4055,14 @@ select: function (item) {
|
|
3857
4055
|
var icol = Polymer.Collection.get(this.items);
|
3858
4056
|
var key = icol.getKey(item);
|
3859
4057
|
if (this.multi) {
|
3860
|
-
|
3861
|
-
var skey = scol.getKey(item);
|
3862
|
-
if (skey >= 0) {
|
4058
|
+
if (this.isSelected(item)) {
|
3863
4059
|
if (this.toggle) {
|
3864
4060
|
this.deselect(item);
|
3865
4061
|
}
|
3866
4062
|
} else {
|
3867
4063
|
this.push('selected', item);
|
3868
|
-
this.
|
3869
|
-
skey = scol.getKey(item);
|
4064
|
+
skey = this._selectedColl.getKey(item);
|
3870
4065
|
this.linkPaths('selected.' + skey, 'items.' + key);
|
3871
|
-
});
|
3872
4066
|
}
|
3873
4067
|
} else {
|
3874
4068
|
if (this.toggle && item == this.selected) {
|
@@ -3913,7 +4107,6 @@ this._flushTemplates();
|
|
3913
4107
|
_render: function () {
|
3914
4108
|
if (this.if) {
|
3915
4109
|
if (!this.ctor) {
|
3916
|
-
this._wrapTextNodes(this._content || this.content);
|
3917
4110
|
this.templatize(this);
|
3918
4111
|
}
|
3919
4112
|
this._ensureInstance();
|
@@ -3949,16 +4142,6 @@ parent.removeChild(n);
|
|
3949
4142
|
this._instance = null;
|
3950
4143
|
}
|
3951
4144
|
},
|
3952
|
-
_wrapTextNodes: function (root) {
|
3953
|
-
for (var n = root.firstChild; n; n = n.nextSibling) {
|
3954
|
-
if (n.nodeType === Node.TEXT_NODE && n.textContent.trim()) {
|
3955
|
-
var s = document.createElement('span');
|
3956
|
-
root.insertBefore(s, n);
|
3957
|
-
s.appendChild(n);
|
3958
|
-
n = s;
|
3959
|
-
}
|
3960
|
-
}
|
3961
|
-
},
|
3962
4145
|
_showHideChildren: function () {
|
3963
4146
|
var hidden = this.__hideTemplateChildren__ || !this.if;
|
3964
4147
|
if (this._instance) {
|
@@ -3976,37 +4159,11 @@ this._instance.notifyPath(path, value, true);
|
|
3976
4159
|
}
|
3977
4160
|
}
|
3978
4161
|
});
|
3979
|
-
Polymer.ImportStatus = {
|
3980
|
-
_ready: false,
|
3981
|
-
_callbacks: [],
|
3982
|
-
whenLoaded: function (cb) {
|
3983
|
-
if (this._ready) {
|
3984
|
-
cb();
|
3985
|
-
} else {
|
3986
|
-
this._callbacks.push(cb);
|
3987
|
-
}
|
3988
|
-
},
|
3989
|
-
_importsLoaded: function () {
|
3990
|
-
this._ready = true;
|
3991
|
-
this._callbacks.forEach(function (cb) {
|
3992
|
-
cb();
|
3993
|
-
});
|
3994
|
-
this._callbacks = [];
|
3995
|
-
}
|
3996
|
-
};
|
3997
|
-
window.addEventListener('load', function () {
|
3998
|
-
Polymer.ImportStatus._importsLoaded();
|
3999
|
-
});
|
4000
|
-
if (window.HTMLImports) {
|
4001
|
-
HTMLImports.whenReady(function () {
|
4002
|
-
Polymer.ImportStatus._importsLoaded();
|
4003
|
-
});
|
4004
|
-
}
|
4005
4162
|
Polymer({
|
4006
4163
|
is: 'dom-bind',
|
4007
4164
|
extends: 'template',
|
4008
4165
|
created: function () {
|
4009
|
-
Polymer.
|
4166
|
+
Polymer.RenderStatus.whenReady(this._markImportsReady.bind(this));
|
4010
4167
|
},
|
4011
4168
|
_ensureReady: function () {
|
4012
4169
|
if (!this._readied) {
|