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

update components

This commit is contained in:
Luke Pulverenti 2015-07-16 19:55:16 -04:00
parent 3e1f88f0b9
commit 2776720c6f
26 changed files with 291 additions and 213 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "iron-input", "name": "iron-input",
"version": "1.0.3", "version": "1.0.4",
"description": "An input element with data binding", "description": "An input element with data binding",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"
@ -33,11 +33,11 @@
"web-component-tester": "*", "web-component-tester": "*",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}, },
"_release": "1.0.3", "_release": "1.0.4",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.3", "tag": "v1.0.4",
"commit": "edb505f41d67120cb505deedb92aa69e90078d2f" "commit": "eebeeb1642ab3e9b1abd5012c1df038250741184"
}, },
"_source": "git://github.com/PolymerElements/iron-input.git", "_source": "git://github.com/PolymerElements/iron-input.git",
"_target": "^1.0.0", "_target": "^1.0.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "iron-input", "name": "iron-input",
"version": "1.0.3", "version": "1.0.4",
"description": "An input element with data binding", "description": "An input element with data binding",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"

View file

@ -41,7 +41,7 @@ It may be desirable to only allow users to enter certain characters. You can use
is separate from validation, and `allowed-pattern` does not affect how the input is validated. is separate from validation, and `allowed-pattern` does not affect how the input is validated.
<!-- only allow characters that match [0-9] --> <!-- only allow characters that match [0-9] -->
<input is="iron-input" prevent-invaild-input allowed-pattern="[0-9]"> <input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]">
@hero hero.svg @hero hero.svg
@demo demo/index.html @demo demo/index.html
@ -154,11 +154,16 @@ is separate from validation, and `allowed-pattern` does not affect how the input
// always matches the charCode. // always matches the charCode.
// None of this makes any sense. // None of this makes any sense.
var nonPrintable = // For these keys, ASCII code == browser keycode.
var anyNonPrintable =
(event.keyCode == 8) || // backspace (event.keyCode == 8) || // backspace
(event.keyCode == 13) || // enter
(event.keyCode == 27); // escape
// For these keys, make sure it's a browser keycode and not an ASCII code.
var mozNonPrintable =
(event.keyCode == 19) || // pause (event.keyCode == 19) || // pause
(event.keyCode == 20) || // caps lock (event.keyCode == 20) || // caps lock
(event.keyCode == 27) || // escape
(event.keyCode == 45) || // insert (event.keyCode == 45) || // insert
(event.keyCode == 46) || // delete (event.keyCode == 46) || // delete
(event.keyCode == 144) || // num lock (event.keyCode == 144) || // num lock
@ -166,7 +171,7 @@ is separate from validation, and `allowed-pattern` does not affect how the input
(event.keyCode > 32 && event.keyCode < 41) || // page up/down, end, home, arrows (event.keyCode > 32 && event.keyCode < 41) || // page up/down, end, home, arrows
(event.keyCode > 111 && event.keyCode < 124); // fn keys (event.keyCode > 111 && event.keyCode < 124); // fn keys
return !(event.charCode == 0 && nonPrintable); return !anyNonPrintable && !(event.charCode == 0 && mozNonPrintable);
}, },
_onKeypress: function(event) { _onKeypress: function(event) {

View file

@ -1,6 +1,6 @@
{ {
"name": "polymer", "name": "polymer",
"version": "1.0.6", "version": "1.0.7",
"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.6", "_release": "1.0.7",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.6", "tag": "v1.0.7",
"commit": "953fcba374812690c279abdacbfaf61e3e3aa347" "commit": "b39d0015ce5428232409eb3aca7ddefea899f894"
}, },
"_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.6", "version": "1.0.7",
"main": [ "main": [
"polymer.html" "polymer.html"
], ],

View file

@ -576,7 +576,8 @@ prevent = dy > dx;
prevent = dx > dy; prevent = dx > dy;
} }
if (prevent) { if (prevent) {
ev.preventDefault(); //This breaks scrolling in safari
//ev.preventDefault();
} }
} }
}, },

View file

@ -1,7 +1,7 @@
{ {
"name": "webcomponentsjs", "name": "webcomponentsjs",
"main": "webcomponents.js", "main": "webcomponents.js",
"version": "0.7.6", "version": "0.7.7",
"homepage": "http://webcomponents.org", "homepage": "http://webcomponents.org",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"
@ -15,11 +15,11 @@
], ],
"license": "BSD", "license": "BSD",
"ignore": [], "ignore": [],
"_release": "0.7.6", "_release": "0.7.7",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v0.7.6", "tag": "v0.7.7",
"commit": "401764710ac11f9ed8a175195107752af2f72eb6" "commit": "274327b631eeb8b48d49702e1f1570d5ce7fb93d"
}, },
"_source": "git://github.com/Polymer/webcomponentsjs.git", "_source": "git://github.com/Polymer/webcomponentsjs.git",
"_target": "^0.7.2", "_target": "^0.7.2",

View file

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.7.6 // @version 0.7.7
if (typeof WeakMap === "undefined") { if (typeof WeakMap === "undefined") {
(function() { (function() {
var defineProperty = Object.defineProperty; var defineProperty = Object.defineProperty;
@ -761,17 +761,23 @@ window.CustomElements.addModule(function(scope) {
var nativePrototype = HTMLElement.prototype; var nativePrototype = HTMLElement.prototype;
if (definition.is) { if (definition.is) {
var inst = document.createElement(definition.tag); var inst = document.createElement(definition.tag);
var expectedPrototype = Object.getPrototypeOf(inst); nativePrototype = Object.getPrototypeOf(inst);
if (expectedPrototype === definition.prototype) {
nativePrototype = expectedPrototype;
}
} }
var proto = definition.prototype, ancestor; var proto = definition.prototype, ancestor;
while (proto && proto !== nativePrototype) { var foundPrototype = false;
while (proto) {
if (proto == nativePrototype) {
foundPrototype = true;
}
ancestor = Object.getPrototypeOf(proto); ancestor = Object.getPrototypeOf(proto);
if (ancestor) {
proto.__proto__ = ancestor; proto.__proto__ = ancestor;
}
proto = ancestor; proto = ancestor;
} }
if (!foundPrototype) {
console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is);
}
definition.native = nativePrototype; definition.native = nativePrototype;
} }
} }
@ -833,6 +839,9 @@ window.CustomElements.addModule(function(scope) {
var isInstance; var isInstance;
if (!Object.__proto__ && !useNative) { if (!Object.__proto__ && !useNative) {
isInstance = function(obj, ctor) { isInstance = function(obj, ctor) {
if (obj instanceof ctor) {
return true;
}
var p = obj; var p = obj;
while (p) { while (p) {
if (p === ctor.prototype) { if (p === ctor.prototype) {

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.7.6 // @version 0.7.7
if (typeof WeakMap === "undefined") { if (typeof WeakMap === "undefined") {
(function() { (function() {
var defineProperty = Object.defineProperty; var defineProperty = Object.defineProperty;

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.7.6 // @version 0.7.7
if (typeof WeakMap === "undefined") { if (typeof WeakMap === "undefined") {
(function() { (function() {
var defineProperty = Object.defineProperty; var defineProperty = Object.defineProperty;

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.7.6 // @version 0.7.7
if (typeof WeakMap === "undefined") { if (typeof WeakMap === "undefined") {
(function() { (function() {
var defineProperty = Object.defineProperty; var defineProperty = Object.defineProperty;

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
{ {
"name": "webcomponentsjs", "name": "webcomponentsjs",
"main": "webcomponents.js", "main": "webcomponents.js",
"version": "0.7.6", "version": "0.7.7",
"homepage": "http://webcomponents.org", "homepage": "http://webcomponents.org",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"

View file

@ -1,6 +1,6 @@
{ {
"name": "webcomponents.js", "name": "webcomponents.js",
"version": "0.7.6", "version": "0.7.7",
"description": "webcomponents.js", "description": "webcomponents.js",
"main": "webcomponents.js", "main": "webcomponents.js",
"directories": { "directories": {

View file

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.7.6 // @version 0.7.7
window.WebComponents = window.WebComponents || {}; window.WebComponents = window.WebComponents || {};
(function(scope) { (function(scope) {
@ -29,7 +29,7 @@ window.WebComponents = window.WebComponents || {};
} }
} }
} }
if (flags.log && flags.log.split) { if (flags.log) {
var parts = flags.log.split(","); var parts = flags.log.split(",");
flags.log = {}; flags.log = {};
parts.forEach(function(f) { parts.forEach(function(f) {
@ -2072,17 +2072,23 @@ window.CustomElements.addModule(function(scope) {
var nativePrototype = HTMLElement.prototype; var nativePrototype = HTMLElement.prototype;
if (definition.is) { if (definition.is) {
var inst = document.createElement(definition.tag); var inst = document.createElement(definition.tag);
var expectedPrototype = Object.getPrototypeOf(inst); nativePrototype = Object.getPrototypeOf(inst);
if (expectedPrototype === definition.prototype) {
nativePrototype = expectedPrototype;
}
} }
var proto = definition.prototype, ancestor; var proto = definition.prototype, ancestor;
while (proto && proto !== nativePrototype) { var foundPrototype = false;
while (proto) {
if (proto == nativePrototype) {
foundPrototype = true;
}
ancestor = Object.getPrototypeOf(proto); ancestor = Object.getPrototypeOf(proto);
if (ancestor) {
proto.__proto__ = ancestor; proto.__proto__ = ancestor;
}
proto = ancestor; proto = ancestor;
} }
if (!foundPrototype) {
console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is);
}
definition.native = nativePrototype; definition.native = nativePrototype;
} }
} }
@ -2144,6 +2150,9 @@ window.CustomElements.addModule(function(scope) {
var isInstance; var isInstance;
if (!Object.__proto__ && !useNative) { if (!Object.__proto__ && !useNative) {
isInstance = function(obj, ctor) { isInstance = function(obj, ctor) {
if (obj instanceof ctor) {
return true;
}
var p = obj; var p = obj;
while (p) { while (p) {
if (p === ctor.prototype) { if (p === ctor.prototype) {

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.7.6 // @version 0.7.7
window.WebComponents = window.WebComponents || {}; window.WebComponents = window.WebComponents || {};
(function(scope) { (function(scope) {
@ -6841,17 +6841,23 @@ window.CustomElements.addModule(function(scope) {
var nativePrototype = HTMLElement.prototype; var nativePrototype = HTMLElement.prototype;
if (definition.is) { if (definition.is) {
var inst = document.createElement(definition.tag); var inst = document.createElement(definition.tag);
var expectedPrototype = Object.getPrototypeOf(inst); nativePrototype = Object.getPrototypeOf(inst);
if (expectedPrototype === definition.prototype) {
nativePrototype = expectedPrototype;
}
} }
var proto = definition.prototype, ancestor; var proto = definition.prototype, ancestor;
while (proto && proto !== nativePrototype) { var foundPrototype = false;
while (proto) {
if (proto == nativePrototype) {
foundPrototype = true;
}
ancestor = Object.getPrototypeOf(proto); ancestor = Object.getPrototypeOf(proto);
if (ancestor) {
proto.__proto__ = ancestor; proto.__proto__ = ancestor;
}
proto = ancestor; proto = ancestor;
} }
if (!foundPrototype) {
console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is);
}
definition.native = nativePrototype; definition.native = nativePrototype;
} }
} }
@ -6913,6 +6919,9 @@ window.CustomElements.addModule(function(scope) {
var isInstance; var isInstance;
if (!Object.__proto__ && !useNative) { if (!Object.__proto__ && !useNative) {
isInstance = function(obj, ctor) { isInstance = function(obj, ctor) {
if (obj instanceof ctor) {
return true;
}
var p = obj; var p = obj;
while (p) { while (p) {
if (p === ctor.prototype) { if (p === ctor.prototype) {

File diff suppressed because one or more lines are too long

View file

@ -72,8 +72,8 @@
} }
.pageWithAbsoluteTabs .pageTabContent { .pageWithAbsoluteTabs .pageTabContent {
padding-left: .3em !important; padding-left: .25em !important;
padding-right: .3em !important; padding-right: .25em !important;
} }
} }

View file

@ -28,7 +28,7 @@
<form class="editItemMetadataForm editMetadataForm"> <form class="editItemMetadataForm editMetadataForm">
<div class="metadataFormFields"> <div class="metadataFormFields">
<div style="margin:2em 0 .5em;"> <div style="margin:2em 0 .5em;text-align:center;">
<paper-button raised class="submit"> <paper-button raised class="submit">
<button class="btnSave clearButton" type="submit" data-role="none" style="display:inline-block;"> <button class="btnSave clearButton" type="submit" data-role="none" style="display:inline-block;">
@ -426,7 +426,7 @@
</neon-animatable> </neon-animatable>
<neon-animatable> <neon-animatable>
<div class="editorTab imageEditorTab"> <div class="editorTab imageEditorTab">
<div style="margin:2em 0 .5em;"> <div style="margin:2em 0 .5em;text-align:center;">
<paper-button raised class="subdued btnBrowseAllImages"><iron-icon icon="cloud"></iron-icon><span>${ButtonBrowseImages}</span></paper-button> <paper-button raised class="subdued btnBrowseAllImages"><iron-icon icon="cloud"></iron-icon><span>${ButtonBrowseImages}</span></paper-button>
<paper-button raised class="subdued btnOpenUploadMenu"><iron-icon icon="add"></iron-icon><span>${ButtonUpload}</span></paper-button> <paper-button raised class="subdued btnOpenUploadMenu"><iron-icon icon="add"></iron-icon><span>${ButtonUpload}</span></paper-button>

View file

@ -738,7 +738,7 @@
var html = ''; var html = '';
tasks = tasks.filter(function (t) { tasks = tasks.filter(function (t) {
return t.State != 'Idle'; return t.State != 'Idle' && !t.IsHidden;
}); });
if (tasks.filter(function (t) { if (tasks.filter(function (t) {

View file

@ -1375,7 +1375,7 @@
} }
} }
function showMoreMenu(page) { function showMoreMenu(page, elem) {
Dashboard.getCurrentUser().done(function (user) { Dashboard.getCurrentUser().done(function (user) {
@ -1401,6 +1401,7 @@
ActionSheetElement.show({ ActionSheetElement.show({
items: menuItems, items: menuItems,
positionTo: elem,
callback: function (id) { callback: function (id) {
switch (id) { switch (id) {
@ -1499,7 +1500,7 @@
page.querySelector('.btnMore iron-icon').icon = AppInfo.moreIcon; page.querySelector('.btnMore iron-icon').icon = AppInfo.moreIcon;
$('.btnMore', page).on('click', function () { $('.btnMore', page).on('click', function () {
showMoreMenu(page); showMoreMenu(page, this);
}); });
}).on('pageshowready', "#editItemMetadataPage", function () { }).on('pageshowready', "#editItemMetadataPage", function () {

View file

@ -75,7 +75,11 @@ document.registerElement(prototype.is, options);
return ctor; return ctor;
}; };
var desugar = function (prototype) { var desugar = function (prototype) {
prototype = Polymer.Base.chainObject(prototype, Polymer.Base); var base = Polymer.Base;
if (prototype.extends) {
base = Polymer.Base._getExtendedPrototype(prototype.extends);
}
prototype = Polymer.Base.chainObject(prototype, base);
prototype.registerCallback(); prototype.registerCallback();
return prototype.constructor; return prototype.constructor;
}; };
@ -108,6 +112,7 @@ return (document._currentScript || document.currentScript).ownerDocument;
} }
}); });
Polymer.Base = { Polymer.Base = {
__isPolymerInstance__: true,
_addFeature: function (feature) { _addFeature: function (feature) {
this.extend(this, feature); this.extend(this, feature);
}, },
@ -177,6 +182,16 @@ object.__proto__ = inherited;
return object; return object;
}; };
Polymer.Base = Polymer.Base.chainObject(Polymer.Base, HTMLElement.prototype); Polymer.Base = Polymer.Base.chainObject(Polymer.Base, HTMLElement.prototype);
if (window.CustomElements) {
Polymer.instanceof = CustomElements.instanceof;
} else {
Polymer.instanceof = function (obj, ctor) {
return obj instanceof ctor;
};
}
Polymer.isInstance = function (obj) {
return Boolean(obj && obj.__isPolymerInstance__);
};
Polymer.telemetry.instanceCount = 0; Polymer.telemetry.instanceCount = 0;
(function () { (function () {
var modules = {}; var modules = {};
@ -305,11 +320,6 @@ this._marshalBehavior(this);
} }
}); });
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_prepExtends: function () {
if (this.extends) {
this.__proto__ = this._getExtendedPrototype(this.extends);
}
},
_getExtendedPrototype: function (tag) { _getExtendedPrototype: function (tag) {
return this._getExtendedNativePrototype(tag); return this._getExtendedNativePrototype(tag);
}, },
@ -522,13 +532,12 @@ debouncer.stop();
} }
} }
}); });
Polymer.version = '1.0.6'; Polymer.version = '1.0.7';
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_registerFeatures: function () { _registerFeatures: function () {
this._prepIs(); this._prepIs();
this._prepAttributes(); this._prepAttributes();
this._prepBehaviors(); this._prepBehaviors();
this._prepExtends();
this._prepConstructor(); this._prepConstructor();
}, },
_prepBehavior: function (b) { _prepBehavior: function (b) {
@ -1288,7 +1297,7 @@ d.appendChild(nc);
return n; return n;
}, },
importNode: function (externalNode, deep) { importNode: function (externalNode, deep) {
var doc = this.node instanceof HTMLDocument ? this.node : this.node.ownerDocument; var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
var n = nativeImportNode.call(doc, externalNode, false); var n = nativeImportNode.call(doc, externalNode, false);
if (deep) { if (deep) {
var c$ = factory(externalNode).childNodes; var c$ = factory(externalNode).childNodes;
@ -1476,15 +1485,15 @@ DomApi.prototype.cloneNode = function (deep) {
return this.node.cloneNode(deep); return this.node.cloneNode(deep);
}; };
DomApi.prototype.importNode = function (externalNode, deep) { DomApi.prototype.importNode = function (externalNode, deep) {
var doc = this.node instanceof HTMLDocument ? this.node : this.node.ownerDocument; var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
return doc.importNode(externalNode, deep); return doc.importNode(externalNode, deep);
}; };
DomApi.prototype.getDestinationInsertionPoints = function () { DomApi.prototype.getDestinationInsertionPoints = function () {
var n$ = this.node.getDestinationInsertionPoints(); var n$ = this.node.getDestinationInsertionPoints && this.node.getDestinationInsertionPoints();
return n$ ? Array.prototype.slice.call(n$) : []; return n$ ? Array.prototype.slice.call(n$) : [];
}; };
DomApi.prototype.getDistributedNodes = function () { DomApi.prototype.getDistributedNodes = function () {
var n$ = this.node.getDistributedNodes(); var n$ = this.node.getDistributedNodes && this.node.getDistributedNodes();
return n$ ? Array.prototype.slice.call(n$) : []; return n$ ? Array.prototype.slice.call(n$) : [];
}; };
DomApi.prototype._distributeParent = function () { DomApi.prototype._distributeParent = function () {
@ -1942,7 +1951,6 @@ _registerFeatures: function () {
this._prepIs(); this._prepIs();
this._prepAttributes(); this._prepAttributes();
this._prepBehaviors(); this._prepBehaviors();
this._prepExtends();
this._prepConstructor(); this._prepConstructor();
this._prepTemplate(); this._prepTemplate();
this._prepShady(); this._prepShady();
@ -2023,6 +2031,14 @@ for (var i = 0, node = root.firstChild; node; node = node.nextSibling, i++) {
if (node.localName === 'template' && !node.hasAttribute('preserve-content')) { if (node.localName === 'template' && !node.hasAttribute('preserve-content')) {
this._parseTemplate(node, i, list, annote); this._parseTemplate(node, i, list, annote);
} }
if (node.nodeType === Node.TEXT_NODE) {
var n = node.nextSibling;
while (n && n.nodeType === Node.TEXT_NODE) {
node.textContent += n.textContent;
root.removeChild(n);
n = n.nextSibling;
}
}
var childAnnotation = this._parseNodeAnnotations(node, list, callback); var childAnnotation = this._parseNodeAnnotations(node, list, callback);
if (childAnnotation) { if (childAnnotation) {
childAnnotation.parent = annote; childAnnotation.parent = annote;
@ -2990,7 +3006,8 @@ Polymer.dom(toElement).setAttribute(name, '');
} }
}, },
getContentChildNodes: function (slctr) { getContentChildNodes: function (slctr) {
return Polymer.dom(Polymer.dom(this.root).querySelector(slctr || 'content')).getDistributedNodes(); var content = Polymer.dom(this.root).querySelector(slctr || 'content');
return content ? Polymer.dom(content).getDistributedNodes() : [];
}, },
getContentChildren: function (slctr) { getContentChildren: function (slctr) {
return this.getContentChildNodes(slctr).filter(function (n) { return this.getContentChildNodes(slctr).filter(function (n) {
@ -3994,9 +4011,11 @@ this.forEachStyleRule(rules, callback);
return this.parser.stringify(rules, preserveProperties); return this.parser.stringify(rules, preserveProperties);
}, },
forRulesInStyles: function (styles, callback) { forRulesInStyles: function (styles, callback) {
if (styles) {
for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) { for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
this.forEachStyleRule(this.rulesForStyle(s), callback); this.forEachStyleRule(this.rulesForStyle(s), callback);
} }
}
}, },
rulesForStyle: function (style) { rulesForStyle: function (style) {
if (!style.__cssRules && style.textContent) { if (!style.__cssRules && style.textContent) {
@ -4775,8 +4794,18 @@ if (!this._scopeSelector && this._needsStyleProperties()) {
this._updateStyleProperties(); this._updateStyleProperties();
} }
}, },
_findStyleHost: function () {
var e = this, root;
while (root = Polymer.dom(e).getOwnerRoot()) {
if (Polymer.isInstance(root.host)) {
return root.host;
}
e = root.host;
}
return styleDefaults;
},
_updateStyleProperties: function () { _updateStyleProperties: function () {
var info, scope = this.domHost || styleDefaults; var info, scope = this._findStyleHost();
if (!scope._styleCache) { if (!scope._styleCache) {
scope._styleCache = new Polymer.StyleCache(); scope._styleCache = new Polymer.StyleCache();
} }
@ -4811,7 +4840,7 @@ styleCache.store(this.is, Object.create(info), this._ownStyleProperties, this._s
} }
}, },
_computeStyleProperties: function (scopeProps) { _computeStyleProperties: function (scopeProps) {
var scope = this.domHost || styleDefaults; var scope = this._findStyleHost();
if (!scope._styleProperties) { if (!scope._styleProperties) {
scope._computeStyleProperties(); scope._computeStyleProperties();
} }
@ -4844,7 +4873,7 @@ return style;
}, },
serializeValueToAttribute: function (value, attribute, node) { serializeValueToAttribute: function (value, attribute, node) {
node = node || this; node = node || this;
if (attribute === 'class') { if (attribute === 'class' && !nativeShadow) {
var host = node === this ? this.domHost || this.dataHost : this; var host = node === this ? this.domHost || this.dataHost : this;
if (host) { if (host) {
value = host._scopeElementClass(node, value); value = host._scopeElementClass(node, value);
@ -4900,7 +4929,6 @@ Polymer.Base._addFeature({
_registerFeatures: function () { _registerFeatures: function () {
this._prepIs(); this._prepIs();
this._prepAttributes(); this._prepAttributes();
this._prepExtends();
this._prepConstructor(); this._prepConstructor();
this._prepTemplate(); this._prepTemplate();
this._prepStyles(); this._prepStyles();
@ -5370,19 +5398,18 @@ delay: Number
}, },
behaviors: [Polymer.Templatizer], behaviors: [Polymer.Templatizer],
observers: ['_itemsChanged(items.*)'], observers: ['_itemsChanged(items.*)'],
created: function () {
this._instances = [];
},
detached: function () { detached: function () {
if (this.rows) { for (var i = 0; i < this._instances.length; i++) {
for (var i = 0; i < this.rows.length; i++) {
this._detachRow(i); this._detachRow(i);
} }
}
}, },
attached: function () { attached: function () {
if (this.rows) {
var parentNode = Polymer.dom(this).parentNode; var parentNode = Polymer.dom(this).parentNode;
for (var i = 0; i < this.rows.length; i++) { for (var i = 0; i < this._instances.length; i++) {
Polymer.dom(parentNode).insertBefore(this.rows[i].root, this); Polymer.dom(parentNode).insertBefore(this._instances[i].root, this);
}
} }
}, },
ready: function () { ready: function () {
@ -5399,7 +5426,7 @@ var sort = this.sort;
this._sortFn = sort && (typeof sort == 'function' ? sort : function () { this._sortFn = sort && (typeof sort == 'function' ? sort : function () {
return dataHost[sort].apply(dataHost, arguments); return dataHost[sort].apply(dataHost, arguments);
}); });
this._fullRefresh = true; this._needFullRefresh = true;
if (this.items) { if (this.items) {
this._debounceTemplate(this._render); this._debounceTemplate(this._render);
} }
@ -5410,7 +5437,7 @@ var filter = this.filter;
this._filterFn = filter && (typeof filter == 'function' ? filter : function () { this._filterFn = filter && (typeof filter == 'function' ? filter : function () {
return dataHost[filter].apply(dataHost, arguments); return dataHost[filter].apply(dataHost, arguments);
}); });
this._fullRefresh = true; this._needFullRefresh = true;
if (this.items) { if (this.items) {
this._debounceTemplate(this._render); this._debounceTemplate(this._render);
} }
@ -5428,7 +5455,7 @@ this.collection = null;
this._error(this._logf('dom-repeat', 'expected array for `items`,' + ' found', this.items)); this._error(this._logf('dom-repeat', 'expected array for `items`,' + ' found', this.items));
} }
this._splices = []; this._splices = [];
this._fullRefresh = true; this._needFullRefresh = true;
this._debounceTemplate(this._render); this._debounceTemplate(this._render);
} else if (change.path == 'items.splices') { } else if (change.path == 'items.splices') {
this._splices = this._splices.concat(change.value.keySplices); this._splices = this._splices.concat(change.value.keySplices);
@ -5445,7 +5472,7 @@ path = path.substring(path.indexOf('.') + 1);
var paths = this._observePaths; var paths = this._observePaths;
for (var i = 0; i < paths.length; i++) { for (var i = 0; i < paths.length; i++) {
if (path.indexOf(paths[i]) === 0) { if (path.indexOf(paths[i]) === 0) {
this._fullRefresh = true; this._needFullRefresh = true;
if (this.delay) { if (this.delay) {
this.debounce('render', this._render, this.delay); this.debounce('render', this._render, this.delay);
} else { } else {
@ -5457,102 +5484,111 @@ return;
} }
}, },
render: function () { render: function () {
this._fullRefresh = true; this._needFullRefresh = true;
this._debounceTemplate(this._render); this._debounceTemplate(this._render);
this._flushTemplates(); this._flushTemplates();
}, },
_render: function () { _render: function () {
var c = this.collection; var c = this.collection;
if (!this._fullRefresh) { if (this._needFullRefresh) {
this._applyFullRefresh();
this._needFullRefresh = false;
} else {
if (this._sortFn) { if (this._sortFn) {
this._applySplicesViewSort(this._splices); this._applySplicesUserSort(this._splices);
} else { } else {
if (this._filterFn) { if (this._filterFn) {
this._fullRefresh = true; this._applyFullRefresh();
} else { } else {
this._applySplicesArraySort(this._splices); this._applySplicesArrayOrder(this._splices);
} }
} }
} }
if (this._fullRefresh) {
this._sortAndFilter();
this._fullRefresh = false;
}
this._splices = []; this._splices = [];
var rowForKey = this._rowForKey = {}; var keyToIdx = this._keyToInstIdx = {};
var keys = this._orderedKeys; for (var i = 0; i < this._instances.length; i++) {
this.rows = this.rows || []; var inst = this._instances[i];
for (var i = 0; i < keys.length; i++) { keyToIdx[inst.__key__] = i;
var key = keys[i]; inst.__setProperty(this.indexAs, i, true);
var item = c.getItem(key);
var row = this.rows[i];
rowForKey[key] = i;
if (!row) {
this.rows.push(row = this._insertRow(i, null, item));
} }
row.__setProperty(this.as, item, true);
row.__setProperty('__key__', key, true);
row.__setProperty(this.indexAs, i, true);
}
for (; i < this.rows.length; i++) {
this._detachRow(i);
}
this.rows.splice(keys.length, this.rows.length - keys.length);
this.fire('dom-change'); this.fire('dom-change');
}, },
_sortAndFilter: function () { _applyFullRefresh: function () {
var c = this.collection; var c = this.collection;
if (!this._sortFn) { var keys;
this._orderedKeys = []; if (this._sortFn) {
keys = c ? c.getKeys() : [];
} else {
keys = [];
var items = this.items; var items = this.items;
if (items) { if (items) {
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {
this._orderedKeys.push(c.getKey(items[i])); keys.push(c.getKey(items[i]));
} }
} }
} else {
this._orderedKeys = c ? c.getKeys() : [];
} }
if (this._filterFn) { if (this._filterFn) {
this._orderedKeys = this._orderedKeys.filter(function (a) { keys = keys.filter(function (a) {
return this._filterFn(c.getItem(a)); return this._filterFn(c.getItem(a));
}, this); }, this);
} }
if (this._sortFn) { if (this._sortFn) {
this._orderedKeys.sort(function (a, b) { keys.sort(function (a, b) {
return this._sortFn(c.getItem(a), c.getItem(b)); return this._sortFn(c.getItem(a), c.getItem(b));
}.bind(this)); }.bind(this));
} }
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var inst = this._instances[i];
if (inst) {
inst.__setProperty('__key__', key, true);
inst.__setProperty(this.as, c.getItem(key), true);
} else {
this._instances.push(this._insertRow(i, key));
}
}
for (; i < this._instances.length; i++) {
this._detachRow(i);
}
this._instances.splice(keys.length, this._instances.length - keys.length);
}, },
_keySort: function (a, b) { _keySort: function (a, b) {
return this.collection.getKey(a) - this.collection.getKey(b); return this.collection.getKey(a) - this.collection.getKey(b);
}, },
_applySplicesViewSort: function (splices) { _applySplicesUserSort: function (splices) {
var c = this.collection; var c = this.collection;
var keys = this._orderedKeys; var instances = this._instances;
var rows = this.rows; var keyMap = {};
var removedRows = [];
var addedKeys = [];
var pool = []; var pool = [];
var sortFn = this._sortFn || this._keySort.bind(this); var sortFn = this._sortFn || this._keySort.bind(this);
splices.forEach(function (s) { splices.forEach(function (s) {
for (var i = 0; i < s.removed.length; i++) { for (var i = 0; i < s.removed.length; i++) {
var idx = this._rowForKey[s.removed[i]]; var key = s.removed[i];
if (idx != null) { keyMap[key] = keyMap[key] ? null : -1;
removedRows.push(idx);
}
} }
for (var i = 0; i < s.added.length; i++) { for (var i = 0; i < s.added.length; i++) {
addedKeys.push(s.added[i]); var key = s.added[i];
keyMap[key] = keyMap[key] ? null : 1;
} }
}, this); }, this);
if (removedRows.length) { var removedIdxs = [];
removedRows.sort(); var addedKeys = [];
for (var i = removedRows.length - 1; i >= 0; i--) { for (var key in keyMap) {
var idx = removedRows[i]; if (keyMap[key] === -1) {
removedIdxs.push(this._keyToInstIdx[key]);
}
if (keyMap[key] === 1) {
addedKeys.push(key);
}
}
if (removedIdxs.length) {
removedIdxs.sort();
for (var i = removedIdxs.length - 1; i >= 0; i--) {
var idx = removedIdxs[i];
if (idx !== undefined) {
pool.push(this._detachRow(idx)); pool.push(this._detachRow(idx));
rows.splice(idx, 1); instances.splice(idx, 1);
keys.splice(idx, 1); }
} }
} }
if (addedKeys.length) { if (addedKeys.length) {
@ -5566,19 +5602,19 @@ return this._sortFn(c.getItem(a), c.getItem(b));
}.bind(this)); }.bind(this));
var start = 0; var start = 0;
for (var i = 0; i < addedKeys.length; i++) { for (var i = 0; i < addedKeys.length; i++) {
start = this._insertRowIntoViewSort(start, addedKeys[i], pool); start = this._insertRowUserSort(start, addedKeys[i], pool);
} }
} }
}, },
_insertRowIntoViewSort: function (start, key, pool) { _insertRowUserSort: function (start, key, pool) {
var c = this.collection; var c = this.collection;
var item = c.getItem(key); var item = c.getItem(key);
var end = this.rows.length - 1; var end = this._instances.length - 1;
var idx = -1; var idx = -1;
var sortFn = this._sortFn || this._keySort.bind(this); var sortFn = this._sortFn || this._keySort.bind(this);
while (start <= end) { while (start <= end) {
var mid = start + end >> 1; var mid = start + end >> 1;
var midKey = this._orderedKeys[mid]; var midKey = this._instances[mid].__key__;
var cmp = sortFn(c.getItem(midKey), item); var cmp = sortFn(c.getItem(midKey), item);
if (cmp < 0) { if (cmp < 0) {
start = mid + 1; start = mid + 1;
@ -5592,106 +5628,110 @@ break;
if (idx < 0) { if (idx < 0) {
idx = end + 1; idx = end + 1;
} }
this._orderedKeys.splice(idx, 0, key); this._instances.splice(idx, 0, this._insertRow(idx, key, pool));
this.rows.splice(idx, 0, this._insertRow(idx, pool, c.getItem(key)));
return idx; return idx;
}, },
_applySplicesArraySort: function (splices) { _applySplicesArrayOrder: function (splices) {
var keys = this._orderedKeys;
var pool = []; var pool = [];
splices.forEach(function (s) {
for (var i = 0; i < s.removed.length; i++) {
pool.push(this._detachRow(s.index + i));
}
this.rows.splice(s.index, s.removed.length);
}, this);
var c = this.collection; var c = this.collection;
splices.forEach(function (s) { splices.forEach(function (s) {
var args = [ for (var i = 0; i < s.removed.length; i++) {
s.index, var inst = this._detachRow(s.index + i);
s.removed.length if (!inst.isPlaceholder) {
].concat(s.added); pool.push(inst);
keys.splice.apply(keys, args); }
}
this._instances.splice(s.index, s.removed.length);
for (var i = 0; i < s.added.length; i++) { for (var i = 0; i < s.added.length; i++) {
var item = c.getItem(s.added[i]); var inst = {
var row = this._insertRow(s.index + i, pool, item); isPlaceholder: true,
this.rows.splice(s.index + i, 0, row); key: s.added[i]
};
this._instances.splice(s.index + i, 0, inst);
} }
}, this); }, this);
for (var i = this._instances.length - 1; i >= 0; i--) {
var inst = this._instances[i];
if (inst.isPlaceholder) {
this._instances[i] = this._insertRow(i, inst.key, pool, true);
}
}
}, },
_detachRow: function (idx) { _detachRow: function (idx) {
var row = this.rows[idx]; var inst = this._instances[idx];
if (!inst.isPlaceholder) {
var parentNode = Polymer.dom(this).parentNode; var parentNode = Polymer.dom(this).parentNode;
for (var i = 0; i < row._children.length; i++) { for (var i = 0; i < inst._children.length; i++) {
var el = row._children[i]; var el = inst._children[i];
Polymer.dom(row.root).appendChild(el); Polymer.dom(inst.root).appendChild(el);
} }
return row; }
return inst;
}, },
_insertRow: function (idx, pool, item) { _insertRow: function (idx, key, pool, replace) {
var row = pool && pool.pop() || this._generateRow(idx, item); var inst;
var beforeRow = this.rows[idx]; if (inst = pool && pool.pop()) {
inst.__setProperty(this.as, this.collection.getItem(key), true);
inst.__setProperty('__key__', key, true);
} else {
inst = this._generateRow(idx, key);
}
var beforeRow = this._instances[replace ? idx + 1 : idx];
var beforeNode = beforeRow ? beforeRow._children[0] : this; var beforeNode = beforeRow ? beforeRow._children[0] : this;
var parentNode = Polymer.dom(this).parentNode; var parentNode = Polymer.dom(this).parentNode;
Polymer.dom(parentNode).insertBefore(row.root, beforeNode); Polymer.dom(parentNode).insertBefore(inst.root, beforeNode);
return row; return inst;
}, },
_generateRow: function (idx, item) { _generateRow: function (idx, key) {
var model = { __key__: this.collection.getKey(item) }; var model = { __key__: key };
model[this.as] = item; model[this.as] = this.collection.getItem(key);
model[this.indexAs] = idx; model[this.indexAs] = idx;
var row = this.stamp(model); var inst = this.stamp(model);
return row; return inst;
}, },
_showHideChildren: function (hidden) { _showHideChildren: function (hidden) {
if (this.rows) { for (var i = 0; i < this._instances.length; i++) {
for (var i = 0; i < this.rows.length; i++) { this._instances[i]._showHideChildren(hidden);
this.rows[i]._showHideChildren(hidden);
}
} }
}, },
_forwardInstanceProp: function (row, prop, value) { _forwardInstanceProp: function (inst, prop, value) {
if (prop == this.as) { if (prop == this.as) {
var idx; var idx;
if (this._sortFn || this._filterFn) { if (this._sortFn || this._filterFn) {
idx = this.items.indexOf(this.collection.getItem(row.__key__)); idx = this.items.indexOf(this.collection.getItem(inst.__key__));
} else { } else {
idx = row[this.indexAs]; idx = inst[this.indexAs];
} }
this.set('items.' + idx, value); this.set('items.' + idx, value);
} }
}, },
_forwardInstancePath: function (row, path, value) { _forwardInstancePath: function (inst, path, value) {
if (path.indexOf(this.as + '.') === 0) { if (path.indexOf(this.as + '.') === 0) {
this.notifyPath('items.' + row.__key__ + '.' + path.slice(this.as.length + 1), value); this.notifyPath('items.' + inst.__key__ + '.' + path.slice(this.as.length + 1), value);
} }
}, },
_forwardParentProp: function (prop, value) { _forwardParentProp: function (prop, value) {
if (this.rows) { this._instances.forEach(function (inst) {
this.rows.forEach(function (row) { inst.__setProperty(prop, value, true);
row.__setProperty(prop, value, true);
}, this); }, this);
}
}, },
_forwardParentPath: function (path, value) { _forwardParentPath: function (path, value) {
if (this.rows) { this._instances.forEach(function (inst) {
this.rows.forEach(function (row) { inst.notifyPath(path, value, true);
row.notifyPath(path, value, true);
}, this); }, this);
}
}, },
_forwardItemPath: function (path, value) { _forwardItemPath: function (path, value) {
if (this._rowForKey) { if (this._keyToInstIdx) {
var dot = path.indexOf('.'); var dot = path.indexOf('.');
var key = path.substring(0, dot < 0 ? path.length : dot); var key = path.substring(0, dot < 0 ? path.length : dot);
var idx = this._rowForKey[key]; var idx = this._keyToInstIdx[key];
var row = this.rows[idx]; var inst = this._instances[idx];
if (row) { if (inst) {
if (dot >= 0) { if (dot >= 0) {
path = this.as + '.' + path.substring(dot + 1); path = this.as + '.' + path.substring(dot + 1);
row.notifyPath(path, value, true); inst.notifyPath(path, value, true);
} else { } else {
row.__setProperty(this.as, value, true); inst.__setProperty(this.as, value, true);
} }
} }
} }
@ -5908,7 +5948,6 @@ created: function () {
Polymer.ImportStatus.whenLoaded(this._readySelf.bind(this)); Polymer.ImportStatus.whenLoaded(this._readySelf.bind(this));
}, },
_registerFeatures: function () { _registerFeatures: function () {
this._prepExtends();
this._prepConstructor(); this._prepConstructor();
}, },
_insertChildren: function () { _insertChildren: function () {
@ -11533,7 +11572,7 @@ It may be desirable to only allow users to enter certain characters. You can use
is separate from validation, and `allowed-pattern` does not affect how the input is validated. is separate from validation, and `allowed-pattern` does not affect how the input is validated.
<!-- only allow characters that match [0-9] --> <!-- only allow characters that match [0-9] -->
<input is="iron-input" prevent-invaild-input allowed-pattern="[0-9]"> <input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]">
@hero hero.svg @hero hero.svg
@demo demo/index.html @demo demo/index.html
@ -11646,11 +11685,16 @@ is separate from validation, and `allowed-pattern` does not affect how the input
// always matches the charCode. // always matches the charCode.
// None of this makes any sense. // None of this makes any sense.
var nonPrintable = // For these keys, ASCII code == browser keycode.
var anyNonPrintable =
(event.keyCode == 8) || // backspace (event.keyCode == 8) || // backspace
(event.keyCode == 13) || // enter
(event.keyCode == 27); // escape
// For these keys, make sure it's a browser keycode and not an ASCII code.
var mozNonPrintable =
(event.keyCode == 19) || // pause (event.keyCode == 19) || // pause
(event.keyCode == 20) || // caps lock (event.keyCode == 20) || // caps lock
(event.keyCode == 27) || // escape
(event.keyCode == 45) || // insert (event.keyCode == 45) || // insert
(event.keyCode == 46) || // delete (event.keyCode == 46) || // delete
(event.keyCode == 144) || // num lock (event.keyCode == 144) || // num lock
@ -11658,7 +11702,7 @@ is separate from validation, and `allowed-pattern` does not affect how the input
(event.keyCode > 32 && event.keyCode < 41) || // page up/down, end, home, arrows (event.keyCode > 32 && event.keyCode < 41) || // page up/down, end, home, arrows
(event.keyCode > 111 && event.keyCode < 124); // fn keys (event.keyCode > 111 && event.keyCode < 124); // fn keys
return !(event.charCode == 0 && nonPrintable); return !anyNonPrintable && !(event.charCode == 0 && mozNonPrintable);
}, },
_onKeypress: function(event) { _onKeypress: function(event) {
@ -11767,8 +11811,7 @@ is separate from validation, and `allowed-pattern` does not affect how the input
}, },
/** /**
* Need to keep a reference to the form this element is registered * The form that the element is registered to.
* to, so that it can unregister if detached.
*/ */
_parentForm: { _parentForm: {
type: Object type: Object
@ -11776,7 +11819,8 @@ is separate from validation, and `allowed-pattern` does not affect how the input
}, },
attached: function() { attached: function() {
this._parentForm = Polymer.dom(this).parentNode; // Note: the iron-form that this element belongs to will set this
// element's _parentForm property when handling this event.
this.fire('iron-form-element-register'); this.fire('iron-form-element-register');
}, },