OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 function assert(condition,opt_message){if(!condition){var message="Assertion fai
led";if(opt_message)message=message+": "+opt_message;var error=new Error(message
);var global=function(){return this}();if(global.traceAssertionsForTesting)conso
le.warn(error.stack);throw error}return condition}function assertNotReached(opt_
message){assert(false,opt_message||"Unreachable code hit")}function assertInstan
ceof(value,type,opt_message){if(!(value instanceof type)){assertNotReached(opt_m
essage||"Value "+value+" is not a[n] "+(type.name||typeof type))}return value} | 4 function assert(condition,opt_message){if(!condition){var message="Assertion fai
led";if(opt_message)message=message+": "+opt_message;var error=new Error(message
);var global=function(){return this}();if(global.traceAssertionsForTesting)conso
le.warn(error.stack);throw error}return condition}function assertNotReached(opt_
message){assert(false,opt_message||"Unreachable code hit")}function assertInstan
ceof(value,type,opt_message){if(!(value instanceof type)){assertNotReached(opt_m
essage||"Value "+value+" is not a[n] "+(type.name||typeof type))}return value} |
5 // Copyright 2016 The Chromium Authors. All rights reserved. | 5 // Copyright 2016 The Chromium Authors. All rights reserved. |
6 // Use of this source code is governed by a BSD-style license that can be | 6 // Use of this source code is governed by a BSD-style license that can be |
7 // found in the LICENSE file. | 7 // found in the LICENSE file. |
8 function PromiseResolver(){this.resolve_;this.reject_;this.promise_=new Promise(
function(resolve,reject){this.resolve_=resolve;this.reject_=reject}.bind(this))}
PromiseResolver.prototype={get promise(){return this.promise_},set promise(p){as
sertNotReached()},get resolve(){return this.resolve_},set resolve(r){assertNotRe
ached()},get reject(){return this.reject_},set reject(s){assertNotReached()}}; | 8 function PromiseResolver(){this.resolve_;this.reject_;this.promise_=new Promise(
function(resolve,reject){this.resolve_=resolve;this.reject_=reject}.bind(this))}
PromiseResolver.prototype={get promise(){return this.promise_},set promise(p){as
sertNotReached()},get resolve(){return this.resolve_},set resolve(r){assertNotRe
ached()},get reject(){return this.reject_},set reject(s){assertNotReached()}}; |
9 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 9 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
10 // Use of this source code is governed by a BSD-style license that can be | 10 // Use of this source code is governed by a BSD-style license that can be |
11 // found in the LICENSE file. | 11 // found in the LICENSE file. |
12 var global=this;var WebUIListener;var cr=cr||function(){"use strict";function ex
portPath(name,opt_object,opt_objectToExportTo){var parts=name.split(".");var cur
=opt_objectToExportTo||global;for(var part;parts.length&&(part=parts.shift());){
if(!parts.length&&opt_object!==undefined){cur[part]=opt_object}else if(part in c
ur){cur=cur[part]}else{cur=cur[part]={}}}return cur}function dispatchPropertyCha
nge(target,propertyName,newValue,oldValue){var e=new Event(propertyName+"Change"
);e.propertyName=propertyName;e.newValue=newValue;e.oldValue=oldValue;target.dis
patchEvent(e)}function getAttributeName(jsName){return jsName.replace(/([A-Z])/g
,"-$1").toLowerCase()}var PropertyKind={JS:"js",ATTR:"attr",BOOL_ATTR:"boolAttr"
};function getGetter(name,kind){switch(kind){case PropertyKind.JS:var privateNam
e=name+"_";return function(){return this[privateName]};case PropertyKind.ATTR:va
r attributeName=getAttributeName(name);return function(){return this.getAttribut
e(attributeName)};case PropertyKind.BOOL_ATTR:var attributeName=getAttributeName
(name);return function(){return this.hasAttribute(attributeName)}}throw"not reac
hed"}function getSetter(name,kind,opt_setHook){switch(kind){case PropertyKind.JS
:var privateName=name+"_";return function(value){var oldValue=this[name];if(valu
e!==oldValue){this[privateName]=value;if(opt_setHook)opt_setHook.call(this,value
,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};case PropertyKind.
ATTR:var attributeName=getAttributeName(name);return function(value){var oldValu
e=this[name];if(value!==oldValue){if(value==undefined)this.removeAttribute(attri
buteName);else this.setAttribute(attributeName,value);if(opt_setHook)opt_setHook
.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};ca
se PropertyKind.BOOL_ATTR:var attributeName=getAttributeName(name);return functi
on(value){var oldValue=this[name];if(value!==oldValue){if(value)this.setAttribut
e(attributeName,name);else this.removeAttribute(attributeName);if(opt_setHook)op
t_setHook.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldVa
lue)}}}throw"not reached"}function defineProperty(obj,name,opt_kind,opt_setHook)
{if(typeof obj=="function")obj=obj.prototype;var kind=opt_kind||PropertyKind.JS;
if(!obj.__lookupGetter__(name))obj.__defineGetter__(name,getGetter(name,kind));i
f(!obj.__lookupSetter__(name))obj.__defineSetter__(name,getSetter(name,kind,opt_
setHook))}var uidCounter=1;function createUid(){return uidCounter++}function get
Uid(item){if(item.hasOwnProperty("uid"))return item.uid;return item.uid=createUi
d()}function dispatchSimpleEvent(target,type,opt_bubbles,opt_cancelable){var e=n
ew Event(type,{bubbles:opt_bubbles,cancelable:opt_cancelable===undefined||opt_ca
ncelable});return target.dispatchEvent(e)}function define(name,fun){var obj=expo
rtPath(name);var exports=fun();for(var propertyName in exports){var propertyDesc
riptor=Object.getOwnPropertyDescriptor(exports,propertyName);if(propertyDescript
or)Object.defineProperty(obj,propertyName,propertyDescriptor)}}function addSingl
etonGetter(ctor){ctor.getInstance=function(){return ctor.instance_||(ctor.instan
ce_=new ctor)}}function makePublic(ctor,methods,opt_target){methods.forEach(func
tion(method){ctor[method]=function(){var target=opt_target?document.getElementBy
Id(opt_target):ctor.getInstance();return target[method+"_"].apply(target,argumen
ts)}})}var chromeSendResolverMap={};function webUIResponse(id,isSuccess,response
){var resolver=chromeSendResolverMap[id];delete chromeSendResolverMap[id];if(isS
uccess)resolver.resolve(response);else resolver.reject(response)}function sendWi
thPromise(methodName,var_args){var args=Array.prototype.slice.call(arguments,1);
var promiseResolver=new PromiseResolver;var id=methodName+"_"+createUid();chrome
SendResolverMap[id]=promiseResolver;chrome.send(methodName,[id].concat(args));re
turn promiseResolver.promise}var webUIListenerMap={};function webUIListenerCallb
ack(event,var_args){var eventListenersMap=webUIListenerMap[event];if(!eventListe
nersMap){return}var args=Array.prototype.slice.call(arguments,1);for(var listene
rId in eventListenersMap){eventListenersMap[listenerId].apply(null,args)}}functi
on addWebUIListener(eventName,callback){webUIListenerMap[eventName]=webUIListene
rMap[eventName]||{};var uid=createUid();webUIListenerMap[eventName][uid]=callbac
k;return{eventName:eventName,uid:uid}}function removeWebUIListener(listener){var
listenerExists=webUIListenerMap[listener.eventName]&&webUIListenerMap[listener.
eventName][listener.uid];if(listenerExists){delete webUIListenerMap[listener.eve
ntName][listener.uid];return true}return false}return{addSingletonGetter:addSing
letonGetter,createUid:createUid,define:define,defineProperty:defineProperty,disp
atchPropertyChange:dispatchPropertyChange,dispatchSimpleEvent:dispatchSimpleEven
t,exportPath:exportPath,getUid:getUid,makePublic:makePublic,PropertyKind:Propert
yKind,addWebUIListener:addWebUIListener,removeWebUIListener:removeWebUIListener,
sendWithPromise:sendWithPromise,webUIListenerCallback:webUIListenerCallback,webU
IResponse:webUIResponse,get doc(){return document},get isMac(){return/Mac/.test(
navigator.platform)},get isWindows(){return/Win/.test(navigator.platform)},get i
sChromeOS(){return/CrOS/.test(navigator.userAgent)},get isLinux(){return/Linux/.
test(navigator.userAgent)},get isAndroid(){return/Android/.test(navigator.userAg
ent)},get isIOS(){return/iPad|iPhone|iPod/.test(navigator.platform)}}}(); | 12 var global=this;var WebUIListener;var cr=cr||function(){"use strict";function ex
portPath(name,opt_object,opt_objectToExportTo){var parts=name.split(".");var cur
=opt_objectToExportTo||global;for(var part;parts.length&&(part=parts.shift());){
if(!parts.length&&opt_object!==undefined){cur[part]=opt_object}else if(part in c
ur){cur=cur[part]}else{cur=cur[part]={}}}return cur}function dispatchPropertyCha
nge(target,propertyName,newValue,oldValue){var e=new Event(propertyName+"Change"
);e.propertyName=propertyName;e.newValue=newValue;e.oldValue=oldValue;target.dis
patchEvent(e)}function getAttributeName(jsName){return jsName.replace(/([A-Z])/g
,"-$1").toLowerCase()}var PropertyKind={JS:"js",ATTR:"attr",BOOL_ATTR:"boolAttr"
};function getGetter(name,kind){switch(kind){case PropertyKind.JS:var privateNam
e=name+"_";return function(){return this[privateName]};case PropertyKind.ATTR:va
r attributeName=getAttributeName(name);return function(){return this.getAttribut
e(attributeName)};case PropertyKind.BOOL_ATTR:var attributeName=getAttributeName
(name);return function(){return this.hasAttribute(attributeName)}}throw"not reac
hed"}function getSetter(name,kind,opt_setHook){switch(kind){case PropertyKind.JS
:var privateName=name+"_";return function(value){var oldValue=this[name];if(valu
e!==oldValue){this[privateName]=value;if(opt_setHook)opt_setHook.call(this,value
,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};case PropertyKind.
ATTR:var attributeName=getAttributeName(name);return function(value){var oldValu
e=this[name];if(value!==oldValue){if(value==undefined)this.removeAttribute(attri
buteName);else this.setAttribute(attributeName,value);if(opt_setHook)opt_setHook
.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};ca
se PropertyKind.BOOL_ATTR:var attributeName=getAttributeName(name);return functi
on(value){var oldValue=this[name];if(value!==oldValue){if(value)this.setAttribut
e(attributeName,name);else this.removeAttribute(attributeName);if(opt_setHook)op
t_setHook.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldVa
lue)}}}throw"not reached"}function defineProperty(obj,name,opt_kind,opt_setHook)
{if(typeof obj=="function")obj=obj.prototype;var kind=opt_kind||PropertyKind.JS;
if(!obj.__lookupGetter__(name))obj.__defineGetter__(name,getGetter(name,kind));i
f(!obj.__lookupSetter__(name))obj.__defineSetter__(name,getSetter(name,kind,opt_
setHook))}var uidCounter=1;function createUid(){return uidCounter++}function get
Uid(item){if(item.hasOwnProperty("uid"))return item.uid;return item.uid=createUi
d()}function dispatchSimpleEvent(target,type,opt_bubbles,opt_cancelable){var e=n
ew Event(type,{bubbles:opt_bubbles,cancelable:opt_cancelable===undefined||opt_ca
ncelable});return target.dispatchEvent(e)}function define(name,fun){var obj=expo
rtPath(name);var exports=fun();for(var propertyName in exports){var propertyDesc
riptor=Object.getOwnPropertyDescriptor(exports,propertyName);if(propertyDescript
or)Object.defineProperty(obj,propertyName,propertyDescriptor)}}function addSingl
etonGetter(ctor){ctor.getInstance=function(){return ctor.instance_||(ctor.instan
ce_=new ctor)}}function makePublic(ctor,methods,opt_target){methods.forEach(func
tion(method){ctor[method]=function(){var target=opt_target?document.getElementBy
Id(opt_target):ctor.getInstance();return target[method+"_"].apply(target,argumen
ts)}})}var chromeSendResolverMap={};function webUIResponse(id,isSuccess,response
){var resolver=chromeSendResolverMap[id];delete chromeSendResolverMap[id];if(isS
uccess)resolver.resolve(response);else resolver.reject(response)}function sendWi
thPromise(methodName,var_args){var args=Array.prototype.slice.call(arguments,1);
var promiseResolver=new PromiseResolver;var id=methodName+"_"+createUid();chrome
SendResolverMap[id]=promiseResolver;chrome.send(methodName,[id].concat(args));re
turn promiseResolver.promise}var webUIListenerMap={};function webUIListenerCallb
ack(event,var_args){var eventListenersMap=webUIListenerMap[event];if(!eventListe
nersMap){return}var args=Array.prototype.slice.call(arguments,1);for(var listene
rId in eventListenersMap){eventListenersMap[listenerId].apply(null,args)}}functi
on addWebUIListener(eventName,callback){webUIListenerMap[eventName]=webUIListene
rMap[eventName]||{};var uid=createUid();webUIListenerMap[eventName][uid]=callbac
k;return{eventName:eventName,uid:uid}}function removeWebUIListener(listener){var
listenerExists=webUIListenerMap[listener.eventName]&&webUIListenerMap[listener.
eventName][listener.uid];if(listenerExists){delete webUIListenerMap[listener.eve
ntName][listener.uid];return true}return false}return{addSingletonGetter:addSing
letonGetter,createUid:createUid,define:define,defineProperty:defineProperty,disp
atchPropertyChange:dispatchPropertyChange,dispatchSimpleEvent:dispatchSimpleEven
t,exportPath:exportPath,getUid:getUid,makePublic:makePublic,PropertyKind:Propert
yKind,addWebUIListener:addWebUIListener,removeWebUIListener:removeWebUIListener,
sendWithPromise:sendWithPromise,webUIListenerCallback:webUIListenerCallback,webU
IResponse:webUIResponse,get doc(){return document},get isMac(){return/Mac/.test(
navigator.platform)},get isWindows(){return/Win/.test(navigator.platform)},get i
sChromeOS(){return/CrOS/.test(navigator.userAgent)},get isLinux(){return/Linux/.
test(navigator.userAgent)},get isAndroid(){return/Android/.test(navigator.userAg
ent)},get isIOS(){return/iPad|iPhone|iPod/.test(navigator.platform)}}}(); |
13 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 13 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
14 // Use of this source code is governed by a BSD-style license that can be | 14 // Use of this source code is governed by a BSD-style license that can be |
15 // found in the LICENSE file. | 15 // found in the LICENSE file. |
16 cr.define("cr.ui",function(){function decorate(source,constr){var elements;if(ty
peof source=="string")elements=cr.doc.querySelectorAll(source);else elements=[so
urce];for(var i=0,el;el=elements[i];i++){if(!(el instanceof constr))constr.decor
ate(el)}}function createElementHelper(tagName,opt_bag){var doc;if(opt_bag&&opt_b
ag.ownerDocument)doc=opt_bag.ownerDocument;else doc=cr.doc;return doc.createElem
ent(tagName)}function define(tagNameOrFunction){var createFunction,tagName;if(ty
peof tagNameOrFunction=="function"){createFunction=tagNameOrFunction;tagName=""}
else{createFunction=createElementHelper;tagName=tagNameOrFunction}function f(opt
_propertyBag){var el=createFunction(tagName,opt_propertyBag);f.decorate(el);for(
var propertyName in opt_propertyBag){el[propertyName]=opt_propertyBag[propertyNa
me]}return el}f.decorate=function(el){el.__proto__=f.prototype;el.decorate()};re
turn f}function limitInputWidth(el,parentEl,min,opt_scale){el.style.width="10px"
;var doc=el.ownerDocument;var win=doc.defaultView;var computedStyle=win.getCompu
tedStyle(el);var parentComputedStyle=win.getComputedStyle(parentEl);var rtl=comp
utedStyle.direction=="rtl";var inputRect=el.getBoundingClientRect();var parentRe
ct=parentEl.getBoundingClientRect();var startPos=rtl?parentRect.right-inputRect.
right:inputRect.left-parentRect.left;var inner=parseInt(computedStyle.borderLeft
Width,10)+parseInt(computedStyle.paddingLeft,10)+parseInt(computedStyle.paddingR
ight,10)+parseInt(computedStyle.borderRightWidth,10);var parentPadding=rtl?parse
Int(parentComputedStyle.paddingLeft,10):parseInt(parentComputedStyle.paddingRigh
t,10);var max=parentEl.clientWidth-startPos-inner-parentPadding;if(opt_scale)max
*=opt_scale;function limit(){if(el.scrollWidth>max){el.style.width=max+"px"}else
{el.style.width=0;var sw=el.scrollWidth;if(sw<min){el.style.width=min+"px"}else{
el.style.width=sw+"px"}}}el.addEventListener("input",limit);limit()}function toC
ssPx(pixels){if(!window.isFinite(pixels))console.error("Pixel value is not a num
ber: "+pixels);return Math.round(pixels)+"px"}function swallowDoubleClick(e){var
doc=e.target.ownerDocument;var counter=Math.min(1,e.detail);function swallow(e)
{e.stopPropagation();e.preventDefault()}function onclick(e){if(e.detail>counter)
{counter=e.detail;swallow(e)}else{doc.removeEventListener("dblclick",swallow,tru
e);doc.removeEventListener("click",onclick,true)}}setTimeout(function(){doc.addE
ventListener("click",onclick,true);doc.addEventListener("dblclick",swallow,true)
},0)}return{decorate:decorate,define:define,limitInputWidth:limitInputWidth,toCs
sPx:toCssPx,swallowDoubleClick:swallowDoubleClick}}); | 16 cr.define("cr.ui",function(){function decorate(source,constr){var elements;if(ty
peof source=="string")elements=cr.doc.querySelectorAll(source);else elements=[so
urce];for(var i=0,el;el=elements[i];i++){if(!(el instanceof constr))constr.decor
ate(el)}}function createElementHelper(tagName,opt_bag){var doc;if(opt_bag&&opt_b
ag.ownerDocument)doc=opt_bag.ownerDocument;else doc=cr.doc;return doc.createElem
ent(tagName)}function define(tagNameOrFunction){var createFunction,tagName;if(ty
peof tagNameOrFunction=="function"){createFunction=tagNameOrFunction;tagName=""}
else{createFunction=createElementHelper;tagName=tagNameOrFunction}function f(opt
_propertyBag){var el=createFunction(tagName,opt_propertyBag);f.decorate(el);for(
var propertyName in opt_propertyBag){el[propertyName]=opt_propertyBag[propertyNa
me]}return el}f.decorate=function(el){el.__proto__=f.prototype;el.decorate()};re
turn f}function limitInputWidth(el,parentEl,min,opt_scale){el.style.width="10px"
;var doc=el.ownerDocument;var win=doc.defaultView;var computedStyle=win.getCompu
tedStyle(el);var parentComputedStyle=win.getComputedStyle(parentEl);var rtl=comp
utedStyle.direction=="rtl";var inputRect=el.getBoundingClientRect();var parentRe
ct=parentEl.getBoundingClientRect();var startPos=rtl?parentRect.right-inputRect.
right:inputRect.left-parentRect.left;var inner=parseInt(computedStyle.borderLeft
Width,10)+parseInt(computedStyle.paddingLeft,10)+parseInt(computedStyle.paddingR
ight,10)+parseInt(computedStyle.borderRightWidth,10);var parentPadding=rtl?parse
Int(parentComputedStyle.paddingLeft,10):parseInt(parentComputedStyle.paddingRigh
t,10);var max=parentEl.clientWidth-startPos-inner-parentPadding;if(opt_scale)max
*=opt_scale;function limit(){if(el.scrollWidth>max){el.style.width=max+"px"}else
{el.style.width=0;var sw=el.scrollWidth;if(sw<min){el.style.width=min+"px"}else{
el.style.width=sw+"px"}}}el.addEventListener("input",limit);limit()}function toC
ssPx(pixels){if(!window.isFinite(pixels))console.error("Pixel value is not a num
ber: "+pixels);return Math.round(pixels)+"px"}function swallowDoubleClick(e){var
doc=e.target.ownerDocument;var counter=Math.min(1,e.detail);function swallow(e)
{e.stopPropagation();e.preventDefault()}function onclick(e){if(e.detail>counter)
{counter=e.detail;swallow(e)}else{doc.removeEventListener("dblclick",swallow,tru
e);doc.removeEventListener("click",onclick,true)}}setTimeout(function(){doc.addE
ventListener("click",onclick,true);doc.addEventListener("dblclick",swallow,true)
},0)}return{decorate:decorate,define:define,limitInputWidth:limitInputWidth,toCs
sPx:toCssPx,swallowDoubleClick:swallowDoubleClick}}); |
17 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 17 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
18 // Use of this source code is governed by a BSD-style license that can be | 18 // Use of this source code is governed by a BSD-style license that can be |
19 // found in the LICENSE file. | 19 // found in the LICENSE file. |
20 cr.define("cr.ui",function(){function KeyboardShortcut(shortcut){var mods={};var
ident="";shortcut.split("|").forEach(function(part){var partLc=part.toLowerCase
();switch(partLc){case"alt":case"ctrl":case"meta":case"shift":mods[partLc+"Key"]
=true;break;default:if(ident)throw Error("Invalid shortcut");ident=part}});this.
ident_=ident;this.mods_=mods}KeyboardShortcut.prototype={matchesEvent:function(e
){if(e.key==this.ident_){var mods=this.mods_;return["altKey","ctrlKey","metaKey"
,"shiftKey"].every(function(k){return e[k]==!!mods[k]})}return false}};var Comma
nd=cr.ui.define("command");Command.prototype={__proto__:HTMLElement.prototype,de
corate:function(){CommandManager.init(assert(this.ownerDocument));if(this.hasAtt
ribute("shortcut"))this.shortcut=this.getAttribute("shortcut")},execute:function
(opt_element){if(this.disabled)return;var doc=this.ownerDocument;if(doc.activeEl
ement){var e=new Event("command",{bubbles:true});e.command=this;(opt_element||do
c.activeElement).dispatchEvent(e)}},canExecuteChange:function(opt_node){dispatch
CanExecuteEvent(this,opt_node||this.ownerDocument.activeElement)},shortcut_:"",g
et shortcut(){return this.shortcut_},set shortcut(shortcut){var oldShortcut=this
.shortcut_;if(shortcut!==oldShortcut){this.keyboardShortcuts_=shortcut.split(/\s
+/).map(function(shortcut){return new KeyboardShortcut(shortcut)});this.shortcut
_=shortcut;cr.dispatchPropertyChange(this,"shortcut",this.shortcut_,oldShortcut)
}},matchesEvent:function(e){if(!this.keyboardShortcuts_)return false;return this
.keyboardShortcuts_.some(function(keyboardShortcut){return keyboardShortcut.matc
hesEvent(e)})}};cr.defineProperty(Command,"label",cr.PropertyKind.ATTR);cr.defin
eProperty(Command,"disabled",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Comman
d,"hidden",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Command,"checked",cr.Pro
pertyKind.BOOL_ATTR);cr.defineProperty(Command,"hideShortcutText",cr.PropertyKin
d.BOOL_ATTR);function dispatchCanExecuteEvent(command,target){var e=new CanExecu
teEvent(command);target.dispatchEvent(e);command.disabled=!e.canExecute}var comm
andManagers={};function CommandManager(doc){doc.addEventListener("focus",this.ha
ndleFocus_.bind(this),true);doc.addEventListener("keydown",this.handleKeyDown_.b
ind(this),false)}CommandManager.init=function(doc){var uid=cr.getUid(doc);if(!(u
id in commandManagers)){commandManagers[uid]=new CommandManager(doc)}};CommandMa
nager.prototype={handleFocus_:function(e){var target=e.target;if(target.menu||ta
rget.command)return;var commands=Array.prototype.slice.call(target.ownerDocument
.querySelectorAll("command"));commands.forEach(function(command){dispatchCanExec
uteEvent(command,target)})},handleKeyDown_:function(e){var target=e.target;var c
ommands=Array.prototype.slice.call(target.ownerDocument.querySelectorAll("comman
d"));for(var i=0,command;command=commands[i];i++){if(command.matchesEvent(e)){co
mmand.canExecuteChange();if(!command.disabled){e.preventDefault();e.stopPropagat
ion();command.execute();return}}}}};function CanExecuteEvent(command){var e=new
Event("canExecute",{bubbles:true,cancelable:true});e.__proto__=CanExecuteEvent.p
rototype;e.command=command;return e}CanExecuteEvent.prototype={__proto__:Event.p
rototype,command:null,canExecute_:false,get canExecute(){return this.canExecute_
},set canExecute(canExecute){this.canExecute_=!!canExecute;this.stopPropagation(
);this.preventDefault()}};return{Command:Command,CanExecuteEvent:CanExecuteEvent
}}); | 20 cr.define("cr.ui",function(){function KeyboardShortcut(shortcut){var mods={};var
ident="";shortcut.split("|").forEach(function(part){var partLc=part.toLowerCase
();switch(partLc){case"alt":case"ctrl":case"meta":case"shift":mods[partLc+"Key"]
=true;break;default:if(ident)throw Error("Invalid shortcut");ident=part}});this.
ident_=ident;this.mods_=mods}KeyboardShortcut.prototype={matchesEvent:function(e
){if(e.key==this.ident_){var mods=this.mods_;return["altKey","ctrlKey","metaKey"
,"shiftKey"].every(function(k){return e[k]==!!mods[k]})}return false}};var Comma
nd=cr.ui.define("command");Command.prototype={__proto__:HTMLElement.prototype,de
corate:function(){CommandManager.init(assert(this.ownerDocument));if(this.hasAtt
ribute("shortcut"))this.shortcut=this.getAttribute("shortcut")},execute:function
(opt_element){if(this.disabled)return;var doc=this.ownerDocument;if(doc.activeEl
ement){var e=new Event("command",{bubbles:true});e.command=this;(opt_element||do
c.activeElement).dispatchEvent(e)}},canExecuteChange:function(opt_node){dispatch
CanExecuteEvent(this,opt_node||this.ownerDocument.activeElement)},shortcut_:"",g
et shortcut(){return this.shortcut_},set shortcut(shortcut){var oldShortcut=this
.shortcut_;if(shortcut!==oldShortcut){this.keyboardShortcuts_=shortcut.split(/\s
+/).map(function(shortcut){return new KeyboardShortcut(shortcut)});this.shortcut
_=shortcut;cr.dispatchPropertyChange(this,"shortcut",this.shortcut_,oldShortcut)
}},matchesEvent:function(e){if(!this.keyboardShortcuts_)return false;return this
.keyboardShortcuts_.some(function(keyboardShortcut){return keyboardShortcut.matc
hesEvent(e)})}};cr.defineProperty(Command,"label",cr.PropertyKind.ATTR);cr.defin
eProperty(Command,"disabled",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Comman
d,"hidden",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Command,"checked",cr.Pro
pertyKind.BOOL_ATTR);cr.defineProperty(Command,"hideShortcutText",cr.PropertyKin
d.BOOL_ATTR);function dispatchCanExecuteEvent(command,target){var e=new CanExecu
teEvent(command);target.dispatchEvent(e);command.disabled=!e.canExecute}var comm
andManagers={};function CommandManager(doc){doc.addEventListener("focus",this.ha
ndleFocus_.bind(this),true);doc.addEventListener("keydown",this.handleKeyDown_.b
ind(this),false)}CommandManager.init=function(doc){var uid=cr.getUid(doc);if(!(u
id in commandManagers)){commandManagers[uid]=new CommandManager(doc)}};CommandMa
nager.prototype={handleFocus_:function(e){var target=e.target;if(target.menu||ta
rget.command)return;var commands=Array.prototype.slice.call(target.ownerDocument
.querySelectorAll("command"));commands.forEach(function(command){dispatchCanExec
uteEvent(command,target)})},handleKeyDown_:function(e){var target=e.target;var c
ommands=Array.prototype.slice.call(target.ownerDocument.querySelectorAll("comman
d"));for(var i=0,command;command=commands[i];i++){if(command.matchesEvent(e)){co
mmand.canExecuteChange();if(!command.disabled){e.preventDefault();e.stopPropagat
ion();command.execute();return}}}}};function CanExecuteEvent(command){var e=new
Event("canExecute",{bubbles:true,cancelable:true});e.__proto__=CanExecuteEvent.p
rototype;e.command=command;return e}CanExecuteEvent.prototype={__proto__:Event.p
rototype,command:null,canExecute_:false,get canExecute(){return this.canExecute_
},set canExecute(canExecute){this.canExecute_=!!canExecute;this.stopPropagation(
);this.preventDefault()}};return{Command:Command,CanExecuteEvent:CanExecuteEvent
}}); |
21 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 21 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
22 // Use of this source code is governed by a BSD-style license that can be | 22 // Use of this source code is governed by a BSD-style license that can be |
23 // found in the LICENSE file. | 23 // found in the LICENSE file. |
24 function $(id){var el=document.getElementById(id);return el?assertInstanceof(el,
HTMLElement):null}function getSVGElement(id){var el=document.getElementById(id);
return el?assertInstanceof(el,Element):null}function announceAccessibleMessage(m
sg){var element=document.createElement("div");element.setAttribute("aria-live","
polite");element.style.position="relative";element.style.left="-9999px";element.
style.height="0px";element.innerText=msg;document.body.appendChild(element);wind
ow.setTimeout(function(){document.body.removeChild(element)},0)}function url(s){
var s2=s.replace(/(\(|\)|\,|\s|\'|\"|\\)/g,"\\$1");if(/\\\\$/.test(s2)){s2+=" "}
return'url("'+s2+'")'}function parseQueryParams(location){var params={};var quer
y=unescape(location.search.substring(1));var vars=query.split("&");for(var i=0;i
<vars.length;i++){var pair=vars[i].split("=");params[pair[0]]=pair[1]}return par
ams}function setQueryParam(location,key,value){var query=parseQueryParams(locati
on);query[encodeURIComponent(key)]=encodeURIComponent(value);var newQuery="";for
(var q in query){newQuery+=(newQuery?"&":"?")+q+"="+query[q]}return location.ori
gin+location.pathname+newQuery+location.hash}function findAncestorByClass(el,cla
ssName){return findAncestor(el,function(el){return el.classList&&el.classList.co
ntains(className)})}function findAncestor(node,predicate){var last=false;while(n
ode!=null&&!(last=predicate(node))){node=node.parentNode}return last?node:null}f
unction swapDomNodes(a,b){var afterA=a.nextSibling;if(afterA==b){swapDomNodes(b,
a);return}var aParent=a.parentNode;b.parentNode.replaceChild(a,b);aParent.insert
Before(b,afterA)}function disableTextSelectAndDrag(opt_allowSelectStart,opt_allo
wDragStart){document.onselectstart=function(e){if(!(opt_allowSelectStart&&opt_al
lowSelectStart.call(this,e)))e.preventDefault()};document.ondragstart=function(e
){if(!(opt_allowDragStart&&opt_allowDragStart.call(this,e)))e.preventDefault()}}
function preventDefaultOnPoundLinkClicks(){document.addEventListener("click",fun
ction(e){var anchor=findAncestor(e.target,function(el){return el.tagName=="A"});
if(anchor&&anchor.getAttribute("href")=="#")e.preventDefault()})}function isRTL(
){return document.documentElement.dir=="rtl"}function getRequiredElement(id){ret
urn assertInstanceof($(id),HTMLElement,"Missing required element: "+id)}function
queryRequiredElement(selectors,opt_context){var element=(opt_context||document)
.querySelector(selectors);return assertInstanceof(element,HTMLElement,"Missing r
equired element: "+selectors)}["click","auxclick"].forEach(function(eventName){d
ocument.addEventListener(eventName,function(e){if(e.button>1)return;if(e.default
Prevented)return;var eventPath=e.path;var anchor=null;if(eventPath){for(var i=0;
i<eventPath.length;i++){var element=eventPath[i];if(element.tagName==="A"&&eleme
nt.href){anchor=element;break}}}var el=e.target;if(!anchor&&el.nodeType==Node.EL
EMENT_NODE&&el.webkitMatchesSelector("A, A *")){while(el.tagName!="A"){el=el.par
entElement}anchor=el}if(!anchor)return;anchor=anchor;if((anchor.protocol=="file:
"||anchor.protocol=="about:")&&(e.button==0||e.button==1)){chrome.send("navigate
ToUrl",[anchor.href,anchor.target,e.button,e.altKey,e.ctrlKey,e.metaKey,e.shiftK
ey]);e.preventDefault()}})});function appendParam(url,key,value){var param=encod
eURIComponent(key)+"="+encodeURIComponent(value);if(url.indexOf("?")==-1)return
url+"?"+param;return url+"&"+param}function createElementWithClassName(type,clas
sName){var elm=document.createElement(type);elm.className=className;return elm}f
unction ensureTransitionEndEvent(el,opt_timeOut){if(opt_timeOut===undefined){var
style=getComputedStyle(el);opt_timeOut=parseFloat(style.transitionDuration)*1e3
;opt_timeOut+=50}var fired=false;el.addEventListener("webkitTransitionEnd",funct
ion f(e){el.removeEventListener("webkitTransitionEnd",f);fired=true});window.set
Timeout(function(){if(!fired)cr.dispatchSimpleEvent(el,"webkitTransitionEnd",tru
e)},opt_timeOut)}function scrollTopForDocument(doc){return doc.documentElement.s
crollTop||doc.body.scrollTop}function setScrollTopForDocument(doc,value){doc.doc
umentElement.scrollTop=doc.body.scrollTop=value}function scrollLeftForDocument(d
oc){return doc.documentElement.scrollLeft||doc.body.scrollLeft}function setScrol
lLeftForDocument(doc,value){doc.documentElement.scrollLeft=doc.body.scrollLeft=v
alue}function HTMLEscape(original){return original.replace(/&/g,"&").replace
(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
function elide(original,maxLength){if(original.length<=maxLength)return original
;return original.substring(0,maxLength-1)+"…"}function quoteString(str){return s
tr.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g,"\\$1")}function listen
Once(target,eventNames,callback){if(!Array.isArray(eventNames))eventNames=eventN
ames.split(/ +/);var removeAllAndCallCallback=function(event){eventNames.forEach
(function(eventName){target.removeEventListener(eventName,removeAllAndCallCallba
ck,false)});return callback(event)};eventNames.forEach(function(eventName){targe
t.addEventListener(eventName,removeAllAndCallCallback,false)})} | 24 function $(id){var el=document.getElementById(id);return el?assertInstanceof(el,
HTMLElement):null}function getSVGElement(id){var el=document.getElementById(id);
return el?assertInstanceof(el,Element):null}function announceAccessibleMessage(m
sg){var element=document.createElement("div");element.setAttribute("aria-live","
polite");element.style.position="fixed";element.style.left="-9999px";element.sty
le.height="0px";element.innerText=msg;document.body.appendChild(element);window.
setTimeout(function(){document.body.removeChild(element)},0)}function url(s){var
s2=s.replace(/(\(|\)|\,|\s|\'|\"|\\)/g,"\\$1");if(/\\\\$/.test(s2)){s2+=" "}ret
urn'url("'+s2+'")'}function parseQueryParams(location){var params={};var query=u
nescape(location.search.substring(1));var vars=query.split("&");for(var i=0;i<va
rs.length;i++){var pair=vars[i].split("=");params[pair[0]]=pair[1]}return params
}function setQueryParam(location,key,value){var query=parseQueryParams(location)
;query[encodeURIComponent(key)]=encodeURIComponent(value);var newQuery="";for(va
r q in query){newQuery+=(newQuery?"&":"?")+q+"="+query[q]}return location.origin
+location.pathname+newQuery+location.hash}function findAncestorByClass(el,classN
ame){return findAncestor(el,function(el){return el.classList&&el.classList.conta
ins(className)})}function findAncestor(node,predicate){var last=false;while(node
!=null&&!(last=predicate(node))){node=node.parentNode}return last?node:null}func
tion swapDomNodes(a,b){var afterA=a.nextSibling;if(afterA==b){swapDomNodes(b,a);
return}var aParent=a.parentNode;b.parentNode.replaceChild(a,b);aParent.insertBef
ore(b,afterA)}function disableTextSelectAndDrag(opt_allowSelectStart,opt_allowDr
agStart){document.onselectstart=function(e){if(!(opt_allowSelectStart&&opt_allow
SelectStart.call(this,e)))e.preventDefault()};document.ondragstart=function(e){i
f(!(opt_allowDragStart&&opt_allowDragStart.call(this,e)))e.preventDefault()}}fun
ction preventDefaultOnPoundLinkClicks(){document.addEventListener("click",functi
on(e){var anchor=findAncestor(e.target,function(el){return el.tagName=="A"});if(
anchor&&anchor.getAttribute("href")=="#")e.preventDefault()})}function isRTL(){r
eturn document.documentElement.dir=="rtl"}function getRequiredElement(id){return
assertInstanceof($(id),HTMLElement,"Missing required element: "+id)}function qu
eryRequiredElement(selectors,opt_context){var element=(opt_context||document).qu
erySelector(selectors);return assertInstanceof(element,HTMLElement,"Missing requ
ired element: "+selectors)}["click","auxclick"].forEach(function(eventName){docu
ment.addEventListener(eventName,function(e){if(e.button>1)return;if(e.defaultPre
vented)return;var eventPath=e.path;var anchor=null;if(eventPath){for(var i=0;i<e
ventPath.length;i++){var element=eventPath[i];if(element.tagName==="A"&&element.
href){anchor=element;break}}}var el=e.target;if(!anchor&&el.nodeType==Node.ELEME
NT_NODE&&el.webkitMatchesSelector("A, A *")){while(el.tagName!="A"){el=el.parent
Element}anchor=el}if(!anchor)return;anchor=anchor;if((anchor.protocol=="file:"||
anchor.protocol=="about:")&&(e.button==0||e.button==1)){chrome.send("navigateToU
rl",[anchor.href,anchor.target,e.button,e.altKey,e.ctrlKey,e.metaKey,e.shiftKey]
);e.preventDefault()}})});function appendParam(url,key,value){var param=encodeUR
IComponent(key)+"="+encodeURIComponent(value);if(url.indexOf("?")==-1)return url
+"?"+param;return url+"&"+param}function createElementWithClassName(type,classNa
me){var elm=document.createElement(type);elm.className=className;return elm}func
tion ensureTransitionEndEvent(el,opt_timeOut){if(opt_timeOut===undefined){var st
yle=getComputedStyle(el);opt_timeOut=parseFloat(style.transitionDuration)*1e3;op
t_timeOut+=50}var fired=false;el.addEventListener("webkitTransitionEnd",function
f(e){el.removeEventListener("webkitTransitionEnd",f);fired=true});window.setTim
eout(function(){if(!fired)cr.dispatchSimpleEvent(el,"webkitTransitionEnd",true)}
,opt_timeOut)}function scrollTopForDocument(doc){return doc.documentElement.scro
llTop||doc.body.scrollTop}function setScrollTopForDocument(doc,value){doc.docume
ntElement.scrollTop=doc.body.scrollTop=value}function scrollLeftForDocument(doc)
{return doc.documentElement.scrollLeft||doc.body.scrollLeft}function setScrollLe
ftForDocument(doc,value){doc.documentElement.scrollLeft=doc.body.scrollLeft=valu
e}function HTMLEscape(original){return original.replace(/&/g,"&").replace(/<
/g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}fun
ction elide(original,maxLength){if(original.length<=maxLength)return original;re
turn original.substring(0,maxLength-1)+"…"}function quoteString(str){return str.
replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g,"\\$1")}function listenOnc
e(target,eventNames,callback){if(!Array.isArray(eventNames))eventNames=eventName
s.split(/ +/);var removeAllAndCallCallback=function(event){eventNames.forEach(fu
nction(eventName){target.removeEventListener(eventName,removeAllAndCallCallback,
false)});return callback(event)};eventNames.forEach(function(eventName){target.a
ddEventListener(eventName,removeAllAndCallCallback,false)})} |
25 // <if expr="is_ios"> | 25 // <if expr="is_ios"> |
26 if(!("key"in KeyboardEvent.prototype)){Object.defineProperty(KeyboardEvent.proto
type,"key",{get:function(){if(this.keyCode>=48&&this.keyCode<=57)return String.f
romCharCode(this.keyCode);if(this.keyCode>=65&&this.keyCode<=90){var result=Stri
ng.fromCharCode(this.keyCode).toLowerCase();if(this.shiftKey)result=result.toUpp
erCase();return result}switch(this.keyCode){case 8:return"Backspace";case 9:retu
rn"Tab";case 13:return"Enter";case 16:return"Shift";case 17:return"Control";case
18:return"Alt";case 27:return"Escape";case 32:return" ";case 33:return"PageUp";
case 34:return"PageDown";case 35:return"End";case 36:return"Home";case 37:return
"ArrowLeft";case 38:return"ArrowUp";case 39:return"ArrowRight";case 40:return"Ar
rowDown";case 45:return"Insert";case 46:return"Delete";case 91:return"Meta";case
112:return"F1";case 113:return"F2";case 114:return"F3";case 115:return"F4";case
116:return"F5";case 117:return"F6";case 118:return"F7";case 119:return"F8";case
120:return"F9";case 121:return"F10";case 122:return"F11";case 123:return"F12";c
ase 187:return"=";case 189:return"-";case 219:return"[";case 221:return"]"}retur
n"Unidentified"}})}else{window.console.log("KeyboardEvent.Key polyfill not requi
red")} | 26 if(!("key"in KeyboardEvent.prototype)){Object.defineProperty(KeyboardEvent.proto
type,"key",{get:function(){if(this.keyCode>=48&&this.keyCode<=57)return String.f
romCharCode(this.keyCode);if(this.keyCode>=65&&this.keyCode<=90){var result=Stri
ng.fromCharCode(this.keyCode).toLowerCase();if(this.shiftKey)result=result.toUpp
erCase();return result}switch(this.keyCode){case 8:return"Backspace";case 9:retu
rn"Tab";case 13:return"Enter";case 16:return"Shift";case 17:return"Control";case
18:return"Alt";case 27:return"Escape";case 32:return" ";case 33:return"PageUp";
case 34:return"PageDown";case 35:return"End";case 36:return"Home";case 37:return
"ArrowLeft";case 38:return"ArrowUp";case 39:return"ArrowRight";case 40:return"Ar
rowDown";case 45:return"Insert";case 46:return"Delete";case 91:return"Meta";case
112:return"F1";case 113:return"F2";case 114:return"F3";case 115:return"F4";case
116:return"F5";case 117:return"F6";case 118:return"F7";case 119:return"F8";case
120:return"F9";case 121:return"F10";case 122:return"F11";case 123:return"F12";c
ase 187:return"=";case 189:return"-";case 219:return"[";case 221:return"]"}retur
n"Unidentified"}})}else{window.console.log("KeyboardEvent.Key polyfill not requi
red")} |
27 // </if> /* is_ios */ | 27 // </if> /* is_ios */ |
28 Polymer.IronResizableBehavior={properties:{_parentResizable:{type:Object,observe
r:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,value:false}},li
steners:{"iron-request-resize-notifications":"_onIronRequestResizeNotifications"
},created:function(){this._interestedResizables=[];this._boundNotifyResize=this.
notifyResize.bind(this)},attached:function(){this.fire("iron-request-resize-noti
fications",null,{node:this,bubbles:true,cancelable:true});if(!this._parentResiza
ble){window.addEventListener("resize",this._boundNotifyResize);this.notifyResize
()}},detached:function(){if(this._parentResizable){this._parentResizable.stopRes
izeNotificationsFor(this)}else{window.removeEventListener("resize",this._boundNo
tifyResize)}this._parentResizable=null},notifyResize:function(){if(!this.isAttac
hed){return}this._interestedResizables.forEach(function(resizable){if(this.resiz
erShouldNotify(resizable)){this._notifyDescendant(resizable)}},this);this._fireR
esize()},assignParentResizable:function(parentResizable){this._parentResizable=p
arentResizable},stopResizeNotificationsFor:function(target){var index=this._inte
restedResizables.indexOf(target);if(index>-1){this._interestedResizables.splice(
index,1);this.unlisten(target,"iron-resize","_onDescendantIronResize")}},resizer
ShouldNotify:function(element){return true},_onDescendantIronResize:function(eve
nt){if(this._notifyingDescendant){event.stopPropagation();return}if(!Polymer.Set
tings.useShadow){this._fireResize()}},_fireResize:function(){this.fire("iron-res
ize",null,{node:this,bubbles:false})},_onIronRequestResizeNotifications:function
(event){var target=event.path?event.path[0]:event.target;if(target===this){retur
n}if(this._interestedResizables.indexOf(target)===-1){this._interestedResizables
.push(target);this.listen(target,"iron-resize","_onDescendantIronResize")}target
.assignParentResizable(this);this._notifyDescendant(target);event.stopPropagatio
n()},_parentResizableChanged:function(parentResizable){if(parentResizable){windo
w.removeEventListener("resize",this._boundNotifyResize)}},_notifyDescendant:func
tion(descendant){if(!this.isAttached){return}this._notifyingDescendant=true;desc
endant.notifyResize();this._notifyingDescendant=false}};(function(){"use strict"
;var KEY_IDENTIFIER={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020"
:"space","U+007F":"del"};var KEY_CODE={8:"backspace",9:"tab",13:"enter",27:"esc"
,33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"r
ight",40:"down",46:"del",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrl
Key",alt:"altKey",meta:"metaKey"};var KEY_CHAR=/[a-z0-9*]/;var IDENT_CHAR=/U\+/;
var ARROW_KEY=/^arrow/;var SPACE_KEY=/^space(bar)?/;var ESC_KEY=/^escape$/;funct
ion transformKey(key,noSpecialChars){var validKey="";if(key){var lKey=key.toLowe
rCase();if(lKey===" "||SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_KEY.te
st(lKey)){validKey="esc"}else if(lKey.length==1){if(!noSpecialChars||KEY_CHAR.te
st(lKey)){validKey=lKey}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replace("ar
row","")}else if(lKey=="multiply"){validKey="*"}else{validKey=lKey}}return valid
Key}function transformKeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(ke
yIdent in KEY_IDENTIFIER){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_CHAR.t
est(keyIdent)){keyIdent=parseInt(keyIdent.replace("U+","0x"),16);validKey=String
.fromCharCode(keyIdent).toLowerCase()}else{validKey=keyIdent.toLowerCase()}}retu
rn validKey}function transformKeyCode(keyCode){var validKey="";if(Number(keyCode
)){if(keyCode>=65&&keyCode<=90){validKey=String.fromCharCode(32+keyCode)}else if
(keyCode>=112&&keyCode<=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&key
Code<=57){validKey=String(keyCode-48)}else if(keyCode>=96&&keyCode<=105){validKe
y=String(keyCode-96)}else{validKey=KEY_CODE[keyCode]}}return validKey}function n
ormalizedKeyForEvent(keyEvent,noSpecialChars){if(keyEvent.key){return transformK
ey(keyEvent.key,noSpecialChars)}if(keyEvent.detail&&keyEvent.detail.key){return
transformKey(keyEvent.detail.key,noSpecialChars)}return transformKeyIdentifier(k
eyEvent.keyIdentifier)||transformKeyCode(keyEvent.keyCode)||""}function keyCombo
MatchesEvent(keyCombo,event){var keyEvent=normalizedKeyForEvent(event,keyCombo.h
asModifiers);return keyEvent===keyCombo.key&&(!keyCombo.hasModifiers||!!event.sh
iftKey===!!keyCombo.shiftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event.altK
ey===!!keyCombo.altKey&&!!event.metaKey===!!keyCombo.metaKey)}function parseKeyC
omboString(keyComboString){if(keyComboString.length===1){return{combo:keyComboSt
ring,key:keyComboString,event:"keydown"}}return keyComboString.split("+").reduce
(function(parsedKeyCombo,keyComboPart){var eventParts=keyComboPart.split(":");va
r keyName=eventParts[0];var event=eventParts[1];if(keyName in MODIFIER_KEYS){par
sedKeyCombo[MODIFIER_KEYS[keyName]]=true;parsedKeyCombo.hasModifiers=true}else{p
arsedKeyCombo.key=keyName;parsedKeyCombo.event=event||"keydown"}return parsedKey
Combo},{combo:keyComboString.split(":").shift()})}function parseEventString(even
tString){return eventString.trim().split(" ").map(function(keyComboString){retur
n parseKeyComboString(keyComboString)})}Polymer.IronA11yKeysBehavior={properties
:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEventPr
opagation:{type:Boolean,value:false},_boundKeyHandlers:{type:Array,value:functio
n(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{}}}},
observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],keyBind
ings:{},registered:function(){this._prepKeyBindings()},attached:function(){this.
_listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListeners(
)},addOwnKeyBinding:function(eventString,handlerName){this._imperativeKeyBinding
s[eventString]=handlerName;this._prepKeyBindings();this._resetKeyEventListeners(
)},removeOwnKeyBindings:function(){this._imperativeKeyBindings={};this._prepKeyB
indings();this._resetKeyEventListeners()},keyboardEventMatchesKeys:function(even
t,eventString){var keyCombos=parseEventString(eventString);for(var i=0;i<keyComb
os.length;++i){if(keyComboMatchesEvent(keyCombos[i],event)){return true}}return
false},_collectKeyBindings:function(){var keyBindings=this.behaviors.map(functio
n(behavior){return behavior.keyBindings});if(keyBindings.indexOf(this.keyBinding
s)===-1){keyBindings.push(this.keyBindings)}return keyBindings},_prepKeyBindings
:function(){this._keyBindings={};this._collectKeyBindings().forEach(function(key
Bindings){for(var eventString in keyBindings){this._addKeyBinding(eventString,ke
yBindings[eventString])}},this);for(var eventString in this._imperativeKeyBindin
gs){this._addKeyBinding(eventString,this._imperativeKeyBindings[eventString])}fo
r(var eventName in this._keyBindings){this._keyBindings[eventName].sort(function
(kb1,kb2){var b1=kb1[0].hasModifiers;var b2=kb2[0].hasModifiers;return b1===b2?0
:b1?-1:1})}},_addKeyBinding:function(eventString,handlerName){parseEventString(e
ventString).forEach(function(keyCombo){this._keyBindings[keyCombo.event]=this._k
eyBindings[keyCombo.event]||[];this._keyBindings[keyCombo.event].push([keyCombo,
handlerName])},this)},_resetKeyEventListeners:function(){this._unlistenKeyEventL
isteners();if(this.isAttached){this._listenKeyEventListeners()}},_listenKeyEvent
Listeners:function(){if(!this.keyEventTarget){return}Object.keys(this._keyBindin
gs).forEach(function(eventName){var keyBindings=this._keyBindings[eventName];var
boundKeyHandler=this._onKeyBindingEvent.bind(this,keyBindings);this._boundKeyHa
ndlers.push([this.keyEventTarget,eventName,boundKeyHandler]);this.keyEventTarget
.addEventListener(eventName,boundKeyHandler)},this)},_unlistenKeyEventListeners:
function(){var keyHandlerTuple;var keyEventTarget;var eventName;var boundKeyHand
ler;while(this._boundKeyHandlers.length){keyHandlerTuple=this._boundKeyHandlers.
pop();keyEventTarget=keyHandlerTuple[0];eventName=keyHandlerTuple[1];boundKeyHan
dler=keyHandlerTuple[2];keyEventTarget.removeEventListener(eventName,boundKeyHan
dler)}},_onKeyBindingEvent:function(keyBindings,event){if(this.stopKeyboardEvent
Propagation){event.stopPropagation()}if(event.defaultPrevented){return}for(var i
=0;i<keyBindings.length;i++){var keyCombo=keyBindings[i][0];var handlerName=keyB
indings[i][1];if(keyComboMatchesEvent(keyCombo,event)){this._triggerKeyHandler(k
eyCombo,handlerName,event);if(event.defaultPrevented){return}}}},_triggerKeyHand
ler:function(keyCombo,handlerName,keyboardEvent){var detail=Object.create(keyCom
bo);detail.keyboardEvent=keyboardEvent;var event=new CustomEvent(keyCombo.event,
{detail:detail,cancelable:true});this[handlerName].call(this,event);if(event.def
aultPrevented){keyboardEvent.preventDefault()}}}})();Polymer.IronScrollTargetBeh
avior={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._
defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached
)"],_shouldHaveListener:true,_scrollTargetChanged:function(scrollTarget,isAttach
ed){var eventTarget;if(this._oldScrollTarget){this._toggleScrollListener(false,t
his._oldScrollTarget);this._oldScrollTarget=null}if(!isAttached){return}if(scrol
lTarget==="document"){this.scrollTarget=this._doc}else if(typeof scrollTarget===
"string"){this.scrollTarget=this.domHost?this.domHost.$[scrollTarget]:Polymer.do
m(this.ownerDocument).querySelector("#"+scrollTarget)}else if(this._isValidScrol
lTarget()){this._boundScrollHandler=this._boundScrollHandler||this._scrollHandle
r.bind(this);this._oldScrollTarget=scrollTarget;this._toggleScrollListener(this.
_shouldHaveListener,scrollTarget)}},_scrollHandler:function scrollHandler(){},ge
t _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.
documentElement},get _scrollTop(){if(this._isValidScrollTarget()){return this.sc
rollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop}return 0},
get _scrollLeft(){if(this._isValidScrollTarget()){return this.scrollTarget===thi
s._doc?window.pageXOffset:this.scrollTarget.scrollLeft}return 0},set _scrollTop(
top){if(this.scrollTarget===this._doc){window.scrollTo(window.pageXOffset,top)}e
lse if(this._isValidScrollTarget()){this.scrollTarget.scrollTop=top}},set _scrol
lLeft(left){if(this.scrollTarget===this._doc){window.scrollTo(left,window.pageYO
ffset)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left}},
scroll:function(left,top){if(this.scrollTarget===this._doc){window.scrollTo(left
,top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left;thi
s.scrollTarget.scrollTop=top}},get _scrollTargetWidth(){if(this._isValidScrollTa
rget()){return this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget
.offsetWidth}return 0},get _scrollTargetHeight(){if(this._isValidScrollTarget())
{return this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offse
tHeight}return 0},_isValidScrollTarget:function(){return this.scrollTarget insta
nceof HTMLElement},_toggleScrollListener:function(yes,scrollTarget){if(!this._bo
undScrollHandler){return}var eventTarget=scrollTarget===this._doc?window:scrollT
arget;if(yes){eventTarget.addEventListener("scroll",this._boundScrollHandler)}el
se{eventTarget.removeEventListener("scroll",this._boundScrollHandler)}},toggleSc
rollListener:function(yes){this._shouldHaveListener=yes;this._toggleScrollListen
er(yes,this.scrollTarget)}};(function(){var IOS=navigator.userAgent.match(/iP(?:
hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;var DEFA
ULT_PHYSICAL_COUNT=3;var HIDDEN_Y="-10000px";var ITEM_WIDTH=0;var ITEM_HEIGHT=1;
var SECRET_TABINDEX=-100;Polymer({is:"iron-list",properties:{items:{type:Array},
maxPhysicalCount:{type:Number,value:500},as:{type:String,value:"item"},indexAs:{
type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:
Boolean,value:false,reflectToAttribute:true},selectionEnabled:{type:Boolean,valu
e:false},selectedItem:{type:Object,notify:true},selectedItems:{type:Object,notif
y:true},multiSelection:{type:Boolean,value:false}},observers:["_itemsChanged(ite
ms.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(mult
iSelection)","_setOverflow(scrollTarget)"],behaviors:[Polymer.Templatizer,Polyme
r.IronResizableBehavior,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTargetBeh
avior],keyBindings:{up:"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"},_rati
o:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,
_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_physicalIndexForKey:null
,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physical
Items:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:n
ull,_collection:null,_maxPages:2,_focusedItem:null,_focusedIndex:-1,_offscreenFo
cusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,
_templateCost:0,get _physicalBottom(){return this._physicalTop+this._physicalSiz
e},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _vi
rtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSi
ze(){var size=this.grid?this._physicalRows*this._rowHeight:this._physicalSize;re
turn size-this._viewportHeight},get _maxScrollTop(){return this._estScrollHeight
-this._viewportHeight+this._scrollerPaddingTop},_minVirtualStart:0,get _maxVirtu
alStart(){return Math.max(0,this._virtualCount-this._physicalCount)},_virtualSta
rtVal:0,set _virtualStart(val){this._virtualStartVal=Math.min(this._maxVirtualSt
art,Math.max(this._minVirtualStart,val))},get _virtualStart(){return this._virtu
alStartVal||0},_physicalStartVal:0,set _physicalStart(val){this._physicalStartVa
l=val%this._physicalCount;if(this._physicalStartVal<0){this._physicalStartVal=th
is._physicalCount+this._physicalStartVal}this._physicalEnd=(this._physicalStart+
this._physicalCount-1)%this._physicalCount},get _physicalStart(){return this._ph
ysicalStartVal||0},_physicalCountVal:0,set _physicalCount(val){this._physicalCou
ntVal=val;this._physicalEnd=(this._physicalStart+this._physicalCount-1)%this._ph
ysicalCount},get _physicalCount(){return this._physicalCountVal},_physicalEnd:0,
get _optPhysicalSize(){if(this.grid){return this._estRowsInView*this._rowHeight*
this._maxPages}return this._viewportHeight*this._maxPages},get _isVisible(){retu
rn Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){if(this
._firstVisibleIndexVal===null){var physicalOffset=Math.floor(this._physicalTop+t
his._scrollerPaddingTop);this._firstVisibleIndexVal=this._iterateItems(function(
pidx,vidx){physicalOffset+=this._getPhysicalSizeIncrement(pidx);if(physicalOffse
t>this._scrollPosition){return this.grid?vidx-vidx%this._itemsPerRow:vidx}if(thi
s.grid&&this._virtualCount-1===vidx){return vidx-vidx%this._itemsPerRow}})||0}re
turn this._firstVisibleIndexVal},get lastVisibleIndex(){if(this._lastVisibleInde
xVal===null){if(this.grid){var lastIndex=this.firstVisibleIndex+this._estRowsInV
iew*this._itemsPerRow-1;this._lastVisibleIndexVal=Math.min(this._virtualCount,la
stIndex)}else{var physicalOffset=this._physicalTop;this._iterateItems(function(p
idx,vidx){if(physicalOffset<this._scrollBottom){this._lastVisibleIndexVal=vidx}e
lse{return true}physicalOffset+=this._getPhysicalSizeIncrement(pidx)})}}return t
his._lastVisibleIndexVal},get _defaultScrollTarget(){return this},get _virtualRo
wCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsInV
iew(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRows(
){return Math.ceil(this._physicalCount/this._itemsPerRow)},ready:function(){this
.addEventListener("focus",this._didFocus.bind(this),true)},attached:function(){i
f(this._physicalCount===0){this._debounceTemplate(this._render)}this.listen(this
,"iron-resize","_resizeHandler")},detached:function(){this.unlisten(this,"iron-r
esize","_resizeHandler")},_setOverflow:function(scrollTarget){this.style.webkitO
verflowScrolling=scrollTarget===this?"touch":"";this.style.overflow=scrollTarget
===this?"auto":""},updateViewportBoundaries:function(){this._scrollerPaddingTop=
this.scrollTarget===this?0:parseInt(window.getComputedStyle(this)["padding-top"]
,10);this._viewportWidth=this.$.items.offsetWidth;this._viewportHeight=this._scr
ollTargetHeight;this.grid&&this._updateGridMetrics()},_scrollHandler:function(){
var scrollTop=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop));var delta
=scrollTop-this._scrollPosition;var isScrollingDown=delta>=0;this._scrollPositio
n=scrollTop;this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;if(Ma
th.abs(delta)>this._physicalSize){var idxAdjustment=Math.round(delta/this._physi
calAverage)*this._itemsPerRow;this._physicalTop=this._physicalTop+delta;this._vi
rtualStart=this._virtualStart+idxAdjustment;this._physicalStart=this._physicalSt
art+idxAdjustment;this._update()}else{var reusables=this._getReusables(isScrolli
ngDown);if(isScrollingDown){this._physicalTop=reusables.physicalTop;this._virtua
lStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this._phy
sicalStart+reusables.indexes.length}else{this._virtualStart=this._virtualStart-r
eusables.indexes.length;this._physicalStart=this._physicalStart-reusables.indexe
s.length}if(reusables.indexes.length===0){this._increasePoolIfNeeded()}else{this
._update(reusables.indexes,isScrollingDown?null:reusables.indexes)}}},_getReusab
les:function(fromTop){var ith,lastIth,offsetContent,physicalItemHeight;var idxs=
[];var protectedOffsetContent=this._hiddenContentSize*this._ratio;var virtualSta
rt=this._virtualStart;var virtualEnd=this._virtualEnd;var physicalCount=this._ph
ysicalCount;var physicalTop=this._physicalTop;var scrollTop=this._scrollTop;var
scrollBottom=this._scrollBottom;if(fromTop){ith=this._physicalStart;lastIth=this
._physicalEnd;offsetContent=scrollTop-physicalTop}else{ith=this._physicalEnd;las
tIth=this._physicalStart;offsetContent=this._physicalBottom-scrollBottom}while(t
rue){physicalItemHeight=this._getPhysicalSizeIncrement(ith);offsetContent=offset
Content-physicalItemHeight;if(idxs.length>=physicalCount||offsetContent<=protect
edOffsetContent){break}if(fromTop){if(virtualEnd+idxs.length+1>=this._virtualCou
nt){break}if(physicalTop+physicalItemHeight>=scrollTop){break}idxs.push(ith);phy
sicalTop=physicalTop+physicalItemHeight;ith=(ith+1)%physicalCount}else{if(virtua
lStart-idxs.length<=0){break}if(physicalTop+this._physicalSize-physicalItemHeigh
t<=scrollBottom){break}idxs.push(ith);physicalTop=physicalTop-physicalItemHeight
;ith=ith===0?physicalCount-1:ith-1}}return{indexes:idxs,physicalTop:physicalTop}
},_update:function(itemSet,movingUp){if(itemSet&&itemSet.length===0){return}this
._manageFocus();this._assignModels(itemSet);this._updateMetrics(itemSet);if(movi
ngUp){while(movingUp.length){var idx=movingUp.pop();this._physicalTop-=this._get
PhysicalSizeIncrement(idx)}}this._positionItems();this._updateScrollerSize();thi
s._increasePoolIfNeeded()},_createPool:function(size){var physicalItems=new Arra
y(size);this._ensureTemplatized();for(var i=0;i<size;i++){var inst=this.stamp(nu
ll);physicalItems[i]=inst.root.querySelector("*");Polymer.dom(this).appendChild(
inst.root)}return physicalItems},_increasePoolIfNeeded:function(){if(this._viewp
ortHeight===0){return false}var self=this;var isClientFull=this._physicalBottom>
=this._scrollBottom&&this._physicalTop<=this._scrollPosition;if(this._physicalSi
ze>=this._optPhysicalSize&&isClientFull){return false}var maxPoolSize=Math.round
(this._physicalCount*.5);if(!isClientFull){this._debounceTemplate(this._increase
Pool.bind(this,maxPoolSize));return true}this._yield(function(){self._increasePo
ol(Math.min(maxPoolSize,Math.max(1,Math.round(50/self._templateCost))))});return
true},_yield:function(cb){var g=window;var handle=g.requestIdleCallback?g.reque
stIdleCallback(cb):g.setTimeout(cb,16);Polymer.dom.addDebouncer({complete:functi
on(){g.cancelIdleCallback?g.cancelIdleCallback(handle):g.clearTimeout(handle);cb
()}})},_increasePool:function(missingItems){var nextPhysicalCount=Math.min(this.
_physicalCount+missingItems,this._virtualCount-this._virtualStart,Math.max(this.
maxPhysicalCount,DEFAULT_PHYSICAL_COUNT));var prevPhysicalCount=this._physicalCo
unt;var delta=nextPhysicalCount-prevPhysicalCount;var ts=window.performance.now(
);if(delta<=0){return}[].push.apply(this._physicalItems,this._createPool(delta))
;[].push.apply(this._physicalSizes,new Array(delta));this._physicalCount=prevPhy
sicalCount+delta;if(this._physicalStart>this._physicalEnd&&this._isIndexRendered
(this._focusedIndex)&&this._getPhysicalIndex(this._focusedIndex)<this._physicalE
nd){this._physicalStart=this._physicalStart+delta}this._update();this._templateC
ost=(window.performance.now()-ts)/delta},_render:function(){if(this.isAttached&&
this._isVisible){if(this._physicalCount===0){this.updateViewportBoundaries();thi
s._increasePool(DEFAULT_PHYSICAL_COUNT)}else{var reusables=this._getReusables(tr
ue);this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualStar
t+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.ind
exes.length;this._update(reusables.indexes);this._update()}}},_ensureTemplatized
:function(){if(!this.ctor){var props={};props.__key__=true;props[this.as]=true;p
rops[this.indexAs]=true;props[this.selectedAs]=true;props.tabIndex=true;this._in
stanceProps=props;this._userTemplate=Polymer.dom(this).querySelector("template")
;if(this._userTemplate){this.templatize(this._userTemplate)}else{console.warn("i
ron-list requires a template to be provided in light-dom")}}},_getStampedChildre
n:function(){return this._physicalItems},_forwardInstancePath:function(inst,path
,value){if(path.indexOf(this.as+".")===0){this.notifyPath("items."+inst.__key__+
"."+path.slice(this.as.length+1),value)}},_forwardParentProp:function(prop,value
){if(this._physicalItems){this._physicalItems.forEach(function(item){item._templ
ateInstance[prop]=value},this)}},_forwardParentPath:function(path,value){if(this
._physicalItems){this._physicalItems.forEach(function(item){item._templateInstan
ce.notifyPath(path,value,true)},this)}},_forwardItemPath:function(path,value){if
(!this._physicalIndexForKey){return}var dot=path.indexOf(".");var key=path.subst
ring(0,dot<0?path.length:dot);var idx=this._physicalIndexForKey[key];var offscre
enItem=this._offscreenFocusedItem;var el=offscreenItem&&offscreenItem._templateI
nstance.__key__===key?offscreenItem:this._physicalItems[idx];if(!el||el._templat
eInstance.__key__!==key){return}if(dot>=0){path=this.as+"."+path.substring(dot+1
);el._templateInstance.notifyPath(path,value,true)}else{var currentItem=el._temp
lateInstance[this.as];if(Array.isArray(this.selectedItems)){for(var i=0;i<this.s
electedItems.length;i++){if(this.selectedItems[i]===currentItem){this.set("selec
tedItems."+i,value);break}}}else if(this.selectedItem===currentItem){this.set("s
electedItem",value)}el._templateInstance[this.as]=value}},_itemsChanged:function
(change){if(change.path==="items"){this._virtualStart=0;this._physicalTop=0;this
._virtualCount=this.items?this.items.length:0;this._collection=this.items?Polyme
r.Collection.get(this.items):null;this._physicalIndexForKey={};this._firstVisibl
eIndexVal=null;this._lastVisibleIndexVal=null;this._physicalCount=this._physical
Count||0;this._physicalItems=this._physicalItems||[];this._physicalSizes=this._p
hysicalSizes||[];this._physicalStart=0;this._resetScrollPosition(0);this._remove
FocusedItem();this._debounceTemplate(this._render)}else if(change.path==="items.
splices"){this._adjustVirtualIndex(change.value.indexSplices);this._virtualCount
=this.items?this.items.length:0;this._debounceTemplate(this._render)}else{this._
forwardItemPath(change.path.split(".").slice(1).join("."),change.value)}},_adjus
tVirtualIndex:function(splices){splices.forEach(function(splice){splice.removed.
forEach(this._removeItem,this);if(splice.index<this._virtualStart){var delta=Mat
h.max(splice.addedCount-splice.removed.length,splice.index-this._virtualStart);t
his._virtualStart=this._virtualStart+delta;if(this._focusedIndex>=0){this._focus
edIndex=this._focusedIndex+delta}}},this)},_removeItem:function(item){this.$.sel
ector.deselect(item);if(this._focusedItem&&this._focusedItem._templateInstance[t
his.as]===item){this._removeFocusedItem()}},_iterateItems:function(fn,itemSet){v
ar pidx,vidx,rtn,i;if(arguments.length===2&&itemSet){for(i=0;i<itemSet.length;i+
+){pidx=itemSet[i];vidx=this._computeVidx(pidx);if((rtn=fn.call(this,pidx,vidx))
!=null){return rtn}}}else{pidx=this._physicalStart;vidx=this._virtualStart;for(;
pidx<this._physicalCount;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){
return rtn}}for(pidx=0;pidx<this._physicalStart;pidx++,vidx++){if((rtn=fn.call(t
his,pidx,vidx))!=null){return rtn}}}},_computeVidx:function(pidx){if(pidx>=this.
_physicalStart){return this._virtualStart+(pidx-this._physicalStart)}return this
._virtualStart+(this._physicalCount-this._physicalStart)+pidx},_assignModels:fun
ction(itemSet){this._iterateItems(function(pidx,vidx){var el=this._physicalItems
[pidx];var inst=el._templateInstance;var item=this.items&&this.items[vidx];if(it
em!=null){inst[this.as]=item;inst.__key__=this._collection.getKey(item);inst[thi
s.selectedAs]=this.$.selector.isSelected(item);inst[this.indexAs]=vidx;inst.tabI
ndex=this._focusedIndex===vidx?0:-1;this._physicalIndexForKey[inst.__key__]=pidx
;el.removeAttribute("hidden")}else{inst.__key__=null;el.setAttribute("hidden",""
)}},itemSet)},_updateMetrics:function(itemSet){Polymer.dom.flush();var newPhysic
alSize=0;var oldPhysicalSize=0;var prevAvgCount=this._physicalAverageCount;var p
revPhysicalAvg=this._physicalAverage;this._iterateItems(function(pidx,vidx){oldP
hysicalSize+=this._physicalSizes[pidx]||0;this._physicalSizes[pidx]=this._physic
alItems[pidx].offsetHeight;newPhysicalSize+=this._physicalSizes[pidx];this._phys
icalAverageCount+=this._physicalSizes[pidx]?1:0},itemSet);if(this.grid){this._up
dateGridMetrics();this._physicalSize=Math.ceil(this._physicalCount/this._itemsPe
rRow)*this._rowHeight}else{this._physicalSize=this._physicalSize+newPhysicalSize
-oldPhysicalSize}if(this._physicalAverageCount!==prevAvgCount){this._physicalAve
rage=Math.round((prevPhysicalAvg*prevAvgCount+newPhysicalSize)/this._physicalAve
rageCount)}},_updateGridMetrics:function(){this._itemWidth=this._physicalCount>0
?this._physicalItems[0].getBoundingClientRect().width:200;this._rowHeight=this._
physicalCount>0?this._physicalItems[0].offsetHeight:200;this._itemsPerRow=this._
itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_po
sitionItems:function(){this._adjustScrollPosition();var y=this._physicalTop;if(t
his.grid){var totalItemWidth=this._itemsPerRow*this._itemWidth;var rowOffset=(th
is._viewportWidth-totalItemWidth)/2;this._iterateItems(function(pidx,vidx){var m
odulus=vidx%this._itemsPerRow;var x=Math.floor(modulus*this._itemWidth+rowOffset
);this.translate3d(x+"px",y+"px",0,this._physicalItems[pidx]);if(this._shouldRen
derNextRow(vidx)){y+=this._rowHeight}})}else{this._iterateItems(function(pidx,vi
dx){this.translate3d(0,y+"px",0,this._physicalItems[pidx]);y+=this._physicalSize
s[pidx]})}},_getPhysicalSizeIncrement:function(pidx){if(!this.grid){return this.
_physicalSizes[pidx]}if(this._computeVidx(pidx)%this._itemsPerRow!==this._itemsP
erRow-1){return 0}return this._rowHeight},_shouldRenderNextRow:function(vidx){re
turn vidx%this._itemsPerRow===this._itemsPerRow-1},_adjustScrollPosition:functio
n(){var deltaHeight=this._virtualStart===0?this._physicalTop:Math.min(this._scro
llPosition+this._physicalTop,0);if(deltaHeight){this._physicalTop=this._physical
Top-deltaHeight;if(!IOS_TOUCH_SCROLLING&&this._physicalTop!==0){this._resetScrol
lPosition(this._scrollTop-deltaHeight)}}},_resetScrollPosition:function(pos){if(
this.scrollTarget){this._scrollTop=pos;this._scrollPosition=this._scrollTop}},_u
pdateScrollerSize:function(forceUpdate){if(this.grid){this._estScrollHeight=this
._virtualRowCount*this._rowHeight}else{this._estScrollHeight=this._physicalBotto
m+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._ph
ysicalAverage}forceUpdate=forceUpdate||this._scrollHeight===0;forceUpdate=forceU
pdate||this._scrollPosition>=this._estScrollHeight-this._physicalSize;forceUpdat
e=forceUpdate||this.grid&&this.$.items.style.height<this._estScrollHeight;if(for
ceUpdate||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._optPhysicalS
ize){this.$.items.style.height=this._estScrollHeight+"px";this._scrollHeight=thi
s._estScrollHeight}},scrollToItem:function(item){return this.scrollToIndex(this.
items.indexOf(item))},scrollToIndex:function(idx){if(typeof idx!=="number"||idx<
0||idx>this.items.length-1){return}Polymer.dom.flush();if(this._physicalCount===
0){return}idx=Math.min(Math.max(idx,0),this._virtualCount-1);if(!this._isIndexRe
ndered(idx)||idx>=this._maxVirtualStart){this._virtualStart=this.grid?idx-this._
itemsPerRow*2:idx-1}this._manageFocus();this._assignModels();this._updateMetrics
();this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._phys
icalAverage;var currentTopItem=this._physicalStart;var currentVirtualItem=this._
virtualStart;var targetOffsetTop=0;var hiddenContentSize=this._hiddenContentSize
;while(currentVirtualItem<idx&&targetOffsetTop<=hiddenContentSize){targetOffsetT
op=targetOffsetTop+this._getPhysicalSizeIncrement(currentTopItem);currentTopItem
=(currentTopItem+1)%this._physicalCount;currentVirtualItem++}this._updateScrolle
rSize(true);this._positionItems();this._resetScrollPosition(this._physicalTop+th
is._scrollerPaddingTop+targetOffsetTop);this._increasePoolIfNeeded();this._first
VisibleIndexVal=null;this._lastVisibleIndexVal=null},_resetAverage:function(){th
is._physicalAverage=0;this._physicalAverageCount=0},_resizeHandler:function(){if
(IOS&&Math.abs(this._viewportHeight-this._scrollTargetHeight)<100){return}Polyme
r.dom.addDebouncer(this.debounce("_debounceTemplate",function(){this.updateViewp
ortBoundaries();this._render();if(this._isVisible){this.toggleScrollListener(tru
e);if(this._physicalCount>0){this._resetAverage();this.scrollToIndex(this.firstV
isibleIndex)}}else{this.toggleScrollListener(false)}}.bind(this),1))},_getModelF
romItem:function(item){var key=this._collection.getKey(item);var pidx=this._phys
icalIndexForKey[key];if(pidx!=null){return this._physicalItems[pidx]._templateIn
stance}return null},_getNormalizedItem:function(item){if(this._collection.getKey
(item)===undefined){if(typeof item==="number"){item=this.items[item];if(!item){t
hrow new RangeError("<item> not found")}return item}throw new TypeError("<item>
should be a valid item")}return item},selectItem:function(item){item=this._getNo
rmalizedItem(item);var model=this._getModelFromItem(item);if(!this.multiSelectio
n&&this.selectedItem){this.deselectItem(this.selectedItem)}if(model){model[this.
selectedAs]=true}this.$.selector.select(item);this.updateSizeForItem(item)},dese
lectItem:function(item){item=this._getNormalizedItem(item);var model=this._getMo
delFromItem(item);if(model){model[this.selectedAs]=false}this.$.selector.deselec
t(item);this.updateSizeForItem(item)},toggleSelectionForItem:function(item){item
=this._getNormalizedItem(item);if(this.$.selector.isSelected(item)){this.deselec
tItem(item)}else{this.selectItem(item)}},clearSelection:function(){function unse
lect(item){var model=this._getModelFromItem(item);if(model){model[this.selectedA
s]=false}}if(Array.isArray(this.selectedItems)){this.selectedItems.forEach(unsel
ect,this)}else if(this.selectedItem){unselect.call(this,this.selectedItem)}this.
$.selector.clearSelection()},_selectionEnabledChanged:function(selectionEnabled)
{var handler=selectionEnabled?this.listen:this.unlisten;handler.call(this,this,"
tap","_selectionHandler")},_selectionHandler:function(e){var model=this.modelFor
Element(e.target);if(!model){return}var modelTabIndex,activeElTabIndex;var targe
t=Polymer.dom(e).path[0];var activeEl=Polymer.dom(this.domHost?this.domHost.root
:document).activeElement;var physicalItem=this._physicalItems[this._getPhysicalI
ndex(model[this.indexAs])];if(target.localName==="input"||target.localName==="bu
tton"||target.localName==="select"){return}modelTabIndex=model.tabIndex;model.ta
bIndex=SECRET_TABINDEX; | 28 Polymer.IronResizableBehavior={properties:{_parentResizable:{type:Object,observe
r:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,value:false}},li
steners:{"iron-request-resize-notifications":"_onIronRequestResizeNotifications"
},created:function(){this._interestedResizables=[];this._boundNotifyResize=this.
notifyResize.bind(this)},attached:function(){this.fire("iron-request-resize-noti
fications",null,{node:this,bubbles:true,cancelable:true});if(!this._parentResiza
ble){window.addEventListener("resize",this._boundNotifyResize);this.notifyResize
()}},detached:function(){if(this._parentResizable){this._parentResizable.stopRes
izeNotificationsFor(this)}else{window.removeEventListener("resize",this._boundNo
tifyResize)}this._parentResizable=null},notifyResize:function(){if(!this.isAttac
hed){return}this._interestedResizables.forEach(function(resizable){if(this.resiz
erShouldNotify(resizable)){this._notifyDescendant(resizable)}},this);this._fireR
esize()},assignParentResizable:function(parentResizable){this._parentResizable=p
arentResizable},stopResizeNotificationsFor:function(target){var index=this._inte
restedResizables.indexOf(target);if(index>-1){this._interestedResizables.splice(
index,1);this.unlisten(target,"iron-resize","_onDescendantIronResize")}},resizer
ShouldNotify:function(element){return true},_onDescendantIronResize:function(eve
nt){if(this._notifyingDescendant){event.stopPropagation();return}if(!Polymer.Set
tings.useShadow){this._fireResize()}},_fireResize:function(){this.fire("iron-res
ize",null,{node:this,bubbles:false})},_onIronRequestResizeNotifications:function
(event){var target=event.path?event.path[0]:event.target;if(target===this){retur
n}if(this._interestedResizables.indexOf(target)===-1){this._interestedResizables
.push(target);this.listen(target,"iron-resize","_onDescendantIronResize")}target
.assignParentResizable(this);this._notifyDescendant(target);event.stopPropagatio
n()},_parentResizableChanged:function(parentResizable){if(parentResizable){windo
w.removeEventListener("resize",this._boundNotifyResize)}},_notifyDescendant:func
tion(descendant){if(!this.isAttached){return}this._notifyingDescendant=true;desc
endant.notifyResize();this._notifyingDescendant=false}};(function(){"use strict"
;var KEY_IDENTIFIER={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020"
:"space","U+007F":"del"};var KEY_CODE={8:"backspace",9:"tab",13:"enter",27:"esc"
,33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"r
ight",40:"down",46:"del",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrl
Key",alt:"altKey",meta:"metaKey"};var KEY_CHAR=/[a-z0-9*]/;var IDENT_CHAR=/U\+/;
var ARROW_KEY=/^arrow/;var SPACE_KEY=/^space(bar)?/;var ESC_KEY=/^escape$/;funct
ion transformKey(key,noSpecialChars){var validKey="";if(key){var lKey=key.toLowe
rCase();if(lKey===" "||SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_KEY.te
st(lKey)){validKey="esc"}else if(lKey.length==1){if(!noSpecialChars||KEY_CHAR.te
st(lKey)){validKey=lKey}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replace("ar
row","")}else if(lKey=="multiply"){validKey="*"}else{validKey=lKey}}return valid
Key}function transformKeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(ke
yIdent in KEY_IDENTIFIER){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_CHAR.t
est(keyIdent)){keyIdent=parseInt(keyIdent.replace("U+","0x"),16);validKey=String
.fromCharCode(keyIdent).toLowerCase()}else{validKey=keyIdent.toLowerCase()}}retu
rn validKey}function transformKeyCode(keyCode){var validKey="";if(Number(keyCode
)){if(keyCode>=65&&keyCode<=90){validKey=String.fromCharCode(32+keyCode)}else if
(keyCode>=112&&keyCode<=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&key
Code<=57){validKey=String(keyCode-48)}else if(keyCode>=96&&keyCode<=105){validKe
y=String(keyCode-96)}else{validKey=KEY_CODE[keyCode]}}return validKey}function n
ormalizedKeyForEvent(keyEvent,noSpecialChars){if(keyEvent.key){return transformK
ey(keyEvent.key,noSpecialChars)}if(keyEvent.detail&&keyEvent.detail.key){return
transformKey(keyEvent.detail.key,noSpecialChars)}return transformKeyIdentifier(k
eyEvent.keyIdentifier)||transformKeyCode(keyEvent.keyCode)||""}function keyCombo
MatchesEvent(keyCombo,event){var keyEvent=normalizedKeyForEvent(event,keyCombo.h
asModifiers);return keyEvent===keyCombo.key&&(!keyCombo.hasModifiers||!!event.sh
iftKey===!!keyCombo.shiftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event.altK
ey===!!keyCombo.altKey&&!!event.metaKey===!!keyCombo.metaKey)}function parseKeyC
omboString(keyComboString){if(keyComboString.length===1){return{combo:keyComboSt
ring,key:keyComboString,event:"keydown"}}return keyComboString.split("+").reduce
(function(parsedKeyCombo,keyComboPart){var eventParts=keyComboPart.split(":");va
r keyName=eventParts[0];var event=eventParts[1];if(keyName in MODIFIER_KEYS){par
sedKeyCombo[MODIFIER_KEYS[keyName]]=true;parsedKeyCombo.hasModifiers=true}else{p
arsedKeyCombo.key=keyName;parsedKeyCombo.event=event||"keydown"}return parsedKey
Combo},{combo:keyComboString.split(":").shift()})}function parseEventString(even
tString){return eventString.trim().split(" ").map(function(keyComboString){retur
n parseKeyComboString(keyComboString)})}Polymer.IronA11yKeysBehavior={properties
:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEventPr
opagation:{type:Boolean,value:false},_boundKeyHandlers:{type:Array,value:functio
n(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{}}}},
observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],keyBind
ings:{},registered:function(){this._prepKeyBindings()},attached:function(){this.
_listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListeners(
)},addOwnKeyBinding:function(eventString,handlerName){this._imperativeKeyBinding
s[eventString]=handlerName;this._prepKeyBindings();this._resetKeyEventListeners(
)},removeOwnKeyBindings:function(){this._imperativeKeyBindings={};this._prepKeyB
indings();this._resetKeyEventListeners()},keyboardEventMatchesKeys:function(even
t,eventString){var keyCombos=parseEventString(eventString);for(var i=0;i<keyComb
os.length;++i){if(keyComboMatchesEvent(keyCombos[i],event)){return true}}return
false},_collectKeyBindings:function(){var keyBindings=this.behaviors.map(functio
n(behavior){return behavior.keyBindings});if(keyBindings.indexOf(this.keyBinding
s)===-1){keyBindings.push(this.keyBindings)}return keyBindings},_prepKeyBindings
:function(){this._keyBindings={};this._collectKeyBindings().forEach(function(key
Bindings){for(var eventString in keyBindings){this._addKeyBinding(eventString,ke
yBindings[eventString])}},this);for(var eventString in this._imperativeKeyBindin
gs){this._addKeyBinding(eventString,this._imperativeKeyBindings[eventString])}fo
r(var eventName in this._keyBindings){this._keyBindings[eventName].sort(function
(kb1,kb2){var b1=kb1[0].hasModifiers;var b2=kb2[0].hasModifiers;return b1===b2?0
:b1?-1:1})}},_addKeyBinding:function(eventString,handlerName){parseEventString(e
ventString).forEach(function(keyCombo){this._keyBindings[keyCombo.event]=this._k
eyBindings[keyCombo.event]||[];this._keyBindings[keyCombo.event].push([keyCombo,
handlerName])},this)},_resetKeyEventListeners:function(){this._unlistenKeyEventL
isteners();if(this.isAttached){this._listenKeyEventListeners()}},_listenKeyEvent
Listeners:function(){if(!this.keyEventTarget){return}Object.keys(this._keyBindin
gs).forEach(function(eventName){var keyBindings=this._keyBindings[eventName];var
boundKeyHandler=this._onKeyBindingEvent.bind(this,keyBindings);this._boundKeyHa
ndlers.push([this.keyEventTarget,eventName,boundKeyHandler]);this.keyEventTarget
.addEventListener(eventName,boundKeyHandler)},this)},_unlistenKeyEventListeners:
function(){var keyHandlerTuple;var keyEventTarget;var eventName;var boundKeyHand
ler;while(this._boundKeyHandlers.length){keyHandlerTuple=this._boundKeyHandlers.
pop();keyEventTarget=keyHandlerTuple[0];eventName=keyHandlerTuple[1];boundKeyHan
dler=keyHandlerTuple[2];keyEventTarget.removeEventListener(eventName,boundKeyHan
dler)}},_onKeyBindingEvent:function(keyBindings,event){if(this.stopKeyboardEvent
Propagation){event.stopPropagation()}if(event.defaultPrevented){return}for(var i
=0;i<keyBindings.length;i++){var keyCombo=keyBindings[i][0];var handlerName=keyB
indings[i][1];if(keyComboMatchesEvent(keyCombo,event)){this._triggerKeyHandler(k
eyCombo,handlerName,event);if(event.defaultPrevented){return}}}},_triggerKeyHand
ler:function(keyCombo,handlerName,keyboardEvent){var detail=Object.create(keyCom
bo);detail.keyboardEvent=keyboardEvent;var event=new CustomEvent(keyCombo.event,
{detail:detail,cancelable:true});this[handlerName].call(this,event);if(event.def
aultPrevented){keyboardEvent.preventDefault()}}}})();Polymer.IronScrollTargetBeh
avior={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._
defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached
)"],_shouldHaveListener:true,_scrollTargetChanged:function(scrollTarget,isAttach
ed){var eventTarget;if(this._oldScrollTarget){this._toggleScrollListener(false,t
his._oldScrollTarget);this._oldScrollTarget=null}if(!isAttached){return}if(scrol
lTarget==="document"){this.scrollTarget=this._doc}else if(typeof scrollTarget===
"string"){this.scrollTarget=this.domHost?this.domHost.$[scrollTarget]:Polymer.do
m(this.ownerDocument).querySelector("#"+scrollTarget)}else if(this._isValidScrol
lTarget()){this._boundScrollHandler=this._boundScrollHandler||this._scrollHandle
r.bind(this);this._oldScrollTarget=scrollTarget;this._toggleScrollListener(this.
_shouldHaveListener,scrollTarget)}},_scrollHandler:function scrollHandler(){},ge
t _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.
documentElement},get _scrollTop(){if(this._isValidScrollTarget()){return this.sc
rollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop}return 0},
get _scrollLeft(){if(this._isValidScrollTarget()){return this.scrollTarget===thi
s._doc?window.pageXOffset:this.scrollTarget.scrollLeft}return 0},set _scrollTop(
top){if(this.scrollTarget===this._doc){window.scrollTo(window.pageXOffset,top)}e
lse if(this._isValidScrollTarget()){this.scrollTarget.scrollTop=top}},set _scrol
lLeft(left){if(this.scrollTarget===this._doc){window.scrollTo(left,window.pageYO
ffset)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left}},
scroll:function(left,top){if(this.scrollTarget===this._doc){window.scrollTo(left
,top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=left;thi
s.scrollTarget.scrollTop=top}},get _scrollTargetWidth(){if(this._isValidScrollTa
rget()){return this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget
.offsetWidth}return 0},get _scrollTargetHeight(){if(this._isValidScrollTarget())
{return this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offse
tHeight}return 0},_isValidScrollTarget:function(){return this.scrollTarget insta
nceof HTMLElement},_toggleScrollListener:function(yes,scrollTarget){if(!this._bo
undScrollHandler){return}var eventTarget=scrollTarget===this._doc?window:scrollT
arget;if(yes){eventTarget.addEventListener("scroll",this._boundScrollHandler)}el
se{eventTarget.removeEventListener("scroll",this._boundScrollHandler)}},toggleSc
rollListener:function(yes){this._shouldHaveListener=yes;this._toggleScrollListen
er(yes,this.scrollTarget)}};(function(){var IOS=navigator.userAgent.match(/iP(?:
hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;var DEFA
ULT_PHYSICAL_COUNT=3;var HIDDEN_Y="-10000px";var ITEM_WIDTH=0;var ITEM_HEIGHT=1;
var SECRET_TABINDEX=-100;Polymer({is:"iron-list",properties:{items:{type:Array},
maxPhysicalCount:{type:Number,value:500},as:{type:String,value:"item"},indexAs:{
type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:
Boolean,value:false,reflectToAttribute:true},selectionEnabled:{type:Boolean,valu
e:false},selectedItem:{type:Object,notify:true},selectedItems:{type:Object,notif
y:true},multiSelection:{type:Boolean,value:false}},observers:["_itemsChanged(ite
ms.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(mult
iSelection)","_setOverflow(scrollTarget)"],behaviors:[Polymer.Templatizer,Polyme
r.IronResizableBehavior,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTargetBeh
avior],keyBindings:{up:"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"},_rati
o:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,
_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_physicalIndexForKey:null
,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physical
Items:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:n
ull,_collection:null,_maxPages:2,_focusedItem:null,_focusedIndex:-1,_offscreenFo
cusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,
_templateCost:0,get _physicalBottom(){return this._physicalTop+this._physicalSiz
e},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _vi
rtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSi
ze(){var size=this.grid?this._physicalRows*this._rowHeight:this._physicalSize;re
turn size-this._viewportHeight},get _maxScrollTop(){return this._estScrollHeight
-this._viewportHeight+this._scrollerPaddingTop},_minVirtualStart:0,get _maxVirtu
alStart(){return Math.max(0,this._virtualCount-this._physicalCount)},_virtualSta
rtVal:0,set _virtualStart(val){this._virtualStartVal=Math.min(this._maxVirtualSt
art,Math.max(this._minVirtualStart,val))},get _virtualStart(){return this._virtu
alStartVal||0},_physicalStartVal:0,set _physicalStart(val){this._physicalStartVa
l=val%this._physicalCount;if(this._physicalStartVal<0){this._physicalStartVal=th
is._physicalCount+this._physicalStartVal}this._physicalEnd=(this._physicalStart+
this._physicalCount-1)%this._physicalCount},get _physicalStart(){return this._ph
ysicalStartVal||0},_physicalCountVal:0,set _physicalCount(val){this._physicalCou
ntVal=val;this._physicalEnd=(this._physicalStart+this._physicalCount-1)%this._ph
ysicalCount},get _physicalCount(){return this._physicalCountVal},_physicalEnd:0,
get _optPhysicalSize(){if(this.grid){return this._estRowsInView*this._rowHeight*
this._maxPages}return this._viewportHeight*this._maxPages},get _isVisible(){retu
rn Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){if(this
._firstVisibleIndexVal===null){var physicalOffset=Math.floor(this._physicalTop+t
his._scrollerPaddingTop);this._firstVisibleIndexVal=this._iterateItems(function(
pidx,vidx){physicalOffset+=this._getPhysicalSizeIncrement(pidx);if(physicalOffse
t>this._scrollPosition){return this.grid?vidx-vidx%this._itemsPerRow:vidx}if(thi
s.grid&&this._virtualCount-1===vidx){return vidx-vidx%this._itemsPerRow}})||0}re
turn this._firstVisibleIndexVal},get lastVisibleIndex(){if(this._lastVisibleInde
xVal===null){if(this.grid){var lastIndex=this.firstVisibleIndex+this._estRowsInV
iew*this._itemsPerRow-1;this._lastVisibleIndexVal=Math.min(this._virtualCount,la
stIndex)}else{var physicalOffset=this._physicalTop;this._iterateItems(function(p
idx,vidx){if(physicalOffset<this._scrollBottom){this._lastVisibleIndexVal=vidx}e
lse{return true}physicalOffset+=this._getPhysicalSizeIncrement(pidx)})}}return t
his._lastVisibleIndexVal},get _defaultScrollTarget(){return this},get _virtualRo
wCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsInV
iew(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRows(
){return Math.ceil(this._physicalCount/this._itemsPerRow)},ready:function(){this
.addEventListener("focus",this._didFocus.bind(this),true)},attached:function(){i
f(this._physicalCount===0){this._debounceTemplate(this._render)}this.listen(this
,"iron-resize","_resizeHandler")},detached:function(){this.unlisten(this,"iron-r
esize","_resizeHandler")},_setOverflow:function(scrollTarget){this.style.webkitO
verflowScrolling=scrollTarget===this?"touch":"";this.style.overflow=scrollTarget
===this?"auto":""},updateViewportBoundaries:function(){this._scrollerPaddingTop=
this.scrollTarget===this?0:parseInt(window.getComputedStyle(this)["padding-top"]
,10);this._viewportWidth=this.$.items.offsetWidth;this._viewportHeight=this._scr
ollTargetHeight;this.grid&&this._updateGridMetrics()},_scrollHandler:function(){
var scrollTop=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop));var delta
=scrollTop-this._scrollPosition;var isScrollingDown=delta>=0;this._scrollPositio
n=scrollTop;this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;if(Ma
th.abs(delta)>this._physicalSize){var idxAdjustment=Math.round(delta/this._physi
calAverage)*this._itemsPerRow;this._physicalTop=this._physicalTop+delta;this._vi
rtualStart=this._virtualStart+idxAdjustment;this._physicalStart=this._physicalSt
art+idxAdjustment;this._update()}else{var reusables=this._getReusables(isScrolli
ngDown);if(isScrollingDown){this._physicalTop=reusables.physicalTop;this._virtua
lStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this._phy
sicalStart+reusables.indexes.length}else{this._virtualStart=this._virtualStart-r
eusables.indexes.length;this._physicalStart=this._physicalStart-reusables.indexe
s.length}if(reusables.indexes.length===0){this._increasePoolIfNeeded()}else{this
._update(reusables.indexes,isScrollingDown?null:reusables.indexes)}}},_getReusab
les:function(fromTop){var ith,lastIth,offsetContent,physicalItemHeight;var idxs=
[];var protectedOffsetContent=this._hiddenContentSize*this._ratio;var virtualSta
rt=this._virtualStart;var virtualEnd=this._virtualEnd;var physicalCount=this._ph
ysicalCount;var physicalTop=this._physicalTop;var scrollTop=this._scrollTop;var
scrollBottom=this._scrollBottom;if(fromTop){ith=this._physicalStart;lastIth=this
._physicalEnd;offsetContent=scrollTop-physicalTop}else{ith=this._physicalEnd;las
tIth=this._physicalStart;offsetContent=this._physicalBottom-scrollBottom}while(t
rue){physicalItemHeight=this._getPhysicalSizeIncrement(ith);offsetContent=offset
Content-physicalItemHeight;if(idxs.length>=physicalCount||offsetContent<=protect
edOffsetContent){break}if(fromTop){if(virtualEnd+idxs.length+1>=this._virtualCou
nt){break}if(physicalTop+physicalItemHeight>=scrollTop){break}idxs.push(ith);phy
sicalTop=physicalTop+physicalItemHeight;ith=(ith+1)%physicalCount}else{if(virtua
lStart-idxs.length<=0){break}if(physicalTop+this._physicalSize-physicalItemHeigh
t<=scrollBottom){break}idxs.push(ith);physicalTop=physicalTop-physicalItemHeight
;ith=ith===0?physicalCount-1:ith-1}}return{indexes:idxs,physicalTop:physicalTop}
},_update:function(itemSet,movingUp){if(itemSet&&itemSet.length===0){return}this
._manageFocus();this._assignModels(itemSet);this._updateMetrics(itemSet);if(movi
ngUp){while(movingUp.length){var idx=movingUp.pop();this._physicalTop-=this._get
PhysicalSizeIncrement(idx)}}this._positionItems();this._updateScrollerSize();thi
s._increasePoolIfNeeded()},_createPool:function(size){var physicalItems=new Arra
y(size);this._ensureTemplatized();for(var i=0;i<size;i++){var inst=this.stamp(nu
ll);physicalItems[i]=inst.root.querySelector("*");Polymer.dom(this).appendChild(
inst.root)}return physicalItems},_increasePoolIfNeeded:function(){if(this._viewp
ortHeight===0){return false}var self=this;var isClientFull=this._physicalBottom>
=this._scrollBottom&&this._physicalTop<=this._scrollPosition;if(this._physicalSi
ze>=this._optPhysicalSize&&isClientFull){return false}var maxPoolSize=Math.round
(this._physicalCount*.5);if(!isClientFull){this._debounceTemplate(this._increase
Pool.bind(this,maxPoolSize));return true}this._yield(function(){self._increasePo
ol(Math.min(maxPoolSize,Math.max(1,Math.round(50/self._templateCost))))});return
true},_yield:function(cb){var g=window;var handle=g.requestIdleCallback?g.reque
stIdleCallback(cb):g.setTimeout(cb,16);Polymer.dom.addDebouncer({complete:functi
on(){g.cancelIdleCallback?g.cancelIdleCallback(handle):g.clearTimeout(handle);cb
()}})},_increasePool:function(missingItems){var nextPhysicalCount=Math.min(this.
_physicalCount+missingItems,this._virtualCount-this._virtualStart,Math.max(this.
maxPhysicalCount,DEFAULT_PHYSICAL_COUNT));var prevPhysicalCount=this._physicalCo
unt;var delta=nextPhysicalCount-prevPhysicalCount;var ts=window.performance.now(
);if(delta<=0){return}[].push.apply(this._physicalItems,this._createPool(delta))
;[].push.apply(this._physicalSizes,new Array(delta));this._physicalCount=prevPhy
sicalCount+delta;if(this._physicalStart>this._physicalEnd&&this._isIndexRendered
(this._focusedIndex)&&this._getPhysicalIndex(this._focusedIndex)<this._physicalE
nd){this._physicalStart=this._physicalStart+delta}this._update();this._templateC
ost=(window.performance.now()-ts)/delta},_render:function(){if(this.isAttached&&
this._isVisible){if(this._physicalCount===0){this.updateViewportBoundaries();thi
s._increasePool(DEFAULT_PHYSICAL_COUNT)}else{var reusables=this._getReusables(tr
ue);this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualStar
t+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.ind
exes.length;this._update(reusables.indexes);this._update()}}},_ensureTemplatized
:function(){if(!this.ctor){var props={};props.__key__=true;props[this.as]=true;p
rops[this.indexAs]=true;props[this.selectedAs]=true;props.tabIndex=true;this._in
stanceProps=props;this._userTemplate=Polymer.dom(this).querySelector("template")
;if(this._userTemplate){this.templatize(this._userTemplate)}else{console.warn("i
ron-list requires a template to be provided in light-dom")}}},_getStampedChildre
n:function(){return this._physicalItems},_forwardInstancePath:function(inst,path
,value){if(path.indexOf(this.as+".")===0){this.notifyPath("items."+inst.__key__+
"."+path.slice(this.as.length+1),value)}},_forwardParentProp:function(prop,value
){if(this._physicalItems){this._physicalItems.forEach(function(item){item._templ
ateInstance[prop]=value},this)}},_forwardParentPath:function(path,value){if(this
._physicalItems){this._physicalItems.forEach(function(item){item._templateInstan
ce.notifyPath(path,value,true)},this)}},_forwardItemPath:function(path,value){if
(!this._physicalIndexForKey){return}var dot=path.indexOf(".");var key=path.subst
ring(0,dot<0?path.length:dot);var idx=this._physicalIndexForKey[key];var offscre
enItem=this._offscreenFocusedItem;var el=offscreenItem&&offscreenItem._templateI
nstance.__key__===key?offscreenItem:this._physicalItems[idx];if(!el||el._templat
eInstance.__key__!==key){return}if(dot>=0){path=this.as+"."+path.substring(dot+1
);el._templateInstance.notifyPath(path,value,true)}else{var currentItem=el._temp
lateInstance[this.as];if(Array.isArray(this.selectedItems)){for(var i=0;i<this.s
electedItems.length;i++){if(this.selectedItems[i]===currentItem){this.set("selec
tedItems."+i,value);break}}}else if(this.selectedItem===currentItem){this.set("s
electedItem",value)}el._templateInstance[this.as]=value}},_itemsChanged:function
(change){if(change.path==="items"){this._virtualStart=0;this._physicalTop=0;this
._virtualCount=this.items?this.items.length:0;this._collection=this.items?Polyme
r.Collection.get(this.items):null;this._physicalIndexForKey={};this._firstVisibl
eIndexVal=null;this._lastVisibleIndexVal=null;this._physicalCount=this._physical
Count||0;this._physicalItems=this._physicalItems||[];this._physicalSizes=this._p
hysicalSizes||[];this._physicalStart=0;this._resetScrollPosition(0);this._remove
FocusedItem();this._debounceTemplate(this._render)}else if(change.path==="items.
splices"){this._adjustVirtualIndex(change.value.indexSplices);this._virtualCount
=this.items?this.items.length:0;this._debounceTemplate(this._render)}else{this._
forwardItemPath(change.path.split(".").slice(1).join("."),change.value)}},_adjus
tVirtualIndex:function(splices){splices.forEach(function(splice){splice.removed.
forEach(this._removeItem,this);if(splice.index<this._virtualStart){var delta=Mat
h.max(splice.addedCount-splice.removed.length,splice.index-this._virtualStart);t
his._virtualStart=this._virtualStart+delta;if(this._focusedIndex>=0){this._focus
edIndex=this._focusedIndex+delta}}},this)},_removeItem:function(item){this.$.sel
ector.deselect(item);if(this._focusedItem&&this._focusedItem._templateInstance[t
his.as]===item){this._removeFocusedItem()}},_iterateItems:function(fn,itemSet){v
ar pidx,vidx,rtn,i;if(arguments.length===2&&itemSet){for(i=0;i<itemSet.length;i+
+){pidx=itemSet[i];vidx=this._computeVidx(pidx);if((rtn=fn.call(this,pidx,vidx))
!=null){return rtn}}}else{pidx=this._physicalStart;vidx=this._virtualStart;for(;
pidx<this._physicalCount;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){
return rtn}}for(pidx=0;pidx<this._physicalStart;pidx++,vidx++){if((rtn=fn.call(t
his,pidx,vidx))!=null){return rtn}}}},_computeVidx:function(pidx){if(pidx>=this.
_physicalStart){return this._virtualStart+(pidx-this._physicalStart)}return this
._virtualStart+(this._physicalCount-this._physicalStart)+pidx},_assignModels:fun
ction(itemSet){this._iterateItems(function(pidx,vidx){var el=this._physicalItems
[pidx];var inst=el._templateInstance;var item=this.items&&this.items[vidx];if(it
em!=null){inst[this.as]=item;inst.__key__=this._collection.getKey(item);inst[thi
s.selectedAs]=this.$.selector.isSelected(item);inst[this.indexAs]=vidx;inst.tabI
ndex=this._focusedIndex===vidx?0:-1;this._physicalIndexForKey[inst.__key__]=pidx
;el.removeAttribute("hidden")}else{inst.__key__=null;el.setAttribute("hidden",""
)}},itemSet)},_updateMetrics:function(itemSet){Polymer.dom.flush();var newPhysic
alSize=0;var oldPhysicalSize=0;var prevAvgCount=this._physicalAverageCount;var p
revPhysicalAvg=this._physicalAverage;this._iterateItems(function(pidx,vidx){oldP
hysicalSize+=this._physicalSizes[pidx]||0;this._physicalSizes[pidx]=this._physic
alItems[pidx].offsetHeight;newPhysicalSize+=this._physicalSizes[pidx];this._phys
icalAverageCount+=this._physicalSizes[pidx]?1:0},itemSet);if(this.grid){this._up
dateGridMetrics();this._physicalSize=Math.ceil(this._physicalCount/this._itemsPe
rRow)*this._rowHeight}else{this._physicalSize=this._physicalSize+newPhysicalSize
-oldPhysicalSize}if(this._physicalAverageCount!==prevAvgCount){this._physicalAve
rage=Math.round((prevPhysicalAvg*prevAvgCount+newPhysicalSize)/this._physicalAve
rageCount)}},_updateGridMetrics:function(){this._itemWidth=this._physicalCount>0
?this._physicalItems[0].getBoundingClientRect().width:200;this._rowHeight=this._
physicalCount>0?this._physicalItems[0].offsetHeight:200;this._itemsPerRow=this._
itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_po
sitionItems:function(){this._adjustScrollPosition();var y=this._physicalTop;if(t
his.grid){var totalItemWidth=this._itemsPerRow*this._itemWidth;var rowOffset=(th
is._viewportWidth-totalItemWidth)/2;this._iterateItems(function(pidx,vidx){var m
odulus=vidx%this._itemsPerRow;var x=Math.floor(modulus*this._itemWidth+rowOffset
);this.translate3d(x+"px",y+"px",0,this._physicalItems[pidx]);if(this._shouldRen
derNextRow(vidx)){y+=this._rowHeight}})}else{this._iterateItems(function(pidx,vi
dx){this.translate3d(0,y+"px",0,this._physicalItems[pidx]);y+=this._physicalSize
s[pidx]})}},_getPhysicalSizeIncrement:function(pidx){if(!this.grid){return this.
_physicalSizes[pidx]}if(this._computeVidx(pidx)%this._itemsPerRow!==this._itemsP
erRow-1){return 0}return this._rowHeight},_shouldRenderNextRow:function(vidx){re
turn vidx%this._itemsPerRow===this._itemsPerRow-1},_adjustScrollPosition:functio
n(){var deltaHeight=this._virtualStart===0?this._physicalTop:Math.min(this._scro
llPosition+this._physicalTop,0);if(deltaHeight){this._physicalTop=this._physical
Top-deltaHeight;if(!IOS_TOUCH_SCROLLING&&this._physicalTop!==0){this._resetScrol
lPosition(this._scrollTop-deltaHeight)}}},_resetScrollPosition:function(pos){if(
this.scrollTarget){this._scrollTop=pos;this._scrollPosition=this._scrollTop}},_u
pdateScrollerSize:function(forceUpdate){if(this.grid){this._estScrollHeight=this
._virtualRowCount*this._rowHeight}else{this._estScrollHeight=this._physicalBotto
m+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._ph
ysicalAverage}forceUpdate=forceUpdate||this._scrollHeight===0;forceUpdate=forceU
pdate||this._scrollPosition>=this._estScrollHeight-this._physicalSize;forceUpdat
e=forceUpdate||this.grid&&this.$.items.style.height<this._estScrollHeight;if(for
ceUpdate||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._optPhysicalS
ize){this.$.items.style.height=this._estScrollHeight+"px";this._scrollHeight=thi
s._estScrollHeight}},scrollToItem:function(item){return this.scrollToIndex(this.
items.indexOf(item))},scrollToIndex:function(idx){if(typeof idx!=="number"||idx<
0||idx>this.items.length-1){return}Polymer.dom.flush();if(this._physicalCount===
0){return}idx=Math.min(Math.max(idx,0),this._virtualCount-1);if(!this._isIndexRe
ndered(idx)||idx>=this._maxVirtualStart){this._virtualStart=this.grid?idx-this._
itemsPerRow*2:idx-1}this._manageFocus();this._assignModels();this._updateMetrics
();this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._phys
icalAverage;var currentTopItem=this._physicalStart;var currentVirtualItem=this._
virtualStart;var targetOffsetTop=0;var hiddenContentSize=this._hiddenContentSize
;while(currentVirtualItem<idx&&targetOffsetTop<=hiddenContentSize){targetOffsetT
op=targetOffsetTop+this._getPhysicalSizeIncrement(currentTopItem);currentTopItem
=(currentTopItem+1)%this._physicalCount;currentVirtualItem++}this._updateScrolle
rSize(true);this._positionItems();this._resetScrollPosition(this._physicalTop+th
is._scrollerPaddingTop+targetOffsetTop);this._increasePoolIfNeeded();this._first
VisibleIndexVal=null;this._lastVisibleIndexVal=null},_resetAverage:function(){th
is._physicalAverage=0;this._physicalAverageCount=0},_resizeHandler:function(){if
(IOS&&Math.abs(this._viewportHeight-this._scrollTargetHeight)<100){return}Polyme
r.dom.addDebouncer(this.debounce("_debounceTemplate",function(){this.updateViewp
ortBoundaries();this._render();if(this._isVisible){this.toggleScrollListener(tru
e);if(this._physicalCount>0){this._resetAverage();this.scrollToIndex(this.firstV
isibleIndex)}}else{this.toggleScrollListener(false)}}.bind(this),1))},_getModelF
romItem:function(item){var key=this._collection.getKey(item);var pidx=this._phys
icalIndexForKey[key];if(pidx!=null){return this._physicalItems[pidx]._templateIn
stance}return null},_getNormalizedItem:function(item){if(this._collection.getKey
(item)===undefined){if(typeof item==="number"){item=this.items[item];if(!item){t
hrow new RangeError("<item> not found")}return item}throw new TypeError("<item>
should be a valid item")}return item},selectItem:function(item){item=this._getNo
rmalizedItem(item);var model=this._getModelFromItem(item);if(!this.multiSelectio
n&&this.selectedItem){this.deselectItem(this.selectedItem)}if(model){model[this.
selectedAs]=true}this.$.selector.select(item);this.updateSizeForItem(item)},dese
lectItem:function(item){item=this._getNormalizedItem(item);var model=this._getMo
delFromItem(item);if(model){model[this.selectedAs]=false}this.$.selector.deselec
t(item);this.updateSizeForItem(item)},toggleSelectionForItem:function(item){item
=this._getNormalizedItem(item);if(this.$.selector.isSelected(item)){this.deselec
tItem(item)}else{this.selectItem(item)}},clearSelection:function(){function unse
lect(item){var model=this._getModelFromItem(item);if(model){model[this.selectedA
s]=false}}if(Array.isArray(this.selectedItems)){this.selectedItems.forEach(unsel
ect,this)}else if(this.selectedItem){unselect.call(this,this.selectedItem)}this.
$.selector.clearSelection()},_selectionEnabledChanged:function(selectionEnabled)
{var handler=selectionEnabled?this.listen:this.unlisten;handler.call(this,this,"
tap","_selectionHandler")},_selectionHandler:function(e){var model=this.modelFor
Element(e.target);if(!model){return}var modelTabIndex,activeElTabIndex;var targe
t=Polymer.dom(e).path[0];var activeEl=Polymer.dom(this.domHost?this.domHost.root
:document).activeElement;var physicalItem=this._physicalItems[this._getPhysicalI
ndex(model[this.indexAs])];if(target.localName==="input"||target.localName==="bu
tton"||target.localName==="select"){return}modelTabIndex=model.tabIndex;model.ta
bIndex=SECRET_TABINDEX; |
29 | 29 |
30 activeElTabIndex=activeEl?activeEl.tabIndex:-1;model.tabIndex=modelTabIndex;if(a
ctiveEl&&physicalItem!==activeEl&&physicalItem.contains(activeEl)&&activeElTabIn
dex!==SECRET_TABINDEX){return}this.toggleSelectionForItem(model[this.as])},_mult
iSelectionChanged:function(multiSelection){this.clearSelection();this.$.selector
.multi=multiSelection},updateSizeForItem:function(item){item=this._getNormalized
Item(item);var key=this._collection.getKey(item);var pidx=this._physicalIndexFor
Key[key];if(pidx!=null){this._updateMetrics([pidx]);this._positionItems()}},_man
ageFocus:function(){var fidx=this._focusedIndex;if(fidx>=0&&fidx<this._virtualCo
unt){if(this._isIndexRendered(fidx)){this._restoreFocusedItem()}else{this._creat
eFocusBackfillItem()}}else if(this._virtualCount>0&&this._physicalCount>0){this.
_focusedIndex=this._virtualStart;this._focusedItem=this._physicalItems[this._phy
sicalStart]}},_isIndexRendered:function(idx){return idx>=this._virtualStart&&idx
<=this._virtualEnd},_isIndexVisible:function(idx){return idx>=this.firstVisibleI
ndex&&idx<=this.lastVisibleIndex},_getPhysicalIndex:function(idx){return this._p
hysicalIndexForKey[this._collection.getKey(this._getNormalizedItem(idx))]},_focu
sPhysicalItem:function(idx){if(idx<0||idx>=this._virtualCount){return}this._rest
oreFocusedItem();if(!this._isIndexRendered(idx)){this.scrollToIndex(idx)}var phy
sicalItem=this._physicalItems[this._getPhysicalIndex(idx)];var model=physicalIte
m._templateInstance;var focusable;model.tabIndex=SECRET_TABINDEX;if(physicalItem
.tabIndex===SECRET_TABINDEX){focusable=physicalItem}if(!focusable){focusable=Pol
ymer.dom(physicalItem).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')}model.t
abIndex=0;this._focusedIndex=idx;focusable&&focusable.focus()},_removeFocusedIte
m:function(){if(this._offscreenFocusedItem){Polymer.dom(this).removeChild(this._
offscreenFocusedItem)}this._offscreenFocusedItem=null;this._focusBackfillItem=nu
ll;this._focusedItem=null;this._focusedIndex=-1},_createFocusBackfillItem:functi
on(){var pidx,fidx=this._focusedIndex;if(this._offscreenFocusedItem||fidx<0){ret
urn}if(!this._focusBackfillItem){var stampedTemplate=this.stamp(null);this._focu
sBackfillItem=stampedTemplate.root.querySelector("*");Polymer.dom(this).appendCh
ild(stampedTemplate.root)}pidx=this._getPhysicalIndex(fidx);if(pidx!=null){this.
_offscreenFocusedItem=this._physicalItems[pidx];this._physicalItems[pidx]=this._
focusBackfillItem;this.translate3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)}},_r
estoreFocusedItem:function(){var pidx,fidx=this._focusedIndex;if(!this._offscree
nFocusedItem||this._focusedIndex<0){return}this._assignModels();pidx=this._getPh
ysicalIndex(fidx);if(pidx!=null){this._focusBackfillItem=this._physicalItems[pid
x];this._physicalItems[pidx]=this._offscreenFocusedItem;this._offscreenFocusedIt
em=null;this.translate3d(0,HIDDEN_Y,0,this._focusBackfillItem)}},_didFocus:funct
ion(e){var targetModel=this.modelForElement(e.target);var focusedModel=this._foc
usedItem?this._focusedItem._templateInstance:null;var hasOffscreenFocusedItem=th
is._offscreenFocusedItem!==null;var fidx=this._focusedIndex;if(!targetModel||!fo
cusedModel){return}if(focusedModel===targetModel){if(!this._isIndexVisible(fidx)
){this.scrollToIndex(fidx)}}else{this._restoreFocusedItem();focusedModel.tabInde
x=-1;targetModel.tabIndex=0;fidx=targetModel[this.indexAs];this._focusedIndex=fi
dx;this._focusedItem=this._physicalItems[this._getPhysicalIndex(fidx)];if(hasOff
screenFocusedItem&&!this._offscreenFocusedItem){this._update()}}},_didMoveUp:fun
ction(){this._focusPhysicalItem(this._focusedIndex-1)},_didMoveDown:function(e){
e.detail.keyboardEvent.preventDefault();this._focusPhysicalItem(this._focusedInd
ex+1)},_didEnter:function(e){this._focusPhysicalItem(this._focusedIndex);this._s
electionHandler(e.detail.keyboardEvent)}})})(); | 30 activeElTabIndex=activeEl?activeEl.tabIndex:-1;model.tabIndex=modelTabIndex;if(a
ctiveEl&&physicalItem!==activeEl&&physicalItem.contains(activeEl)&&activeElTabIn
dex!==SECRET_TABINDEX){return}this.toggleSelectionForItem(model[this.as])},_mult
iSelectionChanged:function(multiSelection){this.clearSelection();this.$.selector
.multi=multiSelection},updateSizeForItem:function(item){item=this._getNormalized
Item(item);var key=this._collection.getKey(item);var pidx=this._physicalIndexFor
Key[key];if(pidx!=null){this._updateMetrics([pidx]);this._positionItems()}},_man
ageFocus:function(){var fidx=this._focusedIndex;if(fidx>=0&&fidx<this._virtualCo
unt){if(this._isIndexRendered(fidx)){this._restoreFocusedItem()}else{this._creat
eFocusBackfillItem()}}else if(this._virtualCount>0&&this._physicalCount>0){this.
_focusedIndex=this._virtualStart;this._focusedItem=this._physicalItems[this._phy
sicalStart]}},_isIndexRendered:function(idx){return idx>=this._virtualStart&&idx
<=this._virtualEnd},_isIndexVisible:function(idx){return idx>=this.firstVisibleI
ndex&&idx<=this.lastVisibleIndex},_getPhysicalIndex:function(idx){return this._p
hysicalIndexForKey[this._collection.getKey(this._getNormalizedItem(idx))]},_focu
sPhysicalItem:function(idx){if(idx<0||idx>=this._virtualCount){return}this._rest
oreFocusedItem();if(!this._isIndexRendered(idx)){this.scrollToIndex(idx)}var phy
sicalItem=this._physicalItems[this._getPhysicalIndex(idx)];var model=physicalIte
m._templateInstance;var focusable;model.tabIndex=SECRET_TABINDEX;if(physicalItem
.tabIndex===SECRET_TABINDEX){focusable=physicalItem}if(!focusable){focusable=Pol
ymer.dom(physicalItem).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')}model.t
abIndex=0;this._focusedIndex=idx;focusable&&focusable.focus()},_removeFocusedIte
m:function(){if(this._offscreenFocusedItem){Polymer.dom(this).removeChild(this._
offscreenFocusedItem)}this._offscreenFocusedItem=null;this._focusBackfillItem=nu
ll;this._focusedItem=null;this._focusedIndex=-1},_createFocusBackfillItem:functi
on(){var pidx,fidx=this._focusedIndex;if(this._offscreenFocusedItem||fidx<0){ret
urn}if(!this._focusBackfillItem){var stampedTemplate=this.stamp(null);this._focu
sBackfillItem=stampedTemplate.root.querySelector("*");Polymer.dom(this).appendCh
ild(stampedTemplate.root)}pidx=this._getPhysicalIndex(fidx);if(pidx!=null){this.
_offscreenFocusedItem=this._physicalItems[pidx];this._physicalItems[pidx]=this._
focusBackfillItem;this.translate3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)}},_r
estoreFocusedItem:function(){var pidx,fidx=this._focusedIndex;if(!this._offscree
nFocusedItem||this._focusedIndex<0){return}this._assignModels();pidx=this._getPh
ysicalIndex(fidx);if(pidx!=null){this._focusBackfillItem=this._physicalItems[pid
x];this._physicalItems[pidx]=this._offscreenFocusedItem;this._offscreenFocusedIt
em=null;this.translate3d(0,HIDDEN_Y,0,this._focusBackfillItem)}},_didFocus:funct
ion(e){var targetModel=this.modelForElement(e.target);var focusedModel=this._foc
usedItem?this._focusedItem._templateInstance:null;var hasOffscreenFocusedItem=th
is._offscreenFocusedItem!==null;var fidx=this._focusedIndex;if(!targetModel||!fo
cusedModel){return}if(focusedModel===targetModel){if(!this._isIndexVisible(fidx)
){this.scrollToIndex(fidx)}}else{this._restoreFocusedItem();focusedModel.tabInde
x=-1;targetModel.tabIndex=0;fidx=targetModel[this.indexAs];this._focusedIndex=fi
dx;this._focusedItem=this._physicalItems[this._getPhysicalIndex(fidx)];if(hasOff
screenFocusedItem&&!this._offscreenFocusedItem){this._update()}}},_didMoveUp:fun
ction(){this._focusPhysicalItem(this._focusedIndex-1)},_didMoveDown:function(e){
e.detail.keyboardEvent.preventDefault();this._focusPhysicalItem(this._focusedInd
ex+1)},_didEnter:function(e){this._focusPhysicalItem(this._focusedIndex);this._s
electionHandler(e.detail.keyboardEvent)}})})(); |
31 // Copyright 2015 The Chromium Authors. All rights reserved. | 31 // Copyright 2015 The Chromium Authors. All rights reserved. |
32 // Use of this source code is governed by a BSD-style license that can be | 32 // Use of this source code is governed by a BSD-style license that can be |
33 // found in the LICENSE file. | 33 // found in the LICENSE file. |
34 cr.define("downloads",function(){function chromeSendWithId(chromeSendName){retur
n function(id){chrome.send(chromeSendName,[id])}}function ActionService(){this.s
earchTerms_=[]}function trim(s){return s.trim()}function truthy(value){return!!v
alue}ActionService.splitTerms=function(searchText){return searchText.split(/"([^
"]*)"/).map(trim).filter(truthy)};ActionService.prototype={cancel:chromeSendWith
Id("cancel"),clearAll:function(){if(loadTimeData.getBoolean("allowDeletingHistor
y")){chrome.send("clearAll");this.search("")}},discardDangerous:chromeSendWithId
("discardDangerous"),download:function(url){var a=document.createElement("a");a.
href=url;a.setAttribute("download","");a.click()},drag:chromeSendWithId("drag"),
loadMore:function(){chrome.send("getDownloads",this.searchTerms_)},isSearching:f
unction(){return this.searchTerms_.length>0},openDownloadsFolder:chrome.send.bin
d(chrome,"openDownloadsFolder"),openFile:chromeSendWithId("openFile"),pause:chro
meSendWithId("pause"),remove:chromeSendWithId("remove"),resume:chromeSendWithId(
"resume"),saveDangerous:chromeSendWithId("saveDangerous"),search:function(search
Text){var searchTerms=ActionService.splitTerms(searchText);var sameTerms=searchT
erms.length==this.searchTerms_.length;for(var i=0;sameTerms&&i<searchTerms.lengt
h;++i){if(searchTerms[i]!=this.searchTerms_[i])sameTerms=false}if(sameTerms)retu
rn false;this.searchTerms_=searchTerms;this.loadMore();return true},show:chromeS
endWithId("show"),undo:chrome.send.bind(chrome,"undo")};cr.addSingletonGetter(Ac
tionService);return{ActionService:ActionService}}); | 34 cr.define("downloads",function(){function chromeSendWithId(chromeSendName){retur
n function(id){chrome.send(chromeSendName,[id])}}function ActionService(){this.s
earchTerms_=[]}function trim(s){return s.trim()}function truthy(value){return!!v
alue}ActionService.splitTerms=function(searchText){return searchText.split(/"([^
"]*)"/).map(trim).filter(truthy)};ActionService.prototype={cancel:chromeSendWith
Id("cancel"),clearAll:function(){if(loadTimeData.getBoolean("allowDeletingHistor
y")){chrome.send("clearAll");this.search("")}},discardDangerous:chromeSendWithId
("discardDangerous"),download:function(url){var a=document.createElement("a");a.
href=url;a.setAttribute("download","");a.click()},drag:chromeSendWithId("drag"),
loadMore:function(){chrome.send("getDownloads",this.searchTerms_)},isSearching:f
unction(){return this.searchTerms_.length>0},openDownloadsFolder:chrome.send.bin
d(chrome,"openDownloadsFolder"),openFile:chromeSendWithId("openFile"),pause:chro
meSendWithId("pause"),remove:chromeSendWithId("remove"),resume:chromeSendWithId(
"resume"),saveDangerous:chromeSendWithId("saveDangerous"),search:function(search
Text){var searchTerms=ActionService.splitTerms(searchText);var sameTerms=searchT
erms.length==this.searchTerms_.length;for(var i=0;sameTerms&&i<searchTerms.lengt
h;++i){if(searchTerms[i]!=this.searchTerms_[i])sameTerms=false}if(sameTerms)retu
rn false;this.searchTerms_=searchTerms;this.loadMore();return true},show:chromeS
endWithId("show"),undo:chrome.send.bind(chrome,"undo")};cr.addSingletonGetter(Ac
tionService);return{ActionService:ActionService}}); |
(...skipping 28 matching lines...) Expand all Loading... |
63 // found in the LICENSE file. | 63 // found in the LICENSE file. |
64 cr.define("downloads",function(){var Toolbar=Polymer({is:"downloads-toolbar",pro
perties:{downloadsShowing:{reflectToAttribute:true,type:Boolean,value:false,obse
rver:"downloadsShowingChanged_"},spinnerActive:{type:Boolean,notify:true}},liste
ners:{"paper-dropdown-close":"onPaperDropdownClose_","paper-dropdown-open":"onPa
perDropdownOpen_"},canUndo:function(){return!this.$.toolbar.getSearchField().isS
earchFocused()},canClearAll:function(){return!this.$.toolbar.getSearchField().ge
tValue()&&this.downloadsShowing},onFindCommand:function(){this.$.toolbar.getSear
chField().showAndFocus()},closeMoreActions_:function(){this.$.more.close()},down
loadsShowingChanged_:function(){this.updateClearAll_()},onClearAllTap_:function(
){assert(this.canClearAll());downloads.ActionService.getInstance().clearAll()},o
nPaperDropdownClose_:function(){window.removeEventListener("resize",assert(this.
boundClose_))},onItemBlur_:function(e){var menu=this.$$("paper-menu");if(menu.it
ems.indexOf(e.relatedTarget)>=0)return;this.$.more.restoreFocusOnClose=false;thi
s.closeMoreActions_();this.$.more.restoreFocusOnClose=true},onPaperDropdownOpen_
:function(){this.boundClose_=this.boundClose_||this.closeMoreActions_.bind(this)
;window.addEventListener("resize",this.boundClose_)},onSearchChanged_:function(e
vent){var actionService=downloads.ActionService.getInstance();if(actionService.s
earch(event.detail))this.spinnerActive=actionService.isSearching();this.updateCl
earAll_()},onOpenDownloadsFolderTap_:function(){downloads.ActionService.getInsta
nce().openDownloadsFolder()},updateClearAll_:function(){this.$$("paper-menu .cle
ar-all").hidden=!this.canClearAll()}});return{Toolbar:Toolbar}}); | 64 cr.define("downloads",function(){var Toolbar=Polymer({is:"downloads-toolbar",pro
perties:{downloadsShowing:{reflectToAttribute:true,type:Boolean,value:false,obse
rver:"downloadsShowingChanged_"},spinnerActive:{type:Boolean,notify:true}},liste
ners:{"paper-dropdown-close":"onPaperDropdownClose_","paper-dropdown-open":"onPa
perDropdownOpen_"},canUndo:function(){return!this.$.toolbar.getSearchField().isS
earchFocused()},canClearAll:function(){return!this.$.toolbar.getSearchField().ge
tValue()&&this.downloadsShowing},onFindCommand:function(){this.$.toolbar.getSear
chField().showAndFocus()},closeMoreActions_:function(){this.$.more.close()},down
loadsShowingChanged_:function(){this.updateClearAll_()},onClearAllTap_:function(
){assert(this.canClearAll());downloads.ActionService.getInstance().clearAll()},o
nPaperDropdownClose_:function(){window.removeEventListener("resize",assert(this.
boundClose_))},onItemBlur_:function(e){var menu=this.$$("paper-menu");if(menu.it
ems.indexOf(e.relatedTarget)>=0)return;this.$.more.restoreFocusOnClose=false;thi
s.closeMoreActions_();this.$.more.restoreFocusOnClose=true},onPaperDropdownOpen_
:function(){this.boundClose_=this.boundClose_||this.closeMoreActions_.bind(this)
;window.addEventListener("resize",this.boundClose_)},onSearchChanged_:function(e
vent){var actionService=downloads.ActionService.getInstance();if(actionService.s
earch(event.detail))this.spinnerActive=actionService.isSearching();this.updateCl
earAll_()},onOpenDownloadsFolderTap_:function(){downloads.ActionService.getInsta
nce().openDownloadsFolder()},updateClearAll_:function(){this.$$("paper-menu .cle
ar-all").hidden=!this.canClearAll()}});return{Toolbar:Toolbar}}); |
65 // Copyright 2015 The Chromium Authors. All rights reserved. | 65 // Copyright 2015 The Chromium Authors. All rights reserved. |
66 // Use of this source code is governed by a BSD-style license that can be | 66 // Use of this source code is governed by a BSD-style license that can be |
67 // found in the LICENSE file. | 67 // found in the LICENSE file. |
68 cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",pro
perties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_
:{type:Boolean,value:false,reflectToAttribute:true},items_:{type:Array,value:fun
ction(){return[]}},spinnerActive_:{type:Boolean,notify:true}},hostAttributes:{lo
ading:true},listeners:{"downloads-list.scroll":"onListScroll_"},observers:["item
sChanged_(items_.*)"],clearAll_:function(){this.set("items_",[])},hasDownloadsCh
anged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$.tool
bar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_){this.$["downloads
-list"].fire("iron-resize")}else{var isSearching=downloads.ActionService.getInst
ance().isSearching();var messageToShow=isSearching?"noSearchResults":"noDownload
s";this.$["no-downloads"].querySelector("span").textContent=loadTimeData.getStri
ng(messageToShow)}},insertItems_:function(index,list){this.splice.apply(this,["i
tems_",index,0].concat(list));this.updateHideDates_(index,index+list.length);thi
s.removeAttribute("loading");this.spinnerActive_=false},itemsChanged_:function()
{this.hasDownloads_=this.items_.length>0},onCanExecute_:function(e){e=e;switch(e
.command.id){case"undo-command":e.canExecute=this.$.toolbar.canUndo();break;case
"clear-all-command":e.canExecute=this.$.toolbar.canClearAll();break;case"find-co
mmand":e.canExecute=true;break}},onCommand_:function(e){if(e.command.id=="clear-
all-command")downloads.ActionService.getInstance().clearAll();else if(e.command.
id=="undo-command")downloads.ActionService.getInstance().undo();else if(e.comman
d.id=="find-command")this.$.toolbar.onFindCommand()},onListScroll_:function(){va
r list=this.$["downloads-list"];if(list.scrollHeight-list.scrollTop-list.offsetH
eight<=100){downloads.ActionService.getInstance().loadMore()}this.hasShadow_=lis
t.scrollTop>0},onLoad_:function(){cr.ui.decorate("command",cr.ui.Command);docume
nt.addEventListener("canExecute",this.onCanExecute_.bind(this));document.addEven
tListener("command",this.onCommand_.bind(this));downloads.ActionService.getInsta
nce().loadMore()},removeItem_:function(index){this.splice("items_",index,1);this
.updateHideDates_(index,index);this.onListScroll_()},updateHideDates_:function(s
tart,end){for(var i=start;i<=end;++i){var current=this.items_[i];if(!current)con
tinue;var prev=this.items_[i-1];current.hideDate=!!prev&&prev.date_string==curre
nt.date_string}},updateItem_:function(index,data){this.set("items_."+index,data)
;this.updateHideDates_(index,index);var list=this.$["downloads-list"];list.updat
eSizeForItem(index)}});Manager.clearAll=function(){Manager.get().clearAll_()};Ma
nager.get=function(){return queryRequiredElement("downloads-manager")};Manager.i
nsertItems=function(index,list){Manager.get().insertItems_(index,list)};Manager.
onLoad=function(){Manager.get().onLoad_()};Manager.removeItem=function(index){Ma
nager.get().removeItem_(index)};Manager.updateItem=function(index,data){Manager.
get().updateItem_(index,data)};return{Manager:Manager}}); | 68 cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",pro
perties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_
:{type:Boolean,value:false,reflectToAttribute:true},items_:{type:Array,value:fun
ction(){return[]}},spinnerActive_:{type:Boolean,notify:true}},hostAttributes:{lo
ading:true},listeners:{"downloads-list.scroll":"onListScroll_"},observers:["item
sChanged_(items_.*)"],clearAll_:function(){this.set("items_",[])},hasDownloadsCh
anged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$.tool
bar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_){this.$["downloads
-list"].fire("iron-resize")}else{var isSearching=downloads.ActionService.getInst
ance().isSearching();var messageToShow=isSearching?"noSearchResults":"noDownload
s";this.$["no-downloads"].querySelector("span").textContent=loadTimeData.getStri
ng(messageToShow)}},insertItems_:function(index,list){this.splice.apply(this,["i
tems_",index,0].concat(list));this.updateHideDates_(index,index+list.length);thi
s.removeAttribute("loading");this.spinnerActive_=false},itemsChanged_:function()
{this.hasDownloads_=this.items_.length>0},onCanExecute_:function(e){e=e;switch(e
.command.id){case"undo-command":e.canExecute=this.$.toolbar.canUndo();break;case
"clear-all-command":e.canExecute=this.$.toolbar.canClearAll();break;case"find-co
mmand":e.canExecute=true;break}},onCommand_:function(e){if(e.command.id=="clear-
all-command")downloads.ActionService.getInstance().clearAll();else if(e.command.
id=="undo-command")downloads.ActionService.getInstance().undo();else if(e.comman
d.id=="find-command")this.$.toolbar.onFindCommand()},onListScroll_:function(){va
r list=this.$["downloads-list"];if(list.scrollHeight-list.scrollTop-list.offsetH
eight<=100){downloads.ActionService.getInstance().loadMore()}this.hasShadow_=lis
t.scrollTop>0},onLoad_:function(){cr.ui.decorate("command",cr.ui.Command);docume
nt.addEventListener("canExecute",this.onCanExecute_.bind(this));document.addEven
tListener("command",this.onCommand_.bind(this));downloads.ActionService.getInsta
nce().loadMore()},removeItem_:function(index){this.splice("items_",index,1);this
.updateHideDates_(index,index);this.onListScroll_()},updateHideDates_:function(s
tart,end){for(var i=start;i<=end;++i){var current=this.items_[i];if(!current)con
tinue;var prev=this.items_[i-1];current.hideDate=!!prev&&prev.date_string==curre
nt.date_string}},updateItem_:function(index,data){this.set("items_."+index,data)
;this.updateHideDates_(index,index);var list=this.$["downloads-list"];list.updat
eSizeForItem(index)}});Manager.clearAll=function(){Manager.get().clearAll_()};Ma
nager.get=function(){return queryRequiredElement("downloads-manager")};Manager.i
nsertItems=function(index,list){Manager.get().insertItems_(index,list)};Manager.
onLoad=function(){Manager.get().onLoad_()};Manager.removeItem=function(index){Ma
nager.get().removeItem_(index)};Manager.updateItem=function(index,data){Manager.
get().updateItem_(index,data)};return{Manager:Manager}}); |
69 // Copyright 2015 The Chromium Authors. All rights reserved. | 69 // Copyright 2015 The Chromium Authors. All rights reserved. |
70 // Use of this source code is governed by a BSD-style license that can be | 70 // Use of this source code is governed by a BSD-style license that can be |
71 // found in the LICENSE file. | 71 // found in the LICENSE file. |
72 window.addEventListener("load",function(){downloads.Manager.onLoad();document.fo
nts.load("bold 12px Roboto")}); | 72 window.addEventListener("load",function(){downloads.Manager.onLoad();document.fo
nts.load("bold 12px Roboto")}); |
OLD | NEW |