Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 2535483003: Require user gesture for powerful download operations (Closed)
Patch Set: Run vulcanize.py Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 13 matching lines...) Expand all
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,"&amp;").replace(/< /g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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)})} 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,"&amp;").replace(/< /g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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 function importModules(moduleNames){return new Promise(function(resolve){define( moduleNames,function(){resolve(Array.from(arguments))})})}Polymer.IronResizableB ehavior={properties:{_parentResizable:{type:Object,observer:"_parentResizableCha nged"},_notifyingDescendant:{type:Boolean,value:false}},listeners:{"iron-request -resize-notifications":"_onIronRequestResizeNotifications"},created:function(){t his._interestedResizables=[];this._boundNotifyResize=this.notifyResize.bind(this )},attached:function(){this.fire("iron-request-resize-notifications",null,{node: this,bubbles:true,cancelable:true});if(!this._parentResizable){window.addEventLi stener("resize",this._boundNotifyResize);this.notifyResize()}},detached:function (){if(this._parentResizable){this._parentResizable.stopResizeNotificationsFor(th is)}else{window.removeEventListener("resize",this._boundNotifyResize)}this._pare ntResizable=null},notifyResize:function(){if(!this.isAttached){return}this._inte restedResizables.forEach(function(resizable){if(this.resizerShouldNotify(resizab le)){this._notifyDescendant(resizable)}},this);this._fireResize()},assignParentR esizable:function(parentResizable){this._parentResizable=parentResizable},stopRe sizeNotificationsFor:function(target){var index=this._interestedResizables.index Of(target);if(index>-1){this._interestedResizables.splice(index,1);this.unlisten (target,"iron-resize","_onDescendantIronResize")}},resizerShouldNotify:function( element){return true},_onDescendantIronResize:function(event){if(this._notifying Descendant){event.stopPropagation();return}if(!Polymer.Settings.useShadow){this. _fireResize()}},_fireResize:function(){this.fire("iron-resize",null,{node:this,b ubbles:false})},_onIronRequestResizeNotifications:function(event){var target=eve nt.path?event.path[0]:event.target;if(target===this){return}if(this._interestedR esizables.indexOf(target)===-1){this._interestedResizables.push(target);this.lis ten(target,"iron-resize","_onDescendantIronResize")}target.assignParentResizable (this);this._notifyDescendant(target);event.stopPropagation()},_parentResizableC hanged:function(parentResizable){if(parentResizable){window.removeEventListener( "resize",this._boundNotifyResize)}},_notifyDescendant:function(descendant){if(!t his.isAttached){return}this._notifyingDescendant=true;descendant.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:"paged own",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"de l",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrlKey",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$/;function transformKey(key,n oSpecialChars){var validKey="";if(key){var lKey=key.toLowerCase();if(lKey===" "| |SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_KEY.test(lKey)){validKey="es c"}else if(lKey.length==1){if(!noSpecialChars||KEY_CHAR.test(lKey)){validKey=lKe y}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replace("arrow","")}else if(lKey= ="multiply"){validKey="*"}else{validKey=lKey}}return validKey}function transform KeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(keyIdent in KEY_IDENTIFI ER){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_CHAR.test(keyIdent)){keyIden t=parseInt(keyIdent.replace("U+","0x"),16);validKey=String.fromCharCode(keyIdent ).toLowerCase()}else{validKey=keyIdent.toLowerCase()}}return validKey}function t ransformKeyCode(keyCode){var validKey="";if(Number(keyCode)){if(keyCode>=65&&key Code<=90){validKey=String.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode <=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&keyCode<=57){validKey=Str ing(keyCode-48)}else if(keyCode>=96&&keyCode<=105){validKey=String(keyCode-96)}e lse{validKey=KEY_CODE[keyCode]}}return validKey}function normalizedKeyForEvent(k eyEvent,noSpecialChars){if(keyEvent.key){return transformKey(keyEvent.key,noSpec ialChars)}if(keyEvent.detail&&keyEvent.detail.key){return transformKey(keyEvent. detail.key,noSpecialChars)}return transformKeyIdentifier(keyEvent.keyIdentifier) ||transformKeyCode(keyEvent.keyCode)||""}function keyComboMatchesEvent(keyCombo, event){var keyEvent=normalizedKeyForEvent(event,keyCombo.hasModifiers);return ke yEvent===keyCombo.key&&(!keyCombo.hasModifiers||!!event.shiftKey===!!keyCombo.sh iftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event.altKey===!!keyCombo.altKey &&!!event.metaKey===!!keyCombo.metaKey)}function parseKeyComboString(keyComboStr ing){if(keyComboString.length===1){return{combo:keyComboString,key:keyComboStrin g,event:"keydown"}}return keyComboString.split("+").reduce(function(parsedKeyCom bo,keyComboPart){var eventParts=keyComboPart.split(":");var keyName=eventParts[0 ];var event=eventParts[1];if(keyName in MODIFIER_KEYS){parsedKeyCombo[MODIFIER_K EYS[keyName]]=true;parsedKeyCombo.hasModifiers=true}else{parsedKeyCombo.key=keyN ame;parsedKeyCombo.event=event||"keydown"}return parsedKeyCombo},{combo:keyCombo String.split(":").shift()})}function parseEventString(eventString){return eventS tring.trim().split(" ").map(function(keyComboString){return parseKeyComboString( keyComboString)})}Polymer.IronA11yKeysBehavior={properties:{keyEventTarget:{type :Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolea n,value:false},_boundKeyHandlers:{type:Array,value:function(){return[]}},_impera tiveKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyE ventListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:fun ction(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListene rs()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:fu nction(eventString,handlerName){this._imperativeKeyBindings[eventString]=handler Name;this._prepKeyBindings();this._resetKeyEventListeners()},removeOwnKeyBinding s:function(){this._imperativeKeyBindings={};this._prepKeyBindings();this._resetK eyEventListeners()},keyboardEventMatchesKeys:function(event,eventString){var key Combos=parseEventString(eventString);for(var i=0;i<keyCombos.length;++i){if(keyC omboMatchesEvent(keyCombos[i],event)){return true}}return false},_collectKeyBind ings:function(){var keyBindings=this.behaviors.map(function(behavior){return beh avior.keyBindings});if(keyBindings.indexOf(this.keyBindings)===-1){keyBindings.p ush(this.keyBindings)}return keyBindings},_prepKeyBindings:function(){this._keyB indings={};this._collectKeyBindings().forEach(function(keyBindings){for(var even tString in keyBindings){this._addKeyBinding(eventString,keyBindings[eventString] )}},this);for(var eventString in this._imperativeKeyBindings){this._addKeyBindin g(eventString,this._imperativeKeyBindings[eventString])}for(var eventName in thi s._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})}},_addKeyBi nding:function(eventString,handlerName){parseEventString(eventString).forEach(fu nction(keyCombo){this._keyBindings[keyCombo.event]=this._keyBindings[keyCombo.ev ent]||[];this._keyBindings[keyCombo.event].push([keyCombo,handlerName])},this)}, _resetKeyEventListeners:function(){this._unlistenKeyEventListeners();if(this.isA ttached){this._listenKeyEventListeners()}},_listenKeyEventListeners:function(){i f(!this.keyEventTarget){return}Object.keys(this._keyBindings).forEach(function(e ventName){var keyBindings=this._keyBindings[eventName];var boundKeyHandler=this. _onKeyBindingEvent.bind(this,keyBindings);this._boundKeyHandlers.push([this.keyE ventTarget,eventName,boundKeyHandler]);this.keyEventTarget.addEventListener(even tName,boundKeyHandler)},this)},_unlistenKeyEventListeners:function(){var keyHand lerTuple;var keyEventTarget;var eventName;var boundKeyHandler;while(this._boundK eyHandlers.length){keyHandlerTuple=this._boundKeyHandlers.pop();keyEventTarget=k eyHandlerTuple[0];eventName=keyHandlerTuple[1];boundKeyHandler=keyHandlerTuple[2 ];keyEventTarget.removeEventListener(eventName,boundKeyHandler)}},_onKeyBindingE vent:function(keyBindings,event){if(this.stopKeyboardEventPropagation){event.sto pPropagation()}if(event.defaultPrevented){return}for(var i=0;i<keyBindings.lengt h;i++){var keyCombo=keyBindings[i][0];var handlerName=keyBindings[i][1];if(keyCo mboMatchesEvent(keyCombo,event)){this._triggerKeyHandler(keyCombo,handlerName,ev ent);if(event.defaultPrevented){return}}}},_triggerKeyHandler:function(keyCombo, handlerName,keyboardEvent){var detail=Object.create(keyCombo);detail.keyboardEve nt=keyboardEvent;var event=new CustomEvent(keyCombo.event,{detail:detail,cancela ble:true});this[handlerName].call(this,event);if(event.defaultPrevented){keyboar dEvent.preventDefault()}}}})();Polymer.IronScrollTargetBehavior={properties:{scr ollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}} ,observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListene r:true,_scrollTargetChanged:function(scrollTarget,isAttached){var eventTarget;if (this._oldScrollTarget){this._toggleScrollListener(false,this._oldScrollTarget); this._oldScrollTarget=null}if(!isAttached){return}if(scrollTarget==="document"){ this.scrollTarget=this._doc}else if(typeof scrollTarget==="string"){this.scrollT arget=this.domHost?this.domHost.$[scrollTarget]:Polymer.dom(this.ownerDocument). querySelector("#"+scrollTarget)}else if(this._isValidScrollTarget()){this._bound ScrollHandler=this._boundScrollHandler||this._scrollHandler.bind(this);this._old ScrollTarget=scrollTarget;this._toggleScrollListener(this._shouldHaveListener,sc rollTarget)}},_scrollHandler:function scrollHandler(){},get _defaultScrollTarget (){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _ scrollTop(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc ?window.pageYOffset:this.scrollTarget.scrollTop}return 0},get _scrollLeft(){if(t his._isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageXOff set:this.scrollTarget.scrollLeft}return 0},set _scrollTop(top){if(this.scrollTar get===this._doc){window.scrollTo(window.pageXOffset,top)}else if(this._isValidSc rollTarget()){this.scrollTarget.scrollTop=top}},set _scrollLeft(left){if(this.sc rollTarget===this._doc){window.scrollTo(left,window.pageYOffset)}else if(this._i sValidScrollTarget()){this.scrollTarget.scrollLeft=left}},scroll:function(left,t op){if(this.scrollTarget===this._doc){window.scrollTo(left,top)}else if(this._is ValidScrollTarget()){this.scrollTarget.scrollLeft=left;this.scrollTarget.scrollT op=top}},get _scrollTargetWidth(){if(this._isValidScrollTarget()){return this.sc rollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth}return 0} ,get _scrollTargetHeight(){if(this._isValidScrollTarget()){return this.scrollTar get===this._doc?window.innerHeight:this.scrollTarget.offsetHeight}return 0},_isV alidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_to ggleScrollListener:function(yes,scrollTarget){if(!this._boundScrollHandler){retu rn}var eventTarget=scrollTarget===this._doc?window:scrollTarget;if(yes){eventTar get.addEventListener("scroll",this._boundScrollHandler)}else{eventTarget.removeE ventListener("scroll",this._boundScrollHandler)}},toggleScrollListener:function( yes){this._shouldHaveListener=yes;this._toggleScrollListener(yes,this.scrollTarg et)}};(function(){var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;var DEFAULT_PHYSICAL_COUNT=3;v ar HIDDEN_Y="-10000px";var ITEM_WIDTH=0;var ITEM_HEIGHT=1;var SECRET_TABINDEX=-1 00;Polymer({is:"iron-list",properties:{items:{type:Array},maxPhysicalCount:{type :Number,value:500},as:{type:String,value:"item"},indexAs:{type:String,value:"ind ex"},selectedAs:{type:String,value:"selected"},grid:{type:Boolean,value:false,re flectToAttribute:true},selectionEnabled:{type:Boolean,value:false},selectedItem: {type:Object,notify:true},selectedItems:{type:Object,notify:true},multiSelection :{type:Boolean,value:false}},observers:["_itemsChanged(items.*)","_selectionEnab ledChanged(selectionEnabled)","_multiSelectionChanged(multiSelection)","_setOver flow(scrollTarget)"],behaviors:[Polymer.Templatizer,Polymer.IronResizableBehavio r,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTargetBehavior],keyBindings:{up :"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"},_ratio:.5,_scrollerPaddingT op:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount: 0,_physicalTop:0,_virtualCount:0,_physicalIndexForKey:null,_estScrollHeight:0,_s crollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSi zes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_collection:null,_ maxPages:2,_focusedItem:null,_focusedIndex:-1,_offscreenFocusedItem:null,_focusB ackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_templateCost:0,get _p hysicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom() {return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this ._virtualStart+this._physicalCount-1},get _hiddenContentSize(){var size=this.gri d?this._physicalRows*this._rowHeight:this._physicalSize;return size-this._viewpo rtHeight},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+ this._scrollerPaddingTop},_minVirtualStart:0,get _maxVirtualStart(){return Math. max(0,this._virtualCount-this._physicalCount)},_virtualStartVal:0,set _virtualSt art(val){this._virtualStartVal=Math.min(this._maxVirtualStart,Math.max(this._min VirtualStart,val))},get _virtualStart(){return this._virtualStartVal||0},_physic alStartVal:0,set _physicalStart(val){this._physicalStartVal=val%this._physicalCo unt;if(this._physicalStartVal<0){this._physicalStartVal=this._physicalCount+this ._physicalStartVal}this._physicalEnd=(this._physicalStart+this._physicalCount-1) %this._physicalCount},get _physicalStart(){return this._physicalStartVal||0},_ph ysicalCountVal:0,set _physicalCount(val){this._physicalCountVal=val;this._physic alEnd=(this._physicalStart+this._physicalCount-1)%this._physicalCount},get _phys icalCount(){return this._physicalCountVal},_physicalEnd:0,get _optPhysicalSize() {if(this.grid){return this._estRowsInView*this._rowHeight*this._maxPages}return this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offset Width||this.offsetHeight)},get firstVisibleIndex(){if(this._firstVisibleIndexVal ===null){var physicalOffset=Math.floor(this._physicalTop+this._scrollerPaddingTo p);this._firstVisibleIndexVal=this._iterateItems(function(pidx,vidx){physicalOff set+=this._getPhysicalSizeIncrement(pidx);if(physicalOffset>this._scrollPosition ){return this.grid?vidx-vidx%this._itemsPerRow:vidx}if(this.grid&&this._virtualC ount-1===vidx){return vidx-vidx%this._itemsPerRow}})||0}return this._firstVisibl eIndexVal},get lastVisibleIndex(){if(this._lastVisibleIndexVal===null){if(this.g rid){var lastIndex=this.firstVisibleIndex+this._estRowsInView*this._itemsPerRow- 1;this._lastVisibleIndexVal=Math.min(this._virtualCount,lastIndex)}else{var phys icalOffset=this._physicalTop;this._iterateItems(function(pidx,vidx){if(physicalO ffset<this._scrollBottom){this._lastVisibleIndexVal=vidx}else{return true}physic alOffset+=this._getPhysicalSizeIncrement(pidx)})}}return this._lastVisibleIndexV al},get _defaultScrollTarget(){return this},get _virtualRowCount(){return Math.c eil(this._virtualCount/this._itemsPerRow)},get _estRowsInView(){return Math.ceil (this._viewportHeight/this._rowHeight)},get _physicalRows(){return Math.ceil(thi s._physicalCount/this._itemsPerRow)},ready:function(){this.addEventListener("foc us",this._didFocus.bind(this),true)},attached:function(){if(this._physicalCount= ==0){this._debounceTemplate(this._render)}this.listen(this,"iron-resize","_resiz eHandler")},detached:function(){this.unlisten(this,"iron-resize","_resizeHandler ")},_setOverflow:function(scrollTarget){this.style.webkitOverflowScrolling=scrol lTarget===this?"touch":"";this.style.overflow=scrollTarget===this?"auto":""},upd ateViewportBoundaries:function(){this._scrollerPaddingTop=this.scrollTarget===th is?0:parseInt(window.getComputedStyle(this)["padding-top"],10);this._viewportWid th=this.$.items.offsetWidth;this._viewportHeight=this._scrollTargetHeight;this.g rid&&this._updateGridMetrics()},_scrollHandler:function(){var scrollTop=Math.max (0,Math.min(this._maxScrollTop,this._scrollTop));var delta=scrollTop-this._scrol lPosition;var isScrollingDown=delta>=0;this._scrollPosition=scrollTop;this._firs tVisibleIndexVal=null;this._lastVisibleIndexVal=null;if(Math.abs(delta)>this._ph ysicalSize){var idxAdjustment=Math.round(delta/this._physicalAverage)*this._item sPerRow;this._physicalTop=this._physicalTop+delta;this._virtualStart=this._virtu alStart+idxAdjustment;this._physicalStart=this._physicalStart+idxAdjustment;this ._update()}else{var reusables=this._getReusables(isScrollingDown);if(isScrolling Down){this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualSt art+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.i ndexes.length}else{this._virtualStart=this._virtualStart-reusables.indexes.lengt h;this._physicalStart=this._physicalStart-reusables.indexes.length}if(reusables. indexes.length===0){this._increasePoolIfNeeded()}else{this._update(reusables.ind exes,isScrollingDown?null:reusables.indexes)}}},_getReusables:function(fromTop){ var ith,lastIth,offsetContent,physicalItemHeight;var idxs=[];var protectedOffset Content=this._hiddenContentSize*this._ratio;var virtualStart=this._virtualStart; var virtualEnd=this._virtualEnd;var physicalCount=this._physicalCount;var physic alTop=this._physicalTop+this._scrollerPaddingTop;var scrollTop=this._scrollTop;v ar scrollBottom=this._scrollBottom;if(fromTop){ith=this._physicalStart;lastIth=t his._physicalEnd;offsetContent=scrollTop-physicalTop}else{ith=this._physicalEnd; lastIth=this._physicalStart;offsetContent=this._physicalBottom-scrollBottom}whil e(true){physicalItemHeight=this._getPhysicalSizeIncrement(ith);offsetContent=off setContent-physicalItemHeight;if(idxs.length>=physicalCount||offsetContent<=prot ectedOffsetContent){break}if(fromTop){if(virtualEnd+idxs.length+1>=this._virtual Count){break}if(physicalTop+physicalItemHeight>=scrollTop){break}idxs.push(ith); physicalTop=physicalTop+physicalItemHeight;ith=(ith+1)%physicalCount}else{if(vir tualStart-idxs.length<=0){break}if(physicalTop+this._physicalSize-physicalItemHe ight<=scrollBottom){break}idxs.push(ith);physicalTop=physicalTop-physicalItemHei ght;ith=ith===0?physicalCount-1:ith-1}}return{indexes:idxs,physicalTop:physicalT op-this._scrollerPaddingTop}},_update:function(itemSet,movingUp){if(itemSet&&ite mSet.length===0){return}this._manageFocus();this._assignModels(itemSet);this._up dateMetrics(itemSet);if(movingUp){while(movingUp.length){var idx=movingUp.pop(); this._physicalTop-=this._getPhysicalSizeIncrement(idx)}}this._positionItems();th is._updateScrollerSize();this._increasePoolIfNeeded()},_createPool:function(size ){var physicalItems=new Array(size);this._ensureTemplatized();for(var i=0;i<size ;i++){var inst=this.stamp(null);physicalItems[i]=inst.root.querySelector("*");Po lymer.dom(this).appendChild(inst.root)}return physicalItems},_increasePoolIfNeed ed:function(){if(this._viewportHeight===0){return false}var self=this;var isClie ntFull=this._physicalBottom>=this._scrollBottom&&this._physicalTop<=this._scroll Position;if(this._physicalSize>=this._optPhysicalSize&&isClientFull){return fals e}var maxPoolSize=Math.round(this._physicalCount*.5);if(!isClientFull){this._deb ounceTemplate(this._increasePool.bind(this,maxPoolSize));return true}this._yield (function(){self._increasePool(Math.min(maxPoolSize,Math.max(1,Math.round(50/sel f._templateCost))))});return true},_yield:function(cb){var g=window;var handle=g .requestIdleCallback?g.requestIdleCallback(cb):g.setTimeout(cb,16);Polymer.dom.a ddDebouncer({complete:function(){g.cancelIdleCallback?g.cancelIdleCallback(handl e):g.clearTimeout(handle);cb()}})},_increasePool:function(missingItems){var next PhysicalCount=Math.min(this._physicalCount+missingItems,this._virtualCount-this. _virtualStart,Math.max(this.maxPhysicalCount,DEFAULT_PHYSICAL_COUNT));var prevPh ysicalCount=this._physicalCount;var delta=nextPhysicalCount-prevPhysicalCount;va r ts=window.performance.now();if(delta<=0){return}[].push.apply(this._physicalIt ems,this._createPool(delta));[].push.apply(this._physicalSizes,new Array(delta)) ;this._physicalCount=prevPhysicalCount+delta;if(this._physicalStart>this._physic alEnd&&this._isIndexRendered(this._focusedIndex)&&this._getPhysicalIndex(this._f ocusedIndex)<this._physicalEnd){this._physicalStart=this._physicalStart+delta}th is._update();this._templateCost=(window.performance.now()-ts)/delta},_render:fun ction(){if(this.isAttached&&this._isVisible){if(this._physicalCount===0){this.up dateViewportBoundaries();this._increasePool(DEFAULT_PHYSICAL_COUNT)}else{var reu sables=this._getReusables(true);this._physicalTop=reusables.physicalTop;this._vi rtualStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this. _physicalStart+reusables.indexes.length;this._update(reusables.indexes);this._up date()}}},_ensureTemplatized:function(){if(!this.ctor){var props={};props.__key_ _=true;props[this.as]=true;props[this.indexAs]=true;props[this.selectedAs]=true; props.tabIndex=true;this._instanceProps=props;this._userTemplate=Polymer.dom(thi s).querySelector("template");if(this._userTemplate){this.templatize(this._userTe mplate)}else{console.warn("iron-list requires a template to be provided in light -dom")}}},_getStampedChildren:function(){return this._physicalItems},_forwardIns tancePath:function(inst,path,value){if(path.indexOf(this.as+".")===0){this.notif yPath("items."+inst.__key__+"."+path.slice(this.as.length+1),value)}},_forwardPa rentProp:function(prop,value){if(this._physicalItems){this._physicalItems.forEac h(function(item){item._templateInstance[prop]=value},this)}},_forwardParentPath: function(path,value){if(this._physicalItems){this._physicalItems.forEach(functio n(item){item._templateInstance.notifyPath(path,value,true)},this)}},_forwardItem Path:function(path,value){if(!this._physicalIndexForKey){return}var dot=path.ind exOf(".");var key=path.substring(0,dot<0?path.length:dot);var idx=this._physical IndexForKey[key];var offscreenItem=this._offscreenFocusedItem;var el=offscreenIt em&&offscreenItem._templateInstance.__key__===key?offscreenItem:this._physicalIt ems[idx];if(!el||el._templateInstance.__key__!==key){return}if(dot>=0){path=this .as+"."+path.substring(dot+1);el._templateInstance.notifyPath(path,value,true)}e lse{var currentItem=el._templateInstance[this.as];if(Array.isArray(this.selected Items)){for(var i=0;i<this.selectedItems.length;i++){if(this.selectedItems[i]=== currentItem){this.set("selectedItems."+i,value);break}}}else if(this.selectedIte m===currentItem){this.set("selectedItem",value)}el._templateInstance[this.as]=va lue}},_itemsChanged:function(change){if(change.path==="items"){this._virtualStar t=0;this._physicalTop=0;this._virtualCount=this.items?this.items.length:0;this._ collection=this.items?Polymer.Collection.get(this.items):null;this._physicalInde xForKey={};this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;this._ physicalCount=this._physicalCount||0;this._physicalItems=this._physicalItems||[] ;this._physicalSizes=this._physicalSizes||[];this._physicalStart=0;this._resetSc rollPosition(0);this._removeFocusedItem();this._debounceTemplate(this._render)}e lse if(change.path==="items.splices"){this._adjustVirtualIndex(change.value.inde xSplices);this._virtualCount=this.items?this.items.length:0;this._debounceTempla te(this._render)}else{this._forwardItemPath(change.path.split(".").slice(1).join ("."),change.value)}},_adjustVirtualIndex:function(splices){splices.forEach(func tion(splice){splice.removed.forEach(this._removeItem,this);if(splice.index<this. _virtualStart){var delta=Math.max(splice.addedCount-splice.removed.length,splice .index-this._virtualStart);this._virtualStart=this._virtualStart+delta;if(this._ focusedIndex>=0){this._focusedIndex=this._focusedIndex+delta}}},this)},_removeIt em:function(item){this.$.selector.deselect(item);if(this._focusedItem&&this._foc usedItem._templateInstance[this.as]===item){this._removeFocusedItem()}},_iterate Items:function(fn,itemSet){var 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;v idx=this._virtualStart;for(;pidx<this._physicalCount;pidx++,vidx++){if((rtn=fn.c all(this,pidx,vidx))!=null){return rtn}}for(pidx=0;pidx<this._physicalStart;pidx ++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}},_computeVidx:f unction(pidx){if(pidx>=this._physicalStart){return this._virtualStart+(pidx-this ._physicalStart)}return this._virtualStart+(this._physicalCount-this._physicalSt art)+pidx},_assignModels:function(itemSet){this._iterateItems(function(pidx,vidx ){var el=this._physicalItems[pidx];var inst=el._templateInstance;var item=this.i tems&&this.items[vidx];if(item!=null){inst[this.as]=item;inst.__key__=this._coll ection.getKey(item);inst[this.selectedAs]=this.$.selector.isSelected(item);inst[ this.indexAs]=vidx;inst.tabIndex=this._focusedIndex===vidx?0:-1;this._physicalIn dexForKey[inst.__key__]=pidx;el.removeAttribute("hidden")}else{inst.__key__=null ;el.setAttribute("hidden","")}},itemSet)},_updateMetrics:function(itemSet){Polym er.dom.flush();var newPhysicalSize=0;var oldPhysicalSize=0;var prevAvgCount=this ._physicalAverageCount;var prevPhysicalAvg=this._physicalAverage;this._iterateIt ems(function(pidx,vidx){oldPhysicalSize+=this._physicalSizes[pidx]||0;this._phys icalSizes[pidx]=this._physicalItems[pidx].offsetHeight;newPhysicalSize+=this._ph ysicalSizes[pidx];this._physicalAverageCount+=this._physicalSizes[pidx]?1:0},ite mSet);if(this.grid){this._updateGridMetrics();this._physicalSize=Math.ceil(this. _physicalCount/this._itemsPerRow)*this._rowHeight}else{this._physicalSize=this._ physicalSize+newPhysicalSize-oldPhysicalSize}if(this._physicalAverageCount!==pre vAvgCount){this._physicalAverage=Math.round((prevPhysicalAvg*prevAvgCount+newPhy sicalSize)/this._physicalAverageCount)}},_updateGridMetrics:function(){this._ite mWidth=this._physicalCount>0?this._physicalItems[0].getBoundingClientRect().widt h:200;this._rowHeight=this._physicalCount>0?this._physicalItems[0].offsetHeight: 200;this._itemsPerRow=this._itemWidth?Math.floor(this._viewportWidth/this._itemW idth):this._itemsPerRow},_positionItems:function(){this._adjustScrollPosition(); var y=this._physicalTop;if(this.grid){var totalItemWidth=this._itemsPerRow*this. _itemWidth;var rowOffset=(this._viewportWidth-totalItemWidth)/2;this._iterateIte ms(function(pidx,vidx){var modulus=vidx%this._itemsPerRow;var x=Math.floor(modul us*this._itemWidth+rowOffset);this.translate3d(x+"px",y+"px",0,this._physicalIte ms[pidx]);if(this._shouldRenderNextRow(vidx)){y+=this._rowHeight}})}else{this._i terateItems(function(pidx,vidx){this.translate3d(0,y+"px",0,this._physicalItems[ pidx]);y+=this._physicalSizes[pidx]})}},_getPhysicalSizeIncrement:function(pidx) {if(!this.grid){return this._physicalSizes[pidx]}if(this._computeVidx(pidx)%this ._itemsPerRow!==this._itemsPerRow-1){return 0}return this._rowHeight},_shouldRen derNextRow:function(vidx){return vidx%this._itemsPerRow===this._itemsPerRow-1},_ adjustScrollPosition:function(){var deltaHeight=this._virtualStart===0?this._phy sicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(deltaHeight){this ._physicalTop=this._physicalTop-deltaHeight;if(!IOS_TOUCH_SCROLLING&&this._physi calTop!==0){this._resetScrollPosition(this._scrollTop-deltaHeight)}}},_resetScro llPosition:function(pos){if(this.scrollTarget){this._scrollTop=pos;this._scrollP osition=this._scrollTop}},_updateScrollerSize:function(forceUpdate){if(this.grid ){this._estScrollHeight=this._virtualRowCount*this._rowHeight}else{this._estScro llHeight=this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-th is._virtualStart,0)*this._physicalAverage}forceUpdate=forceUpdate||this._scrollH eight===0;forceUpdate=forceUpdate||this._scrollPosition>=this._estScrollHeight-t his._physicalSize;forceUpdate=forceUpdate||this.grid&&this.$.items.style.height< this._estScrollHeight;if(forceUpdate||Math.abs(this._estScrollHeight-this._scrol lHeight)>=this._optPhysicalSize){this.$.items.style.height=this._estScrollHeight +"px";this._scrollHeight=this._estScrollHeight}},scrollToItem:function(item){ret urn 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._virtual Count-1);if(!this._isIndexRendered(idx)||idx>=this._maxVirtualStart){this._virtu alStart=this.grid?idx-this._itemsPerRow*2:idx-1}this._manageFocus();this._assign Models();this._updateMetrics();this._physicalTop=Math.floor(this._virtualStart/t his._itemsPerRow)*this._physicalAverage;var currentTopItem=this._physicalStart;v ar currentVirtualItem=this._virtualStart;var targetOffsetTop=0;var hiddenContent Size=this._hiddenContentSize;while(currentVirtualItem<idx&&targetOffsetTop<=hidd enContentSize){targetOffsetTop=targetOffsetTop+this._getPhysicalSizeIncrement(cu rrentTopItem);currentTopItem=(currentTopItem+1)%this._physicalCount;currentVirtu alItem++}this._updateScrollerSize(true);this._positionItems();this._resetScrollP osition(this._physicalTop+this._scrollerPaddingTop+targetOffsetTop);this._increa sePoolIfNeeded();this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null} ,_resetAverage:function(){this._physicalAverage=0;this._physicalAverageCount=0}, _resizeHandler:function(){var delta=Math.abs(this._viewportHeight-this._scrollTa rgetHeight);if(IOS&&delta>0&&delta<100){return}Polymer.dom.addDebouncer(this.deb ounce("_debounceTemplate",function(){this.updateViewportBoundaries();this._rende r();if(this._isVisible){this.toggleScrollListener(true);if(this._physicalCount>0 ){this._resetAverage();this.scrollToIndex(this.firstVisibleIndex)}}else{this.tog gleScrollListener(false)}}.bind(this),1))},_getModelFromItem:function(item){var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[key];if(pid x!=null){return this._physicalItems[pidx]._templateInstance}return null},_getNor malizedItem:function(item){if(this._collection.getKey(item)===undefined){if(type of item==="number"){item=this.items[item];if(!item){throw new RangeError("<item> not found")}return item}throw new TypeError("<item> should be a valid item")}re turn item},selectItem:function(item){item=this._getNormalizedItem(item);var mode l=this._getModelFromItem(item);if(!this.multiSelection&&this.selectedItem){this. deselectItem(this.selectedItem)}if(model){model[this.selectedAs]=true}this.$.sel ector.select(item);this.updateSizeForItem(item)},deselectItem:function(item){ite m=this._getNormalizedItem(item);var model=this._getModelFromItem(item);if(model) {model[this.selectedAs]=false}this.$.selector.deselect(item);this.updateSizeForI tem(item)},toggleSelectionForItem:function(item){item=this._getNormalizedItem(it em);if(this.$.selector.isSelected(item)){this.deselectItem(item)}else{this.selec tItem(item)}},clearSelection:function(){function unselect(item){var model=this._ getModelFromItem(item);if(model){model[this.selectedAs]=false}}if(Array.isArray( this.selectedItems)){this.selectedItems.forEach(unselect,this)}else if(this.sele ctedItem){unselect.call(this,this.selectedItem)}this.$.selector.clearSelection() },_selectionEnabledChanged:function(selectionEnabled){var handler=selectionEnabl ed?this.listen:this.unlisten;handler.call(this,this,"tap","_selectionHandler")}, _selectionHandler:function(e){var model=this.modelForElement(e.target);if(!model ){return}var modelTabIndex,activeElTabIndex;var target=Polymer.dom(e).path[0];va r activeEl=Polymer.dom(this.domHost?this.domHost.root:document).activeElement;va r physicalItem=this._physicalItems[this._getPhysicalIndex(model[this.indexAs])]; 28 function importModules(moduleNames){return new Promise(function(resolve){define( moduleNames,function(){resolve(Array.from(arguments))})})}Polymer.IronResizableB ehavior={properties:{_parentResizable:{type:Object,observer:"_parentResizableCha nged"},_notifyingDescendant:{type:Boolean,value:false}},listeners:{"iron-request -resize-notifications":"_onIronRequestResizeNotifications"},created:function(){t his._interestedResizables=[];this._boundNotifyResize=this.notifyResize.bind(this )},attached:function(){this.fire("iron-request-resize-notifications",null,{node: this,bubbles:true,cancelable:true});if(!this._parentResizable){window.addEventLi stener("resize",this._boundNotifyResize);this.notifyResize()}},detached:function (){if(this._parentResizable){this._parentResizable.stopResizeNotificationsFor(th is)}else{window.removeEventListener("resize",this._boundNotifyResize)}this._pare ntResizable=null},notifyResize:function(){if(!this.isAttached){return}this._inte restedResizables.forEach(function(resizable){if(this.resizerShouldNotify(resizab le)){this._notifyDescendant(resizable)}},this);this._fireResize()},assignParentR esizable:function(parentResizable){this._parentResizable=parentResizable},stopRe sizeNotificationsFor:function(target){var index=this._interestedResizables.index Of(target);if(index>-1){this._interestedResizables.splice(index,1);this.unlisten (target,"iron-resize","_onDescendantIronResize")}},resizerShouldNotify:function( element){return true},_onDescendantIronResize:function(event){if(this._notifying Descendant){event.stopPropagation();return}if(!Polymer.Settings.useShadow){this. _fireResize()}},_fireResize:function(){this.fire("iron-resize",null,{node:this,b ubbles:false})},_onIronRequestResizeNotifications:function(event){var target=eve nt.path?event.path[0]:event.target;if(target===this){return}if(this._interestedR esizables.indexOf(target)===-1){this._interestedResizables.push(target);this.lis ten(target,"iron-resize","_onDescendantIronResize")}target.assignParentResizable (this);this._notifyDescendant(target);event.stopPropagation()},_parentResizableC hanged:function(parentResizable){if(parentResizable){window.removeEventListener( "resize",this._boundNotifyResize)}},_notifyDescendant:function(descendant){if(!t his.isAttached){return}this._notifyingDescendant=true;descendant.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:"paged own",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"de l",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrlKey",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$/;function transformKey(key,n oSpecialChars){var validKey="";if(key){var lKey=key.toLowerCase();if(lKey===" "| |SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_KEY.test(lKey)){validKey="es c"}else if(lKey.length==1){if(!noSpecialChars||KEY_CHAR.test(lKey)){validKey=lKe y}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replace("arrow","")}else if(lKey= ="multiply"){validKey="*"}else{validKey=lKey}}return validKey}function transform KeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(keyIdent in KEY_IDENTIFI ER){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_CHAR.test(keyIdent)){keyIden t=parseInt(keyIdent.replace("U+","0x"),16);validKey=String.fromCharCode(keyIdent ).toLowerCase()}else{validKey=keyIdent.toLowerCase()}}return validKey}function t ransformKeyCode(keyCode){var validKey="";if(Number(keyCode)){if(keyCode>=65&&key Code<=90){validKey=String.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode <=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&keyCode<=57){validKey=Str ing(keyCode-48)}else if(keyCode>=96&&keyCode<=105){validKey=String(keyCode-96)}e lse{validKey=KEY_CODE[keyCode]}}return validKey}function normalizedKeyForEvent(k eyEvent,noSpecialChars){if(keyEvent.key){return transformKey(keyEvent.key,noSpec ialChars)}if(keyEvent.detail&&keyEvent.detail.key){return transformKey(keyEvent. detail.key,noSpecialChars)}return transformKeyIdentifier(keyEvent.keyIdentifier) ||transformKeyCode(keyEvent.keyCode)||""}function keyComboMatchesEvent(keyCombo, event){var keyEvent=normalizedKeyForEvent(event,keyCombo.hasModifiers);return ke yEvent===keyCombo.key&&(!keyCombo.hasModifiers||!!event.shiftKey===!!keyCombo.sh iftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event.altKey===!!keyCombo.altKey &&!!event.metaKey===!!keyCombo.metaKey)}function parseKeyComboString(keyComboStr ing){if(keyComboString.length===1){return{combo:keyComboString,key:keyComboStrin g,event:"keydown"}}return keyComboString.split("+").reduce(function(parsedKeyCom bo,keyComboPart){var eventParts=keyComboPart.split(":");var keyName=eventParts[0 ];var event=eventParts[1];if(keyName in MODIFIER_KEYS){parsedKeyCombo[MODIFIER_K EYS[keyName]]=true;parsedKeyCombo.hasModifiers=true}else{parsedKeyCombo.key=keyN ame;parsedKeyCombo.event=event||"keydown"}return parsedKeyCombo},{combo:keyCombo String.split(":").shift()})}function parseEventString(eventString){return eventS tring.trim().split(" ").map(function(keyComboString){return parseKeyComboString( keyComboString)})}Polymer.IronA11yKeysBehavior={properties:{keyEventTarget:{type :Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolea n,value:false},_boundKeyHandlers:{type:Array,value:function(){return[]}},_impera tiveKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyE ventListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:fun ction(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListene rs()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:fu nction(eventString,handlerName){this._imperativeKeyBindings[eventString]=handler Name;this._prepKeyBindings();this._resetKeyEventListeners()},removeOwnKeyBinding s:function(){this._imperativeKeyBindings={};this._prepKeyBindings();this._resetK eyEventListeners()},keyboardEventMatchesKeys:function(event,eventString){var key Combos=parseEventString(eventString);for(var i=0;i<keyCombos.length;++i){if(keyC omboMatchesEvent(keyCombos[i],event)){return true}}return false},_collectKeyBind ings:function(){var keyBindings=this.behaviors.map(function(behavior){return beh avior.keyBindings});if(keyBindings.indexOf(this.keyBindings)===-1){keyBindings.p ush(this.keyBindings)}return keyBindings},_prepKeyBindings:function(){this._keyB indings={};this._collectKeyBindings().forEach(function(keyBindings){for(var even tString in keyBindings){this._addKeyBinding(eventString,keyBindings[eventString] )}},this);for(var eventString in this._imperativeKeyBindings){this._addKeyBindin g(eventString,this._imperativeKeyBindings[eventString])}for(var eventName in thi s._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})}},_addKeyBi nding:function(eventString,handlerName){parseEventString(eventString).forEach(fu nction(keyCombo){this._keyBindings[keyCombo.event]=this._keyBindings[keyCombo.ev ent]||[];this._keyBindings[keyCombo.event].push([keyCombo,handlerName])},this)}, _resetKeyEventListeners:function(){this._unlistenKeyEventListeners();if(this.isA ttached){this._listenKeyEventListeners()}},_listenKeyEventListeners:function(){i f(!this.keyEventTarget){return}Object.keys(this._keyBindings).forEach(function(e ventName){var keyBindings=this._keyBindings[eventName];var boundKeyHandler=this. _onKeyBindingEvent.bind(this,keyBindings);this._boundKeyHandlers.push([this.keyE ventTarget,eventName,boundKeyHandler]);this.keyEventTarget.addEventListener(even tName,boundKeyHandler)},this)},_unlistenKeyEventListeners:function(){var keyHand lerTuple;var keyEventTarget;var eventName;var boundKeyHandler;while(this._boundK eyHandlers.length){keyHandlerTuple=this._boundKeyHandlers.pop();keyEventTarget=k eyHandlerTuple[0];eventName=keyHandlerTuple[1];boundKeyHandler=keyHandlerTuple[2 ];keyEventTarget.removeEventListener(eventName,boundKeyHandler)}},_onKeyBindingE vent:function(keyBindings,event){if(this.stopKeyboardEventPropagation){event.sto pPropagation()}if(event.defaultPrevented){return}for(var i=0;i<keyBindings.lengt h;i++){var keyCombo=keyBindings[i][0];var handlerName=keyBindings[i][1];if(keyCo mboMatchesEvent(keyCombo,event)){this._triggerKeyHandler(keyCombo,handlerName,ev ent);if(event.defaultPrevented){return}}}},_triggerKeyHandler:function(keyCombo, handlerName,keyboardEvent){var detail=Object.create(keyCombo);detail.keyboardEve nt=keyboardEvent;var event=new CustomEvent(keyCombo.event,{detail:detail,cancela ble:true});this[handlerName].call(this,event);if(event.defaultPrevented){keyboar dEvent.preventDefault()}}}})();Polymer.IronScrollTargetBehavior={properties:{scr ollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}} ,observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListene r:true,_scrollTargetChanged:function(scrollTarget,isAttached){var eventTarget;if (this._oldScrollTarget){this._toggleScrollListener(false,this._oldScrollTarget); this._oldScrollTarget=null}if(!isAttached){return}if(scrollTarget==="document"){ this.scrollTarget=this._doc}else if(typeof scrollTarget==="string"){this.scrollT arget=this.domHost?this.domHost.$[scrollTarget]:Polymer.dom(this.ownerDocument). querySelector("#"+scrollTarget)}else if(this._isValidScrollTarget()){this._bound ScrollHandler=this._boundScrollHandler||this._scrollHandler.bind(this);this._old ScrollTarget=scrollTarget;this._toggleScrollListener(this._shouldHaveListener,sc rollTarget)}},_scrollHandler:function scrollHandler(){},get _defaultScrollTarget (){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _ scrollTop(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc ?window.pageYOffset:this.scrollTarget.scrollTop}return 0},get _scrollLeft(){if(t his._isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageXOff set:this.scrollTarget.scrollLeft}return 0},set _scrollTop(top){if(this.scrollTar get===this._doc){window.scrollTo(window.pageXOffset,top)}else if(this._isValidSc rollTarget()){this.scrollTarget.scrollTop=top}},set _scrollLeft(left){if(this.sc rollTarget===this._doc){window.scrollTo(left,window.pageYOffset)}else if(this._i sValidScrollTarget()){this.scrollTarget.scrollLeft=left}},scroll:function(left,t op){if(this.scrollTarget===this._doc){window.scrollTo(left,top)}else if(this._is ValidScrollTarget()){this.scrollTarget.scrollLeft=left;this.scrollTarget.scrollT op=top}},get _scrollTargetWidth(){if(this._isValidScrollTarget()){return this.sc rollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth}return 0} ,get _scrollTargetHeight(){if(this._isValidScrollTarget()){return this.scrollTar get===this._doc?window.innerHeight:this.scrollTarget.offsetHeight}return 0},_isV alidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_to ggleScrollListener:function(yes,scrollTarget){if(!this._boundScrollHandler){retu rn}var eventTarget=scrollTarget===this._doc?window:scrollTarget;if(yes){eventTar get.addEventListener("scroll",this._boundScrollHandler)}else{eventTarget.removeE ventListener("scroll",this._boundScrollHandler)}},toggleScrollListener:function( yes){this._shouldHaveListener=yes;this._toggleScrollListener(yes,this.scrollTarg et)}};(function(){var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;var DEFAULT_PHYSICAL_COUNT=3;v ar HIDDEN_Y="-10000px";var ITEM_WIDTH=0;var ITEM_HEIGHT=1;var SECRET_TABINDEX=-1 00;Polymer({is:"iron-list",properties:{items:{type:Array},maxPhysicalCount:{type :Number,value:500},as:{type:String,value:"item"},indexAs:{type:String,value:"ind ex"},selectedAs:{type:String,value:"selected"},grid:{type:Boolean,value:false,re flectToAttribute:true},selectionEnabled:{type:Boolean,value:false},selectedItem: {type:Object,notify:true},selectedItems:{type:Object,notify:true},multiSelection :{type:Boolean,value:false}},observers:["_itemsChanged(items.*)","_selectionEnab ledChanged(selectionEnabled)","_multiSelectionChanged(multiSelection)","_setOver flow(scrollTarget)"],behaviors:[Polymer.Templatizer,Polymer.IronResizableBehavio r,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTargetBehavior],keyBindings:{up :"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"},_ratio:.5,_scrollerPaddingT op:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount: 0,_physicalTop:0,_virtualCount:0,_physicalIndexForKey:null,_estScrollHeight:0,_s crollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSi zes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_collection:null,_ maxPages:2,_focusedItem:null,_focusedIndex:-1,_offscreenFocusedItem:null,_focusB ackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_templateCost:0,get _p hysicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom() {return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this ._virtualStart+this._physicalCount-1},get _hiddenContentSize(){var size=this.gri d?this._physicalRows*this._rowHeight:this._physicalSize;return size-this._viewpo rtHeight},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+ this._scrollerPaddingTop},_minVirtualStart:0,get _maxVirtualStart(){return Math. max(0,this._virtualCount-this._physicalCount)},_virtualStartVal:0,set _virtualSt art(val){this._virtualStartVal=Math.min(this._maxVirtualStart,Math.max(this._min VirtualStart,val))},get _virtualStart(){return this._virtualStartVal||0},_physic alStartVal:0,set _physicalStart(val){this._physicalStartVal=val%this._physicalCo unt;if(this._physicalStartVal<0){this._physicalStartVal=this._physicalCount+this ._physicalStartVal}this._physicalEnd=(this._physicalStart+this._physicalCount-1) %this._physicalCount},get _physicalStart(){return this._physicalStartVal||0},_ph ysicalCountVal:0,set _physicalCount(val){this._physicalCountVal=val;this._physic alEnd=(this._physicalStart+this._physicalCount-1)%this._physicalCount},get _phys icalCount(){return this._physicalCountVal},_physicalEnd:0,get _optPhysicalSize() {if(this.grid){return this._estRowsInView*this._rowHeight*this._maxPages}return this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offset Width||this.offsetHeight)},get firstVisibleIndex(){if(this._firstVisibleIndexVal ===null){var physicalOffset=Math.floor(this._physicalTop+this._scrollerPaddingTo p);this._firstVisibleIndexVal=this._iterateItems(function(pidx,vidx){physicalOff set+=this._getPhysicalSizeIncrement(pidx);if(physicalOffset>this._scrollPosition ){return this.grid?vidx-vidx%this._itemsPerRow:vidx}if(this.grid&&this._virtualC ount-1===vidx){return vidx-vidx%this._itemsPerRow}})||0}return this._firstVisibl eIndexVal},get lastVisibleIndex(){if(this._lastVisibleIndexVal===null){if(this.g rid){var lastIndex=this.firstVisibleIndex+this._estRowsInView*this._itemsPerRow- 1;this._lastVisibleIndexVal=Math.min(this._virtualCount,lastIndex)}else{var phys icalOffset=this._physicalTop;this._iterateItems(function(pidx,vidx){if(physicalO ffset<this._scrollBottom){this._lastVisibleIndexVal=vidx}else{return true}physic alOffset+=this._getPhysicalSizeIncrement(pidx)})}}return this._lastVisibleIndexV al},get _defaultScrollTarget(){return this},get _virtualRowCount(){return Math.c eil(this._virtualCount/this._itemsPerRow)},get _estRowsInView(){return Math.ceil (this._viewportHeight/this._rowHeight)},get _physicalRows(){return Math.ceil(thi s._physicalCount/this._itemsPerRow)},ready:function(){this.addEventListener("foc us",this._didFocus.bind(this),true)},attached:function(){if(this._physicalCount= ==0){this._debounceTemplate(this._render)}this.listen(this,"iron-resize","_resiz eHandler")},detached:function(){this.unlisten(this,"iron-resize","_resizeHandler ")},_setOverflow:function(scrollTarget){this.style.webkitOverflowScrolling=scrol lTarget===this?"touch":"";this.style.overflow=scrollTarget===this?"auto":""},upd ateViewportBoundaries:function(){this._scrollerPaddingTop=this.scrollTarget===th is?0:parseInt(window.getComputedStyle(this)["padding-top"],10);this._viewportWid th=this.$.items.offsetWidth;this._viewportHeight=this._scrollTargetHeight;this.g rid&&this._updateGridMetrics()},_scrollHandler:function(){var scrollTop=Math.max (0,Math.min(this._maxScrollTop,this._scrollTop));var delta=scrollTop-this._scrol lPosition;var isScrollingDown=delta>=0;this._scrollPosition=scrollTop;this._firs tVisibleIndexVal=null;this._lastVisibleIndexVal=null;if(Math.abs(delta)>this._ph ysicalSize){var idxAdjustment=Math.round(delta/this._physicalAverage)*this._item sPerRow;this._physicalTop=this._physicalTop+delta;this._virtualStart=this._virtu alStart+idxAdjustment;this._physicalStart=this._physicalStart+idxAdjustment;this ._update()}else{var reusables=this._getReusables(isScrollingDown);if(isScrolling Down){this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtualSt art+reusables.indexes.length;this._physicalStart=this._physicalStart+reusables.i ndexes.length}else{this._virtualStart=this._virtualStart-reusables.indexes.lengt h;this._physicalStart=this._physicalStart-reusables.indexes.length}if(reusables. indexes.length===0){this._increasePoolIfNeeded()}else{this._update(reusables.ind exes,isScrollingDown?null:reusables.indexes)}}},_getReusables:function(fromTop){ var ith,lastIth,offsetContent,physicalItemHeight;var idxs=[];var protectedOffset Content=this._hiddenContentSize*this._ratio;var virtualStart=this._virtualStart; var virtualEnd=this._virtualEnd;var physicalCount=this._physicalCount;var physic alTop=this._physicalTop+this._scrollerPaddingTop;var scrollTop=this._scrollTop;v ar scrollBottom=this._scrollBottom;if(fromTop){ith=this._physicalStart;lastIth=t his._physicalEnd;offsetContent=scrollTop-physicalTop}else{ith=this._physicalEnd; lastIth=this._physicalStart;offsetContent=this._physicalBottom-scrollBottom}whil e(true){physicalItemHeight=this._getPhysicalSizeIncrement(ith);offsetContent=off setContent-physicalItemHeight;if(idxs.length>=physicalCount||offsetContent<=prot ectedOffsetContent){break}if(fromTop){if(virtualEnd+idxs.length+1>=this._virtual Count){break}if(physicalTop+physicalItemHeight>=scrollTop){break}idxs.push(ith); physicalTop=physicalTop+physicalItemHeight;ith=(ith+1)%physicalCount}else{if(vir tualStart-idxs.length<=0){break}if(physicalTop+this._physicalSize-physicalItemHe ight<=scrollBottom){break}idxs.push(ith);physicalTop=physicalTop-physicalItemHei ght;ith=ith===0?physicalCount-1:ith-1}}return{indexes:idxs,physicalTop:physicalT op-this._scrollerPaddingTop}},_update:function(itemSet,movingUp){if(itemSet&&ite mSet.length===0){return}this._manageFocus();this._assignModels(itemSet);this._up dateMetrics(itemSet);if(movingUp){while(movingUp.length){var idx=movingUp.pop(); this._physicalTop-=this._getPhysicalSizeIncrement(idx)}}this._positionItems();th is._updateScrollerSize();this._increasePoolIfNeeded()},_createPool:function(size ){var physicalItems=new Array(size);this._ensureTemplatized();for(var i=0;i<size ;i++){var inst=this.stamp(null);physicalItems[i]=inst.root.querySelector("*");Po lymer.dom(this).appendChild(inst.root)}return physicalItems},_increasePoolIfNeed ed:function(){if(this._viewportHeight===0){return false}var self=this;var isClie ntFull=this._physicalBottom>=this._scrollBottom&&this._physicalTop<=this._scroll Position;if(this._physicalSize>=this._optPhysicalSize&&isClientFull){return fals e}var maxPoolSize=Math.round(this._physicalCount*.5);if(!isClientFull){this._deb ounceTemplate(this._increasePool.bind(this,maxPoolSize));return true}this._yield (function(){self._increasePool(Math.min(maxPoolSize,Math.max(1,Math.round(50/sel f._templateCost))))});return true},_yield:function(cb){var g=window;var handle=g .requestIdleCallback?g.requestIdleCallback(cb):g.setTimeout(cb,16);Polymer.dom.a ddDebouncer({complete:function(){g.cancelIdleCallback?g.cancelIdleCallback(handl e):g.clearTimeout(handle);cb()}})},_increasePool:function(missingItems){var next PhysicalCount=Math.min(this._physicalCount+missingItems,this._virtualCount-this. _virtualStart,Math.max(this.maxPhysicalCount,DEFAULT_PHYSICAL_COUNT));var prevPh ysicalCount=this._physicalCount;var delta=nextPhysicalCount-prevPhysicalCount;va r ts=window.performance.now();if(delta<=0){return}[].push.apply(this._physicalIt ems,this._createPool(delta));[].push.apply(this._physicalSizes,new Array(delta)) ;this._physicalCount=prevPhysicalCount+delta;if(this._physicalStart>this._physic alEnd&&this._isIndexRendered(this._focusedIndex)&&this._getPhysicalIndex(this._f ocusedIndex)<this._physicalEnd){this._physicalStart=this._physicalStart+delta}th is._update();this._templateCost=(window.performance.now()-ts)/delta},_render:fun ction(){if(this.isAttached&&this._isVisible){if(this._physicalCount===0){this.up dateViewportBoundaries();this._increasePool(DEFAULT_PHYSICAL_COUNT)}else{var reu sables=this._getReusables(true);this._physicalTop=reusables.physicalTop;this._vi rtualStart=this._virtualStart+reusables.indexes.length;this._physicalStart=this. _physicalStart+reusables.indexes.length;this._update(reusables.indexes);this._up date()}}},_ensureTemplatized:function(){if(!this.ctor){var props={};props.__key_ _=true;props[this.as]=true;props[this.indexAs]=true;props[this.selectedAs]=true; props.tabIndex=true;this._instanceProps=props;this._userTemplate=Polymer.dom(thi s).querySelector("template");if(this._userTemplate){this.templatize(this._userTe mplate)}else{console.warn("iron-list requires a template to be provided in light -dom")}}},_getStampedChildren:function(){return this._physicalItems},_forwardIns tancePath:function(inst,path,value){if(path.indexOf(this.as+".")===0){this.notif yPath("items."+inst.__key__+"."+path.slice(this.as.length+1),value)}},_forwardPa rentProp:function(prop,value){if(this._physicalItems){this._physicalItems.forEac h(function(item){item._templateInstance[prop]=value},this)}},_forwardParentPath: function(path,value){if(this._physicalItems){this._physicalItems.forEach(functio n(item){item._templateInstance.notifyPath(path,value,true)},this)}},_forwardItem Path:function(path,value){if(!this._physicalIndexForKey){return}var dot=path.ind exOf(".");var key=path.substring(0,dot<0?path.length:dot);var idx=this._physical IndexForKey[key];var offscreenItem=this._offscreenFocusedItem;var el=offscreenIt em&&offscreenItem._templateInstance.__key__===key?offscreenItem:this._physicalIt ems[idx];if(!el||el._templateInstance.__key__!==key){return}if(dot>=0){path=this .as+"."+path.substring(dot+1);el._templateInstance.notifyPath(path,value,true)}e lse{var currentItem=el._templateInstance[this.as];if(Array.isArray(this.selected Items)){for(var i=0;i<this.selectedItems.length;i++){if(this.selectedItems[i]=== currentItem){this.set("selectedItems."+i,value);break}}}else if(this.selectedIte m===currentItem){this.set("selectedItem",value)}el._templateInstance[this.as]=va lue}},_itemsChanged:function(change){if(change.path==="items"){this._virtualStar t=0;this._physicalTop=0;this._virtualCount=this.items?this.items.length:0;this._ collection=this.items?Polymer.Collection.get(this.items):null;this._physicalInde xForKey={};this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;this._ physicalCount=this._physicalCount||0;this._physicalItems=this._physicalItems||[] ;this._physicalSizes=this._physicalSizes||[];this._physicalStart=0;this._resetSc rollPosition(0);this._removeFocusedItem();this._debounceTemplate(this._render)}e lse if(change.path==="items.splices"){this._adjustVirtualIndex(change.value.inde xSplices);this._virtualCount=this.items?this.items.length:0;this._debounceTempla te(this._render)}else{this._forwardItemPath(change.path.split(".").slice(1).join ("."),change.value)}},_adjustVirtualIndex:function(splices){splices.forEach(func tion(splice){splice.removed.forEach(this._removeItem,this);if(splice.index<this. _virtualStart){var delta=Math.max(splice.addedCount-splice.removed.length,splice .index-this._virtualStart);this._virtualStart=this._virtualStart+delta;if(this._ focusedIndex>=0){this._focusedIndex=this._focusedIndex+delta}}},this)},_removeIt em:function(item){this.$.selector.deselect(item);if(this._focusedItem&&this._foc usedItem._templateInstance[this.as]===item){this._removeFocusedItem()}},_iterate Items:function(fn,itemSet){var 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;v idx=this._virtualStart;for(;pidx<this._physicalCount;pidx++,vidx++){if((rtn=fn.c all(this,pidx,vidx))!=null){return rtn}}for(pidx=0;pidx<this._physicalStart;pidx ++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}},_computeVidx:f unction(pidx){if(pidx>=this._physicalStart){return this._virtualStart+(pidx-this ._physicalStart)}return this._virtualStart+(this._physicalCount-this._physicalSt art)+pidx},_assignModels:function(itemSet){this._iterateItems(function(pidx,vidx ){var el=this._physicalItems[pidx];var inst=el._templateInstance;var item=this.i tems&&this.items[vidx];if(item!=null){inst[this.as]=item;inst.__key__=this._coll ection.getKey(item);inst[this.selectedAs]=this.$.selector.isSelected(item);inst[ this.indexAs]=vidx;inst.tabIndex=this._focusedIndex===vidx?0:-1;this._physicalIn dexForKey[inst.__key__]=pidx;el.removeAttribute("hidden")}else{inst.__key__=null ;el.setAttribute("hidden","")}},itemSet)},_updateMetrics:function(itemSet){Polym er.dom.flush();var newPhysicalSize=0;var oldPhysicalSize=0;var prevAvgCount=this ._physicalAverageCount;var prevPhysicalAvg=this._physicalAverage;this._iterateIt ems(function(pidx,vidx){oldPhysicalSize+=this._physicalSizes[pidx]||0;this._phys icalSizes[pidx]=this._physicalItems[pidx].offsetHeight;newPhysicalSize+=this._ph ysicalSizes[pidx];this._physicalAverageCount+=this._physicalSizes[pidx]?1:0},ite mSet);if(this.grid){this._updateGridMetrics();this._physicalSize=Math.ceil(this. _physicalCount/this._itemsPerRow)*this._rowHeight}else{this._physicalSize=this._ physicalSize+newPhysicalSize-oldPhysicalSize}if(this._physicalAverageCount!==pre vAvgCount){this._physicalAverage=Math.round((prevPhysicalAvg*prevAvgCount+newPhy sicalSize)/this._physicalAverageCount)}},_updateGridMetrics:function(){this._ite mWidth=this._physicalCount>0?this._physicalItems[0].getBoundingClientRect().widt h:200;this._rowHeight=this._physicalCount>0?this._physicalItems[0].offsetHeight: 200;this._itemsPerRow=this._itemWidth?Math.floor(this._viewportWidth/this._itemW idth):this._itemsPerRow},_positionItems:function(){this._adjustScrollPosition(); var y=this._physicalTop;if(this.grid){var totalItemWidth=this._itemsPerRow*this. _itemWidth;var rowOffset=(this._viewportWidth-totalItemWidth)/2;this._iterateIte ms(function(pidx,vidx){var modulus=vidx%this._itemsPerRow;var x=Math.floor(modul us*this._itemWidth+rowOffset);this.translate3d(x+"px",y+"px",0,this._physicalIte ms[pidx]);if(this._shouldRenderNextRow(vidx)){y+=this._rowHeight}})}else{this._i terateItems(function(pidx,vidx){this.translate3d(0,y+"px",0,this._physicalItems[ pidx]);y+=this._physicalSizes[pidx]})}},_getPhysicalSizeIncrement:function(pidx) {if(!this.grid){return this._physicalSizes[pidx]}if(this._computeVidx(pidx)%this ._itemsPerRow!==this._itemsPerRow-1){return 0}return this._rowHeight},_shouldRen derNextRow:function(vidx){return vidx%this._itemsPerRow===this._itemsPerRow-1},_ adjustScrollPosition:function(){var deltaHeight=this._virtualStart===0?this._phy sicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(deltaHeight){this ._physicalTop=this._physicalTop-deltaHeight;if(!IOS_TOUCH_SCROLLING&&this._physi calTop!==0){this._resetScrollPosition(this._scrollTop-deltaHeight)}}},_resetScro llPosition:function(pos){if(this.scrollTarget){this._scrollTop=pos;this._scrollP osition=this._scrollTop}},_updateScrollerSize:function(forceUpdate){if(this.grid ){this._estScrollHeight=this._virtualRowCount*this._rowHeight}else{this._estScro llHeight=this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-th is._virtualStart,0)*this._physicalAverage}forceUpdate=forceUpdate||this._scrollH eight===0;forceUpdate=forceUpdate||this._scrollPosition>=this._estScrollHeight-t his._physicalSize;forceUpdate=forceUpdate||this.grid&&this.$.items.style.height< this._estScrollHeight;if(forceUpdate||Math.abs(this._estScrollHeight-this._scrol lHeight)>=this._optPhysicalSize){this.$.items.style.height=this._estScrollHeight +"px";this._scrollHeight=this._estScrollHeight}},scrollToItem:function(item){ret urn 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._virtual Count-1);if(!this._isIndexRendered(idx)||idx>=this._maxVirtualStart){this._virtu alStart=this.grid?idx-this._itemsPerRow*2:idx-1}this._manageFocus();this._assign Models();this._updateMetrics();this._physicalTop=Math.floor(this._virtualStart/t his._itemsPerRow)*this._physicalAverage;var currentTopItem=this._physicalStart;v ar currentVirtualItem=this._virtualStart;var targetOffsetTop=0;var hiddenContent Size=this._hiddenContentSize;while(currentVirtualItem<idx&&targetOffsetTop<=hidd enContentSize){targetOffsetTop=targetOffsetTop+this._getPhysicalSizeIncrement(cu rrentTopItem);currentTopItem=(currentTopItem+1)%this._physicalCount;currentVirtu alItem++}this._updateScrollerSize(true);this._positionItems();this._resetScrollP osition(this._physicalTop+this._scrollerPaddingTop+targetOffsetTop);this._increa sePoolIfNeeded();this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null} ,_resetAverage:function(){this._physicalAverage=0;this._physicalAverageCount=0}, _resizeHandler:function(){var delta=Math.abs(this._viewportHeight-this._scrollTa rgetHeight);if(IOS&&delta>0&&delta<100){return}Polymer.dom.addDebouncer(this.deb ounce("_debounceTemplate",function(){this.updateViewportBoundaries();this._rende r();if(this._isVisible){this.toggleScrollListener(true);if(this._physicalCount>0 ){this._resetAverage();this.scrollToIndex(this.firstVisibleIndex)}}else{this.tog gleScrollListener(false)}}.bind(this),1))},_getModelFromItem:function(item){var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[key];if(pid x!=null){return this._physicalItems[pidx]._templateInstance}return null},_getNor malizedItem:function(item){if(this._collection.getKey(item)===undefined){if(type of item==="number"){item=this.items[item];if(!item){throw new RangeError("<item> not found")}return item}throw new TypeError("<item> should be a valid item")}re turn item},selectItem:function(item){item=this._getNormalizedItem(item);var mode l=this._getModelFromItem(item);if(!this.multiSelection&&this.selectedItem){this. deselectItem(this.selectedItem)}if(model){model[this.selectedAs]=true}this.$.sel ector.select(item);this.updateSizeForItem(item)},deselectItem:function(item){ite m=this._getNormalizedItem(item);var model=this._getModelFromItem(item);if(model) {model[this.selectedAs]=false}this.$.selector.deselect(item);this.updateSizeForI tem(item)},toggleSelectionForItem:function(item){item=this._getNormalizedItem(it em);if(this.$.selector.isSelected(item)){this.deselectItem(item)}else{this.selec tItem(item)}},clearSelection:function(){function unselect(item){var model=this._ getModelFromItem(item);if(model){model[this.selectedAs]=false}}if(Array.isArray( this.selectedItems)){this.selectedItems.forEach(unselect,this)}else if(this.sele ctedItem){unselect.call(this,this.selectedItem)}this.$.selector.clearSelection() },_selectionEnabledChanged:function(selectionEnabled){var handler=selectionEnabl ed?this.listen:this.unlisten;handler.call(this,this,"tap","_selectionHandler")}, _selectionHandler:function(e){var model=this.modelForElement(e.target);if(!model ){return}var modelTabIndex,activeElTabIndex;var target=Polymer.dom(e).path[0];va r activeEl=Polymer.dom(this.domHost?this.domHost.root:document).activeElement;va r physicalItem=this._physicalItems[this._getPhysicalIndex(model[this.indexAs])];
29 29
30 if(target.localName==="input"||target.localName==="button"||target.localName===" select"){return}modelTabIndex=model.tabIndex;model.tabIndex=SECRET_TABINDEX;acti veElTabIndex=activeEl?activeEl.tabIndex:-1;model.tabIndex=modelTabIndex;if(activ eEl&&physicalItem!==activeEl&&physicalItem.contains(activeEl)&&activeElTabIndex! ==SECRET_TABINDEX){return}this.toggleSelectionForItem(model[this.as])},_multiSel ectionChanged:function(multiSelection){this.clearSelection();this.$.selector.mul ti=multiSelection},updateSizeForItem:function(item){item=this._getNormalizedItem (item);var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[ key];if(pidx!=null){this._updateMetrics([pidx]);this._positionItems()}},_manageF ocus:function(){var fidx=this._focusedIndex;if(fidx>=0&&fidx<this._virtualCount) {if(this._isIndexRendered(fidx)){this._restoreFocusedItem()}else{this._createFoc usBackfillItem()}}else if(this._virtualCount>0&&this._physicalCount>0){this._foc usedIndex=this._virtualStart;this._focusedItem=this._physicalItems[this._physica lStart]}},_isIndexRendered:function(idx){return idx>=this._virtualStart&&idx<=th is._virtualEnd},_isIndexVisible:function(idx){return idx>=this.firstVisibleIndex &&idx<=this.lastVisibleIndex},_getPhysicalIndex:function(idx){return this._physi calIndexForKey[this._collection.getKey(this._getNormalizedItem(idx))]},_focusPhy sicalItem:function(idx){if(idx<0||idx>=this._virtualCount){return}this._restoreF ocusedItem();if(!this._isIndexRendered(idx)){this.scrollToIndex(idx)}var physica lItem=this._physicalItems[this._getPhysicalIndex(idx)];var model=physicalItem._t emplateInstance;var focusable;model.tabIndex=SECRET_TABINDEX;if(physicalItem.tab Index===SECRET_TABINDEX){focusable=physicalItem}if(!focusable){focusable=Polymer .dom(physicalItem).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')}model.tabIn dex=0;this._focusedIndex=idx;focusable&&focusable.focus()},_removeFocusedItem:fu nction(){if(this._offscreenFocusedItem){Polymer.dom(this).removeChild(this._offs creenFocusedItem)}this._offscreenFocusedItem=null;this._focusBackfillItem=null;t his._focusedItem=null;this._focusedIndex=-1},_createFocusBackfillItem:function() {var fidx=this._focusedIndex;var pidx=this._getPhysicalIndex(fidx);if(this._offs creenFocusedItem||pidx==null||fidx<0){return}if(!this._focusBackfillItem){var st ampedTemplate=this.stamp(null);this._focusBackfillItem=stampedTemplate.root.quer ySelector("*");Polymer.dom(this).appendChild(stampedTemplate.root)}this._offscre enFocusedItem=this._physicalItems[pidx];this._offscreenFocusedItem._templateInst ance.tabIndex=0;this._physicalItems[pidx]=this._focusBackfillItem;this.translate 3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)},_restoreFocusedItem:function(){var pidx,fidx=this._focusedIndex;if(!this._offscreenFocusedItem||this._focusedIndex< 0){return}this._assignModels();pidx=this._getPhysicalIndex(fidx);if(pidx!=null){ this._focusBackfillItem=this._physicalItems[pidx];this._focusBackfillItem._templ ateInstance.tabIndex=-1;this._physicalItems[pidx]=this._offscreenFocusedItem;thi s._offscreenFocusedItem=null;this.translate3d(0,HIDDEN_Y,0,this._focusBackfillIt em)}},_didFocus:function(e){var targetModel=this.modelForElement(e.target);var f ocusedModel=this._focusedItem?this._focusedItem._templateInstance:null;var hasOf fscreenFocusedItem=this._offscreenFocusedItem!==null;var fidx=this._focusedIndex ;if(!targetModel||!focusedModel){return}if(focusedModel===targetModel){if(!this. _isIndexVisible(fidx)){this.scrollToIndex(fidx)}}else{this._restoreFocusedItem() ;focusedModel.tabIndex=-1;targetModel.tabIndex=0;fidx=targetModel[this.indexAs]; this._focusedIndex=fidx;this._focusedItem=this._physicalItems[this._getPhysicalI ndex(fidx)];if(hasOffscreenFocusedItem&&!this._offscreenFocusedItem){this._updat e()}}},_didMoveUp:function(){this._focusPhysicalItem(this._focusedIndex-1)},_did MoveDown:function(e){e.detail.keyboardEvent.preventDefault();this._focusPhysical Item(this._focusedIndex+1)},_didEnter:function(e){this._focusPhysicalItem(this._ focusedIndex);this._selectionHandler(e.detail.keyboardEvent)}})})(); 30 if(target.localName==="input"||target.localName==="button"||target.localName===" select"){return}modelTabIndex=model.tabIndex;model.tabIndex=SECRET_TABINDEX;acti veElTabIndex=activeEl?activeEl.tabIndex:-1;model.tabIndex=modelTabIndex;if(activ eEl&&physicalItem!==activeEl&&physicalItem.contains(activeEl)&&activeElTabIndex! ==SECRET_TABINDEX){return}this.toggleSelectionForItem(model[this.as])},_multiSel ectionChanged:function(multiSelection){this.clearSelection();this.$.selector.mul ti=multiSelection},updateSizeForItem:function(item){item=this._getNormalizedItem (item);var key=this._collection.getKey(item);var pidx=this._physicalIndexForKey[ key];if(pidx!=null){this._updateMetrics([pidx]);this._positionItems()}},_manageF ocus:function(){var fidx=this._focusedIndex;if(fidx>=0&&fidx<this._virtualCount) {if(this._isIndexRendered(fidx)){this._restoreFocusedItem()}else{this._createFoc usBackfillItem()}}else if(this._virtualCount>0&&this._physicalCount>0){this._foc usedIndex=this._virtualStart;this._focusedItem=this._physicalItems[this._physica lStart]}},_isIndexRendered:function(idx){return idx>=this._virtualStart&&idx<=th is._virtualEnd},_isIndexVisible:function(idx){return idx>=this.firstVisibleIndex &&idx<=this.lastVisibleIndex},_getPhysicalIndex:function(idx){return this._physi calIndexForKey[this._collection.getKey(this._getNormalizedItem(idx))]},_focusPhy sicalItem:function(idx){if(idx<0||idx>=this._virtualCount){return}this._restoreF ocusedItem();if(!this._isIndexRendered(idx)){this.scrollToIndex(idx)}var physica lItem=this._physicalItems[this._getPhysicalIndex(idx)];var model=physicalItem._t emplateInstance;var focusable;model.tabIndex=SECRET_TABINDEX;if(physicalItem.tab Index===SECRET_TABINDEX){focusable=physicalItem}if(!focusable){focusable=Polymer .dom(physicalItem).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')}model.tabIn dex=0;this._focusedIndex=idx;focusable&&focusable.focus()},_removeFocusedItem:fu nction(){if(this._offscreenFocusedItem){Polymer.dom(this).removeChild(this._offs creenFocusedItem)}this._offscreenFocusedItem=null;this._focusBackfillItem=null;t his._focusedItem=null;this._focusedIndex=-1},_createFocusBackfillItem:function() {var fidx=this._focusedIndex;var pidx=this._getPhysicalIndex(fidx);if(this._offs creenFocusedItem||pidx==null||fidx<0){return}if(!this._focusBackfillItem){var st ampedTemplate=this.stamp(null);this._focusBackfillItem=stampedTemplate.root.quer ySelector("*");Polymer.dom(this).appendChild(stampedTemplate.root)}this._offscre enFocusedItem=this._physicalItems[pidx];this._offscreenFocusedItem._templateInst ance.tabIndex=0;this._physicalItems[pidx]=this._focusBackfillItem;this.translate 3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)},_restoreFocusedItem:function(){var pidx,fidx=this._focusedIndex;if(!this._offscreenFocusedItem||this._focusedIndex< 0){return}this._assignModels();pidx=this._getPhysicalIndex(fidx);if(pidx!=null){ this._focusBackfillItem=this._physicalItems[pidx];this._focusBackfillItem._templ ateInstance.tabIndex=-1;this._physicalItems[pidx]=this._offscreenFocusedItem;thi s._offscreenFocusedItem=null;this.translate3d(0,HIDDEN_Y,0,this._focusBackfillIt em)}},_didFocus:function(e){var targetModel=this.modelForElement(e.target);var f ocusedModel=this._focusedItem?this._focusedItem._templateInstance:null;var hasOf fscreenFocusedItem=this._offscreenFocusedItem!==null;var fidx=this._focusedIndex ;if(!targetModel||!focusedModel){return}if(focusedModel===targetModel){if(!this. _isIndexVisible(fidx)){this.scrollToIndex(fidx)}}else{this._restoreFocusedItem() ;focusedModel.tabIndex=-1;targetModel.tabIndex=0;fidx=targetModel[this.indexAs]; this._focusedIndex=fidx;this._focusedItem=this._physicalItems[this._getPhysicalI ndex(fidx)];if(hasOffscreenFocusedItem&&!this._offscreenFocusedItem){this._updat e()}}},_didMoveUp:function(){this._focusPhysicalItem(this._focusedIndex-1)},_did MoveDown:function(e){e.detail.keyboardEvent.preventDefault();this._focusPhysical Item(this._focusedIndex+1)},_didEnter:function(e){this._focusPhysicalItem(this._ focusedIndex);this._selectionHandler(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:function(){chro me.send("openDownloadsFolderRequiringGesture")},openFile:chromeSendWithId("openF ileRequiringGesture"),pause:chromeSendWithId("pause"),remove:chromeSendWithId("r emove"),resume:chromeSendWithId("resume"),saveDangerous:chromeSendWithId("saveDa ngerousRequiringGesture"),search:function(searchText){var searchTerms=ActionServ ice.splitTerms(searchText);var sameTerms=searchTerms.length==this.searchTerms_.l ength;for(var i=0;sameTerms&&i<searchTerms.length;++i){if(searchTerms[i]!=this.s earchTerms_[i])sameTerms=false}if(sameTerms)return false;this.searchTerms_=searc hTerms;this.loadMore();return true},show:chromeSendWithId("show"),undo:chrome.se nd.bind(chrome,"undo")};cr.addSingletonGetter(ActionService);return{ActionServic e:ActionService}});
35 // Copyright 2015 The Chromium Authors. All rights reserved. 35 // Copyright 2015 The Chromium Authors. All rights reserved.
36 // Use of this source code is governed by a BSD-style license that can be 36 // Use of this source code is governed by a BSD-style license that can be
37 // found in the LICENSE file. 37 // found in the LICENSE file.
38 cr.define("downloads",function(){var DangerType={NOT_DANGEROUS:"NOT_DANGEROUS",D ANGEROUS_FILE:"DANGEROUS_FILE",DANGEROUS_URL:"DANGEROUS_URL",DANGEROUS_CONTENT:" DANGEROUS_CONTENT",UNCOMMON_CONTENT:"UNCOMMON_CONTENT",DANGEROUS_HOST:"DANGEROUS _HOST",POTENTIALLY_UNWANTED:"POTENTIALLY_UNWANTED"};var States={IN_PROGRESS:"IN_ PROGRESS",CANCELLED:"CANCELLED",COMPLETE:"COMPLETE",PAUSED:"PAUSED",DANGEROUS:"D ANGEROUS",INTERRUPTED:"INTERRUPTED"};return{DangerType:DangerType,States:States} }); 38 cr.define("downloads",function(){var DangerType={NOT_DANGEROUS:"NOT_DANGEROUS",D ANGEROUS_FILE:"DANGEROUS_FILE",DANGEROUS_URL:"DANGEROUS_URL",DANGEROUS_CONTENT:" DANGEROUS_CONTENT",UNCOMMON_CONTENT:"UNCOMMON_CONTENT",DANGEROUS_HOST:"DANGEROUS _HOST",POTENTIALLY_UNWANTED:"POTENTIALLY_UNWANTED"};var States={IN_PROGRESS:"IN_ PROGRESS",CANCELLED:"CANCELLED",COMPLETE:"COMPLETE",PAUSED:"PAUSED",DANGEROUS:"D ANGEROUS",INTERRUPTED:"INTERRUPTED"};return{DangerType:DangerType,States:States} });
39 // Copyright 2014 The Chromium Authors. All rights reserved. 39 // Copyright 2014 The Chromium Authors. All rights reserved.
40 // Use of this source code is governed by a BSD-style license that can be 40 // Use of this source code is governed by a BSD-style license that can be
41 // found in the LICENSE file. 41 // found in the LICENSE file.
42 var ActionLink=document.registerElement("action-link",{prototype:{__proto__:HTML AnchorElement.prototype,createdCallback:function(){this.tabIndex=this.disabled?- 1:0;if(!this.hasAttribute("role"))this.setAttribute("role","link");this.addEvent Listener("keydown",function(e){if(!this.disabled&&e.key=="Enter"&&!this.href){wi ndow.setTimeout(this.click.bind(this),0)}});function preventDefault(e){e.prevent Default()}function removePreventDefault(){document.removeEventListener("selectst art",preventDefault);document.removeEventListener("mouseup",removePreventDefault )}this.addEventListener("mousedown",function(){document.addEventListener("select start",preventDefault);document.addEventListener("mouseup",removePreventDefault) ;if(document.activeElement!=this)this.classList.add("no-outline")});this.addEven tListener("blur",function(){this.classList.remove("no-outline")})},set disabled( disabled){if(disabled)HTMLAnchorElement.prototype.setAttribute.call(this,"disabl ed","");else HTMLAnchorElement.prototype.removeAttribute.call(this,"disabled");t his.tabIndex=disabled?-1:0},get disabled(){return this.hasAttribute("disabled")} ,setAttribute:function(attr,val){if(attr.toLowerCase()=="disabled")this.disabled =true;else HTMLAnchorElement.prototype.setAttribute.apply(this,arguments)},remov eAttribute:function(attr){if(attr.toLowerCase()=="disabled")this.disabled=false; else HTMLAnchorElement.prototype.removeAttribute.apply(this,arguments)}},"extend s":"a"});(function(){var metaDatas={};var metaArrays={};var singleton=null;Polym er.IronMeta=Polymer({is:"iron-meta",properties:{type:{type:String,value:"default ",observer:"_typeChanged"},key:{type:String,observer:"_keyChanged"},value:{type: Object,notify:true,observer:"_valueChanged"},self:{type:Boolean,observer:"_selfC hanged"},list:{type:Array,notify:true}},hostAttributes:{hidden:true},factoryImpl :function(config){if(config){for(var n in config){switch(n){case"type":case"key" :case"value":this[n]=config[n];break}}}},created:function(){this._metaDatas=meta Datas;this._metaArrays=metaArrays},_keyChanged:function(key,old){this._resetRegi stration(old)},_valueChanged:function(value){this._resetRegistration(this.key)}, _selfChanged:function(self){if(self){this.value=this}},_typeChanged:function(typ e){this._unregisterKey(this.key);if(!metaDatas[type]){metaDatas[type]={}}this._m etaData=metaDatas[type];if(!metaArrays[type]){metaArrays[type]=[]}this.list=meta Arrays[type];this._registerKeyValue(this.key,this.value)},byKey:function(key){re turn this._metaData&&this._metaData[key]},_resetRegistration:function(oldKey){th is._unregisterKey(oldKey);this._registerKeyValue(this.key,this.value)},_unregist erKey:function(key){this._unregister(key,this._metaData,this.list)},_registerKey Value:function(key,value){this._register(key,value,this._metaData,this.list)},_r egister:function(key,value,data,list){if(key&&data&&value!==undefined){data[key] =value;list.push(value)}},_unregister:function(key,data,list){if(key&&data){if(k ey in data){var value=data[key];delete data[key];this.arrayDelete(list,value)}}} });Polymer.IronMeta.getIronMeta=function getIronMeta(){if(singleton===null){sing leton=new Polymer.IronMeta}return singleton};Polymer.IronMetaQuery=Polymer({is:" iron-meta-query",properties:{type:{type:String,value:"default",observer:"_typeCh anged"},key:{type:String,observer:"_keyChanged"},value:{type:Object,notify:true, readOnly:true},list:{type:Array,notify:true}},factoryImpl:function(config){if(co nfig){for(var n in config){switch(n){case"type":case"key":this[n]=config[n];brea k}}}},created:function(){this._metaDatas=metaDatas;this._metaArrays=metaArrays}, _keyChanged:function(key){this._setValue(this._metaData&&this._metaData[key])},_ typeChanged:function(type){this._metaData=metaDatas[type];this.list=metaArrays[t ype];if(this.key){this._keyChanged(this.key)}},byKey:function(key){return this._ metaData&&this._metaData[key]}})})();Polymer({is:"iron-icon",properties:{icon:{t ype:String,observer:"_iconChanged"},theme:{type:String,observer:"_updateIcon"},s rc:{type:String,observer:"_srcChanged"},_meta:{value:Polymer.Base.create("iron-m eta",{type:"iconset"}),observer:"_updateIcon"}},_DEFAULT_ICONSET:"icons",_iconCh anged:function(icon){var parts=(icon||"").split(":");this._iconName=parts.pop(); this._iconsetName=parts.pop()||this._DEFAULT_ICONSET;this._updateIcon()},_srcCha nged:function(src){this._updateIcon()},_usesIconset:function(){return this.icon| |!this.src},_updateIcon:function(){if(this._usesIconset()){if(this._img&&this._i mg.parentNode){Polymer.dom(this.root).removeChild(this._img)}if(this._iconName== =""){if(this._iconset){this._iconset.removeIcon(this)}}else if(this._iconsetName &&this._meta){this._iconset=this._meta.byKey(this._iconsetName);if(this._iconset ){this._iconset.applyIcon(this,this._iconName,this.theme);this.unlisten(window," iron-iconset-added","_updateIcon")}else{this.listen(window,"iron-iconset-added", "_updateIcon")}}}else{if(this._iconset){this._iconset.removeIcon(this)}if(!this. _img){this._img=document.createElement("img");this._img.style.width="100%";this. _img.style.height="100%";this._img.draggable=false}this._img.src=this.src;Polyme r.dom(this.root).appendChild(this._img)}}});Polymer.IronControlState={properties :{focused:{type:Boolean,value:false,notify:true,readOnly:true,reflectToAttribute :true},disabled:{type:Boolean,value:false,notify:true,observer:"_disabledChanged ",reflectToAttribute:true},_oldTabIndex:{type:Number},_boundFocusBlurHandler:{ty pe:Function,value:function(){return this._focusBlurHandler.bind(this)}}},observe rs:["_changedControlState(focused, disabled)"],ready:function(){this.addEventLis tener("focus",this._boundFocusBlurHandler,true);this.addEventListener("blur",thi s._boundFocusBlurHandler,true)},_focusBlurHandler:function(event){if(event.targe t===this){this._setFocused(event.type==="focus")}else if(!this.shadowRoot){var t arget=Polymer.dom(event).localTarget;if(!this.isLightDescendant(target)){this.fi re(event.type,{sourceEvent:event},{node:this,bubbles:event.bubbles,cancelable:ev ent.cancelable})}}},_disabledChanged:function(disabled,old){this.setAttribute("a ria-disabled",disabled?"true":"false");this.style.pointerEvents=disabled?"none": "";if(disabled){this._oldTabIndex=this.tabIndex;this._setFocused(false);this.tab Index=-1;this.blur()}else if(this._oldTabIndex!==undefined){this.tabIndex=this._ oldTabIndex}},_changedControlState:function(){if(this._controlStateChanged){this ._controlStateChanged()}}};Polymer.IronButtonStateImpl={properties:{pressed:{typ e:Boolean,readOnly:true,value:false,reflectToAttribute:true,observer:"_pressedCh anged"},toggles:{type:Boolean,value:false,reflectToAttribute:true},active:{type: Boolean,value:false,notify:true,reflectToAttribute:true},pointerDown:{type:Boole an,readOnly:true,value:false},receivedFocusFromKeyboard:{type:Boolean,readOnly:t rue},ariaActiveAttribute:{type:String,value:"aria-pressed",observer:"_ariaActive AttributeChanged"}},listeners:{down:"_downHandler",up:"_upHandler",tap:"_tapHand ler"},observers:["_detectKeyboardFocus(focused)","_activeChanged(active, ariaAct iveAttribute)"],keyBindings:{"enter:keydown":"_asyncClick","space:keydown":"_spa ceKeyDownHandler","space:keyup":"_spaceKeyUpHandler"},_mouseEventRe:/^mouse/,_ta pHandler:function(){if(this.toggles){this._userActivate(!this.active)}else{this. active=false}},_detectKeyboardFocus:function(focused){this._setReceivedFocusFrom Keyboard(!this.pointerDown&&focused)},_userActivate:function(active){if(this.act ive!==active){this.active=active;this.fire("change")}},_downHandler:function(eve nt){this._setPointerDown(true);this._setPressed(true);this._setReceivedFocusFrom Keyboard(false)},_upHandler:function(){this._setPointerDown(false);this._setPres sed(false)},_spaceKeyDownHandler:function(event){var keyboardEvent=event.detail. keyboardEvent;var target=Polymer.dom(keyboardEvent).localTarget;if(this.isLightD escendant(target))return;keyboardEvent.preventDefault();keyboardEvent.stopImmedi atePropagation();this._setPressed(true)},_spaceKeyUpHandler:function(event){var keyboardEvent=event.detail.keyboardEvent;var target=Polymer.dom(keyboardEvent).l ocalTarget;if(this.isLightDescendant(target))return;if(this.pressed){this._async Click()}this._setPressed(false)},_asyncClick:function(){this.async(function(){th is.click()},1)},_pressedChanged:function(pressed){this._changedButtonState()},_a riaActiveAttributeChanged:function(value,oldValue){if(oldValue&&oldValue!=value& &this.hasAttribute(oldValue)){this.removeAttribute(oldValue)}},_activeChanged:fu nction(active,ariaActiveAttribute){if(this.toggles){this.setAttribute(this.ariaA ctiveAttribute,active?"true":"false")}else{this.removeAttribute(this.ariaActiveA ttribute)}this._changedButtonState()},_controlStateChanged:function(){if(this.di sabled){this._setPressed(false)}else{this._changedButtonState()}},_changedButton State:function(){if(this._buttonStateChanged){this._buttonStateChanged()}}};Poly mer.IronButtonState=[Polymer.IronA11yKeysBehavior,Polymer.IronButtonStateImpl];( function(){var Utility={distance:function(x1,y1,x2,y2){var xDelta=x1-x2;var yDel ta=y1-y2;return Math.sqrt(xDelta*xDelta+yDelta*yDelta)},now:window.performance&& window.performance.now?window.performance.now.bind(window.performance):Date.now} ;function ElementMetrics(element){this.element=element;this.width=this.boundingR ect.width;this.height=this.boundingRect.height;this.size=Math.max(this.width,thi s.height)}ElementMetrics.prototype={get boundingRect(){return this.element.getBo undingClientRect()},furthestCornerDistanceFrom:function(x,y){var topLeft=Utility .distance(x,y,0,0);var topRight=Utility.distance(x,y,this.width,0);var bottomLef t=Utility.distance(x,y,0,this.height);var bottomRight=Utility.distance(x,y,this. width,this.height);return Math.max(topLeft,topRight,bottomLeft,bottomRight)}};fu nction Ripple(element){this.element=element;this.color=window.getComputedStyle(e lement).color;this.wave=document.createElement("div");this.waveContainer=documen t.createElement("div");this.wave.style.backgroundColor=this.color;this.wave.clas sList.add("wave");this.waveContainer.classList.add("wave-container");Polymer.dom (this.waveContainer).appendChild(this.wave);this.resetInteractionState()}Ripple. MAX_RADIUS=300;Ripple.prototype={get recenters(){return this.element.recenters}, get center(){return this.element.center},get mouseDownElapsed(){var elapsed;if(! this.mouseDownStart){return 0}elapsed=Utility.now()-this.mouseDownStart;if(this. mouseUpStart){elapsed-=this.mouseUpElapsed}return elapsed},get mouseUpElapsed(){ return this.mouseUpStart?Utility.now()-this.mouseUpStart:0},get mouseDownElapsed Seconds(){return this.mouseDownElapsed/1e3},get mouseUpElapsedSeconds(){return t his.mouseUpElapsed/1e3},get mouseInteractionSeconds(){return this.mouseDownElaps edSeconds+this.mouseUpElapsedSeconds},get initialOpacity(){return this.element.i nitialOpacity},get opacityDecayVelocity(){return this.element.opacityDecayVeloci ty},get radius(){var width2=this.containerMetrics.width*this.containerMetrics.wi dth;var height2=this.containerMetrics.height*this.containerMetrics.height;var wa veRadius=Math.min(Math.sqrt(width2+height2),Ripple.MAX_RADIUS)*1.1+5;var duratio n=1.1-.2*(waveRadius/Ripple.MAX_RADIUS);var timeNow=this.mouseInteractionSeconds /duration;var size=waveRadius*(1-Math.pow(80,-timeNow));return Math.abs(size)},g et opacity(){if(!this.mouseUpStart){return this.initialOpacity}return Math.max(0 ,this.initialOpacity-this.mouseUpElapsedSeconds*this.opacityDecayVelocity)},get outerOpacity(){var outerOpacity=this.mouseUpElapsedSeconds*.3;var waveOpacity=th is.opacity;return Math.max(0,Math.min(outerOpacity,waveOpacity))},get isOpacityF ullyDecayed(){return this.opacity<.01&&this.radius>=Math.min(this.maxRadius,Ripp le.MAX_RADIUS)},get isRestingAtMaxRadius(){return this.opacity>=this.initialOpac ity&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isAnimationCom plete(){return this.mouseUpStart?this.isOpacityFullyDecayed:this.isRestingAtMaxR adius},get translationFraction(){return Math.min(1,this.radius/this.containerMet rics.size*2/Math.sqrt(2))},get xNow(){if(this.xEnd){return this.xStart+this.tran slationFraction*(this.xEnd-this.xStart)}return this.xStart},get yNow(){if(this.y End){return this.yStart+this.translationFraction*(this.yEnd-this.yStart)}return this.yStart},get isMouseDown(){return this.mouseDownStart&&!this.mouseUpStart},r esetInteractionState:function(){this.maxRadius=0;this.mouseDownStart=0;this.mous eUpStart=0;this.xStart=0;this.yStart=0;this.xEnd=0;this.yEnd=0;this.slideDistanc e=0;this.containerMetrics=new ElementMetrics(this.element)},draw:function(){var scale;var translateString;var dx;var dy;this.wave.style.opacity=this.opacity;sca le=this.radius/(this.containerMetrics.size/2);dx=this.xNow-this.containerMetrics .width/2;dy=this.yNow-this.containerMetrics.height/2;this.waveContainer.style.we bkitTransform="translate("+dx+"px, "+dy+"px)";this.waveContainer.style.transform ="translate3d("+dx+"px, "+dy+"px, 0)";this.wave.style.webkitTransform="scale("+s cale+","+scale+")";this.wave.style.transform="scale3d("+scale+","+scale+",1)"},d ownAction:function(event){var xCenter=this.containerMetrics.width/2;var yCenter= this.containerMetrics.height/2;this.resetInteractionState();this.mouseDownStart= Utility.now();if(this.center){this.xStart=xCenter;this.yStart=yCenter;this.slide Distance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)}else{this .xStart=event?event.detail.x-this.containerMetrics.boundingRect.left:this.contai nerMetrics.width/2;this.yStart=event?event.detail.y-this.containerMetrics.boundi ngRect.top:this.containerMetrics.height/2}if(this.recenters){this.xEnd=xCenter;t his.yEnd=yCenter;this.slideDistance=Utility.distance(this.xStart,this.yStart,thi s.xEnd,this.yEnd)}this.maxRadius=this.containerMetrics.furthestCornerDistanceFro m(this.xStart,this.yStart);this.waveContainer.style.top=(this.containerMetrics.h eight-this.containerMetrics.size)/2+"px";this.waveContainer.style.left=(this.con tainerMetrics.width-this.containerMetrics.size)/2+"px";this.waveContainer.style. width=this.containerMetrics.size+"px";this.waveContainer.style.height=this.conta inerMetrics.size+"px"},upAction:function(event){if(!this.isMouseDown){return}thi s.mouseUpStart=Utility.now()},remove:function(){Polymer.dom(this.waveContainer.p arentNode).removeChild(this.waveContainer)}};Polymer({is:"paper-ripple",behavior s:[Polymer.IronA11yKeysBehavior],properties:{initialOpacity:{type:Number,value:. 25},opacityDecayVelocity:{type:Number,value:.8},recenters:{type:Boolean,value:fa lse},center:{type:Boolean,value:false},ripples:{type:Array,value:function(){retu rn[]}},animating:{type:Boolean,readOnly:true,reflectToAttribute:true,value:false },holdDown:{type:Boolean,value:false,observer:"_holdDownChanged"},noink:{type:Bo olean,value:false},_animating:{type:Boolean},_boundAnimate:{type:Function,value: function(){return this.animate.bind(this)}}},get target(){return this.keyEventTa rget},keyBindings:{"enter:keydown":"_onEnterKeydown","space:keydown":"_onSpaceKe ydown","space:keyup":"_onSpaceKeyup"},attached:function(){if(this.parentNode.nod eType==11){this.keyEventTarget=Polymer.dom(this).getOwnerRoot().host}else{this.k eyEventTarget=this.parentNode}var keyEventTarget=this.keyEventTarget;this.listen (keyEventTarget,"up","uiUpAction");this.listen(keyEventTarget,"down","uiDownActi on")},detached:function(){this.unlisten(this.keyEventTarget,"up","uiUpAction");t his.unlisten(this.keyEventTarget,"down","uiDownAction");this.keyEventTarget=null },get shouldKeepAnimating(){for(var index=0;index<this.ripples.length;++index){i f(!this.ripples[index].isAnimationComplete){return true}}return false},simulated Ripple:function(){this.downAction(null);this.async(function(){this.upAction()},1 )},uiDownAction:function(event){if(!this.noink){this.downAction(event)}},downAct ion:function(event){if(this.holdDown&&this.ripples.length>0){return}var ripple=t his.addRipple();ripple.downAction(event);if(!this._animating){this._animating=tr ue;this.animate()}},uiUpAction:function(event){if(!this.noink){this.upAction(eve nt)}},upAction:function(event){if(this.holdDown){return}this.ripples.forEach(fun ction(ripple){ripple.upAction(event)});this._animating=true;this.animate()},onAn imationComplete:function(){this._animating=false;this.$.background.style.backgro undColor=null;this.fire("transitionend")},addRipple:function(){var ripple=new Ri pple(this);Polymer.dom(this.$.waves).appendChild(ripple.waveContainer);this.$.ba ckground.style.backgroundColor=ripple.color;this.ripples.push(ripple);this._setA nimating(true);return ripple},removeRipple:function(ripple){var rippleIndex=this .ripples.indexOf(ripple);if(rippleIndex<0){return}this.ripples.splice(rippleInde x,1);ripple.remove();if(!this.ripples.length){this._setAnimating(false)}},animat e:function(){if(!this._animating){return}var index;var ripple;for(index=0;index< this.ripples.length;++index){ripple=this.ripples[index];ripple.draw();this.$.bac kground.style.opacity=ripple.outerOpacity;if(ripple.isOpacityFullyDecayed&&!ripp le.isRestingAtMaxRadius){this.removeRipple(ripple)}}if(!this.shouldKeepAnimating &&this.ripples.length===0){this.onAnimationComplete()}else{window.requestAnimati onFrame(this._boundAnimate)}},_onEnterKeydown:function(){this.uiDownAction();thi s.async(this.uiUpAction,1)},_onSpaceKeydown:function(){this.uiDownAction()},_onS paceKeyup:function(){this.uiUpAction()},_holdDownChanged:function(newVal,oldVal) {if(oldVal===undefined){return}if(newVal){this.downAction()}else{this.upAction() }}})})();Polymer.PaperRippleBehavior={properties:{noink:{type:Boolean,observer:" _noinkChanged"},_rippleContainer:{type:Object}},_buttonStateChanged:function(){i f(this.focused){this.ensureRipple()}},_downHandler:function(event){Polymer.IronB uttonStateImpl._downHandler.call(this,event);if(this.pressed){this.ensureRipple( event)}},ensureRipple:function(optTriggeringEvent){if(!this.hasRipple()){this._r ipple=this._createRipple();this._ripple.noink=this.noink;var rippleContainer=thi s._rippleContainer||this.root;if(rippleContainer){Polymer.dom(rippleContainer).a ppendChild(this._ripple)}if(optTriggeringEvent){var domContainer=Polymer.dom(thi s._rippleContainer||this);var target=Polymer.dom(optTriggeringEvent).rootTarget; if(domContainer.deepContains(target)){this._ripple.uiDownAction(optTriggeringEve nt)}}}},getRipple:function(){this.ensureRipple();return this._ripple},hasRipple: function(){return Boolean(this._ripple)},_createRipple:function(){return documen t.createElement("paper-ripple")},_noinkChanged:function(noink){if(this.hasRipple ()){this._ripple.noink=noink}}};Polymer.PaperButtonBehaviorImpl={properties:{ele vation:{type:Number,reflectToAttribute:true,readOnly:true}},observers:["_calcula teElevation(focused, disabled, active, pressed, receivedFocusFromKeyboard)","_co mputeKeyboardClass(receivedFocusFromKeyboard)"],hostAttributes:{role:"button",ta bindex:"0",animated:true},_calculateElevation:function(){var e=1;if(this.disable d){e=0}else if(this.active||this.pressed){e=4}else if(this.receivedFocusFromKeyb oard){e=3}this._setElevation(e)},_computeKeyboardClass:function(receivedFocusFro mKeyboard){this.toggleClass("keyboard-focus",receivedFocusFromKeyboard)},_spaceK eyDownHandler:function(event){Polymer.IronButtonStateImpl._spaceKeyDownHandler.c all(this,event);if(this.hasRipple()&&this.getRipple().ripples.length<1){this._ri pple.uiDownAction()}},_spaceKeyUpHandler:function(event){Polymer.IronButtonState Impl._spaceKeyUpHandler.call(this,event);if(this.hasRipple()){this._ripple.uiUpA ction()}}};Polymer.PaperButtonBehavior=[Polymer.IronButtonState,Polymer.IronCont rolState,Polymer.PaperRippleBehavior,Polymer.PaperButtonBehaviorImpl];Polymer({i s:"paper-button",behaviors:[Polymer.PaperButtonBehavior],properties:{raised:{typ e:Boolean,reflectToAttribute:true,value:false,observer:"_calculateElevation"}},_ calculateElevation:function(){if(!this.raised){this._setElevation(0)}else{Polyme r.PaperButtonBehaviorImpl._calculateElevation.apply(this)}}});Polymer({is:"paper -icon-button-light","extends":"button",behaviors:[Polymer.PaperRippleBehavior],l isteners:{down:"_rippleDown",up:"_rippleUp",focus:"_rippleDown",blur:"_rippleUp" },_rippleDown:function(){this.getRipple().downAction()},_rippleUp:function(){thi s.getRipple().upAction()},ensureRipple:function(var_args){var lastRipple=this._r ipple;Polymer.PaperRippleBehavior.ensureRipple.apply(this,arguments);if(this._ri pple&&this._ripple!==lastRipple){this._ripple.center=true;this._ripple.classList .add("circle")}}});Polymer.IronRangeBehavior={properties:{value:{type:Number,val ue:0,notify:true,reflectToAttribute:true},min:{type:Number,value:0,notify:true}, max:{type:Number,value:100,notify:true},step:{type:Number,value:1,notify:true},r atio:{type:Number,value:0,readOnly:true,notify:true}},observers:["_update(value, min, max, step)"],_calcRatio:function(value){return(this._clampValue(value)-thi s.min)/(this.max-this.min)},_clampValue:function(value){return Math.min(this.max ,Math.max(this.min,this._calcStep(value)))},_calcStep:function(value){value=pars eFloat(value);if(!this.step){return value}var numSteps=Math.round((value-this.mi n)/this.step);if(this.step<1){return numSteps/(1/this.step)+this.min}else{return numSteps*this.step+this.min}},_validateValue:function(){var v=this._clampValue( this.value);this.value=this.oldValue=isNaN(v)?this.oldValue:v;return this.value! ==v},_update:function(){this._validateValue();this._setRatio(this._calcRatio(thi s.value)*100)}};Polymer({is:"paper-progress",behaviors:[Polymer.IronRangeBehavio r],properties:{secondaryProgress:{type:Number,value:0},secondaryRatio:{type:Numb er,value:0,readOnly:true},indeterminate:{type:Boolean,value:false,observer:"_tog gleIndeterminate"},disabled:{type:Boolean,value:false,reflectToAttribute:true,ob server:"_disabledChanged"}},observers:["_progressChanged(secondaryProgress, valu e, min, max)"],hostAttributes:{role:"progressbar"},_toggleIndeterminate:function (indeterminate){this.toggleClass("indeterminate",indeterminate,this.$.primaryPro gress)},_transformProgress:function(progress,ratio){var transform="scaleX("+rati o/100+")";progress.style.transform=progress.style.webkitTransform=transform},_ma inRatioChanged:function(ratio){this._transformProgress(this.$.primaryProgress,ra tio)},_progressChanged:function(secondaryProgress,value,min,max){secondaryProgre ss=this._clampValue(secondaryProgress);value=this._clampValue(value);var seconda ryRatio=this._calcRatio(secondaryProgress)*100;var mainRatio=this._calcRatio(val ue)*100;this._setSecondaryRatio(secondaryRatio);this._transformProgress(this.$.s econdaryProgress,secondaryRatio);this._transformProgress(this.$.primaryProgress, mainRatio);this.secondaryProgress=secondaryProgress;this.setAttribute("aria-valu enow",value);this.setAttribute("aria-valuemin",min);this.setAttribute("aria-valu emax",max)},_disabledChanged:function(disabled){this.setAttribute("aria-disabled ",disabled?"true":"false")},_hideSecondaryProgress:function(secondaryRatio){retu rn secondaryRatio===0}});Polymer({is:"iron-iconset-svg",properties:{name:{type:S tring,observer:"_nameChanged"},size:{type:Number,value:24},rtlMirroring:{type:Bo olean,value:false}},_targetIsRTL:function(target){if(target&&target.nodeType!==N ode.ELEMENT_NODE){target=target.host}return target&&window.getComputedStyle(targ et)["direction"]==="rtl"},attached:function(){this.style.display="none"},getIcon Names:function(){this._icons=this._createIconMap();return Object.keys(this._icon s).map(function(n){return this.name+":"+n},this)},applyIcon:function(element,ico nName){element=element.root||element;this.removeIcon(element);var svg=this._clon eIcon(iconName,this.rtlMirroring&&this._targetIsRTL(element));if(svg){var pde=Po lymer.dom(element);pde.insertBefore(svg,pde.childNodes[0]);return element._svgIc on=svg}return null},removeIcon:function(element){element=element.root||element;i f(element._svgIcon){Polymer.dom(element).removeChild(element._svgIcon);element._ svgIcon=null}},_nameChanged:function(){new Polymer.IronMeta({type:"iconset",key: this.name,value:this});this.async(function(){this.fire("iron-iconset-added",this ,{node:window})})},_createIconMap:function(){var icons=Object.create(null);Polym er.dom(this).querySelectorAll("[id]").forEach(function(icon){icons[icon.id]=icon });return icons},_cloneIcon:function(id,mirrorAllowed){this._icons=this._icons|| this._createIconMap();return this._prepareSvgClone(this._icons[id],this.size,mir rorAllowed)},_prepareSvgClone:function(sourceSvg,size,mirrorAllowed){if(sourceSv g){var content=sourceSvg.cloneNode(true),svg=document.createElementNS("http://ww w.w3.org/2000/svg","svg"),viewBox=content.getAttribute("viewBox")||"0 0 "+size+" "+size,cssText="pointer-events: none; display: block; width: 100%; height: 100% ;";if(mirrorAllowed&&content.hasAttribute("mirror-in-rtl")){cssText+="-webkit-tr ansform:scale(-1,1);transform:scale(-1,1);"}svg.setAttribute("viewBox",viewBox); svg.setAttribute("preserveAspectRatio","xMidYMid meet");svg.style.cssText=cssTex t;svg.appendChild(content).removeAttribute("id");return svg}return null}}); 42 var ActionLink=document.registerElement("action-link",{prototype:{__proto__:HTML AnchorElement.prototype,createdCallback:function(){this.tabIndex=this.disabled?- 1:0;if(!this.hasAttribute("role"))this.setAttribute("role","link");this.addEvent Listener("keydown",function(e){if(!this.disabled&&e.key=="Enter"&&!this.href){wi ndow.setTimeout(this.click.bind(this),0)}});function preventDefault(e){e.prevent Default()}function removePreventDefault(){document.removeEventListener("selectst art",preventDefault);document.removeEventListener("mouseup",removePreventDefault )}this.addEventListener("mousedown",function(){document.addEventListener("select start",preventDefault);document.addEventListener("mouseup",removePreventDefault) ;if(document.activeElement!=this)this.classList.add("no-outline")});this.addEven tListener("blur",function(){this.classList.remove("no-outline")})},set disabled( disabled){if(disabled)HTMLAnchorElement.prototype.setAttribute.call(this,"disabl ed","");else HTMLAnchorElement.prototype.removeAttribute.call(this,"disabled");t his.tabIndex=disabled?-1:0},get disabled(){return this.hasAttribute("disabled")} ,setAttribute:function(attr,val){if(attr.toLowerCase()=="disabled")this.disabled =true;else HTMLAnchorElement.prototype.setAttribute.apply(this,arguments)},remov eAttribute:function(attr){if(attr.toLowerCase()=="disabled")this.disabled=false; else HTMLAnchorElement.prototype.removeAttribute.apply(this,arguments)}},"extend s":"a"});(function(){var metaDatas={};var metaArrays={};var singleton=null;Polym er.IronMeta=Polymer({is:"iron-meta",properties:{type:{type:String,value:"default ",observer:"_typeChanged"},key:{type:String,observer:"_keyChanged"},value:{type: Object,notify:true,observer:"_valueChanged"},self:{type:Boolean,observer:"_selfC hanged"},list:{type:Array,notify:true}},hostAttributes:{hidden:true},factoryImpl :function(config){if(config){for(var n in config){switch(n){case"type":case"key" :case"value":this[n]=config[n];break}}}},created:function(){this._metaDatas=meta Datas;this._metaArrays=metaArrays},_keyChanged:function(key,old){this._resetRegi stration(old)},_valueChanged:function(value){this._resetRegistration(this.key)}, _selfChanged:function(self){if(self){this.value=this}},_typeChanged:function(typ e){this._unregisterKey(this.key);if(!metaDatas[type]){metaDatas[type]={}}this._m etaData=metaDatas[type];if(!metaArrays[type]){metaArrays[type]=[]}this.list=meta Arrays[type];this._registerKeyValue(this.key,this.value)},byKey:function(key){re turn this._metaData&&this._metaData[key]},_resetRegistration:function(oldKey){th is._unregisterKey(oldKey);this._registerKeyValue(this.key,this.value)},_unregist erKey:function(key){this._unregister(key,this._metaData,this.list)},_registerKey Value:function(key,value){this._register(key,value,this._metaData,this.list)},_r egister:function(key,value,data,list){if(key&&data&&value!==undefined){data[key] =value;list.push(value)}},_unregister:function(key,data,list){if(key&&data){if(k ey in data){var value=data[key];delete data[key];this.arrayDelete(list,value)}}} });Polymer.IronMeta.getIronMeta=function getIronMeta(){if(singleton===null){sing leton=new Polymer.IronMeta}return singleton};Polymer.IronMetaQuery=Polymer({is:" iron-meta-query",properties:{type:{type:String,value:"default",observer:"_typeCh anged"},key:{type:String,observer:"_keyChanged"},value:{type:Object,notify:true, readOnly:true},list:{type:Array,notify:true}},factoryImpl:function(config){if(co nfig){for(var n in config){switch(n){case"type":case"key":this[n]=config[n];brea k}}}},created:function(){this._metaDatas=metaDatas;this._metaArrays=metaArrays}, _keyChanged:function(key){this._setValue(this._metaData&&this._metaData[key])},_ typeChanged:function(type){this._metaData=metaDatas[type];this.list=metaArrays[t ype];if(this.key){this._keyChanged(this.key)}},byKey:function(key){return this._ metaData&&this._metaData[key]}})})();Polymer({is:"iron-icon",properties:{icon:{t ype:String,observer:"_iconChanged"},theme:{type:String,observer:"_updateIcon"},s rc:{type:String,observer:"_srcChanged"},_meta:{value:Polymer.Base.create("iron-m eta",{type:"iconset"}),observer:"_updateIcon"}},_DEFAULT_ICONSET:"icons",_iconCh anged:function(icon){var parts=(icon||"").split(":");this._iconName=parts.pop(); this._iconsetName=parts.pop()||this._DEFAULT_ICONSET;this._updateIcon()},_srcCha nged:function(src){this._updateIcon()},_usesIconset:function(){return this.icon| |!this.src},_updateIcon:function(){if(this._usesIconset()){if(this._img&&this._i mg.parentNode){Polymer.dom(this.root).removeChild(this._img)}if(this._iconName== =""){if(this._iconset){this._iconset.removeIcon(this)}}else if(this._iconsetName &&this._meta){this._iconset=this._meta.byKey(this._iconsetName);if(this._iconset ){this._iconset.applyIcon(this,this._iconName,this.theme);this.unlisten(window," iron-iconset-added","_updateIcon")}else{this.listen(window,"iron-iconset-added", "_updateIcon")}}}else{if(this._iconset){this._iconset.removeIcon(this)}if(!this. _img){this._img=document.createElement("img");this._img.style.width="100%";this. _img.style.height="100%";this._img.draggable=false}this._img.src=this.src;Polyme r.dom(this.root).appendChild(this._img)}}});Polymer.IronControlState={properties :{focused:{type:Boolean,value:false,notify:true,readOnly:true,reflectToAttribute :true},disabled:{type:Boolean,value:false,notify:true,observer:"_disabledChanged ",reflectToAttribute:true},_oldTabIndex:{type:Number},_boundFocusBlurHandler:{ty pe:Function,value:function(){return this._focusBlurHandler.bind(this)}}},observe rs:["_changedControlState(focused, disabled)"],ready:function(){this.addEventLis tener("focus",this._boundFocusBlurHandler,true);this.addEventListener("blur",thi s._boundFocusBlurHandler,true)},_focusBlurHandler:function(event){if(event.targe t===this){this._setFocused(event.type==="focus")}else if(!this.shadowRoot){var t arget=Polymer.dom(event).localTarget;if(!this.isLightDescendant(target)){this.fi re(event.type,{sourceEvent:event},{node:this,bubbles:event.bubbles,cancelable:ev ent.cancelable})}}},_disabledChanged:function(disabled,old){this.setAttribute("a ria-disabled",disabled?"true":"false");this.style.pointerEvents=disabled?"none": "";if(disabled){this._oldTabIndex=this.tabIndex;this._setFocused(false);this.tab Index=-1;this.blur()}else if(this._oldTabIndex!==undefined){this.tabIndex=this._ oldTabIndex}},_changedControlState:function(){if(this._controlStateChanged){this ._controlStateChanged()}}};Polymer.IronButtonStateImpl={properties:{pressed:{typ e:Boolean,readOnly:true,value:false,reflectToAttribute:true,observer:"_pressedCh anged"},toggles:{type:Boolean,value:false,reflectToAttribute:true},active:{type: Boolean,value:false,notify:true,reflectToAttribute:true},pointerDown:{type:Boole an,readOnly:true,value:false},receivedFocusFromKeyboard:{type:Boolean,readOnly:t rue},ariaActiveAttribute:{type:String,value:"aria-pressed",observer:"_ariaActive AttributeChanged"}},listeners:{down:"_downHandler",up:"_upHandler",tap:"_tapHand ler"},observers:["_detectKeyboardFocus(focused)","_activeChanged(active, ariaAct iveAttribute)"],keyBindings:{"enter:keydown":"_asyncClick","space:keydown":"_spa ceKeyDownHandler","space:keyup":"_spaceKeyUpHandler"},_mouseEventRe:/^mouse/,_ta pHandler:function(){if(this.toggles){this._userActivate(!this.active)}else{this. active=false}},_detectKeyboardFocus:function(focused){this._setReceivedFocusFrom Keyboard(!this.pointerDown&&focused)},_userActivate:function(active){if(this.act ive!==active){this.active=active;this.fire("change")}},_downHandler:function(eve nt){this._setPointerDown(true);this._setPressed(true);this._setReceivedFocusFrom Keyboard(false)},_upHandler:function(){this._setPointerDown(false);this._setPres sed(false)},_spaceKeyDownHandler:function(event){var keyboardEvent=event.detail. keyboardEvent;var target=Polymer.dom(keyboardEvent).localTarget;if(this.isLightD escendant(target))return;keyboardEvent.preventDefault();keyboardEvent.stopImmedi atePropagation();this._setPressed(true)},_spaceKeyUpHandler:function(event){var keyboardEvent=event.detail.keyboardEvent;var target=Polymer.dom(keyboardEvent).l ocalTarget;if(this.isLightDescendant(target))return;if(this.pressed){this._async Click()}this._setPressed(false)},_asyncClick:function(){this.async(function(){th is.click()},1)},_pressedChanged:function(pressed){this._changedButtonState()},_a riaActiveAttributeChanged:function(value,oldValue){if(oldValue&&oldValue!=value& &this.hasAttribute(oldValue)){this.removeAttribute(oldValue)}},_activeChanged:fu nction(active,ariaActiveAttribute){if(this.toggles){this.setAttribute(this.ariaA ctiveAttribute,active?"true":"false")}else{this.removeAttribute(this.ariaActiveA ttribute)}this._changedButtonState()},_controlStateChanged:function(){if(this.di sabled){this._setPressed(false)}else{this._changedButtonState()}},_changedButton State:function(){if(this._buttonStateChanged){this._buttonStateChanged()}}};Poly mer.IronButtonState=[Polymer.IronA11yKeysBehavior,Polymer.IronButtonStateImpl];( function(){var Utility={distance:function(x1,y1,x2,y2){var xDelta=x1-x2;var yDel ta=y1-y2;return Math.sqrt(xDelta*xDelta+yDelta*yDelta)},now:window.performance&& window.performance.now?window.performance.now.bind(window.performance):Date.now} ;function ElementMetrics(element){this.element=element;this.width=this.boundingR ect.width;this.height=this.boundingRect.height;this.size=Math.max(this.width,thi s.height)}ElementMetrics.prototype={get boundingRect(){return this.element.getBo undingClientRect()},furthestCornerDistanceFrom:function(x,y){var topLeft=Utility .distance(x,y,0,0);var topRight=Utility.distance(x,y,this.width,0);var bottomLef t=Utility.distance(x,y,0,this.height);var bottomRight=Utility.distance(x,y,this. width,this.height);return Math.max(topLeft,topRight,bottomLeft,bottomRight)}};fu nction Ripple(element){this.element=element;this.color=window.getComputedStyle(e lement).color;this.wave=document.createElement("div");this.waveContainer=documen t.createElement("div");this.wave.style.backgroundColor=this.color;this.wave.clas sList.add("wave");this.waveContainer.classList.add("wave-container");Polymer.dom (this.waveContainer).appendChild(this.wave);this.resetInteractionState()}Ripple. MAX_RADIUS=300;Ripple.prototype={get recenters(){return this.element.recenters}, get center(){return this.element.center},get mouseDownElapsed(){var elapsed;if(! this.mouseDownStart){return 0}elapsed=Utility.now()-this.mouseDownStart;if(this. mouseUpStart){elapsed-=this.mouseUpElapsed}return elapsed},get mouseUpElapsed(){ return this.mouseUpStart?Utility.now()-this.mouseUpStart:0},get mouseDownElapsed Seconds(){return this.mouseDownElapsed/1e3},get mouseUpElapsedSeconds(){return t his.mouseUpElapsed/1e3},get mouseInteractionSeconds(){return this.mouseDownElaps edSeconds+this.mouseUpElapsedSeconds},get initialOpacity(){return this.element.i nitialOpacity},get opacityDecayVelocity(){return this.element.opacityDecayVeloci ty},get radius(){var width2=this.containerMetrics.width*this.containerMetrics.wi dth;var height2=this.containerMetrics.height*this.containerMetrics.height;var wa veRadius=Math.min(Math.sqrt(width2+height2),Ripple.MAX_RADIUS)*1.1+5;var duratio n=1.1-.2*(waveRadius/Ripple.MAX_RADIUS);var timeNow=this.mouseInteractionSeconds /duration;var size=waveRadius*(1-Math.pow(80,-timeNow));return Math.abs(size)},g et opacity(){if(!this.mouseUpStart){return this.initialOpacity}return Math.max(0 ,this.initialOpacity-this.mouseUpElapsedSeconds*this.opacityDecayVelocity)},get outerOpacity(){var outerOpacity=this.mouseUpElapsedSeconds*.3;var waveOpacity=th is.opacity;return Math.max(0,Math.min(outerOpacity,waveOpacity))},get isOpacityF ullyDecayed(){return this.opacity<.01&&this.radius>=Math.min(this.maxRadius,Ripp le.MAX_RADIUS)},get isRestingAtMaxRadius(){return this.opacity>=this.initialOpac ity&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isAnimationCom plete(){return this.mouseUpStart?this.isOpacityFullyDecayed:this.isRestingAtMaxR adius},get translationFraction(){return Math.min(1,this.radius/this.containerMet rics.size*2/Math.sqrt(2))},get xNow(){if(this.xEnd){return this.xStart+this.tran slationFraction*(this.xEnd-this.xStart)}return this.xStart},get yNow(){if(this.y End){return this.yStart+this.translationFraction*(this.yEnd-this.yStart)}return this.yStart},get isMouseDown(){return this.mouseDownStart&&!this.mouseUpStart},r esetInteractionState:function(){this.maxRadius=0;this.mouseDownStart=0;this.mous eUpStart=0;this.xStart=0;this.yStart=0;this.xEnd=0;this.yEnd=0;this.slideDistanc e=0;this.containerMetrics=new ElementMetrics(this.element)},draw:function(){var scale;var translateString;var dx;var dy;this.wave.style.opacity=this.opacity;sca le=this.radius/(this.containerMetrics.size/2);dx=this.xNow-this.containerMetrics .width/2;dy=this.yNow-this.containerMetrics.height/2;this.waveContainer.style.we bkitTransform="translate("+dx+"px, "+dy+"px)";this.waveContainer.style.transform ="translate3d("+dx+"px, "+dy+"px, 0)";this.wave.style.webkitTransform="scale("+s cale+","+scale+")";this.wave.style.transform="scale3d("+scale+","+scale+",1)"},d ownAction:function(event){var xCenter=this.containerMetrics.width/2;var yCenter= this.containerMetrics.height/2;this.resetInteractionState();this.mouseDownStart= Utility.now();if(this.center){this.xStart=xCenter;this.yStart=yCenter;this.slide Distance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)}else{this .xStart=event?event.detail.x-this.containerMetrics.boundingRect.left:this.contai nerMetrics.width/2;this.yStart=event?event.detail.y-this.containerMetrics.boundi ngRect.top:this.containerMetrics.height/2}if(this.recenters){this.xEnd=xCenter;t his.yEnd=yCenter;this.slideDistance=Utility.distance(this.xStart,this.yStart,thi s.xEnd,this.yEnd)}this.maxRadius=this.containerMetrics.furthestCornerDistanceFro m(this.xStart,this.yStart);this.waveContainer.style.top=(this.containerMetrics.h eight-this.containerMetrics.size)/2+"px";this.waveContainer.style.left=(this.con tainerMetrics.width-this.containerMetrics.size)/2+"px";this.waveContainer.style. width=this.containerMetrics.size+"px";this.waveContainer.style.height=this.conta inerMetrics.size+"px"},upAction:function(event){if(!this.isMouseDown){return}thi s.mouseUpStart=Utility.now()},remove:function(){Polymer.dom(this.waveContainer.p arentNode).removeChild(this.waveContainer)}};Polymer({is:"paper-ripple",behavior s:[Polymer.IronA11yKeysBehavior],properties:{initialOpacity:{type:Number,value:. 25},opacityDecayVelocity:{type:Number,value:.8},recenters:{type:Boolean,value:fa lse},center:{type:Boolean,value:false},ripples:{type:Array,value:function(){retu rn[]}},animating:{type:Boolean,readOnly:true,reflectToAttribute:true,value:false },holdDown:{type:Boolean,value:false,observer:"_holdDownChanged"},noink:{type:Bo olean,value:false},_animating:{type:Boolean},_boundAnimate:{type:Function,value: function(){return this.animate.bind(this)}}},get target(){return this.keyEventTa rget},keyBindings:{"enter:keydown":"_onEnterKeydown","space:keydown":"_onSpaceKe ydown","space:keyup":"_onSpaceKeyup"},attached:function(){if(this.parentNode.nod eType==11){this.keyEventTarget=Polymer.dom(this).getOwnerRoot().host}else{this.k eyEventTarget=this.parentNode}var keyEventTarget=this.keyEventTarget;this.listen (keyEventTarget,"up","uiUpAction");this.listen(keyEventTarget,"down","uiDownActi on")},detached:function(){this.unlisten(this.keyEventTarget,"up","uiUpAction");t his.unlisten(this.keyEventTarget,"down","uiDownAction");this.keyEventTarget=null },get shouldKeepAnimating(){for(var index=0;index<this.ripples.length;++index){i f(!this.ripples[index].isAnimationComplete){return true}}return false},simulated Ripple:function(){this.downAction(null);this.async(function(){this.upAction()},1 )},uiDownAction:function(event){if(!this.noink){this.downAction(event)}},downAct ion:function(event){if(this.holdDown&&this.ripples.length>0){return}var ripple=t his.addRipple();ripple.downAction(event);if(!this._animating){this._animating=tr ue;this.animate()}},uiUpAction:function(event){if(!this.noink){this.upAction(eve nt)}},upAction:function(event){if(this.holdDown){return}this.ripples.forEach(fun ction(ripple){ripple.upAction(event)});this._animating=true;this.animate()},onAn imationComplete:function(){this._animating=false;this.$.background.style.backgro undColor=null;this.fire("transitionend")},addRipple:function(){var ripple=new Ri pple(this);Polymer.dom(this.$.waves).appendChild(ripple.waveContainer);this.$.ba ckground.style.backgroundColor=ripple.color;this.ripples.push(ripple);this._setA nimating(true);return ripple},removeRipple:function(ripple){var rippleIndex=this .ripples.indexOf(ripple);if(rippleIndex<0){return}this.ripples.splice(rippleInde x,1);ripple.remove();if(!this.ripples.length){this._setAnimating(false)}},animat e:function(){if(!this._animating){return}var index;var ripple;for(index=0;index< this.ripples.length;++index){ripple=this.ripples[index];ripple.draw();this.$.bac kground.style.opacity=ripple.outerOpacity;if(ripple.isOpacityFullyDecayed&&!ripp le.isRestingAtMaxRadius){this.removeRipple(ripple)}}if(!this.shouldKeepAnimating &&this.ripples.length===0){this.onAnimationComplete()}else{window.requestAnimati onFrame(this._boundAnimate)}},_onEnterKeydown:function(){this.uiDownAction();thi s.async(this.uiUpAction,1)},_onSpaceKeydown:function(){this.uiDownAction()},_onS paceKeyup:function(){this.uiUpAction()},_holdDownChanged:function(newVal,oldVal) {if(oldVal===undefined){return}if(newVal){this.downAction()}else{this.upAction() }}})})();Polymer.PaperRippleBehavior={properties:{noink:{type:Boolean,observer:" _noinkChanged"},_rippleContainer:{type:Object}},_buttonStateChanged:function(){i f(this.focused){this.ensureRipple()}},_downHandler:function(event){Polymer.IronB uttonStateImpl._downHandler.call(this,event);if(this.pressed){this.ensureRipple( event)}},ensureRipple:function(optTriggeringEvent){if(!this.hasRipple()){this._r ipple=this._createRipple();this._ripple.noink=this.noink;var rippleContainer=thi s._rippleContainer||this.root;if(rippleContainer){Polymer.dom(rippleContainer).a ppendChild(this._ripple)}if(optTriggeringEvent){var domContainer=Polymer.dom(thi s._rippleContainer||this);var target=Polymer.dom(optTriggeringEvent).rootTarget; if(domContainer.deepContains(target)){this._ripple.uiDownAction(optTriggeringEve nt)}}}},getRipple:function(){this.ensureRipple();return this._ripple},hasRipple: function(){return Boolean(this._ripple)},_createRipple:function(){return documen t.createElement("paper-ripple")},_noinkChanged:function(noink){if(this.hasRipple ()){this._ripple.noink=noink}}};Polymer.PaperButtonBehaviorImpl={properties:{ele vation:{type:Number,reflectToAttribute:true,readOnly:true}},observers:["_calcula teElevation(focused, disabled, active, pressed, receivedFocusFromKeyboard)","_co mputeKeyboardClass(receivedFocusFromKeyboard)"],hostAttributes:{role:"button",ta bindex:"0",animated:true},_calculateElevation:function(){var e=1;if(this.disable d){e=0}else if(this.active||this.pressed){e=4}else if(this.receivedFocusFromKeyb oard){e=3}this._setElevation(e)},_computeKeyboardClass:function(receivedFocusFro mKeyboard){this.toggleClass("keyboard-focus",receivedFocusFromKeyboard)},_spaceK eyDownHandler:function(event){Polymer.IronButtonStateImpl._spaceKeyDownHandler.c all(this,event);if(this.hasRipple()&&this.getRipple().ripples.length<1){this._ri pple.uiDownAction()}},_spaceKeyUpHandler:function(event){Polymer.IronButtonState Impl._spaceKeyUpHandler.call(this,event);if(this.hasRipple()){this._ripple.uiUpA ction()}}};Polymer.PaperButtonBehavior=[Polymer.IronButtonState,Polymer.IronCont rolState,Polymer.PaperRippleBehavior,Polymer.PaperButtonBehaviorImpl];Polymer({i s:"paper-button",behaviors:[Polymer.PaperButtonBehavior],properties:{raised:{typ e:Boolean,reflectToAttribute:true,value:false,observer:"_calculateElevation"}},_ calculateElevation:function(){if(!this.raised){this._setElevation(0)}else{Polyme r.PaperButtonBehaviorImpl._calculateElevation.apply(this)}}});Polymer({is:"paper -icon-button-light","extends":"button",behaviors:[Polymer.PaperRippleBehavior],l isteners:{down:"_rippleDown",up:"_rippleUp",focus:"_rippleDown",blur:"_rippleUp" },_rippleDown:function(){this.getRipple().downAction()},_rippleUp:function(){thi s.getRipple().upAction()},ensureRipple:function(var_args){var lastRipple=this._r ipple;Polymer.PaperRippleBehavior.ensureRipple.apply(this,arguments);if(this._ri pple&&this._ripple!==lastRipple){this._ripple.center=true;this._ripple.classList .add("circle")}}});Polymer.IronRangeBehavior={properties:{value:{type:Number,val ue:0,notify:true,reflectToAttribute:true},min:{type:Number,value:0,notify:true}, max:{type:Number,value:100,notify:true},step:{type:Number,value:1,notify:true},r atio:{type:Number,value:0,readOnly:true,notify:true}},observers:["_update(value, min, max, step)"],_calcRatio:function(value){return(this._clampValue(value)-thi s.min)/(this.max-this.min)},_clampValue:function(value){return Math.min(this.max ,Math.max(this.min,this._calcStep(value)))},_calcStep:function(value){value=pars eFloat(value);if(!this.step){return value}var numSteps=Math.round((value-this.mi n)/this.step);if(this.step<1){return numSteps/(1/this.step)+this.min}else{return numSteps*this.step+this.min}},_validateValue:function(){var v=this._clampValue( this.value);this.value=this.oldValue=isNaN(v)?this.oldValue:v;return this.value! ==v},_update:function(){this._validateValue();this._setRatio(this._calcRatio(thi s.value)*100)}};Polymer({is:"paper-progress",behaviors:[Polymer.IronRangeBehavio r],properties:{secondaryProgress:{type:Number,value:0},secondaryRatio:{type:Numb er,value:0,readOnly:true},indeterminate:{type:Boolean,value:false,observer:"_tog gleIndeterminate"},disabled:{type:Boolean,value:false,reflectToAttribute:true,ob server:"_disabledChanged"}},observers:["_progressChanged(secondaryProgress, valu e, min, max)"],hostAttributes:{role:"progressbar"},_toggleIndeterminate:function (indeterminate){this.toggleClass("indeterminate",indeterminate,this.$.primaryPro gress)},_transformProgress:function(progress,ratio){var transform="scaleX("+rati o/100+")";progress.style.transform=progress.style.webkitTransform=transform},_ma inRatioChanged:function(ratio){this._transformProgress(this.$.primaryProgress,ra tio)},_progressChanged:function(secondaryProgress,value,min,max){secondaryProgre ss=this._clampValue(secondaryProgress);value=this._clampValue(value);var seconda ryRatio=this._calcRatio(secondaryProgress)*100;var mainRatio=this._calcRatio(val ue)*100;this._setSecondaryRatio(secondaryRatio);this._transformProgress(this.$.s econdaryProgress,secondaryRatio);this._transformProgress(this.$.primaryProgress, mainRatio);this.secondaryProgress=secondaryProgress;this.setAttribute("aria-valu enow",value);this.setAttribute("aria-valuemin",min);this.setAttribute("aria-valu emax",max)},_disabledChanged:function(disabled){this.setAttribute("aria-disabled ",disabled?"true":"false")},_hideSecondaryProgress:function(secondaryRatio){retu rn secondaryRatio===0}});Polymer({is:"iron-iconset-svg",properties:{name:{type:S tring,observer:"_nameChanged"},size:{type:Number,value:24},rtlMirroring:{type:Bo olean,value:false}},_targetIsRTL:function(target){if(target&&target.nodeType!==N ode.ELEMENT_NODE){target=target.host}return target&&window.getComputedStyle(targ et)["direction"]==="rtl"},attached:function(){this.style.display="none"},getIcon Names:function(){this._icons=this._createIconMap();return Object.keys(this._icon s).map(function(n){return this.name+":"+n},this)},applyIcon:function(element,ico nName){element=element.root||element;this.removeIcon(element);var svg=this._clon eIcon(iconName,this.rtlMirroring&&this._targetIsRTL(element));if(svg){var pde=Po lymer.dom(element);pde.insertBefore(svg,pde.childNodes[0]);return element._svgIc on=svg}return null},removeIcon:function(element){element=element.root||element;i f(element._svgIcon){Polymer.dom(element).removeChild(element._svgIcon);element._ svgIcon=null}},_nameChanged:function(){new Polymer.IronMeta({type:"iconset",key: this.name,value:this});this.async(function(){this.fire("iron-iconset-added",this ,{node:window})})},_createIconMap:function(){var icons=Object.create(null);Polym er.dom(this).querySelectorAll("[id]").forEach(function(icon){icons[icon.id]=icon });return icons},_cloneIcon:function(id,mirrorAllowed){this._icons=this._icons|| this._createIconMap();return this._prepareSvgClone(this._icons[id],this.size,mir rorAllowed)},_prepareSvgClone:function(sourceSvg,size,mirrorAllowed){if(sourceSv g){var content=sourceSvg.cloneNode(true),svg=document.createElementNS("http://ww w.w3.org/2000/svg","svg"),viewBox=content.getAttribute("viewBox")||"0 0 "+size+" "+size,cssText="pointer-events: none; display: block; width: 100%; height: 100% ;";if(mirrorAllowed&&content.hasAttribute("mirror-in-rtl")){cssText+="-webkit-tr ansform:scale(-1,1);transform:scale(-1,1);"}svg.setAttribute("viewBox",viewBox); svg.setAttribute("preserveAspectRatio","xMidYMid meet");svg.style.cssText=cssTex t;svg.appendChild(content).removeAttribute("id");return svg}return null}});
43 // Copyright 2015 The Chromium Authors. All rights reserved. 43 // Copyright 2015 The Chromium Authors. All rights reserved.
44 // Use of this source code is governed by a BSD-style license that can be 44 // Use of this source code is governed by a BSD-style license that can be
(...skipping 17 matching lines...) Expand all
62 // found in the LICENSE file. 62 // found in the LICENSE file.
63 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}}); 63 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 // Copyright 2015 The Chromium Authors. All rights reserved. 64 // Copyright 2015 The Chromium Authors. All rights reserved.
65 // Use of this source code is governed by a BSD-style license that can be 65 // Use of this source code is governed by a BSD-style license that can be
66 // found in the LICENSE file. 66 // found in the LICENSE file.
67 cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",pro perties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_ :{type:Boolean,value:false,reflectToAttribute:true},inSearchMode_:{type:Boolean, value:false},items_:{type:Array,value:function(){return[]}},spinnerActive_:{type :Boolean,notify:true}},hostAttributes:{loading:true},listeners:{"downloads-list. scroll":"onListScroll_","toolbar.search-changed":"onSearchChanged_"},observers:[ "itemsChanged_(items_.*)"],clearAll_:function(){this.set("items_",[])},hasDownlo adsChanged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$ .toolbar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_)this.$["downl oads-list"].fire("iron-resize")},insertItems_:function(index,list){this.splice.a pply(this,["items_",index,0].concat(list));this.updateHideDates_(index,index+lis t.length);this.removeAttribute("loading");this.spinnerActive_=false},itemsChange d_:function(){this.hasDownloads_=this.items_.length>0},noDownloadsText_:function (){return loadTimeData.getString(this.inSearchMode_?"noSearchResults":"noDownloa ds")},onCanExecute_:function(e){e=e;switch(e.command.id){case"undo-command":e.ca nExecute=this.$.toolbar.canUndo();break;case"clear-all-command":e.canExecute=thi s.$.toolbar.canClearAll();break;case"find-command":e.canExecute=true;break}},onC ommand_:function(e){if(e.command.id=="clear-all-command")downloads.ActionService .getInstance().clearAll();else if(e.command.id=="undo-command")downloads.ActionS ervice.getInstance().undo();else if(e.command.id=="find-command")this.$.toolbar. onFindCommand()},onListScroll_:function(){var list=this.$["downloads-list"];if(l ist.scrollHeight-list.scrollTop-list.offsetHeight<=100){downloads.ActionService. getInstance().loadMore()}this.hasShadow_=list.scrollTop>0},onLoad_:function(){cr .ui.decorate("command",cr.ui.Command);document.addEventListener("canExecute",thi s.onCanExecute_.bind(this));document.addEventListener("command",this.onCommand_. bind(this));downloads.ActionService.getInstance().loadMore()},onSearchChanged_:f unction(){this.inSearchMode_=downloads.ActionService.getInstance().isSearching() },removeItem_:function(index){this.splice("items_",index,1);this.updateHideDates _(index,index);this.onListScroll_()},updateHideDates_:function(start,end){for(va r i=start;i<=end;++i){var current=this.items_[i];if(!current)continue;var prev=t his.items_[i-1];var hideDate=!!prev&&prev.date_string==current.date_string;this. set("items_."+i+".hideDate",hideDate)}},updateItem_:function(index,data){this.se t("items_."+index,data);this.updateHideDates_(index,index);var list=this.$["down loads-list"];list.updateSizeForItem(index)}});Manager.clearAll=function(){Manage r.get().clearAll_()};Manager.get=function(){return queryRequiredElement("downloa ds-manager")};Manager.insertItems=function(index,list){Manager.get().insertItems _(index,list)};Manager.onLoad=function(){Manager.get().onLoad_()};Manager.remove Item=function(index){Manager.get().removeItem_(index)};Manager.updateItem=functi on(index,data){Manager.get().updateItem_(index,data)};return{Manager:Manager}}); 67 cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",pro perties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_ :{type:Boolean,value:false,reflectToAttribute:true},inSearchMode_:{type:Boolean, value:false},items_:{type:Array,value:function(){return[]}},spinnerActive_:{type :Boolean,notify:true}},hostAttributes:{loading:true},listeners:{"downloads-list. scroll":"onListScroll_","toolbar.search-changed":"onSearchChanged_"},observers:[ "itemsChanged_(items_.*)"],clearAll_:function(){this.set("items_",[])},hasDownlo adsChanged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$ .toolbar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_)this.$["downl oads-list"].fire("iron-resize")},insertItems_:function(index,list){this.splice.a pply(this,["items_",index,0].concat(list));this.updateHideDates_(index,index+lis t.length);this.removeAttribute("loading");this.spinnerActive_=false},itemsChange d_:function(){this.hasDownloads_=this.items_.length>0},noDownloadsText_:function (){return loadTimeData.getString(this.inSearchMode_?"noSearchResults":"noDownloa ds")},onCanExecute_:function(e){e=e;switch(e.command.id){case"undo-command":e.ca nExecute=this.$.toolbar.canUndo();break;case"clear-all-command":e.canExecute=thi s.$.toolbar.canClearAll();break;case"find-command":e.canExecute=true;break}},onC ommand_:function(e){if(e.command.id=="clear-all-command")downloads.ActionService .getInstance().clearAll();else if(e.command.id=="undo-command")downloads.ActionS ervice.getInstance().undo();else if(e.command.id=="find-command")this.$.toolbar. onFindCommand()},onListScroll_:function(){var list=this.$["downloads-list"];if(l ist.scrollHeight-list.scrollTop-list.offsetHeight<=100){downloads.ActionService. getInstance().loadMore()}this.hasShadow_=list.scrollTop>0},onLoad_:function(){cr .ui.decorate("command",cr.ui.Command);document.addEventListener("canExecute",thi s.onCanExecute_.bind(this));document.addEventListener("command",this.onCommand_. bind(this));downloads.ActionService.getInstance().loadMore()},onSearchChanged_:f unction(){this.inSearchMode_=downloads.ActionService.getInstance().isSearching() },removeItem_:function(index){this.splice("items_",index,1);this.updateHideDates _(index,index);this.onListScroll_()},updateHideDates_:function(start,end){for(va r i=start;i<=end;++i){var current=this.items_[i];if(!current)continue;var prev=t his.items_[i-1];var hideDate=!!prev&&prev.date_string==current.date_string;this. set("items_."+i+".hideDate",hideDate)}},updateItem_:function(index,data){this.se t("items_."+index,data);this.updateHideDates_(index,index);var list=this.$["down loads-list"];list.updateSizeForItem(index)}});Manager.clearAll=function(){Manage r.get().clearAll_()};Manager.get=function(){return queryRequiredElement("downloa ds-manager")};Manager.insertItems=function(index,list){Manager.get().insertItems _(index,list)};Manager.onLoad=function(){Manager.get().onLoad_()};Manager.remove Item=function(index){Manager.get().removeItem_(index)};Manager.updateItem=functi on(index,data){Manager.get().updateItem_(index,data)};return{Manager:Manager}});
68 // Copyright 2015 The Chromium Authors. All rights reserved. 68 // Copyright 2015 The Chromium Authors. All rights reserved.
69 // Use of this source code is governed by a BSD-style license that can be 69 // Use of this source code is governed by a BSD-style license that can be
70 // found in the LICENSE file. 70 // found in the LICENSE file.
71 window.addEventListener("load",function(){downloads.Manager.onLoad();document.fo nts.load("bold 12px Roboto")}); 71 window.addEventListener("load",function(){downloads.Manager.onLoad();document.fo nts.load("bold 12px Roboto")});
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698