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

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

Issue 2537893004: Remove XSS from chrome://downloads (Closed)
Patch Set: 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 25 matching lines...) Expand all
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
45 // found in the LICENSE file. 45 // found in the LICENSE file.
46 cr.define("downloads",function(){var Item=Polymer({is:"downloads-item",propertie s:{data:{type:Object},completelyOnDisk_:{computed:"computeCompletelyOnDisk_("+"d ata.state, data.file_externally_removed)",type:Boolean,value:true},controlledBy_ :{computed:"computeControlledBy_(data.by_ext_id, data.by_ext_name)",type:String, value:""},isActive_:{computed:"computeIsActive_("+"data.state, data.file_externa lly_removed)",type:Boolean,value:true},isDangerous_:{computed:"computeIsDangerou s_(data.state)",type:Boolean,value:false},isMalware_:{computed:"computeIsMalware _(isDangerous_, data.danger_type)",type:Boolean,value:false},isInProgress_:{comp uted:"computeIsInProgress_(data.state)",type:Boolean,value:false},pauseOrResumeT ext_:{computed:"computePauseOrResumeText_(isInProgress_, data.resume)",type:Stri ng},showCancel_:{computed:"computeShowCancel_(data.state)",type:Boolean,value:fa lse},showProgress_:{computed:"computeShowProgress_(showCancel_, data.percent)",t ype:Boolean,value:false}},observers:["observeControlledBy_(controlledBy_)","obse rveIsDangerous_(isDangerous_, data)"],ready:function(){this.content=this.$.conte nt},chopUrl_:function(url){return url.slice(0,300)},computeClass_:function(){var classes=[];if(this.isActive_)classes.push("is-active");if(this.isDangerous_)cla sses.push("dangerous");if(this.showProgress_)classes.push("show-progress");retur n classes.join(" ")},computeCompletelyOnDisk_:function(){return this.data.state= =downloads.States.COMPLETE&&!this.data.file_externally_removed},computeControlle dBy_:function(){if(!this.data.by_ext_id||!this.data.by_ext_name)return"";var url ="chrome://extensions#"+this.data.by_ext_id;var name=this.data.by_ext_name;retur n loadTimeData.getStringF("controlledByUrl",url,name)},computeDangerIcon_:functi on(){return this.isDangerous_?"cr:warning":""},computeDate_:function(){assert(ty peof this.data.hideDate=="boolean");if(this.data.hideDate)return"";return assert (this.data.since_string||this.data.date_string)},computeDescription_:function(){ var data=this.data;switch(data.state){case downloads.States.DANGEROUS:var fileNa me=data.file_name;switch(data.danger_type){case downloads.DangerType.DANGEROUS_F ILE:return loadTimeData.getString("dangerFileDesc");case downloads.DangerType.DA NGEROUS_URL:case downloads.DangerType.DANGEROUS_CONTENT:case downloads.DangerTyp e.DANGEROUS_HOST:return loadTimeData.getString("dangerDownloadDesc");case downlo ads.DangerType.UNCOMMON_CONTENT:return loadTimeData.getString("dangerUncommonDes c");case downloads.DangerType.POTENTIALLY_UNWANTED:return loadTimeData.getString ("dangerSettingsDesc")}break;case downloads.States.IN_PROGRESS:case downloads.St ates.PAUSED:return data.progress_status_text}return""},computeIsActive_:function (){return this.data.state!=downloads.States.CANCELLED&&this.data.state!=download s.States.INTERRUPTED&&!this.data.file_externally_removed},computeIsDangerous_:fu nction(){return this.data.state==downloads.States.DANGEROUS},computeIsInProgress _:function(){return this.data.state==downloads.States.IN_PROGRESS},computeIsMalw are_:function(){return this.isDangerous_&&(this.data.danger_type==downloads.Dang erType.DANGEROUS_CONTENT||this.data.danger_type==downloads.DangerType.DANGEROUS_ HOST||this.data.danger_type==downloads.DangerType.DANGEROUS_URL||this.data.dange r_type==downloads.DangerType.POTENTIALLY_UNWANTED)},computePauseOrResumeText_:fu nction(){if(this.isInProgress_)return loadTimeData.getString("controlPause");if( this.data.resume)return loadTimeData.getString("controlResume");return""},comput eRemoveStyle_:function(){var canDelete=loadTimeData.getBoolean("allowDeletingHis tory");var hideRemove=this.isDangerous_||this.showCancel_||!canDelete;return hid eRemove?"visibility: hidden":""},computeShowCancel_:function(){return this.data. state==downloads.States.IN_PROGRESS||this.data.state==downloads.States.PAUSED},c omputeShowProgress_:function(){return this.showCancel_&&this.data.percent>=-1},c omputeTag_:function(){switch(this.data.state){case downloads.States.CANCELLED:re turn loadTimeData.getString("statusCancelled");case downloads.States.INTERRUPTED :return this.data.last_reason_text;case downloads.States.COMPLETE:return this.da ta.file_externally_removed?loadTimeData.getString("statusRemoved"):""}return""}, isIndeterminate_:function(){return this.data.percent==-1},observeControlledBy_:f unction(){this.$["controlled-by"].innerHTML=this.controlledBy_},observeIsDangero us_:function(){if(!this.data)return;if(this.isDangerous_){this.$.url.removeAttri bute("href")}else{this.$.url.href=assert(this.data.url);var filePath=encodeURICo mponent(this.data.file_path);var scaleFactor="?scale="+window.devicePixelRatio+" x";this.$["file-icon"].src="chrome://fileicon/"+filePath+scaleFactor}},onCancelT ap_:function(){downloads.ActionService.getInstance().cancel(this.data.id)},onDis cardDangerousTap_:function(){downloads.ActionService.getInstance().discardDanger ous(this.data.id)},onDragStart_:function(e){e.preventDefault();downloads.ActionS ervice.getInstance().drag(this.data.id)},onFileLinkTap_:function(e){e.preventDef ault();downloads.ActionService.getInstance().openFile(this.data.id)},onPauseOrRe sumeTap_:function(){if(this.isInProgress_)downloads.ActionService.getInstance(). pause(this.data.id);else downloads.ActionService.getInstance().resume(this.data. id)},onRemoveTap_:function(){downloads.ActionService.getInstance().remove(this.d ata.id)},onRetryTap_:function(){downloads.ActionService.getInstance().download(t his.data.url)},onSaveDangerousTap_:function(){downloads.ActionService.getInstanc e().saveDangerous(this.data.id)},onShowTap_:function(){downloads.ActionService.g etInstance().show(this.data.id)}});return{Item:Item}});Polymer.PaperItemBehavior Impl={hostAttributes:{role:"option",tabindex:"0"}};Polymer.PaperItemBehavior=[Po lymer.IronButtonState,Polymer.IronControlState,Polymer.PaperItemBehaviorImpl];Po lymer({is:"paper-item",behaviors:[Polymer.PaperItemBehavior]});Polymer.IronSelec tion=function(selectCallback){this.selection=[];this.selectCallback=selectCallba ck};Polymer.IronSelection.prototype={get:function(){return this.multi?this.selec tion.slice():this.selection[0]},clear:function(excludes){this.selection.slice(). forEach(function(item){if(!excludes||excludes.indexOf(item)<0){this.setItemSelec ted(item,false)}},this)},isSelected:function(item){return this.selection.indexOf (item)>=0},setItemSelected:function(item,isSelected){if(item!=null){if(isSelecte d!==this.isSelected(item)){if(isSelected){this.selection.push(item)}else{var i=t his.selection.indexOf(item);if(i>=0){this.selection.splice(i,1)}}if(this.selectC allback){this.selectCallback(item,isSelected)}}}},select:function(item){if(this. multi){this.toggle(item)}else if(this.get()!==item){this.setItemSelected(this.ge t(),false);this.setItemSelected(item,true)}},toggle:function(item){this.setItemS elected(item,!this.isSelected(item))}};Polymer.IronSelectableBehavior={propertie s:{attrForSelected:{type:String,value:null},selected:{type:String,notify:true},s electedItem:{type:Object,readOnly:true,notify:true},activateEvent:{type:String,v alue:"tap",observer:"_activateEventChanged"},selectable:String,selectedClass:{ty pe:String,value:"iron-selected"},selectedAttribute:{type:String,value:null},fall backSelection:{type:String,value:null},items:{type:Array,readOnly:true,notify:tr ue,value:function(){return[]}},_excludedLocalNames:{type:Object,value:function() {return{template:1}}}},observers:["_updateAttrForSelected(attrForSelected)","_up dateSelected(selected)","_checkFallback(fallbackSelection)"],created:function(){ this._bindFilterItem=this._filterItem.bind(this);this._selection=new Polymer.Iro nSelection(this._applySelection.bind(this))},attached:function(){this._observer= this._observeItems(this);this._updateItems();if(!this._shouldUpdateSelection){th is._updateSelected()}this._addListener(this.activateEvent)},detached:function(){ if(this._observer){Polymer.dom(this).unobserveNodes(this._observer)}this._remove Listener(this.activateEvent)},indexOf:function(item){return this.items.indexOf(i tem)},select:function(value){this.selected=value},selectPrevious:function(){var length=this.items.length;var index=(Number(this._valueToIndex(this.selected))-1+ length)%length;this.selected=this._indexToValue(index)},selectNext:function(){va r index=(Number(this._valueToIndex(this.selected))+1)%this.items.length;this.sel ected=this._indexToValue(index)},selectIndex:function(index){this.select(this._i ndexToValue(index))},forceSynchronousItemUpdate:function(){this._updateItems()}, get _shouldUpdateSelection(){return this.selected!=null},_checkFallback:function (){if(this._shouldUpdateSelection){this._updateSelected()}},_addListener:functio n(eventName){this.listen(this,eventName,"_activateHandler")},_removeListener:fun ction(eventName){this.unlisten(this,eventName,"_activateHandler")},_activateEven tChanged:function(eventName,old){this._removeListener(old);this._addListener(eve ntName)},_updateItems:function(){var nodes=Polymer.dom(this).queryDistributedEle ments(this.selectable||"*");nodes=Array.prototype.filter.call(nodes,this._bindFi lterItem);this._setItems(nodes)},_updateAttrForSelected:function(){if(this._shou ldUpdateSelection){this.selected=this._indexToValue(this.indexOf(this.selectedIt em))}},_updateSelected:function(){this._selectSelected(this.selected)},_selectSe lected:function(selected){this._selection.select(this._valueToItem(this.selected ));if(this.fallbackSelection&&this.items.length&&this._selection.get()===undefin ed){this.selected=this.fallbackSelection}},_filterItem:function(node){return!thi s._excludedLocalNames[node.localName]},_valueToItem:function(value){return value ==null?null:this.items[this._valueToIndex(value)]},_valueToIndex:function(value) {if(this.attrForSelected){for(var i=0,item;item=this.items[i];i++){if(this._valu eForItem(item)==value){return i}}}else{return Number(value)}},_indexToValue:func tion(index){if(this.attrForSelected){var item=this.items[index];if(item){return this._valueForItem(item)}}else{return index}},_valueForItem:function(item){var p ropValue=item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)];return prop Value!=undefined?propValue:item.getAttribute(this.attrForSelected)},_applySelect ion:function(item,isSelected){if(this.selectedClass){this.toggleClass(this.selec tedClass,isSelected,item)}if(this.selectedAttribute){this.toggleAttribute(this.s electedAttribute,isSelected,item)}this._selectionChange();this.fire("iron-"+(isS elected?"select":"deselect"),{item:item})},_selectionChange:function(){this._set SelectedItem(this._selection.get())},_observeItems:function(node){return Polymer .dom(node).observeNodes(function(mutation){this._updateItems();if(this._shouldUp dateSelection){this._updateSelected()}this.fire("iron-items-changed",mutation,{b ubbles:false,cancelable:false})})},_activateHandler:function(e){var t=e.target;v ar items=this.items;while(t&&t!=this){var i=items.indexOf(t);if(i>=0){var value= this._indexToValue(i);this._itemActivate(value,t);return}t=t.parentNode}},_itemA ctivate:function(value,item){if(!this.fire("iron-activate",{selected:value,item: item},{cancelable:true}).defaultPrevented){this.select(value)}}};Polymer.IronMul tiSelectableBehaviorImpl={properties:{multi:{type:Boolean,value:false,observer:" multiChanged"},selectedValues:{type:Array,notify:true},selectedItems:{type:Array ,readOnly:true,notify:true}},observers:["_updateSelected(selectedValues.splices) "],select:function(value){if(this.multi){if(this.selectedValues){this._toggleSel ected(value)}else{this.selectedValues=[value]}}else{this.selected=value}},multiC hanged:function(multi){this._selection.multi=multi},get _shouldUpdateSelection() {return this.selected!=null||this.selectedValues!=null&&this.selectedValues.leng th},_updateAttrForSelected:function(){if(!this.multi){Polymer.IronSelectableBeha vior._updateAttrForSelected.apply(this)}else if(this._shouldUpdateSelection){thi s.selectedValues=this.selectedItems.map(function(selectedItem){return this._inde xToValue(this.indexOf(selectedItem))},this).filter(function(unfilteredValue){ret urn unfilteredValue!=null},this)}},_updateSelected:function(){if(this.multi){thi s._selectMulti(this.selectedValues)}else{this._selectSelected(this.selected)}},_ selectMulti:function(values){if(values){var selectedItems=this._valuesToItems(va lues);this._selection.clear(selectedItems);for(var i=0;i<selectedItems.length;i+ +){this._selection.setItemSelected(selectedItems[i],true)}if(this.fallbackSelect ion&&this.items.length&&!this._selection.get().length){var fallback=this._valueT oItem(this.fallbackSelection);if(fallback){this.selectedValues=[this.fallbackSel ection]}}}else{this._selection.clear()}},_selectionChange:function(){var s=this. _selection.get();if(this.multi){this._setSelectedItems(s)}else{this._setSelected Items([s]);this._setSelectedItem(s)}},_toggleSelected:function(value){var i=this .selectedValues.indexOf(value);var unselected=i<0;if(unselected){this.push("sele ctedValues",value)}else{this.splice("selectedValues",i,1)}},_valuesToItems:funct ion(values){return values==null?null:values.map(function(value){return this._val ueToItem(value)},this)}};Polymer.IronMultiSelectableBehavior=[Polymer.IronSelect ableBehavior,Polymer.IronMultiSelectableBehaviorImpl];Polymer.IronMenuBehaviorIm pl={properties:{focusedItem:{observer:"_focusedItemChanged",readOnly:true,type:O bject},attrForItemTitle:{type:String}},hostAttributes:{role:"menu",tabindex:"0"} ,observers:["_updateMultiselectable(multi)"],listeners:{focus:"_onFocus",keydown :"_onKeydown","iron-items-changed":"_onIronItemsChanged"},keyBindings:{up:"_onUp Key",down:"_onDownKey",esc:"_onEscKey","shift+tab:keydown":"_onShiftTabDown"},at tached:function(){this._resetTabindices()},select:function(value){if(this._defau ltFocusAsync){this.cancelAsync(this._defaultFocusAsync);this._defaultFocusAsync= null}var item=this._valueToItem(value);if(item&&item.hasAttribute("disabled"))re turn;this._setFocusedItem(item);Polymer.IronMultiSelectableBehaviorImpl.select.a pply(this,arguments)},_resetTabindices:function(){var selectedItem=this.multi?th is.selectedItems&&this.selectedItems[0]:this.selectedItem;this.items.forEach(fun ction(item){item.setAttribute("tabindex",item===selectedItem?"0":"-1")},this)},_ updateMultiselectable:function(multi){if(multi){this.setAttribute("aria-multisel ectable","true")}else{this.removeAttribute("aria-multiselectable")}},_focusWithK eyboardEvent:function(event){for(var i=0,item;item=this.items[i];i++){var attr=t his.attrForItemTitle||"textContent";var title=item[attr]||item.getAttribute(attr );if(!item.hasAttribute("disabled")&&title&&title.trim().charAt(0).toLowerCase() ===String.fromCharCode(event.keyCode).toLowerCase()){this._setFocusedItem(item); break}}},_focusPrevious:function(){var length=this.items.length;var curFocusInde x=Number(this.indexOf(this.focusedItem));for(var i=1;i<length+1;i++){var item=th is.items[(curFocusIndex-i+length)%length];if(!item.hasAttribute("disabled")){var owner=Polymer.dom(item).getOwnerRoot()||document;this._setFocusedItem(item);if( Polymer.dom(owner).activeElement==item){return}}}},_focusNext:function(){var len gth=this.items.length;var curFocusIndex=Number(this.indexOf(this.focusedItem));f or(var i=1;i<length+1;i++){var item=this.items[(curFocusIndex+i)%length];if(!ite m.hasAttribute("disabled")){var owner=Polymer.dom(item).getOwnerRoot()||document ;this._setFocusedItem(item);if(Polymer.dom(owner).activeElement==item){return}}} },_applySelection:function(item,isSelected){if(isSelected){item.setAttribute("ar ia-selected","true")}else{item.removeAttribute("aria-selected")}Polymer.IronSele ctableBehavior._applySelection.apply(this,arguments)},_focusedItemChanged:functi on(focusedItem,old){old&&old.setAttribute("tabindex","-1");if(focusedItem){focus edItem.setAttribute("tabindex","0");focusedItem.focus()}},_onIronItemsChanged:fu nction(event){if(event.detail.addedNodes.length){this._resetTabindices()}},_onSh iftTabDown:function(event){var oldTabIndex=this.getAttribute("tabindex");Polymer .IronMenuBehaviorImpl._shiftTabPressed=true;this._setFocusedItem(null);this.setA ttribute("tabindex","-1");this.async(function(){this.setAttribute("tabindex",old TabIndex);Polymer.IronMenuBehaviorImpl._shiftTabPressed=false},1)},_onFocus:func tion(event){if(Polymer.IronMenuBehaviorImpl._shiftTabPressed){return}var rootTar get=Polymer.dom(event).rootTarget;if(rootTarget!==this&&typeof rootTarget.tabInd ex!=="undefined"&&!this.isLightDescendant(rootTarget)){return}this._defaultFocus Async=this.async(function(){var selectedItem=this.multi?this.selectedItems&&this .selectedItems[0]:this.selectedItem;this._setFocusedItem(null);if(selectedItem){ this._setFocusedItem(selectedItem)}else if(this.items[0]){this._focusNext()}})}, _onUpKey:function(event){this._focusPrevious();event.detail.keyboardEvent.preven tDefault()},_onDownKey:function(event){this._focusNext();event.detail.keyboardEv ent.preventDefault()},_onEscKey:function(event){this.focusedItem.blur()},_onKeyd own:function(event){if(!this.keyboardEventMatchesKeys(event,"up down esc")){this ._focusWithKeyboardEvent(event)}event.stopPropagation()},_activateHandler:functi on(event){Polymer.IronSelectableBehavior._activateHandler.call(this,event);event .stopPropagation()}};Polymer.IronMenuBehaviorImpl._shiftTabPressed=false;Polymer .IronMenuBehavior=[Polymer.IronMultiSelectableBehavior,Polymer.IronA11yKeysBehav ior,Polymer.IronMenuBehaviorImpl];(function(){Polymer({is:"paper-menu",behaviors :[Polymer.IronMenuBehavior]})})();Polymer.IronFitBehavior={properties:{sizingTar get:{type:Object,value:function(){return this}},fitInto:{type:Object,value:windo w},noOverlap:{type:Boolean},positionTarget:{type:Element},horizontalAlign:{type: String},verticalAlign:{type:String},dynamicAlign:{type:Boolean},horizontalOffset :{type:Number,value:0,notify:true},verticalOffset:{type:Number,value:0,notify:tr ue},autoFitOnAttach:{type:Boolean,value:false},_fitInfo:{type:Object}},get _fitW idth(){var fitWidth;if(this.fitInto===window){fitWidth=this.fitInto.innerWidth}e lse{fitWidth=this.fitInto.getBoundingClientRect().width}return fitWidth},get _fi tHeight(){var fitHeight;if(this.fitInto===window){fitHeight=this.fitInto.innerHe ight}else{fitHeight=this.fitInto.getBoundingClientRect().height}return fitHeight },get _fitLeft(){var fitLeft;if(this.fitInto===window){fitLeft=0}else{fitLeft=th is.fitInto.getBoundingClientRect().left}return fitLeft},get _fitTop(){var fitTop ;if(this.fitInto===window){fitTop=0}else{fitTop=this.fitInto.getBoundingClientRe ct().top}return fitTop},get _defaultPositionTarget(){var parent=Polymer.dom(this ).parentNode;if(parent&&parent.nodeType===Node.DOCUMENT_FRAGMENT_NODE){parent=pa rent.host}return parent},get _localeHorizontalAlign(){if(this._isRTL){if(this.ho rizontalAlign==="right"){return"left"}if(this.horizontalAlign==="left"){return"r ight"}}return this.horizontalAlign},attached:function(){this._isRTL=window.getCo mputedStyle(this).direction=="rtl";this.positionTarget=this.positionTarget||this ._defaultPositionTarget;if(this.autoFitOnAttach){if(window.getComputedStyle(this ).display==="none"){setTimeout(function(){this.fit()}.bind(this))}else{this.fit( )}}},fit:function(){this.position();this.constrain();this.center()},_discoverInf o:function(){if(this._fitInfo){return}var target=window.getComputedStyle(this);v ar sizer=window.getComputedStyle(this.sizingTarget);this._fitInfo={inlineStyle:{ top:this.style.top||"",left:this.style.left||"",position:this.style.position||"" },sizerInlineStyle:{maxWidth:this.sizingTarget.style.maxWidth||"",maxHeight:this .sizingTarget.style.maxHeight||"",boxSizing:this.sizingTarget.style.boxSizing||" "},positionedBy:{vertically:target.top!=="auto"?"top":target.bottom!=="auto"?"bo ttom":null,horizontally:target.left!=="auto"?"left":target.right!=="auto"?"right ":null},sizedBy:{height:sizer.maxHeight!=="none",width:sizer.maxWidth!=="none",m inWidth:parseInt(sizer.minWidth,10)||0,minHeight:parseInt(sizer.minHeight,10)||0 },margin:{top:parseInt(target.marginTop,10)||0,right:parseInt(target.marginRight ,10)||0,bottom:parseInt(target.marginBottom,10)||0,left:parseInt(target.marginLe ft,10)||0}};if(this.verticalOffset){this._fitInfo.margin.top=this._fitInfo.margi n.bottom=this.verticalOffset;this._fitInfo.inlineStyle.marginTop=this.style.marg inTop||"";this._fitInfo.inlineStyle.marginBottom=this.style.marginBottom||"";thi s.style.marginTop=this.style.marginBottom=this.verticalOffset+"px"}if(this.horiz ontalOffset){this._fitInfo.margin.left=this._fitInfo.margin.right=this.horizonta lOffset;this._fitInfo.inlineStyle.marginLeft=this.style.marginLeft||"";this._fit Info.inlineStyle.marginRight=this.style.marginRight||"";this.style.marginLeft=th is.style.marginRight=this.horizontalOffset+"px"}},resetFit:function(){var info=t his._fitInfo||{};for(var property in info.sizerInlineStyle){this.sizingTarget.st yle[property]=info.sizerInlineStyle[property]}for(var property in info.inlineSty le){this.style[property]=info.inlineStyle[property]}this._fitInfo=null},refit:fu nction(){var scrollLeft=this.sizingTarget.scrollLeft;var scrollTop=this.sizingTa rget.scrollTop;this.resetFit();this.fit();this.sizingTarget.scrollLeft=scrollLef t;this.sizingTarget.scrollTop=scrollTop},position:function(){if(!this.horizontal Align&&!this.verticalAlign){return}this._discoverInfo();this.style.position="fix ed";this.sizingTarget.style.boxSizing="border-box";this.style.left="0px";this.st yle.top="0px";var rect=this.getBoundingClientRect();var positionRect=this.__getN ormalizedRect(this.positionTarget);var fitRect=this.__getNormalizedRect(this.fit Into);var margin=this._fitInfo.margin;var size={width:rect.width+margin.left+mar gin.right,height:rect.height+margin.top+margin.bottom};var position=this.__getPo sition(this._localeHorizontalAlign,this.verticalAlign,size,positionRect,fitRect) ;var left=position.left+margin.left;var top=position.top+margin.top;var right=Ma th.min(fitRect.right-margin.right,left+rect.width);var bottom=Math.min(fitRect.b ottom-margin.bottom,top+rect.height);var minWidth=this._fitInfo.sizedBy.minWidth ;var minHeight=this._fitInfo.sizedBy.minHeight;if(left<margin.left){left=margin. left;if(right-left<minWidth){left=right-minWidth}}if(top<margin.top){top=margin. top;if(bottom-top<minHeight){top=bottom-minHeight}}this.sizingTarget.style.maxWi dth=right-left+"px";this.sizingTarget.style.maxHeight=bottom-top+"px";this.style .left=left-rect.left+"px";this.style.top=top-rect.top+"px"},constrain:function() {if(this.horizontalAlign||this.verticalAlign){return}this._discoverInfo();var in fo=this._fitInfo;if(!info.positionedBy.vertically){this.style.position="fixed";t his.style.top="0px"}if(!info.positionedBy.horizontally){this.style.position="fix ed";this.style.left="0px"}this.sizingTarget.style.boxSizing="border-box";var rec t=this.getBoundingClientRect();if(!info.sizedBy.height){this.__sizeDimension(rec t,info.positionedBy.vertically,"top","bottom","Height")}if(!info.sizedBy.width){ this.__sizeDimension(rect,info.positionedBy.horizontally,"left","right","Width") }},_sizeDimension:function(rect,positionedBy,start,end,extent){this.__sizeDimens ion(rect,positionedBy,start,end,extent)},__sizeDimension:function(rect,positione dBy,start,end,extent){var info=this._fitInfo;var fitRect=this.__getNormalizedRec t(this.fitInto);var max=extent==="Width"?fitRect.width:fitRect.height;var flip=p ositionedBy===end;var offset=flip?max-rect[end]:rect[start];var margin=info.marg in[flip?start:end];var offsetExtent="offset"+extent;var sizingOffset=this[offset Extent]-this.sizingTarget[offsetExtent];this.sizingTarget.style["max"+extent]=ma x-margin-offset-sizingOffset+"px"},center:function(){if(this.horizontalAlign||th is.verticalAlign){return}this._discoverInfo();var positionedBy=this._fitInfo.pos itionedBy;if(positionedBy.vertically&&positionedBy.horizontally){return}this.sty le.position="fixed";if(!positionedBy.vertically){this.style.top="0px"}if(!positi onedBy.horizontally){this.style.left="0px"}var rect=this.getBoundingClientRect() ;var fitRect=this.__getNormalizedRect(this.fitInto);if(!positionedBy.vertically) {var top=fitRect.top-rect.top+(fitRect.height-rect.height)/2;this.style.top=top+ "px"}if(!positionedBy.horizontally){var left=fitRect.left-rect.left+(fitRect.wid th-rect.width)/2;this.style.left=left+"px"}},__getNormalizedRect:function(target ){if(target===document.documentElement||target===window){return{top:0,left:0,wid th:window.innerWidth,height:window.innerHeight,right:window.innerWidth,bottom:wi ndow.innerHeight}}return target.getBoundingClientRect()},__getCroppedArea:functi on(position,size,fitRect){var verticalCrop=Math.min(0,position.top)+Math.min(0,f itRect.bottom-(position.top+size.height));var horizontalCrop=Math.min(0,position .left)+Math.min(0,fitRect.right-(position.left+size.width));return Math.abs(vert icalCrop)*size.width+Math.abs(horizontalCrop)*size.height},__getPosition:functio n(hAlign,vAlign,size,positionRect,fitRect){var positions=[{verticalAlign:"top",h orizontalAlign:"left",top:positionRect.top,left:positionRect.left},{verticalAlig n:"top",horizontalAlign:"right",top:positionRect.top,left:positionRect.right-siz e.width},{verticalAlign:"bottom",horizontalAlign:"left",top:positionRect.bottom- size.height,left:positionRect.left},{verticalAlign:"bottom",horizontalAlign:"rig ht",top:positionRect.bottom-size.height,left:positionRect.right-size.width}];if( this.noOverlap){for(var i=0,l=positions.length;i<l;i++){var copy={};for(var key in positions[i]){copy[key]=positions[i][key]}positions.push(copy)}positions[0].t op=positions[1].top+=positionRect.height;positions[2].top=positions[3].top-=posi tionRect.height;positions[4].left=positions[6].left+=positionRect.width;position s[5].left=positions[7].left-=positionRect.width}vAlign=vAlign==="auto"?null:vAli gn;hAlign=hAlign==="auto"?null:hAlign;var position;for(var i=0;i<positions.lengt h;i++){var pos=positions[i];if(!this.dynamicAlign&&!this.noOverlap&&pos.vertical Align===vAlign&&pos.horizontalAlign===hAlign){position=pos;break}var alignOk=(!v Align||pos.verticalAlign===vAlign)&&(!hAlign||pos.horizontalAlign===hAlign);if(! this.dynamicAlign&&!alignOk){continue}position=position||pos;pos.croppedArea=thi s.__getCroppedArea(pos,size,fitRect);var diff=pos.croppedArea-position.croppedAr ea;if(diff<0||diff===0&&alignOk){position=pos}if(position.croppedArea===0&&align Ok){break}}return position}};(function(){"use strict";Polymer({is:"iron-overlay- backdrop",properties:{opened:{reflectToAttribute:true,type:Boolean,value:false,o bserver:"_openedChanged"}},listeners:{transitionend:"_onTransitionend"},created: function(){this.__openedRaf=null},attached:function(){this.opened&&this._openedC hanged(this.opened)},prepare:function(){if(this.opened&&!this.parentNode){Polyme r.dom(document.body).appendChild(this)}},open:function(){this.opened=true},close :function(){this.opened=false},complete:function(){if(!this.opened&&this.parentN ode===document.body){Polymer.dom(this.parentNode).removeChild(this)}},_onTransit ionend:function(event){if(event&&event.target===this){this.complete()}},_openedC hanged:function(opened){if(opened){this.prepare()}else{var cs=window.getComputed Style(this);if(cs.transitionDuration==="0s"||cs.opacity==0){this.complete()}}if( !this.isAttached){return}if(this.__openedRaf){window.cancelAnimationFrame(this._ _openedRaf);this.__openedRaf=null}this.scrollTop=this.scrollTop;this.__openedRaf =window.requestAnimationFrame(function(){this.__openedRaf=null;this.toggleClass( "opened",this.opened)}.bind(this))}})})();Polymer.IronOverlayManagerClass=functi on(){this._overlays=[];this._minimumZ=101;this._backdropElement=null;Polymer.Ges tures.add(document,"tap",this._onCaptureClick.bind(this));document.addEventListe ner("focus",this._onCaptureFocus.bind(this),true);document.addEventListener("key down",this._onCaptureKeyDown.bind(this),true)};Polymer.IronOverlayManagerClass.p rototype={constructor:Polymer.IronOverlayManagerClass,get backdropElement(){if(! this._backdropElement){this._backdropElement=document.createElement("iron-overla y-backdrop")}return this._backdropElement},get deepActiveElement(){var active=do cument.activeElement||document.body;while(active.root&&Polymer.dom(active.root). activeElement){active=Polymer.dom(active.root).activeElement}return active},_bri ngOverlayAtIndexToFront:function(i){var overlay=this._overlays[i];if(!overlay){r eturn}var lastI=this._overlays.length-1;var currentOverlay=this._overlays[lastI] ;if(currentOverlay&&this._shouldBeBehindOverlay(overlay,currentOverlay)){lastI-- }if(i>=lastI){return}var minimumZ=Math.max(this.currentOverlayZ(),this._minimumZ );if(this._getZ(overlay)<=minimumZ){this._applyOverlayZ(overlay,minimumZ)}while( i<lastI){this._overlays[i]=this._overlays[i+1];i++}this._overlays[lastI]=overlay },addOrRemoveOverlay:function(overlay){if(overlay.opened){this.addOverlay(overla y)}else{this.removeOverlay(overlay)}},addOverlay:function(overlay){var i=this._o verlays.indexOf(overlay);if(i>=0){this._bringOverlayAtIndexToFront(i);this.track Backdrop();return}var insertionIndex=this._overlays.length;var currentOverlay=th is._overlays[insertionIndex-1];var minimumZ=Math.max(this._getZ(currentOverlay), this._minimumZ);var newZ=this._getZ(overlay);if(currentOverlay&&this._shouldBeBe hindOverlay(overlay,currentOverlay)){this._applyOverlayZ(currentOverlay,minimumZ );insertionIndex--;var previousOverlay=this._overlays[insertionIndex-1];minimumZ =Math.max(this._getZ(previousOverlay),this._minimumZ)}if(newZ<=minimumZ){this._a pplyOverlayZ(overlay,minimumZ)}this._overlays.splice(insertionIndex,0,overlay);t his.trackBackdrop()},removeOverlay:function(overlay){var i=this._overlays.indexO f(overlay);if(i===-1){return}this._overlays.splice(i,1);this.trackBackdrop()},cu rrentOverlay:function(){var i=this._overlays.length-1;return this._overlays[i]}, currentOverlayZ:function(){return this._getZ(this.currentOverlay())},ensureMinim umZ:function(minimumZ){this._minimumZ=Math.max(this._minimumZ,minimumZ)},focusOv erlay:function(){var current=this.currentOverlay();if(current){current._applyFoc us()}},trackBackdrop:function(){var overlay=this._overlayWithBackdrop();if(!over lay&&!this._backdropElement){return}this.backdropElement.style.zIndex=this._getZ (overlay)-1;this.backdropElement.opened=!!overlay},getBackdrops:function(){var b ackdrops=[];for(var i=0;i<this._overlays.length;i++){if(this._overlays[i].withBa ckdrop){backdrops.push(this._overlays[i])}}return backdrops},backdropZ:function( ){return this._getZ(this._overlayWithBackdrop())-1},_overlayWithBackdrop:functio n(){for(var i=0;i<this._overlays.length;i++){if(this._overlays[i].withBackdrop){ return this._overlays[i]}}},_getZ:function(overlay){var z=this._minimumZ;if(over lay){var z1=Number(overlay.style.zIndex||window.getComputedStyle(overlay).zIndex );if(z1===z1){z=z1}}return z},_setZ:function(element,z){element.style.zIndex=z}, _applyOverlayZ:function(overlay,aboveZ){this._setZ(overlay,aboveZ+2)},_overlayIn Path:function(path){path=path||[];for(var i=0;i<path.length;i++){if(path[i]._man ager===this){return path[i]}}},_onCaptureClick:function(event){var overlay=this. currentOverlay();if(overlay&&this._overlayInPath(Polymer.dom(event).path)!==over lay){overlay._onCaptureClick(event)}},_onCaptureFocus:function(event){var overla y=this.currentOverlay();if(overlay){overlay._onCaptureFocus(event)}},_onCaptureK eyDown:function(event){var overlay=this.currentOverlay();if(overlay){if(Polymer. IronA11yKeysBehavior.keyboardEventMatchesKeys(event,"esc")){overlay._onCaptureEs c(event)}else if(Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(event,"ta b")){overlay._onCaptureTab(event)}}},_shouldBeBehindOverlay:function(overlay1,ov erlay2){return!overlay1.alwaysOnTop&&overlay2.alwaysOnTop}};Polymer.IronOverlayM anager=new Polymer.IronOverlayManagerClass;(function(){"use strict";Polymer.Iron OverlayBehaviorImpl={properties:{opened:{observer:"_openedChanged",type:Boolean, value:false,notify:true},canceled:{observer:"_canceledChanged",readOnly:true,typ e:Boolean,value:false},withBackdrop:{observer:"_withBackdropChanged",type:Boolea n},noAutoFocus:{type:Boolean,value:false},noCancelOnEscKey:{type:Boolean,value:f alse},noCancelOnOutsideClick:{type:Boolean,value:false},closingReason:{type:Obje ct 46 cr.define("downloads",function(){var Item=Polymer({is:"downloads-item",propertie s:{data:{type:Object},completelyOnDisk_:{computed:"computeCompletelyOnDisk_("+"d ata.state, data.file_externally_removed)",type:Boolean,value:true},controlledBy_ :{computed:"computeControlledBy_(data.by_ext_id, data.by_ext_name)",type:String, value:""},isActive_:{computed:"computeIsActive_("+"data.state, data.file_externa lly_removed)",type:Boolean,value:true},isDangerous_:{computed:"computeIsDangerou s_(data.state)",type:Boolean,value:false},isMalware_:{computed:"computeIsMalware _(isDangerous_, data.danger_type)",type:Boolean,value:false},isInProgress_:{comp uted:"computeIsInProgress_(data.state)",type:Boolean,value:false},pauseOrResumeT ext_:{computed:"computePauseOrResumeText_(isInProgress_, data.resume)",type:Stri ng},showCancel_:{computed:"computeShowCancel_(data.state)",type:Boolean,value:fa lse},showProgress_:{computed:"computeShowProgress_(showCancel_, data.percent)",t ype:Boolean,value:false}},observers:["observeControlledBy_(controlledBy_)","obse rveIsDangerous_(isDangerous_, data)"],ready:function(){this.content=this.$.conte nt},chopUrl_:function(url){return url.slice(0,300)},computeClass_:function(){var classes=[];if(this.isActive_)classes.push("is-active");if(this.isDangerous_)cla sses.push("dangerous");if(this.showProgress_)classes.push("show-progress");retur n classes.join(" ")},computeCompletelyOnDisk_:function(){return this.data.state= =downloads.States.COMPLETE&&!this.data.file_externally_removed},computeControlle dBy_:function(){if(!this.data.by_ext_id||!this.data.by_ext_name)return"";var url ="chrome://extensions#"+this.data.by_ext_id;var name=this.data.by_ext_name;retur n loadTimeData.getStringF("controlledByUrl",url,HTMLEscape(name))},computeDanger Icon_:function(){return this.isDangerous_?"cr:warning":""},computeDate_:function (){assert(typeof this.data.hideDate=="boolean");if(this.data.hideDate)return"";r eturn assert(this.data.since_string||this.data.date_string)},computeDescription_ :function(){var data=this.data;switch(data.state){case downloads.States.DANGEROU S:var fileName=data.file_name;switch(data.danger_type){case downloads.DangerType .DANGEROUS_FILE:return loadTimeData.getString("dangerFileDesc");case downloads.D angerType.DANGEROUS_URL:case downloads.DangerType.DANGEROUS_CONTENT:case downloa ds.DangerType.DANGEROUS_HOST:return loadTimeData.getString("dangerDownloadDesc") ;case downloads.DangerType.UNCOMMON_CONTENT:return loadTimeData.getString("dange rUncommonDesc");case downloads.DangerType.POTENTIALLY_UNWANTED:return loadTimeDa ta.getString("dangerSettingsDesc")}break;case downloads.States.IN_PROGRESS:case downloads.States.PAUSED:return data.progress_status_text}return""},computeIsActi ve_:function(){return this.data.state!=downloads.States.CANCELLED&&this.data.sta te!=downloads.States.INTERRUPTED&&!this.data.file_externally_removed},computeIsD angerous_:function(){return this.data.state==downloads.States.DANGEROUS},compute IsInProgress_:function(){return this.data.state==downloads.States.IN_PROGRESS},c omputeIsMalware_:function(){return this.isDangerous_&&(this.data.danger_type==do wnloads.DangerType.DANGEROUS_CONTENT||this.data.danger_type==downloads.DangerTyp e.DANGEROUS_HOST||this.data.danger_type==downloads.DangerType.DANGEROUS_URL||thi s.data.danger_type==downloads.DangerType.POTENTIALLY_UNWANTED)},computePauseOrRe sumeText_:function(){if(this.isInProgress_)return loadTimeData.getString("contro lPause");if(this.data.resume)return loadTimeData.getString("controlResume");retu rn""},computeRemoveStyle_:function(){var canDelete=loadTimeData.getBoolean("allo wDeletingHistory");var hideRemove=this.isDangerous_||this.showCancel_||!canDelet e;return hideRemove?"visibility: hidden":""},computeShowCancel_:function(){retur n this.data.state==downloads.States.IN_PROGRESS||this.data.state==downloads.Stat es.PAUSED},computeShowProgress_:function(){return this.showCancel_&&this.data.pe rcent>=-1},computeTag_:function(){switch(this.data.state){case downloads.States. CANCELLED:return loadTimeData.getString("statusCancelled");case downloads.States .INTERRUPTED:return this.data.last_reason_text;case downloads.States.COMPLETE:re turn this.data.file_externally_removed?loadTimeData.getString("statusRemoved"):" "}return""},isIndeterminate_:function(){return this.data.percent==-1},observeCon trolledBy_:function(){this.$["controlled-by"].innerHTML=this.controlledBy_},obse rveIsDangerous_:function(){if(!this.data)return;if(this.isDangerous_){this.$.url .removeAttribute("href")}else{this.$.url.href=assert(this.data.url);var filePath =encodeURIComponent(this.data.file_path);var scaleFactor="?scale="+window.device PixelRatio+"x";this.$["file-icon"].src="chrome://fileicon/"+filePath+scaleFactor }},onCancelTap_:function(){downloads.ActionService.getInstance().cancel(this.dat a.id)},onDiscardDangerousTap_:function(){downloads.ActionService.getInstance().d iscardDangerous(this.data.id)},onDragStart_:function(e){e.preventDefault();downl oads.ActionService.getInstance().drag(this.data.id)},onFileLinkTap_:function(e){ e.preventDefault();downloads.ActionService.getInstance().openFile(this.data.id)} ,onPauseOrResumeTap_:function(){if(this.isInProgress_)downloads.ActionService.ge tInstance().pause(this.data.id);else downloads.ActionService.getInstance().resum e(this.data.id)},onRemoveTap_:function(){downloads.ActionService.getInstance().r emove(this.data.id)},onRetryTap_:function(){downloads.ActionService.getInstance( ).download(this.data.url)},onSaveDangerousTap_:function(){downloads.ActionServic e.getInstance().saveDangerous(this.data.id)},onShowTap_:function(){downloads.Act ionService.getInstance().show(this.data.id)}});return{Item:Item}});Polymer.Paper ItemBehaviorImpl={hostAttributes:{role:"option",tabindex:"0"}};Polymer.PaperItem Behavior=[Polymer.IronButtonState,Polymer.IronControlState,Polymer.PaperItemBeha viorImpl];Polymer({is:"paper-item",behaviors:[Polymer.PaperItemBehavior]});Polym er.IronSelection=function(selectCallback){this.selection=[];this.selectCallback= selectCallback};Polymer.IronSelection.prototype={get:function(){return this.mult i?this.selection.slice():this.selection[0]},clear:function(excludes){this.select ion.slice().forEach(function(item){if(!excludes||excludes.indexOf(item)<0){this. setItemSelected(item,false)}},this)},isSelected:function(item){return this.selec tion.indexOf(item)>=0},setItemSelected:function(item,isSelected){if(item!=null){ if(isSelected!==this.isSelected(item)){if(isSelected){this.selection.push(item)} else{var i=this.selection.indexOf(item);if(i>=0){this.selection.splice(i,1)}}if( this.selectCallback){this.selectCallback(item,isSelected)}}}},select:function(it em){if(this.multi){this.toggle(item)}else if(this.get()!==item){this.setItemSele cted(this.get(),false);this.setItemSelected(item,true)}},toggle:function(item){t his.setItemSelected(item,!this.isSelected(item))}};Polymer.IronSelectableBehavio r={properties:{attrForSelected:{type:String,value:null},selected:{type:String,no tify:true},selectedItem:{type:Object,readOnly:true,notify:true},activateEvent:{t ype:String,value:"tap",observer:"_activateEventChanged"},selectable:String,selec tedClass:{type:String,value:"iron-selected"},selectedAttribute:{type:String,valu e:null},fallbackSelection:{type:String,value:null},items:{type:Array,readOnly:tr ue,notify:true,value:function(){return[]}},_excludedLocalNames:{type:Object,valu e:function(){return{template:1}}}},observers:["_updateAttrForSelected(attrForSel ected)","_updateSelected(selected)","_checkFallback(fallbackSelection)"],created :function(){this._bindFilterItem=this._filterItem.bind(this);this._selection=new Polymer.IronSelection(this._applySelection.bind(this))},attached:function(){thi s._observer=this._observeItems(this);this._updateItems();if(!this._shouldUpdateS election){this._updateSelected()}this._addListener(this.activateEvent)},detached :function(){if(this._observer){Polymer.dom(this).unobserveNodes(this._observer)} this._removeListener(this.activateEvent)},indexOf:function(item){return this.ite ms.indexOf(item)},select:function(value){this.selected=value},selectPrevious:fun ction(){var length=this.items.length;var index=(Number(this._valueToIndex(this.s elected))-1+length)%length;this.selected=this._indexToValue(index)},selectNext:f unction(){var index=(Number(this._valueToIndex(this.selected))+1)%this.items.len gth;this.selected=this._indexToValue(index)},selectIndex:function(index){this.se lect(this._indexToValue(index))},forceSynchronousItemUpdate:function(){this._upd ateItems()},get _shouldUpdateSelection(){return this.selected!=null},_checkFallb ack:function(){if(this._shouldUpdateSelection){this._updateSelected()}},_addList ener:function(eventName){this.listen(this,eventName,"_activateHandler")},_remove Listener:function(eventName){this.unlisten(this,eventName,"_activateHandler")},_ activateEventChanged:function(eventName,old){this._removeListener(old);this._add Listener(eventName)},_updateItems:function(){var nodes=Polymer.dom(this).queryDi stributedElements(this.selectable||"*");nodes=Array.prototype.filter.call(nodes, this._bindFilterItem);this._setItems(nodes)},_updateAttrForSelected:function(){i f(this._shouldUpdateSelection){this.selected=this._indexToValue(this.indexOf(thi s.selectedItem))}},_updateSelected:function(){this._selectSelected(this.selected )},_selectSelected:function(selected){this._selection.select(this._valueToItem(t his.selected));if(this.fallbackSelection&&this.items.length&&this._selection.get ()===undefined){this.selected=this.fallbackSelection}},_filterItem:function(node ){return!this._excludedLocalNames[node.localName]},_valueToItem:function(value){ return value==null?null:this.items[this._valueToIndex(value)]},_valueToIndex:fun ction(value){if(this.attrForSelected){for(var i=0,item;item=this.items[i];i++){i f(this._valueForItem(item)==value){return i}}}else{return Number(value)}},_index ToValue:function(index){if(this.attrForSelected){var item=this.items[index];if(i tem){return this._valueForItem(item)}}else{return index}},_valueForItem:function (item){var propValue=item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)] ;return propValue!=undefined?propValue:item.getAttribute(this.attrForSelected)}, _applySelection:function(item,isSelected){if(this.selectedClass){this.toggleClas s(this.selectedClass,isSelected,item)}if(this.selectedAttribute){this.toggleAttr ibute(this.selectedAttribute,isSelected,item)}this._selectionChange();this.fire( "iron-"+(isSelected?"select":"deselect"),{item:item})},_selectionChange:function (){this._setSelectedItem(this._selection.get())},_observeItems:function(node){re turn Polymer.dom(node).observeNodes(function(mutation){this._updateItems();if(th is._shouldUpdateSelection){this._updateSelected()}this.fire("iron-items-changed" ,mutation,{bubbles:false,cancelable:false})})},_activateHandler:function(e){var t=e.target;var items=this.items;while(t&&t!=this){var i=items.indexOf(t);if(i>=0 ){var value=this._indexToValue(i);this._itemActivate(value,t);return}t=t.parentN ode}},_itemActivate:function(value,item){if(!this.fire("iron-activate",{selected :value,item:item},{cancelable:true}).defaultPrevented){this.select(value)}}};Pol ymer.IronMultiSelectableBehaviorImpl={properties:{multi:{type:Boolean,value:fals e,observer:"multiChanged"},selectedValues:{type:Array,notify:true},selectedItems :{type:Array,readOnly:true,notify:true}},observers:["_updateSelected(selectedVal ues.splices)"],select:function(value){if(this.multi){if(this.selectedValues){thi s._toggleSelected(value)}else{this.selectedValues=[value]}}else{this.selected=va lue}},multiChanged:function(multi){this._selection.multi=multi},get _shouldUpdat eSelection(){return this.selected!=null||this.selectedValues!=null&&this.selecte dValues.length},_updateAttrForSelected:function(){if(!this.multi){Polymer.IronSe lectableBehavior._updateAttrForSelected.apply(this)}else if(this._shouldUpdateSe lection){this.selectedValues=this.selectedItems.map(function(selectedItem){retur n this._indexToValue(this.indexOf(selectedItem))},this).filter(function(unfilter edValue){return unfilteredValue!=null},this)}},_updateSelected:function(){if(thi s.multi){this._selectMulti(this.selectedValues)}else{this._selectSelected(this.s elected)}},_selectMulti:function(values){if(values){var selectedItems=this._valu esToItems(values);this._selection.clear(selectedItems);for(var i=0;i<selectedIte ms.length;i++){this._selection.setItemSelected(selectedItems[i],true)}if(this.fa llbackSelection&&this.items.length&&!this._selection.get().length){var fallback= this._valueToItem(this.fallbackSelection);if(fallback){this.selectedValues=[this .fallbackSelection]}}}else{this._selection.clear()}},_selectionChange:function() {var s=this._selection.get();if(this.multi){this._setSelectedItems(s)}else{this. _setSelectedItems([s]);this._setSelectedItem(s)}},_toggleSelected:function(value ){var i=this.selectedValues.indexOf(value);var unselected=i<0;if(unselected){thi s.push("selectedValues",value)}else{this.splice("selectedValues",i,1)}},_valuesT oItems:function(values){return values==null?null:values.map(function(value){retu rn this._valueToItem(value)},this)}};Polymer.IronMultiSelectableBehavior=[Polyme r.IronSelectableBehavior,Polymer.IronMultiSelectableBehaviorImpl];Polymer.IronMe nuBehaviorImpl={properties:{focusedItem:{observer:"_focusedItemChanged",readOnly :true,type:Object},attrForItemTitle:{type:String}},hostAttributes:{role:"menu",t abindex:"0"},observers:["_updateMultiselectable(multi)"],listeners:{focus:"_onFo cus",keydown:"_onKeydown","iron-items-changed":"_onIronItemsChanged"},keyBinding s:{up:"_onUpKey",down:"_onDownKey",esc:"_onEscKey","shift+tab:keydown":"_onShift TabDown"},attached:function(){this._resetTabindices()},select:function(value){if (this._defaultFocusAsync){this.cancelAsync(this._defaultFocusAsync);this._defaul tFocusAsync=null}var item=this._valueToItem(value);if(item&&item.hasAttribute("d isabled"))return;this._setFocusedItem(item);Polymer.IronMultiSelectableBehaviorI mpl.select.apply(this,arguments)},_resetTabindices:function(){var selectedItem=t his.multi?this.selectedItems&&this.selectedItems[0]:this.selectedItem;this.items .forEach(function(item){item.setAttribute("tabindex",item===selectedItem?"0":"-1 ")},this)},_updateMultiselectable:function(multi){if(multi){this.setAttribute("a ria-multiselectable","true")}else{this.removeAttribute("aria-multiselectable")}} ,_focusWithKeyboardEvent:function(event){for(var i=0,item;item=this.items[i];i++ ){var attr=this.attrForItemTitle||"textContent";var title=item[attr]||item.getAt tribute(attr);if(!item.hasAttribute("disabled")&&title&&title.trim().charAt(0).t oLowerCase()===String.fromCharCode(event.keyCode).toLowerCase()){this._setFocuse dItem(item);break}}},_focusPrevious:function(){var length=this.items.length;var curFocusIndex=Number(this.indexOf(this.focusedItem));for(var i=1;i<length+1;i++) {var item=this.items[(curFocusIndex-i+length)%length];if(!item.hasAttribute("dis abled")){var owner=Polymer.dom(item).getOwnerRoot()||document;this._setFocusedIt em(item);if(Polymer.dom(owner).activeElement==item){return}}}},_focusNext:functi on(){var length=this.items.length;var curFocusIndex=Number(this.indexOf(this.foc usedItem));for(var i=1;i<length+1;i++){var item=this.items[(curFocusIndex+i)%len gth];if(!item.hasAttribute("disabled")){var owner=Polymer.dom(item).getOwnerRoot ()||document;this._setFocusedItem(item);if(Polymer.dom(owner).activeElement==ite m){return}}}},_applySelection:function(item,isSelected){if(isSelected){item.setA ttribute("aria-selected","true")}else{item.removeAttribute("aria-selected")}Poly mer.IronSelectableBehavior._applySelection.apply(this,arguments)},_focusedItemCh anged:function(focusedItem,old){old&&old.setAttribute("tabindex","-1");if(focuse dItem){focusedItem.setAttribute("tabindex","0");focusedItem.focus()}},_onIronIte msChanged:function(event){if(event.detail.addedNodes.length){this._resetTabindic es()}},_onShiftTabDown:function(event){var oldTabIndex=this.getAttribute("tabind ex");Polymer.IronMenuBehaviorImpl._shiftTabPressed=true;this._setFocusedItem(nul l);this.setAttribute("tabindex","-1");this.async(function(){this.setAttribute("t abindex",oldTabIndex);Polymer.IronMenuBehaviorImpl._shiftTabPressed=false},1)},_ onFocus:function(event){if(Polymer.IronMenuBehaviorImpl._shiftTabPressed){return }var rootTarget=Polymer.dom(event).rootTarget;if(rootTarget!==this&&typeof rootT arget.tabIndex!=="undefined"&&!this.isLightDescendant(rootTarget)){return}this._ defaultFocusAsync=this.async(function(){var selectedItem=this.multi?this.selecte dItems&&this.selectedItems[0]:this.selectedItem;this._setFocusedItem(null);if(se lectedItem){this._setFocusedItem(selectedItem)}else if(this.items[0]){this._focu sNext()}})},_onUpKey:function(event){this._focusPrevious();event.detail.keyboard Event.preventDefault()},_onDownKey:function(event){this._focusNext();event.detai l.keyboardEvent.preventDefault()},_onEscKey:function(event){this.focusedItem.blu r()},_onKeydown:function(event){if(!this.keyboardEventMatchesKeys(event,"up down esc")){this._focusWithKeyboardEvent(event)}event.stopPropagation()},_activateHa ndler:function(event){Polymer.IronSelectableBehavior._activateHandler.call(this, event);event.stopPropagation()}};Polymer.IronMenuBehaviorImpl._shiftTabPressed=f alse;Polymer.IronMenuBehavior=[Polymer.IronMultiSelectableBehavior,Polymer.IronA 11yKeysBehavior,Polymer.IronMenuBehaviorImpl];(function(){Polymer({is:"paper-men u",behaviors:[Polymer.IronMenuBehavior]})})();Polymer.IronFitBehavior={propertie s:{sizingTarget:{type:Object,value:function(){return this}},fitInto:{type:Object ,value:window},noOverlap:{type:Boolean},positionTarget:{type:Element},horizontal Align:{type:String},verticalAlign:{type:String},dynamicAlign:{type:Boolean},hori zontalOffset:{type:Number,value:0,notify:true},verticalOffset:{type:Number,value :0,notify:true},autoFitOnAttach:{type:Boolean,value:false},_fitInfo:{type:Object }},get _fitWidth(){var fitWidth;if(this.fitInto===window){fitWidth=this.fitInto. innerWidth}else{fitWidth=this.fitInto.getBoundingClientRect().width}return fitWi dth},get _fitHeight(){var fitHeight;if(this.fitInto===window){fitHeight=this.fit Into.innerHeight}else{fitHeight=this.fitInto.getBoundingClientRect().height}retu rn fitHeight},get _fitLeft(){var fitLeft;if(this.fitInto===window){fitLeft=0}els e{fitLeft=this.fitInto.getBoundingClientRect().left}return fitLeft},get _fitTop( ){var fitTop;if(this.fitInto===window){fitTop=0}else{fitTop=this.fitInto.getBoun dingClientRect().top}return fitTop},get _defaultPositionTarget(){var parent=Poly mer.dom(this).parentNode;if(parent&&parent.nodeType===Node.DOCUMENT_FRAGMENT_NOD E){parent=parent.host}return parent},get _localeHorizontalAlign(){if(this._isRTL ){if(this.horizontalAlign==="right"){return"left"}if(this.horizontalAlign==="lef t"){return"right"}}return this.horizontalAlign},attached:function(){this._isRTL= window.getComputedStyle(this).direction=="rtl";this.positionTarget=this.position Target||this._defaultPositionTarget;if(this.autoFitOnAttach){if(window.getComput edStyle(this).display==="none"){setTimeout(function(){this.fit()}.bind(this))}el se{this.fit()}}},fit:function(){this.position();this.constrain();this.center()}, _discoverInfo:function(){if(this._fitInfo){return}var target=window.getComputedS tyle(this);var sizer=window.getComputedStyle(this.sizingTarget);this._fitInfo={i nlineStyle:{top:this.style.top||"",left:this.style.left||"",position:this.style. position||""},sizerInlineStyle:{maxWidth:this.sizingTarget.style.maxWidth||"",ma xHeight:this.sizingTarget.style.maxHeight||"",boxSizing:this.sizingTarget.style. boxSizing||""},positionedBy:{vertically:target.top!=="auto"?"top":target.bottom! =="auto"?"bottom":null,horizontally:target.left!=="auto"?"left":target.right!==" auto"?"right":null},sizedBy:{height:sizer.maxHeight!=="none",width:sizer.maxWidt h!=="none",minWidth:parseInt(sizer.minWidth,10)||0,minHeight:parseInt(sizer.minH eight,10)||0},margin:{top:parseInt(target.marginTop,10)||0,right:parseInt(target .marginRight,10)||0,bottom:parseInt(target.marginBottom,10)||0,left:parseInt(tar get.marginLeft,10)||0}};if(this.verticalOffset){this._fitInfo.margin.top=this._f itInfo.margin.bottom=this.verticalOffset;this._fitInfo.inlineStyle.marginTop=thi s.style.marginTop||"";this._fitInfo.inlineStyle.marginBottom=this.style.marginBo ttom||"";this.style.marginTop=this.style.marginBottom=this.verticalOffset+"px"}i f(this.horizontalOffset){this._fitInfo.margin.left=this._fitInfo.margin.right=th is.horizontalOffset;this._fitInfo.inlineStyle.marginLeft=this.style.marginLeft|| "";this._fitInfo.inlineStyle.marginRight=this.style.marginRight||"";this.style.m arginLeft=this.style.marginRight=this.horizontalOffset+"px"}},resetFit:function( ){var info=this._fitInfo||{};for(var property in info.sizerInlineStyle){this.siz ingTarget.style[property]=info.sizerInlineStyle[property]}for(var property in in fo.inlineStyle){this.style[property]=info.inlineStyle[property]}this._fitInfo=nu ll},refit:function(){var scrollLeft=this.sizingTarget.scrollLeft;var scrollTop=t his.sizingTarget.scrollTop;this.resetFit();this.fit();this.sizingTarget.scrollLe ft=scrollLeft;this.sizingTarget.scrollTop=scrollTop},position:function(){if(!thi s.horizontalAlign&&!this.verticalAlign){return}this._discoverInfo();this.style.p osition="fixed";this.sizingTarget.style.boxSizing="border-box";this.style.left=" 0px";this.style.top="0px";var rect=this.getBoundingClientRect();var positionRect =this.__getNormalizedRect(this.positionTarget);var fitRect=this.__getNormalizedR ect(this.fitInto);var margin=this._fitInfo.margin;var size={width:rect.width+mar gin.left+margin.right,height:rect.height+margin.top+margin.bottom};var position= this.__getPosition(this._localeHorizontalAlign,this.verticalAlign,size,positionR ect,fitRect);var left=position.left+margin.left;var top=position.top+margin.top; var right=Math.min(fitRect.right-margin.right,left+rect.width);var bottom=Math.m in(fitRect.bottom-margin.bottom,top+rect.height);var minWidth=this._fitInfo.size dBy.minWidth;var minHeight=this._fitInfo.sizedBy.minHeight;if(left<margin.left){ left=margin.left;if(right-left<minWidth){left=right-minWidth}}if(top<margin.top) {top=margin.top;if(bottom-top<minHeight){top=bottom-minHeight}}this.sizingTarget .style.maxWidth=right-left+"px";this.sizingTarget.style.maxHeight=bottom-top+"px ";this.style.left=left-rect.left+"px";this.style.top=top-rect.top+"px"},constrai n:function(){if(this.horizontalAlign||this.verticalAlign){return}this._discoverI nfo();var info=this._fitInfo;if(!info.positionedBy.vertically){this.style.positi on="fixed";this.style.top="0px"}if(!info.positionedBy.horizontally){this.style.p osition="fixed";this.style.left="0px"}this.sizingTarget.style.boxSizing="border- box";var rect=this.getBoundingClientRect();if(!info.sizedBy.height){this.__sizeD imension(rect,info.positionedBy.vertically,"top","bottom","Height")}if(!info.siz edBy.width){this.__sizeDimension(rect,info.positionedBy.horizontally,"left","rig ht","Width")}},_sizeDimension:function(rect,positionedBy,start,end,extent){this. __sizeDimension(rect,positionedBy,start,end,extent)},__sizeDimension:function(re ct,positionedBy,start,end,extent){var info=this._fitInfo;var fitRect=this.__getN ormalizedRect(this.fitInto);var max=extent==="Width"?fitRect.width:fitRect.heigh t;var flip=positionedBy===end;var offset=flip?max-rect[end]:rect[start];var marg in=info.margin[flip?start:end];var offsetExtent="offset"+extent;var sizingOffset =this[offsetExtent]-this.sizingTarget[offsetExtent];this.sizingTarget.style["max "+extent]=max-margin-offset-sizingOffset+"px"},center:function(){if(this.horizon talAlign||this.verticalAlign){return}this._discoverInfo();var positionedBy=this. _fitInfo.positionedBy;if(positionedBy.vertically&&positionedBy.horizontally){ret urn}this.style.position="fixed";if(!positionedBy.vertically){this.style.top="0px "}if(!positionedBy.horizontally){this.style.left="0px"}var rect=this.getBounding ClientRect();var fitRect=this.__getNormalizedRect(this.fitInto);if(!positionedBy .vertically){var top=fitRect.top-rect.top+(fitRect.height-rect.height)/2;this.st yle.top=top+"px"}if(!positionedBy.horizontally){var left=fitRect.left-rect.left+ (fitRect.width-rect.width)/2;this.style.left=left+"px"}},__getNormalizedRect:fun ction(target){if(target===document.documentElement||target===window){return{top: 0,left:0,width:window.innerWidth,height:window.innerHeight,right:window.innerWid th,bottom:window.innerHeight}}return target.getBoundingClientRect()},__getCroppe dArea:function(position,size,fitRect){var verticalCrop=Math.min(0,position.top)+ Math.min(0,fitRect.bottom-(position.top+size.height));var horizontalCrop=Math.mi n(0,position.left)+Math.min(0,fitRect.right-(position.left+size.width));return M ath.abs(verticalCrop)*size.width+Math.abs(horizontalCrop)*size.height},__getPosi tion:function(hAlign,vAlign,size,positionRect,fitRect){var positions=[{verticalA lign:"top",horizontalAlign:"left",top:positionRect.top,left:positionRect.left},{ verticalAlign:"top",horizontalAlign:"right",top:positionRect.top,left:positionRe ct.right-size.width},{verticalAlign:"bottom",horizontalAlign:"left",top:position Rect.bottom-size.height,left:positionRect.left},{verticalAlign:"bottom",horizont alAlign:"right",top:positionRect.bottom-size.height,left:positionRect.right-size .width}];if(this.noOverlap){for(var i=0,l=positions.length;i<l;i++){var copy={}; for(var key in positions[i]){copy[key]=positions[i][key]}positions.push(copy)}po sitions[0].top=positions[1].top+=positionRect.height;positions[2].top=positions[ 3].top-=positionRect.height;positions[4].left=positions[6].left+=positionRect.wi dth;positions[5].left=positions[7].left-=positionRect.width}vAlign=vAlign==="aut o"?null:vAlign;hAlign=hAlign==="auto"?null:hAlign;var position;for(var i=0;i<pos itions.length;i++){var pos=positions[i];if(!this.dynamicAlign&&!this.noOverlap&& pos.verticalAlign===vAlign&&pos.horizontalAlign===hAlign){position=pos;break}var alignOk=(!vAlign||pos.verticalAlign===vAlign)&&(!hAlign||pos.horizontalAlign=== hAlign);if(!this.dynamicAlign&&!alignOk){continue}position=position||pos;pos.cro ppedArea=this.__getCroppedArea(pos,size,fitRect);var diff=pos.croppedArea-positi on.croppedArea;if(diff<0||diff===0&&alignOk){position=pos}if(position.croppedAre a===0&&alignOk){break}}return position}};(function(){"use strict";Polymer({is:"i ron-overlay-backdrop",properties:{opened:{reflectToAttribute:true,type:Boolean,v alue:false,observer:"_openedChanged"}},listeners:{transitionend:"_onTransitionen d"},created:function(){this.__openedRaf=null},attached:function(){this.opened&&t his._openedChanged(this.opened)},prepare:function(){if(this.opened&&!this.parent Node){Polymer.dom(document.body).appendChild(this)}},open:function(){this.opened =true},close:function(){this.opened=false},complete:function(){if(!this.opened&& this.parentNode===document.body){Polymer.dom(this.parentNode).removeChild(this)} },_onTransitionend:function(event){if(event&&event.target===this){this.complete( )}},_openedChanged:function(opened){if(opened){this.prepare()}else{var cs=window .getComputedStyle(this);if(cs.transitionDuration==="0s"||cs.opacity==0){this.com plete()}}if(!this.isAttached){return}if(this.__openedRaf){window.cancelAnimation Frame(this.__openedRaf);this.__openedRaf=null}this.scrollTop=this.scrollTop;this .__openedRaf=window.requestAnimationFrame(function(){this.__openedRaf=null;this. toggleClass("opened",this.opened)}.bind(this))}})})();Polymer.IronOverlayManager Class=function(){this._overlays=[];this._minimumZ=101;this._backdropElement=null ;Polymer.Gestures.add(document,"tap",this._onCaptureClick.bind(this));document.a ddEventListener("focus",this._onCaptureFocus.bind(this),true);document.addEventL istener("keydown",this._onCaptureKeyDown.bind(this),true)};Polymer.IronOverlayMa nagerClass.prototype={constructor:Polymer.IronOverlayManagerClass,get backdropEl ement(){if(!this._backdropElement){this._backdropElement=document.createElement( "iron-overlay-backdrop")}return this._backdropElement},get deepActiveElement(){v ar active=document.activeElement||document.body;while(active.root&&Polymer.dom(a ctive.root).activeElement){active=Polymer.dom(active.root).activeElement}return active},_bringOverlayAtIndexToFront:function(i){var overlay=this._overlays[i];if (!overlay){return}var lastI=this._overlays.length-1;var currentOverlay=this._ove rlays[lastI];if(currentOverlay&&this._shouldBeBehindOverlay(overlay,currentOverl ay)){lastI--}if(i>=lastI){return}var minimumZ=Math.max(this.currentOverlayZ(),th is._minimumZ);if(this._getZ(overlay)<=minimumZ){this._applyOverlayZ(overlay,mini mumZ)}while(i<lastI){this._overlays[i]=this._overlays[i+1];i++}this._overlays[la stI]=overlay},addOrRemoveOverlay:function(overlay){if(overlay.opened){this.addOv erlay(overlay)}else{this.removeOverlay(overlay)}},addOverlay:function(overlay){v ar i=this._overlays.indexOf(overlay);if(i>=0){this._bringOverlayAtIndexToFront(i );this.trackBackdrop();return}var insertionIndex=this._overlays.length;var curre ntOverlay=this._overlays[insertionIndex-1];var minimumZ=Math.max(this._getZ(curr entOverlay),this._minimumZ);var newZ=this._getZ(overlay);if(currentOverlay&&this ._shouldBeBehindOverlay(overlay,currentOverlay)){this._applyOverlayZ(currentOver lay,minimumZ);insertionIndex--;var previousOverlay=this._overlays[insertionIndex -1];minimumZ=Math.max(this._getZ(previousOverlay),this._minimumZ)}if(newZ<=minim umZ){this._applyOverlayZ(overlay,minimumZ)}this._overlays.splice(insertionIndex, 0,overlay);this.trackBackdrop()},removeOverlay:function(overlay){var i=this._ove rlays.indexOf(overlay);if(i===-1){return}this._overlays.splice(i,1);this.trackBa ckdrop()},currentOverlay:function(){var i=this._overlays.length-1;return this._o verlays[i]},currentOverlayZ:function(){return this._getZ(this.currentOverlay())} ,ensureMinimumZ:function(minimumZ){this._minimumZ=Math.max(this._minimumZ,minimu mZ)},focusOverlay:function(){var current=this.currentOverlay();if(current){curre nt._applyFocus()}},trackBackdrop:function(){var overlay=this._overlayWithBackdro p();if(!overlay&&!this._backdropElement){return}this.backdropElement.style.zInde x=this._getZ(overlay)-1;this.backdropElement.opened=!!overlay},getBackdrops:func tion(){var backdrops=[];for(var i=0;i<this._overlays.length;i++){if(this._overla ys[i].withBackdrop){backdrops.push(this._overlays[i])}}return backdrops},backdro pZ:function(){return this._getZ(this._overlayWithBackdrop())-1},_overlayWithBack drop:function(){for(var i=0;i<this._overlays.length;i++){if(this._overlays[i].wi thBackdrop){return this._overlays[i]}}},_getZ:function(overlay){var z=this._mini mumZ;if(overlay){var z1=Number(overlay.style.zIndex||window.getComputedStyle(ove rlay).zIndex);if(z1===z1){z=z1}}return z},_setZ:function(element,z){element.styl e.zIndex=z},_applyOverlayZ:function(overlay,aboveZ){this._setZ(overlay,aboveZ+2) },_overlayInPath:function(path){path=path||[];for(var i=0;i<path.length;i++){if( path[i]._manager===this){return path[i]}}},_onCaptureClick:function(event){var o verlay=this.currentOverlay();if(overlay&&this._overlayInPath(Polymer.dom(event). path)!==overlay){overlay._onCaptureClick(event)}},_onCaptureFocus:function(event ){var overlay=this.currentOverlay();if(overlay){overlay._onCaptureFocus(event)}} ,_onCaptureKeyDown:function(event){var overlay=this.currentOverlay();if(overlay) {if(Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(event,"esc")){overlay. _onCaptureEsc(event)}else if(Polymer.IronA11yKeysBehavior.keyboardEventMatchesKe ys(event,"tab")){overlay._onCaptureTab(event)}}},_shouldBeBehindOverlay:function (overlay1,overlay2){return!overlay1.alwaysOnTop&&overlay2.alwaysOnTop}};Polymer. IronOverlayManager=new Polymer.IronOverlayManagerClass;(function(){"use strict"; Polymer.IronOverlayBehaviorImpl={properties:{opened:{observer:"_openedChanged",t ype:Boolean,value:false,notify:true},canceled:{observer:"_canceledChanged",readO nly:true,type:Boolean,value:false},withBackdrop:{observer:"_withBackdropChanged" ,type:Boolean},noAutoFocus:{type:Boolean,value:false},noCancelOnEscKey:{type:Boo lean,value:false},noCancelOnOutsideClick:{type:Boolean,value:false},closingReaso n:{
47 },restoreFocusOnClose:{type:Boolean,value:false},alwaysOnTop:{type:Boolean},_man ager:{type:Object,value:Polymer.IronOverlayManager},_focusedChild:{type:Object}} ,listeners:{"iron-resize":"_onIronResize"},get backdropElement(){return this._ma nager.backdropElement},get _focusNode(){return this._focusedChild||Polymer.dom(t his).querySelector("[autofocus]")||this},get _focusableNodes(){var FOCUSABLE_WIT H_DISABLED=["a[href]","area[href]","iframe","[tabindex]","[contentEditable=true] "];var FOCUSABLE_WITHOUT_DISABLED=["input","select","textarea","button"];var sel ector=FOCUSABLE_WITH_DISABLED.join(':not([tabindex="-1"]),')+':not([tabindex="-1 "]),'+FOCUSABLE_WITHOUT_DISABLED.join(':not([disabled]):not([tabindex="-1"]),')+ ':not([disabled]):not([tabindex="-1"])';var focusables=Polymer.dom(this).querySe lectorAll(selector);if(this.tabIndex>=0){focusables.splice(0,0,this)}return focu sables.sort(function(a,b){if(a.tabIndex===b.tabIndex){return 0}if(a.tabIndex===0 ||a.tabIndex>b.tabIndex){return 1}return-1})},ready:function(){this.__isAnimatin g=false;this.__shouldRemoveTabIndex=false;this.__firstFocusableNode=this.__lastF ocusableNode=null;this.__raf=null;this.__restoreFocusNode=null;this._ensureSetup ()},attached:function(){if(this.opened){this._openedChanged(this.opened)}this._o bserver=Polymer.dom(this).observeNodes(this._onNodesChange)},detached:function() {Polymer.dom(this).unobserveNodes(this._observer);this._observer=null;if(this.__ raf){window.cancelAnimationFrame(this.__raf);this.__raf=null}this._manager.remov eOverlay(this)},toggle:function(){this._setCanceled(false);this.opened=!this.ope ned},open:function(){this._setCanceled(false);this.opened=true},close:function() {this._setCanceled(false);this.opened=false},cancel:function(event){var cancelEv ent=this.fire("iron-overlay-canceled",event,{cancelable:true});if(cancelEvent.de faultPrevented){return}this._setCanceled(true);this.opened=false},_ensureSetup:f unction(){if(this._overlaySetup){return}this._overlaySetup=true;this.style.outli ne="none";this.style.display="none"},_openedChanged:function(opened){if(opened){ this.removeAttribute("aria-hidden")}else{this.setAttribute("aria-hidden","true") }if(!this.isAttached){return}this.__isAnimating=true;this.__onNextAnimationFrame (this.__openedChanged)},_canceledChanged:function(){this.closingReason=this.clos ingReason||{};this.closingReason.canceled=this.canceled},_withBackdropChanged:fu nction(){if(this.withBackdrop&&!this.hasAttribute("tabindex")){this.setAttribute ("tabindex","-1");this.__shouldRemoveTabIndex=true}else if(this.__shouldRemoveTa bIndex){this.removeAttribute("tabindex");this.__shouldRemoveTabIndex=false}if(th is.opened&&this.isAttached){this._manager.trackBackdrop()}},_prepareRenderOpened :function(){this.__restoreFocusNode=this._manager.deepActiveElement;this._prepar ePositioning();this.refit();this._finishPositioning();if(this.noAutoFocus&&docum ent.activeElement===this._focusNode){this._focusNode.blur();this.__restoreFocusN ode.focus()}},_renderOpened:function(){this._finishRenderOpened()},_renderClosed :function(){this._finishRenderClosed()},_finishRenderOpened:function(){this.noti fyResize();this.__isAnimating=false;var focusableNodes=this._focusableNodes;this .__firstFocusableNode=focusableNodes[0];this.__lastFocusableNode=focusableNodes[ focusableNodes.length-1];this.fire("iron-overlay-opened")},_finishRenderClosed:f unction(){this.style.display="none";this.style.zIndex="";this.notifyResize();thi s.__isAnimating=false;this.fire("iron-overlay-closed",this.closingReason)},_prep arePositioning:function(){this.style.transition=this.style.webkitTransition="non e";this.style.transform=this.style.webkitTransform="none";this.style.display=""} ,_finishPositioning:function(){this.style.display="none";this.scrollTop=this.scr ollTop;this.style.transition=this.style.webkitTransition="";this.style.transform =this.style.webkitTransform="";this.style.display="";this.scrollTop=this.scrollT op},_applyFocus:function(){if(this.opened){if(!this.noAutoFocus){this._focusNode .focus()}}else{this._focusNode.blur();this._focusedChild=null;if(this.restoreFoc usOnClose&&this.__restoreFocusNode){this.__restoreFocusNode.focus()}this.__resto reFocusNode=null;var currentOverlay=this._manager.currentOverlay();if(currentOve rlay&&this!==currentOverlay){currentOverlay._applyFocus()}}},_onCaptureClick:fun ction(event){if(!this.noCancelOnOutsideClick){this.cancel(event)}},_onCaptureFoc us:function(event){if(!this.withBackdrop){return}var path=Polymer.dom(event).pat h;if(path.indexOf(this)===-1){event.stopPropagation();this._applyFocus()}else{th is._focusedChild=path[0]}},_onCaptureEsc:function(event){if(!this.noCancelOnEscK ey){this.cancel(event)}},_onCaptureTab:function(event){if(!this.withBackdrop){re turn}var shift=event.shiftKey;var nodeToCheck=shift?this.__firstFocusableNode:th is.__lastFocusableNode;var nodeToSet=shift?this.__lastFocusableNode:this.__first FocusableNode;var shouldWrap=false;if(nodeToCheck===nodeToSet){shouldWrap=true}e lse{var focusedNode=this._manager.deepActiveElement;shouldWrap=focusedNode===nod eToCheck||focusedNode===this}if(shouldWrap){event.preventDefault();this._focused Child=nodeToSet;this._applyFocus()}},_onIronResize:function(){if(this.opened&&!t his.__isAnimating){this.__onNextAnimationFrame(this.refit)}},_onNodesChange:func tion(){if(this.opened&&!this.__isAnimating){this.notifyResize()}},__openedChange d:function(){if(this.opened){this._prepareRenderOpened();this._manager.addOverla y(this);this._applyFocus();this._renderOpened()}else{this._manager.removeOverlay (this);this._applyFocus();this._renderClosed()}},__onNextAnimationFrame:function (callback){if(this.__raf){window.cancelAnimationFrame(this.__raf)}var self=this; this.__raf=window.requestAnimationFrame(function nextAnimationFrame(){self.__raf =null;callback.call(self)})}};Polymer.IronOverlayBehavior=[Polymer.IronFitBehavi or,Polymer.IronResizableBehavior,Polymer.IronOverlayBehaviorImpl]})();Polymer.Ne onAnimatableBehavior={properties:{animationConfig:{type:Object},entryAnimation:{ observer:"_entryAnimationChanged",type:String},exitAnimation:{observer:"_exitAni mationChanged",type:String}},_entryAnimationChanged:function(){this.animationCon fig=this.animationConfig||{};this.animationConfig["entry"]=[{name:this.entryAnim ation,node:this}]},_exitAnimationChanged:function(){this.animationConfig=this.an imationConfig||{};this.animationConfig["exit"]=[{name:this.exitAnimation,node:th is}]},_copyProperties:function(config1,config2){for(var property in config2){con fig1[property]=config2[property]}},_cloneConfig:function(config){var clone={isCl one:true};this._copyProperties(clone,config);return clone},_getAnimationConfigRe cursive:function(type,map,allConfigs){if(!this.animationConfig){return}if(this.a nimationConfig.value&&typeof this.animationConfig.value==="function"){this._warn (this._logf("playAnimation","Please put 'animationConfig' inside of your compone nts 'properties' object instead of outside of it."));return}var thisConfig;if(ty pe){thisConfig=this.animationConfig[type]}else{thisConfig=this.animationConfig}i f(!Array.isArray(thisConfig)){thisConfig=[thisConfig]}if(thisConfig){for(var con fig,index=0;config=thisConfig[index];index++){if(config.animatable){config.anima table._getAnimationConfigRecursive(config.type||type,map,allConfigs)}else{if(con fig.id){var cachedConfig=map[config.id];if(cachedConfig){if(!cachedConfig.isClon e){map[config.id]=this._cloneConfig(cachedConfig);cachedConfig=map[config.id]}th is._copyProperties(cachedConfig,config)}else{map[config.id]=config}}else{allConf igs.push(config)}}}}},getAnimationConfig:function(type){var map={};var allConfig s=[];this._getAnimationConfigRecursive(type,map,allConfigs);for(var key in map){ allConfigs.push(map[key])}return allConfigs}};Polymer.NeonAnimationRunnerBehavio rImpl={_configureAnimations:function(configs){var results=[];if(configs.length>0 ){for(var config,index=0;config=configs[index];index++){var neonAnimation=docume nt.createElement(config.name);if(neonAnimation.isNeonAnimation){var result=null; try{result=neonAnimation.configure(config);if(typeof result.cancel!="function"){ result=document.timeline.play(result)}}catch(e){result=null;console.warn("Couldn t play","(",config.name,").",e)}if(result){results.push({neonAnimation:neonAnima tion,config:config,animation:result})}}else{console.warn(this.is+":",config.name ,"not found!")}}}return results},_shouldComplete:function(activeEntries){var fin ished=true;for(var i=0;i<activeEntries.length;i++){if(activeEntries[i].animation .playState!="finished"){finished=false;break}}return finished},_complete:functio n(activeEntries){for(var i=0;i<activeEntries.length;i++){activeEntries[i].neonAn imation.complete(activeEntries[i].config)}for(var i=0;i<activeEntries.length;i++ ){activeEntries[i].animation.cancel()}},playAnimation:function(type,cookie){var configs=this.getAnimationConfig(type);if(!configs){return}this._active=this._act ive||{};if(this._active[type]){this._complete(this._active[type]);delete this._a ctive[type]}var activeEntries=this._configureAnimations(configs);if(activeEntrie s.length==0){this.fire("neon-animation-finish",cookie,{bubbles:false});return}th is._active[type]=activeEntries;for(var i=0;i<activeEntries.length;i++){activeEnt ries[i].animation.onfinish=function(){if(this._shouldComplete(activeEntries)){th is._complete(activeEntries);delete this._active[type];this.fire("neon-animation- finish",cookie,{bubbles:false})}}.bind(this)}},cancelAnimation:function(){for(va r k in this._animations){this._animations[k].cancel()}this._animations={}}};Poly mer.NeonAnimationRunnerBehavior=[Polymer.NeonAnimatableBehavior,Polymer.NeonAnim ationRunnerBehaviorImpl];Polymer.NeonAnimationBehavior={properties:{animationTim ing:{type:Object,value:function(){return{duration:500,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"both"}}}},isNeonAnimation:true,timingFromConfig:function(confi g){if(config.timing){for(var property in config.timing){this.animationTiming[pro perty]=config.timing[property]}}return this.animationTiming},setPrefixedProperty :function(node,property,value){var map={transform:["webkitTransform"],transformO rigin:["mozTransformOrigin","webkitTransformOrigin"]};var prefixes=map[property] ;for(var prefix,index=0;prefix=prefixes[index];index++){node.style[prefix]=value }node.style[property]=value},complete:function(){}};Polymer({is:"opaque-animatio n",behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var node =config.node;this._effect=new KeyframeEffect(node,[{opacity:"1"},{opacity:"1"}], this.timingFromConfig(config));node.style.opacity="0";return this._effect},compl ete:function(config){config.node.style.opacity=""}});(function(){"use strict";va r LAST_TOUCH_POSITION={pageX:0,pageY:0};var ROOT_TARGET=null;var SCROLLABLE_NODE S=[];Polymer.IronDropdownScrollManager={get currentLockingElement(){return this. _lockingElements[this._lockingElements.length-1]},elementIsScrollLocked:function (element){var currentLockingElement=this.currentLockingElement;if(currentLocking Element===undefined)return false;var scrollLocked;if(this._hasCachedLockedElemen t(element)){return true}if(this._hasCachedUnlockedElement(element)){return false }scrollLocked=!!currentLockingElement&&currentLockingElement!==element&&!this._c omposedTreeContains(currentLockingElement,element);if(scrollLocked){this._locked ElementCache.push(element)}else{this._unlockedElementCache.push(element)}return scrollLocked},pushScrollLock:function(element){if(this._lockingElements.indexOf( element)>=0){return}if(this._lockingElements.length===0){this._lockScrollInterac tions()}this._lockingElements.push(element);this._lockedElementCache=[];this._un lockedElementCache=[]},removeScrollLock:function(element){var index=this._lockin gElements.indexOf(element);if(index===-1){return}this._lockingElements.splice(in dex,1);this._lockedElementCache=[];this._unlockedElementCache=[];if(this._lockin gElements.length===0){this._unlockScrollInteractions()}},_lockingElements:[],_lo ckedElementCache:null,_unlockedElementCache:null,_hasCachedLockedElement:functio n(element){return this._lockedElementCache.indexOf(element)>-1},_hasCachedUnlock edElement:function(element){return this._unlockedElementCache.indexOf(element)>- 1},_composedTreeContains:function(element,child){var contentElements;var distrib utedNodes;var contentIndex;var nodeIndex;if(element.contains(child)){return true }contentElements=Polymer.dom(element).querySelectorAll("content");for(contentInd ex=0;contentIndex<contentElements.length;++contentIndex){distributedNodes=Polyme r.dom(contentElements[contentIndex]).getDistributedNodes();for(nodeIndex=0;nodeI ndex<distributedNodes.length;++nodeIndex){if(this._composedTreeContains(distribu tedNodes[nodeIndex],child)){return true}}}return false},_scrollInteractionHandle r:function(event){if(event.cancelable&&this._shouldPreventScrolling(event)){even t.preventDefault()}if(event.targetTouches){var touch=event.targetTouches[0];LAST _TOUCH_POSITION.pageX=touch.pageX;LAST_TOUCH_POSITION.pageY=touch.pageY}},_lockS crollInteractions:function(){this._boundScrollHandler=this._boundScrollHandler|| this._scrollInteractionHandler.bind(this);document.addEventListener("wheel",this ._boundScrollHandler,true);document.addEventListener("mousewheel",this._boundScr ollHandler,true);document.addEventListener("DOMMouseScroll",this._boundScrollHan dler,true);document.addEventListener("touchstart",this._boundScrollHandler,true) ;document.addEventListener("touchmove",this._boundScrollHandler,true)},_unlockSc rollInteractions:function(){document.removeEventListener("wheel",this._boundScro llHandler,true);document.removeEventListener("mousewheel",this._boundScrollHandl er,true);document.removeEventListener("DOMMouseScroll",this._boundScrollHandler, true);document.removeEventListener("touchstart",this._boundScrollHandler,true);d ocument.removeEventListener("touchmove",this._boundScrollHandler,true)},_shouldP reventScrolling:function(event){var target=Polymer.dom(event).rootTarget;if(even t.type!=="touchmove"&&ROOT_TARGET!==target){ROOT_TARGET=target;SCROLLABLE_NODES= this._getScrollableNodes(Polymer.dom(event).path)}if(!SCROLLABLE_NODES.length){r eturn true}if(event.type==="touchstart"){return false}var info=this._getScrollIn fo(event);return!this._getScrollingNode(SCROLLABLE_NODES,info.deltaX,info.deltaY )},_getScrollableNodes:function(nodes){var scrollables=[];var lockingIndex=nodes .indexOf(this.currentLockingElement);for(var i=0;i<=lockingIndex;i++){var node=n odes[i];if(node.nodeType===11){continue}var style=node.style;if(style.overflow!= ="scroll"&&style.overflow!=="auto"){style=window.getComputedStyle(node)}if(style .overflow==="scroll"||style.overflow==="auto"){scrollables.push(node)}}return sc rollables},_getScrollingNode:function(nodes,deltaX,deltaY){if(!deltaX&&!deltaY){ return}var verticalScroll=Math.abs(deltaY)>=Math.abs(deltaX);for(var i=0;i<nodes .length;i++){var node=nodes[i];var canScroll=false;if(verticalScroll){canScroll= deltaY<0?node.scrollTop>0:node.scrollTop<node.scrollHeight-node.clientHeight}els e{canScroll=deltaX<0?node.scrollLeft>0:node.scrollLeft<node.scrollWidth-node.cli entWidth}if(canScroll){return node}}},_getScrollInfo:function(event){var info={d eltaX:event.deltaX,deltaY:event.deltaY};if("deltaX"in event){}else if("wheelDelt aX"in event){info.deltaX=-event.wheelDeltaX;info.deltaY=-event.wheelDeltaY}else if("axis"in event){info.deltaX=event.axis===1?event.detail:0;info.deltaY=event.a xis===2?event.detail:0}else if(event.targetTouches){var touch=event.targetTouche s[0];info.deltaX=LAST_TOUCH_POSITION.pageX-touch.pageX;info.deltaY=LAST_TOUCH_PO SITION.pageY-touch.pageY}return info}}})();(function(){"use strict";Polymer({is: "iron-dropdown",behaviors:[Polymer.IronControlState,Polymer.IronA11yKeysBehavior ,Polymer.IronOverlayBehavior,Polymer.NeonAnimationRunnerBehavior],properties:{ho rizontalAlign:{type:String,value:"left",reflectToAttribute:true},verticalAlign:{ type:String,value:"top",reflectToAttribute:true},openAnimationConfig:{type:Objec t},closeAnimationConfig:{type:Object},focusTarget:{type:Object},noAnimations:{ty pe:Boolean,value:false},allowOutsideScroll:{type:Boolean,value:false},_boundOnCa ptureScroll:{type:Function,value:function(){return this._onCaptureScroll.bind(th is)}}},listeners:{"neon-animation-finish":"_onNeonAnimationFinish"},observers:[" _updateOverlayPosition(positionTarget, verticalAlign, horizontalAlign, verticalO ffset, horizontalOffset)"],get containedElement(){return Polymer.dom(this.$.cont ent).getDistributedNodes()[0]},get _focusTarget(){return this.focusTarget||this. containedElement},ready:function(){this._scrollTop=0;this._scrollLeft=0;this._re fitOnScrollRAF=null},attached:function(){if(!this.sizingTarget||this.sizingTarge t===this){this.sizingTarget=this.containedElement}},detached:function(){this.can celAnimation();document.removeEventListener("scroll",this._boundOnCaptureScroll) ;Polymer.IronDropdownScrollManager.removeScrollLock(this)},_openedChanged:functi on(){if(this.opened&&this.disabled){this.cancel()}else{this.cancelAnimation();th is._updateAnimationConfig();this._saveScrollPosition();if(this.opened){document. addEventListener("scroll",this._boundOnCaptureScroll);!this.allowOutsideScroll&& Polymer.IronDropdownScrollManager.pushScrollLock(this)}else{document.removeEvent Listener("scroll",this._boundOnCaptureScroll);Polymer.IronDropdownScrollManager. removeScrollLock(this)}Polymer.IronOverlayBehaviorImpl._openedChanged.apply(this ,arguments)}},_renderOpened:function(){if(!this.noAnimations&&this.animationConf ig.open){this.$.contentWrapper.classList.add("animating");this.playAnimation("op en")}else{Polymer.IronOverlayBehaviorImpl._renderOpened.apply(this,arguments)}}, _renderClosed:function(){if(!this.noAnimations&&this.animationConfig.close){this .$.contentWrapper.classList.add("animating");this.playAnimation("close")}else{Po lymer.IronOverlayBehaviorImpl._renderClosed.apply(this,arguments)}},_onNeonAnima tionFinish:function(){this.$.contentWrapper.classList.remove("animating");if(thi s.opened){this._finishRenderOpened()}else{this._finishRenderClosed()}},_onCaptur eScroll:function(){if(!this.allowOutsideScroll){this._restoreScrollPosition()}el se{this._refitOnScrollRAF&&window.cancelAnimationFrame(this._refitOnScrollRAF);t his._refitOnScrollRAF=window.requestAnimationFrame(this.refit.bind(this))}},_sav eScrollPosition:function(){if(document.scrollingElement){this._scrollTop=documen t.scrollingElement.scrollTop;this._scrollLeft=document.scrollingElement.scrollLe ft}else{this._scrollTop=Math.max(document.documentElement.scrollTop,document.bod y.scrollTop);this._scrollLeft=Math.max(document.documentElement.scrollLeft,docum ent.body.scrollLeft)}},_restoreScrollPosition:function(){if(document.scrollingEl ement){document.scrollingElement.scrollTop=this._scrollTop;document.scrollingEle ment.scrollLeft=this._scrollLeft}else{document.documentElement.scrollTop=this._s crollTop;document.documentElement.scrollLeft=this._scrollLeft;document.body.scro llTop=this._scrollTop;document.body.scrollLeft=this._scrollLeft}},_updateAnimati onConfig:function(){var animations=(this.openAnimationConfig||[]).concat(this.cl oseAnimationConfig||[]);for(var i=0;i<animations.length;i++){animations[i].node= this.containedElement}this.animationConfig={open:this.openAnimationConfig,close: this.closeAnimationConfig}},_updateOverlayPosition:function(){if(this.isAttached ){this.notifyResize()}},_applyFocus:function(){var focusTarget=this.focusTarget| |this.containedElement;if(focusTarget&&this.opened&&!this.noAutoFocus){focusTarg et.focus()}else{Polymer.IronOverlayBehaviorImpl._applyFocus.apply(this,arguments )}}})})();Polymer({is:"fade-in-animation",behaviors:[Polymer.NeonAnimationBehavi or],configure:function(config){var node=config.node;this._effect=new KeyframeEff ect(node,[{opacity:"0"},{opacity:"1"}],this.timingFromConfig(config));return thi s._effect}});Polymer({is:"fade-out-animation",behaviors:[Polymer.NeonAnimationBe havior],configure:function(config){var node=config.node;this._effect=new Keyfram eEffect(node,[{opacity:"1"},{opacity:"0"}],this.timingFromConfig(config));return this._effect}});Polymer({is:"paper-menu-grow-height-animation",behaviors:[Polym er.NeonAnimationBehavior],configure:function(config){var node=config.node;var re ct=node.getBoundingClientRect();var height=rect.height;this._effect=new Keyframe Effect(node,[{height:height/2+"px"},{height:height+"px"}],this.timingFromConfig( config));return this._effect}});Polymer({is:"paper-menu-grow-width-animation",be haviors:[Polymer.NeonAnimationBehavior],configure:function(config){var node=conf ig.node;var rect=node.getBoundingClientRect();var width=rect.width;this._effect= new KeyframeEffect(node,[{width:width/2+"px"},{width:width+"px"}],this.timingFro mConfig(config));return this._effect}});Polymer({is:"paper-menu-shrink-width-ani mation",behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var node=config.node;var rect=node.getBoundingClientRect();var width=rect.width;thi s._effect=new KeyframeEffect(node,[{width:width+"px"},{width:width-width/20+"px" }],this.timingFromConfig(config));return this._effect}});Polymer({is:"paper-menu -shrink-height-animation",behaviors:[Polymer.NeonAnimationBehavior],configure:fu nction(config){var node=config.node;var rect=node.getBoundingClientRect();var he ight=rect.height;var top=rect.top;this.setPrefixedProperty(node,"transformOrigin ","0 0");this._effect=new KeyframeEffect(node,[{height:height+"px",transform:"tr anslateY(0)"},{height:height/2+"px",transform:"translateY(-20px)"}],this.timingF romConfig(config));return this._effect}});(function(){"use strict";var config={A NIMATION_CUBIC_BEZIER:"cubic-bezier(.3,.95,.5,1)",MAX_ANIMATION_TIME_MS:400};var PaperMenuButton=Polymer({is:"paper-menu-button",behaviors:[Polymer.IronA11yKeys Behavior,Polymer.IronControlState],properties:{opened:{type:Boolean,value:false, notify:true,observer:"_openedChanged"},horizontalAlign:{type:String,value:"left" ,reflectToAttribute:true},verticalAlign:{type:String,value:"top",reflectToAttrib ute:true},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,value:0,noti fy:true},verticalOffset:{type:Number,value:0,notify:true},noOverlap:{type:Boolea n},noAnimations:{type:Boolean,value:false},ignoreSelect:{type:Boolean,value:fals e},closeOnActivate:{type:Boolean,value:false},openAnimationConfig:{type:Object,v alue:function(){return[{name:"fade-in-animation",timing:{delay:100,duration:200} },{name:"paper-menu-grow-width-animation",timing:{delay:100,duration:150,easing: config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-grow-height-animation",timing: {delay:100,duration:275,easing:config.ANIMATION_CUBIC_BEZIER}}]}},closeAnimation Config:{type:Object,value:function(){return[{name:"fade-out-animation",timing:{d uration:150}},{name:"paper-menu-shrink-width-animation",timing:{delay:100,durati on:50,easing:config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-shrink-height-ani mation",timing:{duration:200,easing:"ease-in"}}]}},allowOutsideScroll:{type:Bool ean,value:false},restoreFocusOnClose:{type:Boolean,value:true},_dropdownContent: {type:Object}},hostAttributes:{role:"group","aria-haspopup":"true"},listeners:{" iron-activate":"_onIronActivate","iron-select":"_onIronSelect"},get contentEleme nt(){return Polymer.dom(this.$.content).getDistributedNodes()[0]},toggle:functio n(){if(this.opened){this.close()}else{this.open()}},open:function(){if(this.disa bled){return}this.$.dropdown.open()},close:function(){this.$.dropdown.close()},_ onIronSelect:function(event){if(!this.ignoreSelect){this.close()}},_onIronActiva te:function(event){if(this.closeOnActivate){this.close()}},_openedChanged:functi on(opened,oldOpened){if(opened){this._dropdownContent=this.contentElement;this.f ire("paper-dropdown-open")}else if(oldOpened!=null){this.fire("paper-dropdown-cl ose")}},_disabledChanged:function(disabled){Polymer.IronControlState._disabledCh anged.apply(this,arguments);if(disabled&&this.opened){this.close()}},__onIronOve rlayCanceled:function(event){var uiEvent=event.detail;var target=Polymer.dom(uiE vent).rootTarget;var trigger=this.$.trigger;var path=Polymer.dom(uiEvent).path;i f(path.indexOf(trigger)>-1){event.preventDefault()}}});Object.keys(config).forEa ch(function(key){PaperMenuButton[key]=config[key]});Polymer.PaperMenuButton=Pape rMenuButton})();Polymer.PaperInkyFocusBehaviorImpl={observers:["_focusedChanged( receivedFocusFromKeyboard)"],_focusedChanged:function(receivedFocusFromKeyboard) {if(receivedFocusFromKeyboard){this.ensureRipple()}if(this.hasRipple()){this._ri pple.holdDown=receivedFocusFromKeyboard}},_createRipple:function(){var ripple=Po lymer.PaperRippleBehavior._createRipple();ripple.id="ink";ripple.setAttribute("c enter","");ripple.classList.add("circle");return ripple}};Polymer.PaperInkyFocus Behavior=[Polymer.IronButtonState,Polymer.IronControlState,Polymer.PaperRippleBe havior,Polymer.PaperInkyFocusBehaviorImpl];Polymer({is:"paper-icon-button",hostA ttributes:{role:"button",tabindex:"0"},behaviors:[Polymer.PaperInkyFocusBehavior ],properties:{src:{type:String},icon:{type:String},alt:{type:String,observer:"_a ltChanged"}},_altChanged:function(newValue,oldValue){var label=this.getAttribute ("aria-label");if(!label||oldValue==label){this.setAttribute("aria-label",newVal ue)}}});Polymer({is:"iron-media-query",properties:{queryMatches:{type:Boolean,va lue:false,readOnly:true,notify:true},query:{type:String,observer:"queryChanged"} ,full:{type:Boolean,value:false},_boundMQHandler:{value:function(){return this.q ueryHandler.bind(this)}},_mq:{value:null}},attached:function(){this.style.displa y="none";this.queryChanged()},detached:function(){this._remove()},_add:function( ){if(this._mq){this._mq.addListener(this._boundMQHandler)}},_remove:function(){i f(this._mq){this._mq.removeListener(this._boundMQHandler)}this._mq=null},queryCh anged:function(){this._remove();var query=this.query;if(!query){return}if(!this. full&&query[0]!=="("){query="("+query+")"}this._mq=window.matchMedia(query);this ._add();this.queryHandler(this._mq)},queryHandler:function(mq){this._setQueryMat ches(mq.matches)}});Polymer.PaperSpinnerBehavior={listeners:{animationend:"__res et",webkitAnimationEnd:"__reset"},properties:{active:{type:Boolean,value:false,r eflectToAttribute:true,observer:"__activeChanged"},alt:{type:String,value:"loadi ng",observer:"__altChanged"},__coolingDown:{type:Boolean,value:false}},__compute ContainerClasses:function(active,coolingDown){return[active||coolingDown?"active ":"",coolingDown?"cooldown":""].join(" ")},__activeChanged:function(active,old){ this.__setAriaHidden(!active);this.__coolingDown=!active&&old},__altChanged:func tion(alt){if(alt===this.getPropertyInfo("alt").value){this.alt=this.getAttribute ("aria-label")||alt}else{this.__setAriaHidden(alt==="");this.setAttribute("aria- label",alt)}},__setAriaHidden:function(hidden){var attr="aria-hidden";if(hidden) {this.setAttribute(attr,"true")}else{this.removeAttribute(attr)}},__reset:functi on(){this.active=false;this.__coolingDown=false}};Polymer({is:"paper-spinner-lit e",behaviors:[Polymer.PaperSpinnerBehavior]}); 47 type:Object},restoreFocusOnClose:{type:Boolean,value:false},alwaysOnTop:{type:Bo olean},_manager:{type:Object,value:Polymer.IronOverlayManager},_focusedChild:{ty pe:Object}},listeners:{"iron-resize":"_onIronResize"},get backdropElement(){retu rn this._manager.backdropElement},get _focusNode(){return this._focusedChild||Po lymer.dom(this).querySelector("[autofocus]")||this},get _focusableNodes(){var FO CUSABLE_WITH_DISABLED=["a[href]","area[href]","iframe","[tabindex]","[contentEdi table=true]"];var FOCUSABLE_WITHOUT_DISABLED=["input","select","textarea","butto n"];var selector=FOCUSABLE_WITH_DISABLED.join(':not([tabindex="-1"]),')+':not([t abindex="-1"]),'+FOCUSABLE_WITHOUT_DISABLED.join(':not([disabled]):not([tabindex ="-1"]),')+':not([disabled]):not([tabindex="-1"])';var focusables=Polymer.dom(th is).querySelectorAll(selector);if(this.tabIndex>=0){focusables.splice(0,0,this)} return focusables.sort(function(a,b){if(a.tabIndex===b.tabIndex){return 0}if(a.t abIndex===0||a.tabIndex>b.tabIndex){return 1}return-1})},ready:function(){this._ _isAnimating=false;this.__shouldRemoveTabIndex=false;this.__firstFocusableNode=t his.__lastFocusableNode=null;this.__raf=null;this.__restoreFocusNode=null;this._ ensureSetup()},attached:function(){if(this.opened){this._openedChanged(this.open ed)}this._observer=Polymer.dom(this).observeNodes(this._onNodesChange)},detached :function(){Polymer.dom(this).unobserveNodes(this._observer);this._observer=null ;if(this.__raf){window.cancelAnimationFrame(this.__raf);this.__raf=null}this._ma nager.removeOverlay(this)},toggle:function(){this._setCanceled(false);this.opene d=!this.opened},open:function(){this._setCanceled(false);this.opened=true},close :function(){this._setCanceled(false);this.opened=false},cancel:function(event){v ar cancelEvent=this.fire("iron-overlay-canceled",event,{cancelable:true});if(can celEvent.defaultPrevented){return}this._setCanceled(true);this.opened=false},_en sureSetup:function(){if(this._overlaySetup){return}this._overlaySetup=true;this. style.outline="none";this.style.display="none"},_openedChanged:function(opened){ if(opened){this.removeAttribute("aria-hidden")}else{this.setAttribute("aria-hidd en","true")}if(!this.isAttached){return}this.__isAnimating=true;this.__onNextAni mationFrame(this.__openedChanged)},_canceledChanged:function(){this.closingReaso n=this.closingReason||{};this.closingReason.canceled=this.canceled},_withBackdro pChanged:function(){if(this.withBackdrop&&!this.hasAttribute("tabindex")){this.s etAttribute("tabindex","-1");this.__shouldRemoveTabIndex=true}else if(this.__sho uldRemoveTabIndex){this.removeAttribute("tabindex");this.__shouldRemoveTabIndex= false}if(this.opened&&this.isAttached){this._manager.trackBackdrop()}},_prepareR enderOpened:function(){this.__restoreFocusNode=this._manager.deepActiveElement;t his._preparePositioning();this.refit();this._finishPositioning();if(this.noAutoF ocus&&document.activeElement===this._focusNode){this._focusNode.blur();this.__re storeFocusNode.focus()}},_renderOpened:function(){this._finishRenderOpened()},_r enderClosed:function(){this._finishRenderClosed()},_finishRenderOpened:function( ){this.notifyResize();this.__isAnimating=false;var focusableNodes=this._focusabl eNodes;this.__firstFocusableNode=focusableNodes[0];this.__lastFocusableNode=focu sableNodes[focusableNodes.length-1];this.fire("iron-overlay-opened")},_finishRen derClosed:function(){this.style.display="none";this.style.zIndex="";this.notifyR esize();this.__isAnimating=false;this.fire("iron-overlay-closed",this.closingRea son)},_preparePositioning:function(){this.style.transition=this.style.webkitTran sition="none";this.style.transform=this.style.webkitTransform="none";this.style. display=""},_finishPositioning:function(){this.style.display="none";this.scrollT op=this.scrollTop;this.style.transition=this.style.webkitTransition="";this.styl e.transform=this.style.webkitTransform="";this.style.display="";this.scrollTop=t his.scrollTop},_applyFocus:function(){if(this.opened){if(!this.noAutoFocus){this ._focusNode.focus()}}else{this._focusNode.blur();this._focusedChild=null;if(this .restoreFocusOnClose&&this.__restoreFocusNode){this.__restoreFocusNode.focus()}t his.__restoreFocusNode=null;var currentOverlay=this._manager.currentOverlay();if (currentOverlay&&this!==currentOverlay){currentOverlay._applyFocus()}}},_onCaptu reClick:function(event){if(!this.noCancelOnOutsideClick){this.cancel(event)}},_o nCaptureFocus:function(event){if(!this.withBackdrop){return}var path=Polymer.dom (event).path;if(path.indexOf(this)===-1){event.stopPropagation();this._applyFocu s()}else{this._focusedChild=path[0]}},_onCaptureEsc:function(event){if(!this.noC ancelOnEscKey){this.cancel(event)}},_onCaptureTab:function(event){if(!this.withB ackdrop){return}var shift=event.shiftKey;var nodeToCheck=shift?this.__firstFocus ableNode:this.__lastFocusableNode;var nodeToSet=shift?this.__lastFocusableNode:t his.__firstFocusableNode;var shouldWrap=false;if(nodeToCheck===nodeToSet){should Wrap=true}else{var focusedNode=this._manager.deepActiveElement;shouldWrap=focuse dNode===nodeToCheck||focusedNode===this}if(shouldWrap){event.preventDefault();th is._focusedChild=nodeToSet;this._applyFocus()}},_onIronResize:function(){if(this .opened&&!this.__isAnimating){this.__onNextAnimationFrame(this.refit)}},_onNodes Change:function(){if(this.opened&&!this.__isAnimating){this.notifyResize()}},__o penedChanged:function(){if(this.opened){this._prepareRenderOpened();this._manage r.addOverlay(this);this._applyFocus();this._renderOpened()}else{this._manager.re moveOverlay(this);this._applyFocus();this._renderClosed()}},__onNextAnimationFra me:function(callback){if(this.__raf){window.cancelAnimationFrame(this.__raf)}var self=this;this.__raf=window.requestAnimationFrame(function nextAnimationFrame() {self.__raf=null;callback.call(self)})}};Polymer.IronOverlayBehavior=[Polymer.Ir onFitBehavior,Polymer.IronResizableBehavior,Polymer.IronOverlayBehaviorImpl]})() ;Polymer.NeonAnimatableBehavior={properties:{animationConfig:{type:Object},entry Animation:{observer:"_entryAnimationChanged",type:String},exitAnimation:{observe r:"_exitAnimationChanged",type:String}},_entryAnimationChanged:function(){this.a nimationConfig=this.animationConfig||{};this.animationConfig["entry"]=[{name:thi s.entryAnimation,node:this}]},_exitAnimationChanged:function(){this.animationCon fig=this.animationConfig||{};this.animationConfig["exit"]=[{name:this.exitAnimat ion,node:this}]},_copyProperties:function(config1,config2){for(var property in c onfig2){config1[property]=config2[property]}},_cloneConfig:function(config){var clone={isClone:true};this._copyProperties(clone,config);return clone},_getAnimat ionConfigRecursive:function(type,map,allConfigs){if(!this.animationConfig){retur n}if(this.animationConfig.value&&typeof this.animationConfig.value==="function") {this._warn(this._logf("playAnimation","Please put 'animationConfig' inside of y our components 'properties' object instead of outside of it."));return}var thisC onfig;if(type){thisConfig=this.animationConfig[type]}else{thisConfig=this.animat ionConfig}if(!Array.isArray(thisConfig)){thisConfig=[thisConfig]}if(thisConfig){ for(var config,index=0;config=thisConfig[index];index++){if(config.animatable){c onfig.animatable._getAnimationConfigRecursive(config.type||type,map,allConfigs)} else{if(config.id){var cachedConfig=map[config.id];if(cachedConfig){if(!cachedCo nfig.isClone){map[config.id]=this._cloneConfig(cachedConfig);cachedConfig=map[co nfig.id]}this._copyProperties(cachedConfig,config)}else{map[config.id]=config}}e lse{allConfigs.push(config)}}}}},getAnimationConfig:function(type){var map={};va r allConfigs=[];this._getAnimationConfigRecursive(type,map,allConfigs);for(var k ey in map){allConfigs.push(map[key])}return allConfigs}};Polymer.NeonAnimationRu nnerBehaviorImpl={_configureAnimations:function(configs){var results=[];if(confi gs.length>0){for(var config,index=0;config=configs[index];index++){var neonAnima tion=document.createElement(config.name);if(neonAnimation.isNeonAnimation){var r esult=null;try{result=neonAnimation.configure(config);if(typeof result.cancel!=" function"){result=document.timeline.play(result)}}catch(e){result=null;console.w arn("Couldnt play","(",config.name,").",e)}if(result){results.push({neonAnimatio n:neonAnimation,config:config,animation:result})}}else{console.warn(this.is+":", config.name,"not found!")}}}return results},_shouldComplete:function(activeEntri es){var finished=true;for(var i=0;i<activeEntries.length;i++){if(activeEntries[i ].animation.playState!="finished"){finished=false;break}}return finished},_compl ete:function(activeEntries){for(var i=0;i<activeEntries.length;i++){activeEntrie s[i].neonAnimation.complete(activeEntries[i].config)}for(var i=0;i<activeEntries .length;i++){activeEntries[i].animation.cancel()}},playAnimation:function(type,c ookie){var configs=this.getAnimationConfig(type);if(!configs){return}this._activ e=this._active||{};if(this._active[type]){this._complete(this._active[type]);del ete this._active[type]}var activeEntries=this._configureAnimations(configs);if(a ctiveEntries.length==0){this.fire("neon-animation-finish",cookie,{bubbles:false} );return}this._active[type]=activeEntries;for(var i=0;i<activeEntries.length;i++ ){activeEntries[i].animation.onfinish=function(){if(this._shouldComplete(activeE ntries)){this._complete(activeEntries);delete this._active[type];this.fire("neon -animation-finish",cookie,{bubbles:false})}}.bind(this)}},cancelAnimation:functi on(){for(var k in this._animations){this._animations[k].cancel()}this._animation s={}}};Polymer.NeonAnimationRunnerBehavior=[Polymer.NeonAnimatableBehavior,Polym er.NeonAnimationRunnerBehaviorImpl];Polymer.NeonAnimationBehavior={properties:{a nimationTiming:{type:Object,value:function(){return{duration:500,easing:"cubic-b ezier(0.4, 0, 0.2, 1)",fill:"both"}}}},isNeonAnimation:true,timingFromConfig:fun ction(config){if(config.timing){for(var property in config.timing){this.animatio nTiming[property]=config.timing[property]}}return this.animationTiming},setPrefi xedProperty:function(node,property,value){var map={transform:["webkitTransform"] ,transformOrigin:["mozTransformOrigin","webkitTransformOrigin"]};var prefixes=ma p[property];for(var prefix,index=0;prefix=prefixes[index];index++){node.style[pr efix]=value}node.style[property]=value},complete:function(){}};Polymer({is:"opaq ue-animation",behaviors:[Polymer.NeonAnimationBehavior],configure:function(confi g){var node=config.node;this._effect=new KeyframeEffect(node,[{opacity:"1"},{opa city:"1"}],this.timingFromConfig(config));node.style.opacity="0";return this._ef fect},complete:function(config){config.node.style.opacity=""}});(function(){"use strict";var LAST_TOUCH_POSITION={pageX:0,pageY:0};var ROOT_TARGET=null;var SCRO LLABLE_NODES=[];Polymer.IronDropdownScrollManager={get currentLockingElement(){r eturn this._lockingElements[this._lockingElements.length-1]},elementIsScrollLock ed:function(element){var currentLockingElement=this.currentLockingElement;if(cur rentLockingElement===undefined)return false;var scrollLocked;if(this._hasCachedL ockedElement(element)){return true}if(this._hasCachedUnlockedElement(element)){r eturn false}scrollLocked=!!currentLockingElement&&currentLockingElement!==elemen t&&!this._composedTreeContains(currentLockingElement,element);if(scrollLocked){t his._lockedElementCache.push(element)}else{this._unlockedElementCache.push(eleme nt)}return scrollLocked},pushScrollLock:function(element){if(this._lockingElemen ts.indexOf(element)>=0){return}if(this._lockingElements.length===0){this._lockSc rollInteractions()}this._lockingElements.push(element);this._lockedElementCache= [];this._unlockedElementCache=[]},removeScrollLock:function(element){var index=t his._lockingElements.indexOf(element);if(index===-1){return}this._lockingElement s.splice(index,1);this._lockedElementCache=[];this._unlockedElementCache=[];if(t his._lockingElements.length===0){this._unlockScrollInteractions()}},_lockingElem ents:[],_lockedElementCache:null,_unlockedElementCache:null,_hasCachedLockedElem ent:function(element){return this._lockedElementCache.indexOf(element)>-1},_hasC achedUnlockedElement:function(element){return this._unlockedElementCache.indexOf (element)>-1},_composedTreeContains:function(element,child){var contentElements; var distributedNodes;var contentIndex;var nodeIndex;if(element.contains(child)){ return true}contentElements=Polymer.dom(element).querySelectorAll("content");for (contentIndex=0;contentIndex<contentElements.length;++contentIndex){distributedN odes=Polymer.dom(contentElements[contentIndex]).getDistributedNodes();for(nodeIn dex=0;nodeIndex<distributedNodes.length;++nodeIndex){if(this._composedTreeContai ns(distributedNodes[nodeIndex],child)){return true}}}return false},_scrollIntera ctionHandler:function(event){if(event.cancelable&&this._shouldPreventScrolling(e vent)){event.preventDefault()}if(event.targetTouches){var touch=event.targetTouc hes[0];LAST_TOUCH_POSITION.pageX=touch.pageX;LAST_TOUCH_POSITION.pageY=touch.pag eY}},_lockScrollInteractions:function(){this._boundScrollHandler=this._boundScro llHandler||this._scrollInteractionHandler.bind(this);document.addEventListener(" wheel",this._boundScrollHandler,true);document.addEventListener("mousewheel",thi s._boundScrollHandler,true);document.addEventListener("DOMMouseScroll",this._bou ndScrollHandler,true);document.addEventListener("touchstart",this._boundScrollHa ndler,true);document.addEventListener("touchmove",this._boundScrollHandler,true) },_unlockScrollInteractions:function(){document.removeEventListener("wheel",this ._boundScrollHandler,true);document.removeEventListener("mousewheel",this._bound ScrollHandler,true);document.removeEventListener("DOMMouseScroll",this._boundScr ollHandler,true);document.removeEventListener("touchstart",this._boundScrollHand ler,true);document.removeEventListener("touchmove",this._boundScrollHandler,true )},_shouldPreventScrolling:function(event){var target=Polymer.dom(event).rootTar get;if(event.type!=="touchmove"&&ROOT_TARGET!==target){ROOT_TARGET=target;SCROLL ABLE_NODES=this._getScrollableNodes(Polymer.dom(event).path)}if(!SCROLLABLE_NODE S.length){return true}if(event.type==="touchstart"){return false}var info=this._ getScrollInfo(event);return!this._getScrollingNode(SCROLLABLE_NODES,info.deltaX, info.deltaY)},_getScrollableNodes:function(nodes){var scrollables=[];var locking Index=nodes.indexOf(this.currentLockingElement);for(var i=0;i<=lockingIndex;i++) {var node=nodes[i];if(node.nodeType===11){continue}var style=node.style;if(style .overflow!=="scroll"&&style.overflow!=="auto"){style=window.getComputedStyle(nod e)}if(style.overflow==="scroll"||style.overflow==="auto"){scrollables.push(node) }}return scrollables},_getScrollingNode:function(nodes,deltaX,deltaY){if(!deltaX &&!deltaY){return}var verticalScroll=Math.abs(deltaY)>=Math.abs(deltaX);for(var i=0;i<nodes.length;i++){var node=nodes[i];var canScroll=false;if(verticalScroll) {canScroll=deltaY<0?node.scrollTop>0:node.scrollTop<node.scrollHeight-node.clien tHeight}else{canScroll=deltaX<0?node.scrollLeft>0:node.scrollLeft<node.scrollWid th-node.clientWidth}if(canScroll){return node}}},_getScrollInfo:function(event){ var info={deltaX:event.deltaX,deltaY:event.deltaY};if("deltaX"in event){}else if ("wheelDeltaX"in event){info.deltaX=-event.wheelDeltaX;info.deltaY=-event.wheelD eltaY}else if("axis"in event){info.deltaX=event.axis===1?event.detail:0;info.del taY=event.axis===2?event.detail:0}else if(event.targetTouches){var touch=event.t argetTouches[0];info.deltaX=LAST_TOUCH_POSITION.pageX-touch.pageX;info.deltaY=LA ST_TOUCH_POSITION.pageY-touch.pageY}return info}}})();(function(){"use strict";P olymer({is:"iron-dropdown",behaviors:[Polymer.IronControlState,Polymer.IronA11yK eysBehavior,Polymer.IronOverlayBehavior,Polymer.NeonAnimationRunnerBehavior],pro perties:{horizontalAlign:{type:String,value:"left",reflectToAttribute:true},vert icalAlign:{type:String,value:"top",reflectToAttribute:true},openAnimationConfig: {type:Object},closeAnimationConfig:{type:Object},focusTarget:{type:Object},noAni mations:{type:Boolean,value:false},allowOutsideScroll:{type:Boolean,value:false} ,_boundOnCaptureScroll:{type:Function,value:function(){return this._onCaptureScr oll.bind(this)}}},listeners:{"neon-animation-finish":"_onNeonAnimationFinish"},o bservers:["_updateOverlayPosition(positionTarget, verticalAlign, horizontalAlign , verticalOffset, horizontalOffset)"],get containedElement(){return Polymer.dom( this.$.content).getDistributedNodes()[0]},get _focusTarget(){return this.focusTa rget||this.containedElement},ready:function(){this._scrollTop=0;this._scrollLeft =0;this._refitOnScrollRAF=null},attached:function(){if(!this.sizingTarget||this. sizingTarget===this){this.sizingTarget=this.containedElement}},detached:function (){this.cancelAnimation();document.removeEventListener("scroll",this._boundOnCap tureScroll);Polymer.IronDropdownScrollManager.removeScrollLock(this)},_openedCha nged:function(){if(this.opened&&this.disabled){this.cancel()}else{this.cancelAni mation();this._updateAnimationConfig();this._saveScrollPosition();if(this.opened ){document.addEventListener("scroll",this._boundOnCaptureScroll);!this.allowOuts ideScroll&&Polymer.IronDropdownScrollManager.pushScrollLock(this)}else{document. removeEventListener("scroll",this._boundOnCaptureScroll);Polymer.IronDropdownScr ollManager.removeScrollLock(this)}Polymer.IronOverlayBehaviorImpl._openedChanged .apply(this,arguments)}},_renderOpened:function(){if(!this.noAnimations&&this.an imationConfig.open){this.$.contentWrapper.classList.add("animating");this.playAn imation("open")}else{Polymer.IronOverlayBehaviorImpl._renderOpened.apply(this,ar guments)}},_renderClosed:function(){if(!this.noAnimations&&this.animationConfig. close){this.$.contentWrapper.classList.add("animating");this.playAnimation("clos e")}else{Polymer.IronOverlayBehaviorImpl._renderClosed.apply(this,arguments)}},_ onNeonAnimationFinish:function(){this.$.contentWrapper.classList.remove("animati ng");if(this.opened){this._finishRenderOpened()}else{this._finishRenderClosed()} },_onCaptureScroll:function(){if(!this.allowOutsideScroll){this._restoreScrollPo sition()}else{this._refitOnScrollRAF&&window.cancelAnimationFrame(this._refitOnS crollRAF);this._refitOnScrollRAF=window.requestAnimationFrame(this.refit.bind(th is))}},_saveScrollPosition:function(){if(document.scrollingElement){this._scroll Top=document.scrollingElement.scrollTop;this._scrollLeft=document.scrollingEleme nt.scrollLeft}else{this._scrollTop=Math.max(document.documentElement.scrollTop,d ocument.body.scrollTop);this._scrollLeft=Math.max(document.documentElement.scrol lLeft,document.body.scrollLeft)}},_restoreScrollPosition:function(){if(document. scrollingElement){document.scrollingElement.scrollTop=this._scrollTop;document.s crollingElement.scrollLeft=this._scrollLeft}else{document.documentElement.scroll Top=this._scrollTop;document.documentElement.scrollLeft=this._scrollLeft;documen t.body.scrollTop=this._scrollTop;document.body.scrollLeft=this._scrollLeft}},_up dateAnimationConfig:function(){var animations=(this.openAnimationConfig||[]).con cat(this.closeAnimationConfig||[]);for(var i=0;i<animations.length;i++){animatio ns[i].node=this.containedElement}this.animationConfig={open:this.openAnimationCo nfig,close:this.closeAnimationConfig}},_updateOverlayPosition:function(){if(this .isAttached){this.notifyResize()}},_applyFocus:function(){var focusTarget=this.f ocusTarget||this.containedElement;if(focusTarget&&this.opened&&!this.noAutoFocus ){focusTarget.focus()}else{Polymer.IronOverlayBehaviorImpl._applyFocus.apply(thi s,arguments)}}})})();Polymer({is:"fade-in-animation",behaviors:[Polymer.NeonAnim ationBehavior],configure:function(config){var node=config.node;this._effect=new KeyframeEffect(node,[{opacity:"0"},{opacity:"1"}],this.timingFromConfig(config)) ;return this._effect}});Polymer({is:"fade-out-animation",behaviors:[Polymer.Neon AnimationBehavior],configure:function(config){var node=config.node;this._effect= new KeyframeEffect(node,[{opacity:"1"},{opacity:"0"}],this.timingFromConfig(conf ig));return this._effect}});Polymer({is:"paper-menu-grow-height-animation",behav iors:[Polymer.NeonAnimationBehavior],configure:function(config){var node=config. node;var rect=node.getBoundingClientRect();var height=rect.height;this._effect=n ew KeyframeEffect(node,[{height:height/2+"px"},{height:height+"px"}],this.timing FromConfig(config));return this._effect}});Polymer({is:"paper-menu-grow-width-an imation",behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){va r node=config.node;var rect=node.getBoundingClientRect();var width=rect.width;th is._effect=new KeyframeEffect(node,[{width:width/2+"px"},{width:width+"px"}],thi s.timingFromConfig(config));return this._effect}});Polymer({is:"paper-menu-shrin k-width-animation",behaviors:[Polymer.NeonAnimationBehavior],configure:function( config){var node=config.node;var rect=node.getBoundingClientRect();var width=rec t.width;this._effect=new KeyframeEffect(node,[{width:width+"px"},{width:width-wi dth/20+"px"}],this.timingFromConfig(config));return this._effect}});Polymer({is: "paper-menu-shrink-height-animation",behaviors:[Polymer.NeonAnimationBehavior],c onfigure:function(config){var node=config.node;var rect=node.getBoundingClientRe ct();var height=rect.height;var top=rect.top;this.setPrefixedProperty(node,"tran sformOrigin","0 0");this._effect=new KeyframeEffect(node,[{height:height+"px",tr ansform:"translateY(0)"},{height:height/2+"px",transform:"translateY(-20px)"}],t his.timingFromConfig(config));return this._effect}});(function(){"use strict";va r config={ANIMATION_CUBIC_BEZIER:"cubic-bezier(.3,.95,.5,1)",MAX_ANIMATION_TIME_ MS:400};var PaperMenuButton=Polymer({is:"paper-menu-button",behaviors:[Polymer.I ronA11yKeysBehavior,Polymer.IronControlState],properties:{opened:{type:Boolean,v alue:false,notify:true,observer:"_openedChanged"},horizontalAlign:{type:String,v alue:"left",reflectToAttribute:true},verticalAlign:{type:String,value:"top",refl ectToAttribute:true},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,v alue:0,notify:true},verticalOffset:{type:Number,value:0,notify:true},noOverlap:{ type:Boolean},noAnimations:{type:Boolean,value:false},ignoreSelect:{type:Boolean ,value:false},closeOnActivate:{type:Boolean,value:false},openAnimationConfig:{ty pe:Object,value:function(){return[{name:"fade-in-animation",timing:{delay:100,du ration:200}},{name:"paper-menu-grow-width-animation",timing:{delay:100,duration: 150,easing:config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-grow-height-animati on",timing:{delay:100,duration:275,easing:config.ANIMATION_CUBIC_BEZIER}}]}},clo seAnimationConfig:{type:Object,value:function(){return[{name:"fade-out-animation ",timing:{duration:150}},{name:"paper-menu-shrink-width-animation",timing:{delay :100,duration:50,easing:config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-shrink -height-animation",timing:{duration:200,easing:"ease-in"}}]}},allowOutsideScroll :{type:Boolean,value:false},restoreFocusOnClose:{type:Boolean,value:true},_dropd ownContent:{type:Object}},hostAttributes:{role:"group","aria-haspopup":"true"},l isteners:{"iron-activate":"_onIronActivate","iron-select":"_onIronSelect"},get c ontentElement(){return Polymer.dom(this.$.content).getDistributedNodes()[0]},tog gle:function(){if(this.opened){this.close()}else{this.open()}},open:function(){i f(this.disabled){return}this.$.dropdown.open()},close:function(){this.$.dropdown .close()},_onIronSelect:function(event){if(!this.ignoreSelect){this.close()}},_o nIronActivate:function(event){if(this.closeOnActivate){this.close()}},_openedCha nged:function(opened,oldOpened){if(opened){this._dropdownContent=this.contentEle ment;this.fire("paper-dropdown-open")}else if(oldOpened!=null){this.fire("paper- dropdown-close")}},_disabledChanged:function(disabled){Polymer.IronControlState. _disabledChanged.apply(this,arguments);if(disabled&&this.opened){this.close()}}, __onIronOverlayCanceled:function(event){var uiEvent=event.detail;var target=Poly mer.dom(uiEvent).rootTarget;var trigger=this.$.trigger;var path=Polymer.dom(uiEv ent).path;if(path.indexOf(trigger)>-1){event.preventDefault()}}});Object.keys(co nfig).forEach(function(key){PaperMenuButton[key]=config[key]});Polymer.PaperMenu Button=PaperMenuButton})();Polymer.PaperInkyFocusBehaviorImpl={observers:["_focu sedChanged(receivedFocusFromKeyboard)"],_focusedChanged:function(receivedFocusFr omKeyboard){if(receivedFocusFromKeyboard){this.ensureRipple()}if(this.hasRipple( )){this._ripple.holdDown=receivedFocusFromKeyboard}},_createRipple:function(){va r ripple=Polymer.PaperRippleBehavior._createRipple();ripple.id="ink";ripple.setA ttribute("center","");ripple.classList.add("circle");return ripple}};Polymer.Pap erInkyFocusBehavior=[Polymer.IronButtonState,Polymer.IronControlState,Polymer.Pa perRippleBehavior,Polymer.PaperInkyFocusBehaviorImpl];Polymer({is:"paper-icon-bu tton",hostAttributes:{role:"button",tabindex:"0"},behaviors:[Polymer.PaperInkyFo cusBehavior],properties:{src:{type:String},icon:{type:String},alt:{type:String,o bserver:"_altChanged"}},_altChanged:function(newValue,oldValue){var label=this.g etAttribute("aria-label");if(!label||oldValue==label){this.setAttribute("aria-la bel",newValue)}}});Polymer({is:"iron-media-query",properties:{queryMatches:{type :Boolean,value:false,readOnly:true,notify:true},query:{type:String,observer:"que ryChanged"},full:{type:Boolean,value:false},_boundMQHandler:{value:function(){re turn this.queryHandler.bind(this)}},_mq:{value:null}},attached:function(){this.s tyle.display="none";this.queryChanged()},detached:function(){this._remove()},_ad d:function(){if(this._mq){this._mq.addListener(this._boundMQHandler)}},_remove:f unction(){if(this._mq){this._mq.removeListener(this._boundMQHandler)}this._mq=nu ll},queryChanged:function(){this._remove();var query=this.query;if(!query){retur n}if(!this.full&&query[0]!=="("){query="("+query+")"}this._mq=window.matchMedia( query);this._add();this.queryHandler(this._mq)},queryHandler:function(mq){this._ setQueryMatches(mq.matches)}});Polymer.PaperSpinnerBehavior={listeners:{animatio nend:"__reset",webkitAnimationEnd:"__reset"},properties:{active:{type:Boolean,va lue:false,reflectToAttribute:true,observer:"__activeChanged"},alt:{type:String,v alue:"loading",observer:"__altChanged"},__coolingDown:{type:Boolean,value:false} },__computeContainerClasses:function(active,coolingDown){return[active||coolingD own?"active":"",coolingDown?"cooldown":""].join(" ")},__activeChanged:function(a ctive,old){this.__setAriaHidden(!active);this.__coolingDown=!active&&old},__altC hanged:function(alt){if(alt===this.getPropertyInfo("alt").value){this.alt=this.g etAttribute("aria-label")||alt}else{this.__setAriaHidden(alt==="");this.setAttri bute("aria-label",alt)}},__setAriaHidden:function(hidden){var attr="aria-hidden" ;if(hidden){this.setAttribute(attr,"true")}else{this.removeAttribute(attr)}},__r eset:function(){this.active=false;this.__coolingDown=false}};Polymer({is:"paper- spinner-lite",behaviors:[Polymer.PaperSpinnerBehavior]});
48 // Copyright 2016 The Chromium Authors. All rights reserved. 48 // Copyright 2016 The Chromium Authors. All rights reserved.
49 // Use of this source code is governed by a BSD-style license that can be 49 // Use of this source code is governed by a BSD-style license that can be
50 // found in the LICENSE file. 50 // found in the LICENSE file.
51 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{ type:String,value:""},showingSearch:{type:Boolean,value:false,notify:true,observ er:"showingSearchChanged_",reflectToAttribute:true},lastValue_:{type:String,valu e:""}},getSearchInput:function(){},getValue:function(){return this.getSearchInpu t().value},setValue:function(value,opt_noEvent){var searchInput=this.getSearchIn put();searchInput.value=value;if(searchInput.bindValue!=undefined)searchInput.bi ndValue=value;this.onValueChanged_(value,!!opt_noEvent)},showAndFocus:function() {this.showingSearch=true;this.focus_()},focus_:function(){this.getSearchInput(). focus()},onSearchTermSearch:function(){this.onValueChanged_(this.getValue(),fals e)},onValueChanged_:function(newValue,noEvent){if(newValue==this.lastValue_)retu rn;this.lastValue_=newValue;if(!noEvent)this.fire("search-changed",newValue)},on SearchTermKeydown:function(e){if(e.key=="Escape")this.showingSearch=false},showi ngSearchChanged_:function(current,previous){if(previous==undefined)return;if(thi s.showingSearch){this.focus_();return}this.setValue("");this.getSearchInput().bl ur()}}; 51 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{ type:String,value:""},showingSearch:{type:Boolean,value:false,notify:true,observ er:"showingSearchChanged_",reflectToAttribute:true},lastValue_:{type:String,valu e:""}},getSearchInput:function(){},getValue:function(){return this.getSearchInpu t().value},setValue:function(value,opt_noEvent){var searchInput=this.getSearchIn put();searchInput.value=value;if(searchInput.bindValue!=undefined)searchInput.bi ndValue=value;this.onValueChanged_(value,!!opt_noEvent)},showAndFocus:function() {this.showingSearch=true;this.focus_()},focus_:function(){this.getSearchInput(). focus()},onSearchTermSearch:function(){this.onValueChanged_(this.getValue(),fals e)},onValueChanged_:function(newValue,noEvent){if(newValue==this.lastValue_)retu rn;this.lastValue_=newValue;if(!noEvent)this.fire("search-changed",newValue)},on SearchTermKeydown:function(e){if(e.key=="Escape")this.showingSearch=false},showi ngSearchChanged_:function(current,previous){if(previous==undefined)return;if(thi s.showingSearch){this.focus_();return}this.setValue("");this.getSearchInput().bl ur()}};
52 // Copyright 2016 The Chromium Authors. All rights reserved. 52 // Copyright 2016 The Chromium Authors. All rights reserved.
53 // Use of this source code is governed by a BSD-style license that can be 53 // Use of this source code is governed by a BSD-style license that can be
54 // found in the LICENSE file. 54 // found in the LICENSE file.
55 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti es:{narrow:{type:Boolean,reflectToAttribute:true},label:String,clearLabel:String ,spinnerActive:{type:Boolean,reflectToAttribute:true},hasSearchText_:{type:Boole an,reflectToAttribute:true},isSpinnerShown_:{type:Boolean,computed:"computeIsSpi nnerShown_(spinnerActive, showingSearch)"},searchFocused_:{type:Boolean,value:fa lse}},listeners:{tap:"showSearch_"},getSearchInput:function(){return this.$.sear chInput},setValue:function(value,opt_noEvent){CrSearchFieldBehavior.setValue.cal l(this,value,opt_noEvent);this.onSearchInput_()},isSearchFocused:function(){retu rn this.searchFocused_},computeIconTabIndex_:function(narrow){return narrow?0:-1 },computeIsSpinnerShown_:function(){return this.spinnerActive&&this.showingSearc h},onInputFocus_:function(){this.searchFocused_=true},onInputBlur_:function(){th is.searchFocused_=false;if(!this.hasSearchText_)this.showingSearch=false},onSear chInput_:function(){var newValue=this.$.searchInput.value;this.hasSearchText_=ne wValue!="";if(newValue!="")this.showingSearch=true},showSearch_:function(e){if(e .target!=this.$.clearSearch)this.showingSearch=true},clearSearch_:function(e){th is.setValue("");this.getSearchInput().focus()}}); 55 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti es:{narrow:{type:Boolean,reflectToAttribute:true},label:String,clearLabel:String ,spinnerActive:{type:Boolean,reflectToAttribute:true},hasSearchText_:{type:Boole an,reflectToAttribute:true},isSpinnerShown_:{type:Boolean,computed:"computeIsSpi nnerShown_(spinnerActive, showingSearch)"},searchFocused_:{type:Boolean,value:fa lse}},listeners:{tap:"showSearch_"},getSearchInput:function(){return this.$.sear chInput},setValue:function(value,opt_noEvent){CrSearchFieldBehavior.setValue.cal l(this,value,opt_noEvent);this.onSearchInput_()},isSearchFocused:function(){retu rn this.searchFocused_},computeIconTabIndex_:function(narrow){return narrow?0:-1 },computeIsSpinnerShown_:function(){return this.spinnerActive&&this.showingSearc h},onInputFocus_:function(){this.searchFocused_=true},onInputBlur_:function(){th is.searchFocused_=false;if(!this.hasSearchText_)this.showingSearch=false},onSear chInput_:function(){var newValue=this.$.searchInput.value;this.hasSearchText_=ne wValue!="";if(newValue!="")this.showingSearch=true},showSearch_:function(e){if(e .target!=this.$.clearSearch)this.showingSearch=true},clearSearch_:function(e){th is.setValue("");this.getSearchInput().focus()}});
56 // Copyright 2016 The Chromium Authors. All rights reserved. 56 // Copyright 2016 The Chromium Authors. All rights reserved.
57 // Use of this source code is governed by a BSD-style license that can be 57 // Use of this source code is governed by a BSD-style license that can be
58 // found in the LICENSE file. 58 // found in the LICENSE file.
59 Polymer({is:"cr-toolbar",properties:{pageName:String,searchPrompt:String,clearLa bel:String,menuLabel:String,menuPromo:String,spinnerActive:Boolean,showMenu:{typ e:Boolean,value:false},showMenuPromo:{type:Boolean,value:false},closeMenuPromo:S tring,narrow_:{type:Boolean,reflectToAttribute:true},showingSearch_:{type:Boolea n,reflectToAttribute:true}},observers:["possiblyShowMenuPromo_(showMenu, showMen uPromo, showingSearch_)"],getSearchField:function(){return this.$.search},onClos ePromoTap_:function(){this.fire("cr-toolbar-menu-promo-close")},onMenuTap_:funct ion(){this.fire("cr-toolbar-menu-tap")},possiblyShowMenuPromo_:function(){Polyme r.RenderStatus.afterNextRender(this,function(){if(this.showMenu&&this.showMenuPr omo&&!this.showingSearch_){this.$$("#menuPromo").animate({opacity:[0,.9]},{durat ion:500,fill:"forwards"});this.fire("cr-toolbar-menu-promo-shown")}}.bind(this)) },titleIfNotShowMenuPromo_:function(title,showMenuPromo){return showMenuPromo?"" :title}}); 59 Polymer({is:"cr-toolbar",properties:{pageName:String,searchPrompt:String,clearLa bel:String,menuLabel:String,menuPromo:String,spinnerActive:Boolean,showMenu:{typ e:Boolean,value:false},showMenuPromo:{type:Boolean,value:false},closeMenuPromo:S tring,narrow_:{type:Boolean,reflectToAttribute:true},showingSearch_:{type:Boolea n,reflectToAttribute:true}},observers:["possiblyShowMenuPromo_(showMenu, showMen uPromo, showingSearch_)"],getSearchField:function(){return this.$.search},onClos ePromoTap_:function(){this.fire("cr-toolbar-menu-promo-close")},onMenuTap_:funct ion(){this.fire("cr-toolbar-menu-tap")},possiblyShowMenuPromo_:function(){Polyme r.RenderStatus.afterNextRender(this,function(){if(this.showMenu&&this.showMenuPr omo&&!this.showingSearch_){this.$$("#menuPromo").animate({opacity:[0,.9]},{durat ion:500,fill:"forwards"});this.fire("cr-toolbar-menu-promo-shown")}}.bind(this)) },titleIfNotShowMenuPromo_:function(title,showMenuPromo){return showMenuPromo?"" :title}});
60 // Copyright 2015 The Chromium Authors. All rights reserved. 60 // Copyright 2015 The Chromium Authors. All rights reserved.
61 // Use of this source code is governed by a BSD-style license that can be 61 // Use of this source code is governed by a BSD-style license that can be
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
« no previous file with comments | « chrome/browser/resources/md_downloads/compiled_resources2.gyp ('k') | chrome/browser/resources/md_downloads/item.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698