1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update polymer

This commit is contained in:
Luke Pulverenti 2015-08-08 12:16:34 -04:00
parent d131f21626
commit 891f7bd872
9 changed files with 557 additions and 208 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "polymer", "name": "polymer",
"version": "1.0.8", "version": "1.0.9",
"main": [ "main": [
"polymer.html" "polymer.html"
], ],
@ -24,11 +24,11 @@
}, },
"private": true, "private": true,
"homepage": "https://github.com/Polymer/polymer", "homepage": "https://github.com/Polymer/polymer",
"_release": "1.0.8", "_release": "1.0.9",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.8", "tag": "v1.0.9",
"commit": "61968bc4e5db93e76306a13517014d4d3b787021" "commit": "8e894841ae36be85bade4b42f858ccb99b770e5d"
}, },
"_source": "git://github.com/Polymer/polymer.git", "_source": "git://github.com/Polymer/polymer.git",
"_target": "^1.0.0", "_target": "^1.0.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "polymer", "name": "polymer",
"version": "1.0.8", "version": "1.0.9",
"main": [ "main": [
"polymer.html" "polymer.html"
], ],

View file

@ -95,6 +95,38 @@ get: function () {
return (document._currentScript || document.currentScript).ownerDocument; return (document._currentScript || document.currentScript).ownerDocument;
} }
}); });
Polymer.RenderStatus = {
_ready: false,
_callbacks: [],
whenReady: function (cb) {
if (this._ready) {
cb();
} else {
this._callbacks.push(cb);
}
},
_makeReady: function () {
this._ready = true;
this._callbacks.forEach(function (cb) {
cb();
});
this._callbacks = [];
},
_catchFirstRender: function () {
requestAnimationFrame(function () {
Polymer.RenderStatus._makeReady();
});
}
};
if (window.HTMLImports) {
HTMLImports.whenReady(function () {
Polymer.RenderStatus._catchFirstRender();
});
} else {
Polymer.RenderStatus._catchFirstRender();
}
Polymer.ImportStatus = Polymer.RenderStatus;
Polymer.ImportStatus.whenLoaded = Polymer.ImportStatus.whenReady;
Polymer.Base = { Polymer.Base = {
__isPolymerInstance__: true, __isPolymerInstance__: true,
_addFeature: function (feature) { _addFeature: function (feature) {
@ -111,17 +143,22 @@ this._doBehavior('created');
this._initFeatures(); this._initFeatures();
}, },
attachedCallback: function () { attachedCallback: function () {
Polymer.RenderStatus.whenReady(function () {
this.isAttached = true; this.isAttached = true;
this._doBehavior('attached'); this._doBehavior('attached');
}.bind(this));
}, },
detachedCallback: function () { detachedCallback: function () {
this.isAttached = false; this.isAttached = false;
this._doBehavior('detached'); this._doBehavior('detached');
}, },
attributeChangedCallback: function (name) { attributeChangedCallback: function (name) {
this._setAttributeToProperty(this, name); this._attributeChangedImpl(name);
this._doBehavior('attributeChanged', arguments); this._doBehavior('attributeChanged', arguments);
}, },
_attributeChangedImpl: function (name) {
this._setAttributeToProperty(this, name);
},
extend: function (prototype, api) { extend: function (prototype, api) {
if (prototype && api) { if (prototype && api) {
Object.getOwnPropertyNames(api).forEach(function (n) { Object.getOwnPropertyNames(api).forEach(function (n) {
@ -179,6 +216,7 @@ return Boolean(obj && obj.__isPolymerInstance__);
Polymer.telemetry.instanceCount = 0; Polymer.telemetry.instanceCount = 0;
(function () { (function () {
var modules = {}; var modules = {};
var lcModules = {};
var DomModule = function () { var DomModule = function () {
return document.createElement('dom-module'); return document.createElement('dom-module');
}; };
@ -193,10 +231,11 @@ var id = id || this.id || this.getAttribute('name') || this.getAttribute('is');
if (id) { if (id) {
this.id = id; this.id = id;
modules[id] = this; modules[id] = this;
lcModules[id.toLowerCase()] = this;
} }
}, },
import: function (id, selector) { import: function (id, selector) {
var m = modules[id]; var m = modules[id] || lcModules[id.toLowerCase()];
if (!m) { if (!m) {
forceDocumentUpgrade(); forceDocumentUpgrade();
m = modules[id]; m = modules[id];
@ -234,6 +273,9 @@ var id = module.id || module.getAttribute('name') || module.getAttribute('is');
this.is = id; this.is = id;
} }
} }
if (this.is) {
this.is = this.is.toLowerCase();
}
} }
}); });
Polymer.Base._addFeature({ Polymer.Base._addFeature({
@ -521,7 +563,7 @@ debouncer.stop();
} }
} }
}); });
Polymer.version = '1.0.8'; Polymer.version = '1.0.9';
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_registerFeatures: function () { _registerFeatures: function () {
this._prepIs(); this._prepIs();

View file

@ -14,6 +14,10 @@ this._template = this._template || Polymer.DomModule.import(this.is, 'template')
if (this._template && this._template.hasAttribute('is')) { if (this._template && this._template.hasAttribute('is')) {
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.')); this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
} }
if (this._template && !this._template.content && HTMLTemplateElement.bootstrap) {
HTMLTemplateElement.decorate(this._template);
HTMLTemplateElement.bootstrap(this._template.content);
}
}, },
_stampTemplate: function () { _stampTemplate: function () {
if (this._template) { if (this._template) {
@ -434,6 +438,14 @@ if (this.patch) {
this.patch(); this.patch();
} }
}; };
if (window.wrap && Settings.useShadow && !Settings.useNativeShadow) {
DomApi = function (node) {
this.node = wrap(node);
if (this.patch) {
this.patch();
}
};
}
DomApi.prototype = { DomApi.prototype = {
flush: function () { flush: function () {
Polymer.dom.flush(); Polymer.dom.flush();
@ -507,6 +519,9 @@ this.insertBefore(node, ref_node);
this.removeChild(ref_node); this.removeChild(ref_node);
return node; return node;
}, },
_hasCachedOwnerRoot: function (node) {
return Boolean(node._ownerShadyRoot !== undefined);
},
getOwnerRoot: function () { getOwnerRoot: function () {
return this._ownerShadyRootForNode(this.node); return this._ownerShadyRootForNode(this.node);
}, },
@ -645,8 +660,7 @@ children.splice(index, 1);
node._lightParent = null; node._lightParent = null;
}, },
_removeOwnerShadyRoot: function (node) { _removeOwnerShadyRoot: function (node) {
var hasCachedRoot = factory(node).getOwnerRoot() !== undefined; if (this._hasCachedOwnerRoot(node)) {
if (hasCachedRoot) {
var c$ = factory(node).childNodes; var c$ = factory(node).childNodes;
for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) { for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) {
this._removeOwnerShadyRoot(n); this._removeOwnerShadyRoot(n);

View file

@ -424,6 +424,19 @@ var MOUSE_EVENTS = [
'mouseup', 'mouseup',
'click' 'click'
]; ];
var MOUSE_WHICH_TO_BUTTONS = [
0,
1,
4,
2
];
var MOUSE_HAS_BUTTONS = function () {
try {
return new MouseEvent('test', { buttons: 1 }).buttons === 1;
} catch (e) {
return false;
}
}();
var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/); var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
var mouseCanceller = function (mouseEvent) { var mouseCanceller = function (mouseEvent) {
mouseEvent[HANDLED_OBJ] = { skip: true }; mouseEvent[HANDLED_OBJ] = { skip: true };
@ -462,6 +475,34 @@ POINTERSTATE.mouse.mouseIgnoreJob = null;
}; };
POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT); POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT);
} }
function hasLeftMouseButton(ev) {
var type = ev.type;
if (MOUSE_EVENTS.indexOf(type) === -1) {
return false;
}
if (type === 'mousemove') {
var buttons = ev.buttons === undefined ? 1 : ev.buttons;
if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0;
}
return Boolean(buttons & 1);
} else {
var button = ev.button === undefined ? 0 : ev.button;
return button === 0;
}
}
function isSyntheticClick(ev) {
if (ev.type === 'click') {
if (ev.detail === 0) {
return true;
}
var t = Gestures.findOriginalTarget(ev);
var bcr = t.getBoundingClientRect();
var x = ev.pageX, y = ev.pageY;
return !(x >= bcr.left && x <= bcr.right && (y >= bcr.top && y <= bcr.bottom));
}
return false;
}
var POINTERSTATE = { var POINTERSTATE = {
mouse: { mouse: {
target: null, target: null,
@ -486,6 +527,16 @@ break;
} }
return ta; return ta;
} }
function trackDocument(stateObj, movefn, upfn) {
stateObj.movefn = movefn;
stateObj.upfn = upfn;
document.addEventListener('mousemove', movefn);
document.addEventListener('mouseup', upfn);
}
function untrackDocument(stateObj) {
document.removeEventListener('mousemove', stateObj.movefn);
document.removeEventListener('mouseup', stateObj.upfn);
}
var Gestures = { var Gestures = {
gestures: {}, gestures: {},
recognizers: [], recognizers: [],
@ -586,8 +637,7 @@ prevent = dy > dx;
prevent = dx > dy; prevent = dx > dy;
} }
if (prevent) { if (prevent) {
// This prevents side scrolling in safari ev.preventDefault();
//ev.preventDefault();
} else { } else {
Gestures.prevent('track'); Gestures.prevent('track');
} }
@ -692,18 +742,48 @@ deps: [
'touchstart', 'touchstart',
'touchend' 'touchend'
], ],
flow: {
start: [
'mousedown',
'touchstart'
],
end: [
'mouseup',
'touchend'
]
},
emits: [ emits: [
'down', 'down',
'up' 'up'
], ],
info: {
movefn: function () {
},
upfn: function () {
}
},
reset: function () {
untrackDocument(this.info);
},
mousedown: function (e) { mousedown: function (e) {
if (!hasLeftMouseButton(e)) {
return;
}
var t = Gestures.findOriginalTarget(e); var t = Gestures.findOriginalTarget(e);
var self = this; var self = this;
var upfn = function upfn(e) { var movefn = function movefn(e) {
if (!hasLeftMouseButton(e)) {
self.fire('up', t, e); self.fire('up', t, e);
document.removeEventListener('mouseup', upfn); untrackDocument(self.info);
}
}; };
document.addEventListener('mouseup', upfn); var upfn = function upfn(e) {
if (hasLeftMouseButton(e)) {
self.fire('up', t, e);
}
untrackDocument(self.info);
};
trackDocument(this.info, movefn, upfn);
this.fire('down', t, e); this.fire('down', t, e);
}, },
touchstart: function (e) { touchstart: function (e) {
@ -754,6 +834,10 @@ this.moves.shift();
} }
this.moves.push(move); this.moves.push(move);
}, },
movefn: function () {
},
upfn: function () {
},
prevent: false prevent: false
}, },
reset: function () { reset: function () {
@ -763,6 +847,7 @@ this.info.moves = [];
this.info.x = 0; this.info.x = 0;
this.info.y = 0; this.info.y = 0;
this.info.prevent = false; this.info.prevent = false;
untrackDocument(this.info);
}, },
hasMovedEnough: function (x, y) { hasMovedEnough: function (x, y) {
if (this.info.prevent) { if (this.info.prevent) {
@ -776,6 +861,9 @@ var dy = Math.abs(this.info.y - y);
return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE; return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
}, },
mousedown: function (e) { mousedown: function (e) {
if (!hasLeftMouseButton(e)) {
return;
}
var t = Gestures.findOriginalTarget(e); var t = Gestures.findOriginalTarget(e);
var self = this; var self = this;
var movefn = function movefn(e) { var movefn = function movefn(e) {
@ -786,6 +874,10 @@ self.info.addMove({
x: x, x: x,
y: y y: y
}); });
if (!hasLeftMouseButton(e)) {
self.info.state = 'end';
untrackDocument(self.info);
}
self.fire(t, e); self.fire(t, e);
self.info.started = true; self.info.started = true;
} }
@ -795,11 +887,9 @@ if (self.info.started) {
Gestures.prevent('tap'); Gestures.prevent('tap');
movefn(e); movefn(e);
} }
document.removeEventListener('mousemove', movefn); untrackDocument(self.info);
document.removeEventListener('mouseup', upfn);
}; };
document.addEventListener('mousemove', movefn); trackDocument(this.info, movefn, upfn);
document.addEventListener('mouseup', upfn);
this.info.x = e.clientX; this.info.x = e.clientX;
this.info.y = e.clientY; this.info.y = e.clientY;
}, },
@ -894,10 +984,14 @@ this.info.x = e.clientX;
this.info.y = e.clientY; this.info.y = e.clientY;
}, },
mousedown: function (e) { mousedown: function (e) {
if (hasLeftMouseButton(e)) {
this.save(e); this.save(e);
}
}, },
click: function (e) { click: function (e) {
if (hasLeftMouseButton(e)) {
this.forward(e); this.forward(e);
}
}, },
touchstart: function (e) { touchstart: function (e) {
this.save(e.changedTouches[0]); this.save(e.changedTouches[0]);
@ -909,7 +1003,7 @@ forward: function (e) {
var dx = Math.abs(e.clientX - this.info.x); var dx = Math.abs(e.clientX - this.info.x);
var dy = Math.abs(e.clientY - this.info.y); var dy = Math.abs(e.clientY - this.info.y);
var t = Gestures.findOriginalTarget(e); var t = Gestures.findOriginalTarget(e);
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) { if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE || isSyntheticClick(e)) {
if (!this.info.prevent) { if (!this.info.prevent) {
Gestures.fire(t, 'tap', { Gestures.fire(t, 'tap', {
x: e.clientX, x: e.clientX,
@ -1530,7 +1624,7 @@ trigger: trigger
}); });
}, },
_parseMethod: function (expression) { _parseMethod: function (expression) {
var m = expression.match(/(\w*)\((.*)\)/); var m = expression.match(/([^\s]+)\((.*)\)/);
if (m) { if (m) {
var sig = { var sig = {
method: m[1], method: m[1],
@ -1625,6 +1719,10 @@ this._handlers = [];
_marshalAttributes: function () { _marshalAttributes: function () {
this._takeAttributesToModel(this._config); this._takeAttributesToModel(this._config);
}, },
_attributeChangedImpl: function (name) {
var model = this._clientsReadied ? this : this._config;
this._setAttributeToProperty(model, name);
},
_configValue: function (name, value) { _configValue: function (name, value) {
this._config[name] = value; this._config[name] = value;
}, },
@ -1904,36 +2002,56 @@ var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var len = array.length; var len = array.length;
var ret = array.push.apply(array, args); var ret = array.push.apply(array, args);
if (args.length) {
this._notifySplice(array, path, len, args.length, []); this._notifySplice(array, path, len, args.length, []);
}
return ret; return ret;
}, },
pop: function (path) { pop: function (path) {
var array = this.get(path); var array = this.get(path);
var hadLength = Boolean(array.length);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var rem = array.slice(-1);
var ret = array.pop.apply(array, args); var ret = array.pop.apply(array, args);
this._notifySplice(array, path, array.length, 0, rem); if (hadLength) {
this._notifySplice(array, path, array.length, 0, [ret]);
}
return ret; return ret;
}, },
splice: function (path, start, deleteCount) { splice: function (path, start, deleteCount) {
var array = this.get(path); var array = this.get(path);
if (start < 0) {
start = array.length - Math.floor(-start);
} else {
start = Math.floor(start);
}
if (!start) {
start = 0;
}
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var ret = array.splice.apply(array, args); var ret = array.splice.apply(array, args);
this._notifySplice(array, path, start, args.length - 2, ret); var addedCount = Math.max(args.length - 2, 0);
if (addedCount || ret.length) {
this._notifySplice(array, path, start, addedCount, ret);
}
return ret; return ret;
}, },
shift: function (path) { shift: function (path) {
var array = this.get(path); var array = this.get(path);
var hadLength = Boolean(array.length);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var ret = array.shift.apply(array, args); var ret = array.shift.apply(array, args);
if (hadLength) {
this._notifySplice(array, path, 0, 0, [ret]); this._notifySplice(array, path, 0, 0, [ret]);
}
return ret; return ret;
}, },
unshift: function (path) { unshift: function (path) {
var array = this.get(path); var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var ret = array.unshift.apply(array, args); var ret = array.unshift.apply(array, args);
if (args.length) {
this._notifySplice(array, path, 0, args.length, []); this._notifySplice(array, path, 0, args.length, []);
}
return ret; return ret;
} }
}); });
@ -1956,7 +2074,7 @@ text = this._clean(text);
return this._parseCss(this._lex(text), text); return this._parseCss(this._lex(text), text);
}, },
_clean: function (cssText) { _clean: function (cssText) {
return cssText.replace(rx.comments, '').replace(rx.port, ''); return cssText.replace(this._rx.comments, '').replace(this._rx.port, '');
}, },
_lex: function (text) { _lex: function (text) {
var root = { var root = {
@ -1995,15 +2113,15 @@ var ss = node.previous ? node.previous.end : node.parent.start;
t = text.substring(ss, node.start - 1); t = text.substring(ss, node.start - 1);
t = t.substring(t.lastIndexOf(';') + 1); t = t.substring(t.lastIndexOf(';') + 1);
var s = node.parsedSelector = node.selector = t.trim(); var s = node.parsedSelector = node.selector = t.trim();
node.atRule = s.indexOf(AT_START) === 0; node.atRule = s.indexOf(this.AT_START) === 0;
if (node.atRule) { if (node.atRule) {
if (s.indexOf(MEDIA_START) === 0) { if (s.indexOf(this.MEDIA_START) === 0) {
node.type = this.types.MEDIA_RULE; node.type = this.types.MEDIA_RULE;
} else if (s.match(rx.keyframesRule)) { } else if (s.match(this._rx.keyframesRule)) {
node.type = this.types.KEYFRAMES_RULE; node.type = this.types.KEYFRAMES_RULE;
} }
} else { } else {
if (s.indexOf(VAR_START) === 0) { if (s.indexOf(this.VAR_START) === 0) {
node.type = this.types.MIXIN_RULE; node.type = this.types.MIXIN_RULE;
} else { } else {
node.type = this.types.STYLE_RULE; node.type = this.types.STYLE_RULE;
@ -2023,12 +2141,12 @@ text = text || '';
var cssText = ''; var cssText = '';
if (node.cssText || node.rules) { if (node.cssText || node.rules) {
var r$ = node.rules; var r$ = node.rules;
if (r$ && (preserveProperties || !hasMixinRules(r$))) { if (r$ && (preserveProperties || !this._hasMixinRules(r$))) {
for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
cssText = this.stringify(r, preserveProperties, cssText); cssText = this.stringify(r, preserveProperties, cssText);
} }
} else { } else {
cssText = preserveProperties ? node.cssText : removeCustomProps(node.cssText); cssText = preserveProperties ? node.cssText : this.removeCustomProps(node.cssText);
cssText = cssText.trim(); cssText = cssText.trim();
if (cssText) { if (cssText) {
cssText = ' ' + cssText + '\n'; cssText = ' ' + cssText + '\n';
@ -2046,6 +2164,19 @@ text += this.CLOSE_BRACE + '\n\n';
} }
return text; return text;
}, },
_hasMixinRules: function (rules) {
return rules[0].selector.indexOf(this.VAR_START) >= 0;
},
removeCustomProps: function (cssText) {
cssText = this.removeCustomPropAssignment(cssText);
return this.removeCustomPropApply(cssText);
},
removeCustomPropAssignment: function (cssText) {
return cssText.replace(this._rx.customProp, '').replace(this._rx.mixinProp, '');
},
removeCustomPropApply: function (cssText) {
return cssText.replace(this._rx.mixinApply, '').replace(this._rx.varApply, '');
},
types: { types: {
STYLE_RULE: 1, STYLE_RULE: 1,
KEYFRAMES_RULE: 7, KEYFRAMES_RULE: 7,
@ -2053,18 +2184,8 @@ MEDIA_RULE: 4,
MIXIN_RULE: 1000 MIXIN_RULE: 1000
}, },
OPEN_BRACE: '{', OPEN_BRACE: '{',
CLOSE_BRACE: '}' CLOSE_BRACE: '}',
}; _rx: {
function hasMixinRules(rules) {
return rules[0].selector.indexOf(VAR_START) >= 0;
}
function removeCustomProps(cssText) {
return cssText.replace(rx.customProp, '').replace(rx.mixinProp, '').replace(rx.mixinApply, '').replace(rx.varApply, '');
}
var VAR_START = '--';
var MEDIA_START = '@media';
var AT_START = '@';
var rx = {
comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim, comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
port: /@import[^;]*;/gim, port: /@import[^;]*;/gim,
customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim, customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
@ -2072,6 +2193,10 @@ mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim,
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim, mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim, varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim,
keyframesRule: /^@[^\s]*keyframes/ keyframesRule: /^@[^\s]*keyframes/
},
VAR_START: '--',
MEDIA_START: '@media',
AT_START: '@'
}; };
return api; return api;
}(); }();
@ -2104,7 +2229,7 @@ clearStyleRules: function (style) {
style.__cssRules = null; style.__cssRules = null;
}, },
forEachStyleRule: function (node, callback) { forEachStyleRule: function (node, callback) {
var s = node.selector; var s = node.parsedSelector;
var skipRules = false; var skipRules = false;
if (node.type === this.ruleTypes.STYLE_RULE) { if (node.type === this.ruleTypes.STYLE_RULE) {
callback(node); callback(node);
@ -2244,7 +2369,7 @@ var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) { for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
p$[i] = transformer.call(this, p, scope, hostScope); p$[i] = transformer.call(this, p, scope, hostScope);
} }
rule.selector = p$.join(COMPLEX_SELECTOR_SEP); rule.selector = rule.transformedSelector = p$.join(COMPLEX_SELECTOR_SEP);
}, },
_transformComplexSelector: function (selector, scope, hostScope) { _transformComplexSelector: function (selector, scope, hostScope) {
var stop = false; var stop = false;
@ -2599,7 +2724,8 @@ return property && property.trim() || '';
}, },
valueForProperties: function (property, props) { valueForProperties: function (property, props) {
var parts = property.split(';'); var parts = property.split(';');
for (var i = 0, p, m; i < parts.length && (p = parts[i]); i++) { for (var i = 0, p, m; i < parts.length; i++) {
if (p = parts[i]) {
m = p.match(this.rx.MIXIN_MATCH); m = p.match(this.rx.MIXIN_MATCH);
if (m) { if (m) {
p = this.valueForProperty(props[m[1]], props); p = this.valueForProperty(props[m[1]], props);
@ -2613,6 +2739,7 @@ p = pp.join(':');
} }
parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || ''; parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || '';
} }
}
return parts.join(';'); return parts.join(';');
}, },
applyProperties: function (rule, props) { applyProperties: function (rule, props) {
@ -2632,7 +2759,7 @@ styleUtil.forRulesInStyles(styles, function (rule) {
if (!rule.propertyInfo) { if (!rule.propertyInfo) {
self.decorateRule(rule); self.decorateRule(rule);
} }
if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.selector)) { if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.transformedSelector || rule.parsedSelector)) {
self.collectProperties(rule, props); self.collectProperties(rule, props);
addToBitMask(i, o); addToBitMask(i, o);
} }
@ -3030,9 +3157,9 @@ this._pushHost();
this._stampTemplate(); this._stampTemplate();
this._popHost(); this._popHost();
this._marshalAnnotationReferences(); this._marshalAnnotationReferences();
this._marshalHostAttributes();
this._setupDebouncers(); this._setupDebouncers();
this._marshalInstanceEffects(); this._marshalInstanceEffects();
this._marshalHostAttributes();
this._marshalBehaviors(); this._marshalBehaviors();
this._marshalAttributes(); this._marshalAttributes();
this._tryReady(); this._tryReady();
@ -3045,6 +3172,7 @@ this._listenListeners(b.listeners);
var nativeShadow = Polymer.Settings.useNativeShadow; var nativeShadow = Polymer.Settings.useNativeShadow;
var propertyUtils = Polymer.StyleProperties; var propertyUtils = Polymer.StyleProperties;
var styleUtil = Polymer.StyleUtil; var styleUtil = Polymer.StyleUtil;
var cssParse = Polymer.CssParse;
var styleDefaults = Polymer.StyleDefaults; var styleDefaults = Polymer.StyleDefaults;
var styleTransformer = Polymer.StyleTransformer; var styleTransformer = Polymer.StyleTransformer;
Polymer({ Polymer({
@ -3082,7 +3210,7 @@ var self = this;
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) { e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) {
var css = rule.cssText = rule.parsedCssText; var css = rule.cssText = rule.parsedCssText;
if (rule.propertyInfo && rule.propertyInfo.cssText) { if (rule.propertyInfo && rule.propertyInfo.cssText) {
css = css.replace(propertyUtils.rx.VAR_ASSIGN, ''); css = cssParse.removeCustomPropAssignment(css);
rule.cssText = propertyUtils.valueForProperties(css, props); rule.cssText = propertyUtils.valueForProperties(css, props);
} }
styleTransformer.documentRule(rule); styleTransformer.documentRule(rule);
@ -3130,10 +3258,24 @@ _showHideChildrenImpl: function (hide) {
var c = this._children; var c = this._children;
for (var i = 0; i < c.length; i++) { for (var i = 0; i < c.length; i++) {
var n = c[i]; var n = c[i];
if (n.style) { if (Boolean(hide) != Boolean(n.__hideTemplateChildren__)) {
n.style.display = hide ? 'none' : ''; if (n.nodeType === Node.TEXT_NODE) {
n.__hideTemplateChildren__ = hide; if (hide) {
n.__polymerTextContent__ = n.textContent;
n.textContent = '';
} else {
n.textContent = n.__polymerTextContent__;
} }
} else if (n.style) {
if (hide) {
n.__polymerDisplay__ = n.style.display;
n.style.display = 'none';
} else {
n.style.display = n.__polymerDisplay__;
}
}
}
n.__hideTemplateChildren__ = hide;
} }
}, },
_debounceTemplate: function (fn) { _debounceTemplate: function (fn) {
@ -3816,16 +3958,23 @@ is: 'array-selector',
properties: { properties: {
items: { items: {
type: Array, type: Array,
observer: '_itemsChanged' observer: '_resetSelection'
},
multi: {
type: Boolean,
value: false,
observer: '_resetSelection'
}, },
selected: { selected: {
type: Object, type: Object,
notify: true notify: true
}, },
toggle: Boolean, toggle: {
multi: Boolean type: Boolean,
value: false
}
}, },
_itemsChanged: function () { _resetSelection: function () {
if (Array.isArray(this.selected)) { if (Array.isArray(this.selected)) {
for (var i = 0; i < this.selected.length; i++) { for (var i = 0; i < this.selected.length; i++) {
this.unlinkPaths('selected.' + i); this.unlinkPaths('selected.' + i);
@ -3834,20 +3983,28 @@ this.unlinkPaths('selected.' + i);
this.unlinkPaths('selected'); this.unlinkPaths('selected');
} }
if (this.multi) { if (this.multi) {
if (!this.selected || this.selected.length) {
this.selected = []; this.selected = [];
this._selectedColl = Polymer.Collection.get(this.selected);
}
} else { } else {
this.selected = null; this.selected = null;
this._selectedColl = null;
}
},
isSelected: function (item) {
if (this.multi) {
return this._selectedColl.getKey(item) !== undefined;
} else {
return this.selected == item;
} }
}, },
deselect: function (item) { deselect: function (item) {
if (this.multi) { if (this.multi) {
var scol = Polymer.Collection.get(this.selected); if (this.isSelected(item)) {
var sidx = this.selected.indexOf(item); var skey = this._selectedColl.getKey(item);
if (sidx >= 0) { this.arrayDelete('selected', item);
var skey = scol.getKey(item);
this.splice('selected', sidx, 1);
this.unlinkPaths('selected.' + skey); this.unlinkPaths('selected.' + skey);
return true;
} }
} else { } else {
this.selected = null; this.selected = null;
@ -3858,18 +4015,14 @@ select: function (item) {
var icol = Polymer.Collection.get(this.items); var icol = Polymer.Collection.get(this.items);
var key = icol.getKey(item); var key = icol.getKey(item);
if (this.multi) { if (this.multi) {
var scol = Polymer.Collection.get(this.selected); if (this.isSelected(item)) {
var skey = scol.getKey(item);
if (skey >= 0) {
if (this.toggle) { if (this.toggle) {
this.deselect(item); this.deselect(item);
} }
} else { } else {
this.push('selected', item); this.push('selected', item);
this.async(function () { skey = this._selectedColl.getKey(item);
skey = scol.getKey(item);
this.linkPaths('selected.' + skey, 'items.' + key); this.linkPaths('selected.' + skey, 'items.' + key);
});
} }
} else { } else {
if (this.toggle && item == this.selected) { if (this.toggle && item == this.selected) {
@ -3914,7 +4067,6 @@ this._flushTemplates();
_render: function () { _render: function () {
if (this.if) { if (this.if) {
if (!this.ctor) { if (!this.ctor) {
this._wrapTextNodes(this._content || this.content);
this.templatize(this); this.templatize(this);
} }
this._ensureInstance(); this._ensureInstance();
@ -3950,16 +4102,6 @@ parent.removeChild(n);
this._instance = null; this._instance = null;
} }
}, },
_wrapTextNodes: function (root) {
for (var n = root.firstChild; n; n = n.nextSibling) {
if (n.nodeType === Node.TEXT_NODE && n.textContent.trim()) {
var s = document.createElement('span');
root.insertBefore(s, n);
s.appendChild(n);
n = s;
}
}
},
_showHideChildren: function () { _showHideChildren: function () {
var hidden = this.__hideTemplateChildren__ || !this.if; var hidden = this.__hideTemplateChildren__ || !this.if;
if (this._instance) { if (this._instance) {
@ -3977,37 +4119,11 @@ this._instance.notifyPath(path, value, true);
} }
} }
}); });
Polymer.ImportStatus = {
_ready: false,
_callbacks: [],
whenLoaded: function (cb) {
if (this._ready) {
cb();
} else {
this._callbacks.push(cb);
}
},
_importsLoaded: function () {
this._ready = true;
this._callbacks.forEach(function (cb) {
cb();
});
this._callbacks = [];
}
};
window.addEventListener('load', function () {
Polymer.ImportStatus._importsLoaded();
});
if (window.HTMLImports) {
HTMLImports.whenReady(function () {
Polymer.ImportStatus._importsLoaded();
});
}
Polymer({ Polymer({
is: 'dom-bind', is: 'dom-bind',
extends: 'template', extends: 'template',
created: function () { created: function () {
Polymer.ImportStatus.whenLoaded(this._markImportsReady.bind(this)); Polymer.RenderStatus.whenReady(this._markImportsReady.bind(this));
}, },
_ensureReady: function () { _ensureReady: function () {
if (!this._readied) { if (!this._readied) {

View file

@ -7,6 +7,10 @@
max-width: 100%; max-width: 100%;
} }
.neon-animating .tvGuideHeader {
position: static;
}
.bottomSecondaryNav .tvGuideHeader { .bottomSecondaryNav .tvGuideHeader {
top: 48px; top: 48px;
} }

View file

@ -36,7 +36,7 @@
var page = this; var page = this;
$('form').off('submit', onSubmit).on('submit', onSubmit); $('form', page).off('submit', onSubmit).on('submit', onSubmit);
$('.btnSelectSyncPath', page).on('click', function () { $('.btnSelectSyncPath', page).on('click', function () {

View file

@ -1699,6 +1699,7 @@ var AppInfo = {};
AppInfo.enableMovieTrailersTab = true; AppInfo.enableMovieTrailersTab = true;
} }
AppInfo.enableAppLayouts = true;
if (isCordova) { if (isCordova) {
AppInfo.enableAppLayouts = true; AppInfo.enableAppLayouts = true;
AppInfo.hasKnownExternalPlayerSupport = true; AppInfo.hasKnownExternalPlayerSupport = true;

View file

@ -119,6 +119,38 @@ get: function () {
return (document._currentScript || document.currentScript).ownerDocument; return (document._currentScript || document.currentScript).ownerDocument;
} }
}); });
Polymer.RenderStatus = {
_ready: false,
_callbacks: [],
whenReady: function (cb) {
if (this._ready) {
cb();
} else {
this._callbacks.push(cb);
}
},
_makeReady: function () {
this._ready = true;
this._callbacks.forEach(function (cb) {
cb();
});
this._callbacks = [];
},
_catchFirstRender: function () {
requestAnimationFrame(function () {
Polymer.RenderStatus._makeReady();
});
}
};
if (window.HTMLImports) {
HTMLImports.whenReady(function () {
Polymer.RenderStatus._catchFirstRender();
});
} else {
Polymer.RenderStatus._catchFirstRender();
}
Polymer.ImportStatus = Polymer.RenderStatus;
Polymer.ImportStatus.whenLoaded = Polymer.ImportStatus.whenReady;
Polymer.Base = { Polymer.Base = {
__isPolymerInstance__: true, __isPolymerInstance__: true,
_addFeature: function (feature) { _addFeature: function (feature) {
@ -135,17 +167,22 @@ this._doBehavior('created');
this._initFeatures(); this._initFeatures();
}, },
attachedCallback: function () { attachedCallback: function () {
Polymer.RenderStatus.whenReady(function () {
this.isAttached = true; this.isAttached = true;
this._doBehavior('attached'); this._doBehavior('attached');
}.bind(this));
}, },
detachedCallback: function () { detachedCallback: function () {
this.isAttached = false; this.isAttached = false;
this._doBehavior('detached'); this._doBehavior('detached');
}, },
attributeChangedCallback: function (name) { attributeChangedCallback: function (name) {
this._setAttributeToProperty(this, name); this._attributeChangedImpl(name);
this._doBehavior('attributeChanged', arguments); this._doBehavior('attributeChanged', arguments);
}, },
_attributeChangedImpl: function (name) {
this._setAttributeToProperty(this, name);
},
extend: function (prototype, api) { extend: function (prototype, api) {
if (prototype && api) { if (prototype && api) {
Object.getOwnPropertyNames(api).forEach(function (n) { Object.getOwnPropertyNames(api).forEach(function (n) {
@ -203,6 +240,7 @@ return Boolean(obj && obj.__isPolymerInstance__);
Polymer.telemetry.instanceCount = 0; Polymer.telemetry.instanceCount = 0;
(function () { (function () {
var modules = {}; var modules = {};
var lcModules = {};
var DomModule = function () { var DomModule = function () {
return document.createElement('dom-module'); return document.createElement('dom-module');
}; };
@ -217,10 +255,11 @@ var id = id || this.id || this.getAttribute('name') || this.getAttribute('is');
if (id) { if (id) {
this.id = id; this.id = id;
modules[id] = this; modules[id] = this;
lcModules[id.toLowerCase()] = this;
} }
}, },
import: function (id, selector) { import: function (id, selector) {
var m = modules[id]; var m = modules[id] || lcModules[id.toLowerCase()];
if (!m) { if (!m) {
forceDocumentUpgrade(); forceDocumentUpgrade();
m = modules[id]; m = modules[id];
@ -258,6 +297,9 @@ var id = module.id || module.getAttribute('name') || module.getAttribute('is');
this.is = id; this.is = id;
} }
} }
if (this.is) {
this.is = this.is.toLowerCase();
}
} }
}); });
Polymer.Base._addFeature({ Polymer.Base._addFeature({
@ -545,7 +587,7 @@ debouncer.stop();
} }
} }
}); });
Polymer.version = '1.0.8'; Polymer.version = '1.0.9';
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_registerFeatures: function () { _registerFeatures: function () {
this._prepIs(); this._prepIs();
@ -571,6 +613,10 @@ this._template = this._template || Polymer.DomModule.import(this.is, 'template')
if (this._template && this._template.hasAttribute('is')) { if (this._template && this._template.hasAttribute('is')) {
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.')); this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
} }
if (this._template && !this._template.content && HTMLTemplateElement.bootstrap) {
HTMLTemplateElement.decorate(this._template);
HTMLTemplateElement.bootstrap(this._template.content);
}
}, },
_stampTemplate: function () { _stampTemplate: function () {
if (this._template) { if (this._template) {
@ -991,6 +1037,14 @@ if (this.patch) {
this.patch(); this.patch();
} }
}; };
if (window.wrap && Settings.useShadow && !Settings.useNativeShadow) {
DomApi = function (node) {
this.node = wrap(node);
if (this.patch) {
this.patch();
}
};
}
DomApi.prototype = { DomApi.prototype = {
flush: function () { flush: function () {
Polymer.dom.flush(); Polymer.dom.flush();
@ -1064,6 +1118,9 @@ this.insertBefore(node, ref_node);
this.removeChild(ref_node); this.removeChild(ref_node);
return node; return node;
}, },
_hasCachedOwnerRoot: function (node) {
return Boolean(node._ownerShadyRoot !== undefined);
},
getOwnerRoot: function () { getOwnerRoot: function () {
return this._ownerShadyRootForNode(this.node); return this._ownerShadyRootForNode(this.node);
}, },
@ -1202,8 +1259,7 @@ children.splice(index, 1);
node._lightParent = null; node._lightParent = null;
}, },
_removeOwnerShadyRoot: function (node) { _removeOwnerShadyRoot: function (node) {
var hasCachedRoot = factory(node).getOwnerRoot() !== undefined; if (this._hasCachedOwnerRoot(node)) {
if (hasCachedRoot) {
var c$ = factory(node).childNodes; var c$ = factory(node).childNodes;
for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) { for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) {
this._removeOwnerShadyRoot(n); this._removeOwnerShadyRoot(n);
@ -2435,6 +2491,19 @@ var MOUSE_EVENTS = [
'mouseup', 'mouseup',
'click' 'click'
]; ];
var MOUSE_WHICH_TO_BUTTONS = [
0,
1,
4,
2
];
var MOUSE_HAS_BUTTONS = function () {
try {
return new MouseEvent('test', { buttons: 1 }).buttons === 1;
} catch (e) {
return false;
}
}();
var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/); var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
var mouseCanceller = function (mouseEvent) { var mouseCanceller = function (mouseEvent) {
mouseEvent[HANDLED_OBJ] = { skip: true }; mouseEvent[HANDLED_OBJ] = { skip: true };
@ -2473,6 +2542,34 @@ POINTERSTATE.mouse.mouseIgnoreJob = null;
}; };
POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT); POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT);
} }
function hasLeftMouseButton(ev) {
var type = ev.type;
if (MOUSE_EVENTS.indexOf(type) === -1) {
return false;
}
if (type === 'mousemove') {
var buttons = ev.buttons === undefined ? 1 : ev.buttons;
if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0;
}
return Boolean(buttons & 1);
} else {
var button = ev.button === undefined ? 0 : ev.button;
return button === 0;
}
}
function isSyntheticClick(ev) {
if (ev.type === 'click') {
if (ev.detail === 0) {
return true;
}
var t = Gestures.findOriginalTarget(ev);
var bcr = t.getBoundingClientRect();
var x = ev.pageX, y = ev.pageY;
return !(x >= bcr.left && x <= bcr.right && (y >= bcr.top && y <= bcr.bottom));
}
return false;
}
var POINTERSTATE = { var POINTERSTATE = {
mouse: { mouse: {
target: null, target: null,
@ -2497,6 +2594,16 @@ break;
} }
return ta; return ta;
} }
function trackDocument(stateObj, movefn, upfn) {
stateObj.movefn = movefn;
stateObj.upfn = upfn;
document.addEventListener('mousemove', movefn);
document.addEventListener('mouseup', upfn);
}
function untrackDocument(stateObj) {
document.removeEventListener('mousemove', stateObj.movefn);
document.removeEventListener('mouseup', stateObj.upfn);
}
var Gestures = { var Gestures = {
gestures: {}, gestures: {},
recognizers: [], recognizers: [],
@ -2597,8 +2704,7 @@ prevent = dy > dx;
prevent = dx > dy; prevent = dx > dy;
} }
if (prevent) { if (prevent) {
// This prevents side scrolling in safari ev.preventDefault();
//ev.preventDefault();
} else { } else {
Gestures.prevent('track'); Gestures.prevent('track');
} }
@ -2703,18 +2809,48 @@ deps: [
'touchstart', 'touchstart',
'touchend' 'touchend'
], ],
flow: {
start: [
'mousedown',
'touchstart'
],
end: [
'mouseup',
'touchend'
]
},
emits: [ emits: [
'down', 'down',
'up' 'up'
], ],
info: {
movefn: function () {
},
upfn: function () {
}
},
reset: function () {
untrackDocument(this.info);
},
mousedown: function (e) { mousedown: function (e) {
if (!hasLeftMouseButton(e)) {
return;
}
var t = Gestures.findOriginalTarget(e); var t = Gestures.findOriginalTarget(e);
var self = this; var self = this;
var upfn = function upfn(e) { var movefn = function movefn(e) {
if (!hasLeftMouseButton(e)) {
self.fire('up', t, e); self.fire('up', t, e);
document.removeEventListener('mouseup', upfn); untrackDocument(self.info);
}
}; };
document.addEventListener('mouseup', upfn); var upfn = function upfn(e) {
if (hasLeftMouseButton(e)) {
self.fire('up', t, e);
}
untrackDocument(self.info);
};
trackDocument(this.info, movefn, upfn);
this.fire('down', t, e); this.fire('down', t, e);
}, },
touchstart: function (e) { touchstart: function (e) {
@ -2765,6 +2901,10 @@ this.moves.shift();
} }
this.moves.push(move); this.moves.push(move);
}, },
movefn: function () {
},
upfn: function () {
},
prevent: false prevent: false
}, },
reset: function () { reset: function () {
@ -2774,6 +2914,7 @@ this.info.moves = [];
this.info.x = 0; this.info.x = 0;
this.info.y = 0; this.info.y = 0;
this.info.prevent = false; this.info.prevent = false;
untrackDocument(this.info);
}, },
hasMovedEnough: function (x, y) { hasMovedEnough: function (x, y) {
if (this.info.prevent) { if (this.info.prevent) {
@ -2787,6 +2928,9 @@ var dy = Math.abs(this.info.y - y);
return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE; return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
}, },
mousedown: function (e) { mousedown: function (e) {
if (!hasLeftMouseButton(e)) {
return;
}
var t = Gestures.findOriginalTarget(e); var t = Gestures.findOriginalTarget(e);
var self = this; var self = this;
var movefn = function movefn(e) { var movefn = function movefn(e) {
@ -2797,6 +2941,10 @@ self.info.addMove({
x: x, x: x,
y: y y: y
}); });
if (!hasLeftMouseButton(e)) {
self.info.state = 'end';
untrackDocument(self.info);
}
self.fire(t, e); self.fire(t, e);
self.info.started = true; self.info.started = true;
} }
@ -2806,11 +2954,9 @@ if (self.info.started) {
Gestures.prevent('tap'); Gestures.prevent('tap');
movefn(e); movefn(e);
} }
document.removeEventListener('mousemove', movefn); untrackDocument(self.info);
document.removeEventListener('mouseup', upfn);
}; };
document.addEventListener('mousemove', movefn); trackDocument(this.info, movefn, upfn);
document.addEventListener('mouseup', upfn);
this.info.x = e.clientX; this.info.x = e.clientX;
this.info.y = e.clientY; this.info.y = e.clientY;
}, },
@ -2905,10 +3051,14 @@ this.info.x = e.clientX;
this.info.y = e.clientY; this.info.y = e.clientY;
}, },
mousedown: function (e) { mousedown: function (e) {
if (hasLeftMouseButton(e)) {
this.save(e); this.save(e);
}
}, },
click: function (e) { click: function (e) {
if (hasLeftMouseButton(e)) {
this.forward(e); this.forward(e);
}
}, },
touchstart: function (e) { touchstart: function (e) {
this.save(e.changedTouches[0]); this.save(e.changedTouches[0]);
@ -2920,7 +3070,7 @@ forward: function (e) {
var dx = Math.abs(e.clientX - this.info.x); var dx = Math.abs(e.clientX - this.info.x);
var dy = Math.abs(e.clientY - this.info.y); var dy = Math.abs(e.clientY - this.info.y);
var t = Gestures.findOriginalTarget(e); var t = Gestures.findOriginalTarget(e);
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) { if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE || isSyntheticClick(e)) {
if (!this.info.prevent) { if (!this.info.prevent) {
Gestures.fire(t, 'tap', { Gestures.fire(t, 'tap', {
x: e.clientX, x: e.clientX,
@ -3541,7 +3691,7 @@ trigger: trigger
}); });
}, },
_parseMethod: function (expression) { _parseMethod: function (expression) {
var m = expression.match(/(\w*)\((.*)\)/); var m = expression.match(/([^\s]+)\((.*)\)/);
if (m) { if (m) {
var sig = { var sig = {
method: m[1], method: m[1],
@ -3636,6 +3786,10 @@ this._handlers = [];
_marshalAttributes: function () { _marshalAttributes: function () {
this._takeAttributesToModel(this._config); this._takeAttributesToModel(this._config);
}, },
_attributeChangedImpl: function (name) {
var model = this._clientsReadied ? this : this._config;
this._setAttributeToProperty(model, name);
},
_configValue: function (name, value) { _configValue: function (name, value) {
this._config[name] = value; this._config[name] = value;
}, },
@ -3915,36 +4069,56 @@ var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var len = array.length; var len = array.length;
var ret = array.push.apply(array, args); var ret = array.push.apply(array, args);
if (args.length) {
this._notifySplice(array, path, len, args.length, []); this._notifySplice(array, path, len, args.length, []);
}
return ret; return ret;
}, },
pop: function (path) { pop: function (path) {
var array = this.get(path); var array = this.get(path);
var hadLength = Boolean(array.length);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var rem = array.slice(-1);
var ret = array.pop.apply(array, args); var ret = array.pop.apply(array, args);
this._notifySplice(array, path, array.length, 0, rem); if (hadLength) {
this._notifySplice(array, path, array.length, 0, [ret]);
}
return ret; return ret;
}, },
splice: function (path, start, deleteCount) { splice: function (path, start, deleteCount) {
var array = this.get(path); var array = this.get(path);
if (start < 0) {
start = array.length - Math.floor(-start);
} else {
start = Math.floor(start);
}
if (!start) {
start = 0;
}
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var ret = array.splice.apply(array, args); var ret = array.splice.apply(array, args);
this._notifySplice(array, path, start, args.length - 2, ret); var addedCount = Math.max(args.length - 2, 0);
if (addedCount || ret.length) {
this._notifySplice(array, path, start, addedCount, ret);
}
return ret; return ret;
}, },
shift: function (path) { shift: function (path) {
var array = this.get(path); var array = this.get(path);
var hadLength = Boolean(array.length);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var ret = array.shift.apply(array, args); var ret = array.shift.apply(array, args);
if (hadLength) {
this._notifySplice(array, path, 0, 0, [ret]); this._notifySplice(array, path, 0, 0, [ret]);
}
return ret; return ret;
}, },
unshift: function (path) { unshift: function (path) {
var array = this.get(path); var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
var ret = array.unshift.apply(array, args); var ret = array.unshift.apply(array, args);
if (args.length) {
this._notifySplice(array, path, 0, args.length, []); this._notifySplice(array, path, 0, args.length, []);
}
return ret; return ret;
} }
}); });
@ -3967,7 +4141,7 @@ text = this._clean(text);
return this._parseCss(this._lex(text), text); return this._parseCss(this._lex(text), text);
}, },
_clean: function (cssText) { _clean: function (cssText) {
return cssText.replace(rx.comments, '').replace(rx.port, ''); return cssText.replace(this._rx.comments, '').replace(this._rx.port, '');
}, },
_lex: function (text) { _lex: function (text) {
var root = { var root = {
@ -4006,15 +4180,15 @@ var ss = node.previous ? node.previous.end : node.parent.start;
t = text.substring(ss, node.start - 1); t = text.substring(ss, node.start - 1);
t = t.substring(t.lastIndexOf(';') + 1); t = t.substring(t.lastIndexOf(';') + 1);
var s = node.parsedSelector = node.selector = t.trim(); var s = node.parsedSelector = node.selector = t.trim();
node.atRule = s.indexOf(AT_START) === 0; node.atRule = s.indexOf(this.AT_START) === 0;
if (node.atRule) { if (node.atRule) {
if (s.indexOf(MEDIA_START) === 0) { if (s.indexOf(this.MEDIA_START) === 0) {
node.type = this.types.MEDIA_RULE; node.type = this.types.MEDIA_RULE;
} else if (s.match(rx.keyframesRule)) { } else if (s.match(this._rx.keyframesRule)) {
node.type = this.types.KEYFRAMES_RULE; node.type = this.types.KEYFRAMES_RULE;
} }
} else { } else {
if (s.indexOf(VAR_START) === 0) { if (s.indexOf(this.VAR_START) === 0) {
node.type = this.types.MIXIN_RULE; node.type = this.types.MIXIN_RULE;
} else { } else {
node.type = this.types.STYLE_RULE; node.type = this.types.STYLE_RULE;
@ -4034,12 +4208,12 @@ text = text || '';
var cssText = ''; var cssText = '';
if (node.cssText || node.rules) { if (node.cssText || node.rules) {
var r$ = node.rules; var r$ = node.rules;
if (r$ && (preserveProperties || !hasMixinRules(r$))) { if (r$ && (preserveProperties || !this._hasMixinRules(r$))) {
for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
cssText = this.stringify(r, preserveProperties, cssText); cssText = this.stringify(r, preserveProperties, cssText);
} }
} else { } else {
cssText = preserveProperties ? node.cssText : removeCustomProps(node.cssText); cssText = preserveProperties ? node.cssText : this.removeCustomProps(node.cssText);
cssText = cssText.trim(); cssText = cssText.trim();
if (cssText) { if (cssText) {
cssText = ' ' + cssText + '\n'; cssText = ' ' + cssText + '\n';
@ -4057,6 +4231,19 @@ text += this.CLOSE_BRACE + '\n\n';
} }
return text; return text;
}, },
_hasMixinRules: function (rules) {
return rules[0].selector.indexOf(this.VAR_START) >= 0;
},
removeCustomProps: function (cssText) {
cssText = this.removeCustomPropAssignment(cssText);
return this.removeCustomPropApply(cssText);
},
removeCustomPropAssignment: function (cssText) {
return cssText.replace(this._rx.customProp, '').replace(this._rx.mixinProp, '');
},
removeCustomPropApply: function (cssText) {
return cssText.replace(this._rx.mixinApply, '').replace(this._rx.varApply, '');
},
types: { types: {
STYLE_RULE: 1, STYLE_RULE: 1,
KEYFRAMES_RULE: 7, KEYFRAMES_RULE: 7,
@ -4064,18 +4251,8 @@ MEDIA_RULE: 4,
MIXIN_RULE: 1000 MIXIN_RULE: 1000
}, },
OPEN_BRACE: '{', OPEN_BRACE: '{',
CLOSE_BRACE: '}' CLOSE_BRACE: '}',
}; _rx: {
function hasMixinRules(rules) {
return rules[0].selector.indexOf(VAR_START) >= 0;
}
function removeCustomProps(cssText) {
return cssText.replace(rx.customProp, '').replace(rx.mixinProp, '').replace(rx.mixinApply, '').replace(rx.varApply, '');
}
var VAR_START = '--';
var MEDIA_START = '@media';
var AT_START = '@';
var rx = {
comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim, comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
port: /@import[^;]*;/gim, port: /@import[^;]*;/gim,
customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim, customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
@ -4083,6 +4260,10 @@ mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim,
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim, mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim, varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim,
keyframesRule: /^@[^\s]*keyframes/ keyframesRule: /^@[^\s]*keyframes/
},
VAR_START: '--',
MEDIA_START: '@media',
AT_START: '@'
}; };
return api; return api;
}(); }();
@ -4115,7 +4296,7 @@ clearStyleRules: function (style) {
style.__cssRules = null; style.__cssRules = null;
}, },
forEachStyleRule: function (node, callback) { forEachStyleRule: function (node, callback) {
var s = node.selector; var s = node.parsedSelector;
var skipRules = false; var skipRules = false;
if (node.type === this.ruleTypes.STYLE_RULE) { if (node.type === this.ruleTypes.STYLE_RULE) {
callback(node); callback(node);
@ -4255,7 +4436,7 @@ var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) { for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
p$[i] = transformer.call(this, p, scope, hostScope); p$[i] = transformer.call(this, p, scope, hostScope);
} }
rule.selector = p$.join(COMPLEX_SELECTOR_SEP); rule.selector = rule.transformedSelector = p$.join(COMPLEX_SELECTOR_SEP);
}, },
_transformComplexSelector: function (selector, scope, hostScope) { _transformComplexSelector: function (selector, scope, hostScope) {
var stop = false; var stop = false;
@ -4610,7 +4791,8 @@ return property && property.trim() || '';
}, },
valueForProperties: function (property, props) { valueForProperties: function (property, props) {
var parts = property.split(';'); var parts = property.split(';');
for (var i = 0, p, m; i < parts.length && (p = parts[i]); i++) { for (var i = 0, p, m; i < parts.length; i++) {
if (p = parts[i]) {
m = p.match(this.rx.MIXIN_MATCH); m = p.match(this.rx.MIXIN_MATCH);
if (m) { if (m) {
p = this.valueForProperty(props[m[1]], props); p = this.valueForProperty(props[m[1]], props);
@ -4624,6 +4806,7 @@ p = pp.join(':');
} }
parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || ''; parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || '';
} }
}
return parts.join(';'); return parts.join(';');
}, },
applyProperties: function (rule, props) { applyProperties: function (rule, props) {
@ -4643,7 +4826,7 @@ styleUtil.forRulesInStyles(styles, function (rule) {
if (!rule.propertyInfo) { if (!rule.propertyInfo) {
self.decorateRule(rule); self.decorateRule(rule);
} }
if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.selector)) { if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.transformedSelector || rule.parsedSelector)) {
self.collectProperties(rule, props); self.collectProperties(rule, props);
addToBitMask(i, o); addToBitMask(i, o);
} }
@ -5041,9 +5224,9 @@ this._pushHost();
this._stampTemplate(); this._stampTemplate();
this._popHost(); this._popHost();
this._marshalAnnotationReferences(); this._marshalAnnotationReferences();
this._marshalHostAttributes();
this._setupDebouncers(); this._setupDebouncers();
this._marshalInstanceEffects(); this._marshalInstanceEffects();
this._marshalHostAttributes();
this._marshalBehaviors(); this._marshalBehaviors();
this._marshalAttributes(); this._marshalAttributes();
this._tryReady(); this._tryReady();
@ -5056,6 +5239,7 @@ this._listenListeners(b.listeners);
var nativeShadow = Polymer.Settings.useNativeShadow; var nativeShadow = Polymer.Settings.useNativeShadow;
var propertyUtils = Polymer.StyleProperties; var propertyUtils = Polymer.StyleProperties;
var styleUtil = Polymer.StyleUtil; var styleUtil = Polymer.StyleUtil;
var cssParse = Polymer.CssParse;
var styleDefaults = Polymer.StyleDefaults; var styleDefaults = Polymer.StyleDefaults;
var styleTransformer = Polymer.StyleTransformer; var styleTransformer = Polymer.StyleTransformer;
Polymer({ Polymer({
@ -5093,7 +5277,7 @@ var self = this;
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) { e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) {
var css = rule.cssText = rule.parsedCssText; var css = rule.cssText = rule.parsedCssText;
if (rule.propertyInfo && rule.propertyInfo.cssText) { if (rule.propertyInfo && rule.propertyInfo.cssText) {
css = css.replace(propertyUtils.rx.VAR_ASSIGN, ''); css = cssParse.removeCustomPropAssignment(css);
rule.cssText = propertyUtils.valueForProperties(css, props); rule.cssText = propertyUtils.valueForProperties(css, props);
} }
styleTransformer.documentRule(rule); styleTransformer.documentRule(rule);
@ -5141,10 +5325,24 @@ _showHideChildrenImpl: function (hide) {
var c = this._children; var c = this._children;
for (var i = 0; i < c.length; i++) { for (var i = 0; i < c.length; i++) {
var n = c[i]; var n = c[i];
if (n.style) { if (Boolean(hide) != Boolean(n.__hideTemplateChildren__)) {
n.style.display = hide ? 'none' : ''; if (n.nodeType === Node.TEXT_NODE) {
n.__hideTemplateChildren__ = hide; if (hide) {
n.__polymerTextContent__ = n.textContent;
n.textContent = '';
} else {
n.textContent = n.__polymerTextContent__;
} }
} else if (n.style) {
if (hide) {
n.__polymerDisplay__ = n.style.display;
n.style.display = 'none';
} else {
n.style.display = n.__polymerDisplay__;
}
}
}
n.__hideTemplateChildren__ = hide;
} }
}, },
_debounceTemplate: function (fn) { _debounceTemplate: function (fn) {
@ -5827,16 +6025,23 @@ is: 'array-selector',
properties: { properties: {
items: { items: {
type: Array, type: Array,
observer: '_itemsChanged' observer: '_resetSelection'
},
multi: {
type: Boolean,
value: false,
observer: '_resetSelection'
}, },
selected: { selected: {
type: Object, type: Object,
notify: true notify: true
}, },
toggle: Boolean, toggle: {
multi: Boolean type: Boolean,
value: false
}
}, },
_itemsChanged: function () { _resetSelection: function () {
if (Array.isArray(this.selected)) { if (Array.isArray(this.selected)) {
for (var i = 0; i < this.selected.length; i++) { for (var i = 0; i < this.selected.length; i++) {
this.unlinkPaths('selected.' + i); this.unlinkPaths('selected.' + i);
@ -5845,20 +6050,28 @@ this.unlinkPaths('selected.' + i);
this.unlinkPaths('selected'); this.unlinkPaths('selected');
} }
if (this.multi) { if (this.multi) {
if (!this.selected || this.selected.length) {
this.selected = []; this.selected = [];
this._selectedColl = Polymer.Collection.get(this.selected);
}
} else { } else {
this.selected = null; this.selected = null;
this._selectedColl = null;
}
},
isSelected: function (item) {
if (this.multi) {
return this._selectedColl.getKey(item) !== undefined;
} else {
return this.selected == item;
} }
}, },
deselect: function (item) { deselect: function (item) {
if (this.multi) { if (this.multi) {
var scol = Polymer.Collection.get(this.selected); if (this.isSelected(item)) {
var sidx = this.selected.indexOf(item); var skey = this._selectedColl.getKey(item);
if (sidx >= 0) { this.arrayDelete('selected', item);
var skey = scol.getKey(item);
this.splice('selected', sidx, 1);
this.unlinkPaths('selected.' + skey); this.unlinkPaths('selected.' + skey);
return true;
} }
} else { } else {
this.selected = null; this.selected = null;
@ -5869,18 +6082,14 @@ select: function (item) {
var icol = Polymer.Collection.get(this.items); var icol = Polymer.Collection.get(this.items);
var key = icol.getKey(item); var key = icol.getKey(item);
if (this.multi) { if (this.multi) {
var scol = Polymer.Collection.get(this.selected); if (this.isSelected(item)) {
var skey = scol.getKey(item);
if (skey >= 0) {
if (this.toggle) { if (this.toggle) {
this.deselect(item); this.deselect(item);
} }
} else { } else {
this.push('selected', item); this.push('selected', item);
this.async(function () { skey = this._selectedColl.getKey(item);
skey = scol.getKey(item);
this.linkPaths('selected.' + skey, 'items.' + key); this.linkPaths('selected.' + skey, 'items.' + key);
});
} }
} else { } else {
if (this.toggle && item == this.selected) { if (this.toggle && item == this.selected) {
@ -5925,7 +6134,6 @@ this._flushTemplates();
_render: function () { _render: function () {
if (this.if) { if (this.if) {
if (!this.ctor) { if (!this.ctor) {
this._wrapTextNodes(this._content || this.content);
this.templatize(this); this.templatize(this);
} }
this._ensureInstance(); this._ensureInstance();
@ -5961,16 +6169,6 @@ parent.removeChild(n);
this._instance = null; this._instance = null;
} }
}, },
_wrapTextNodes: function (root) {
for (var n = root.firstChild; n; n = n.nextSibling) {
if (n.nodeType === Node.TEXT_NODE && n.textContent.trim()) {
var s = document.createElement('span');
root.insertBefore(s, n);
s.appendChild(n);
n = s;
}
}
},
_showHideChildren: function () { _showHideChildren: function () {
var hidden = this.__hideTemplateChildren__ || !this.if; var hidden = this.__hideTemplateChildren__ || !this.if;
if (this._instance) { if (this._instance) {
@ -5988,37 +6186,11 @@ this._instance.notifyPath(path, value, true);
} }
} }
}); });
Polymer.ImportStatus = {
_ready: false,
_callbacks: [],
whenLoaded: function (cb) {
if (this._ready) {
cb();
} else {
this._callbacks.push(cb);
}
},
_importsLoaded: function () {
this._ready = true;
this._callbacks.forEach(function (cb) {
cb();
});
this._callbacks = [];
}
};
window.addEventListener('load', function () {
Polymer.ImportStatus._importsLoaded();
});
if (window.HTMLImports) {
HTMLImports.whenReady(function () {
Polymer.ImportStatus._importsLoaded();
});
}
Polymer({ Polymer({
is: 'dom-bind', is: 'dom-bind',
extends: 'template', extends: 'template',
created: function () { created: function () {
Polymer.ImportStatus.whenLoaded(this._markImportsReady.bind(this)); Polymer.RenderStatus.whenReady(this._markImportsReady.bind(this));
}, },
_ensureReady: function () { _ensureReady: function () {
if (!this._readied) { if (!this._readied) {