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

Side by Side Diff: chrome/browser/resources/md_history/lazy_load.crisper.js

Issue 2597573002: MD History/Downloads: convert .bind(this) and function property values to use => (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 Polymer({is:"iron-collapse",behaviors:[Polymer.IronResizableBehavior],properties :{horizontal:{type:Boolean,value:false,observer:"_horizontalChanged"},opened:{ty pe:Boolean,value:false,notify:true,observer:"_openedChanged"},noAnimation:{type: Boolean},_desiredSize:{type:String,value:""}},get dimension(){return this.horizo ntal?"width":"height"},get _dimensionMax(){return this.horizontal?"maxWidth":"ma xHeight"},get _dimensionMaxCss(){return this.horizontal?"max-width":"max-height" },hostAttributes:{role:"group","aria-hidden":"true","aria-expanded":"false"},lis teners:{transitionend:"_transitionEnd"},attached:function(){this._transitionEnd( )},toggle:function(){this.opened=!this.opened},show:function(){this.opened=true} ,hide:function(){this.opened=false},updateSize:function(size,animated){size=size ==="auto"?"":size;if(this._desiredSize===size){return}this._desiredSize=size;thi s._updateTransition(false);var willAnimate=animated&&!this.noAnimation&&this._is Displayed;if(willAnimate){var startSize=this._calcSize();if(size===""){this.styl e[this._dimensionMax]="";size=this._calcSize()}this.style[this._dimensionMax]=st artSize;this.scrollTop=this.scrollTop;this._updateTransition(true);willAnimate=s ize!==startSize}this.style[this._dimensionMax]=size;if(!willAnimate){this._trans itionEnd()}},enableTransition:function(enabled){Polymer.Base._warn("`enableTrans ition()` is deprecated, use `noAnimation` instead.");this.noAnimation=!enabled}, _updateTransition:function(enabled){this.style.transitionDuration=enabled&&!this .noAnimation?"":"0s"},_horizontalChanged:function(){this.style.transitionPropert y=this._dimensionMaxCss;var otherDimension=this._dimensionMax==="maxWidth"?"maxH eight":"maxWidth";this.style[otherDimension]="";this.updateSize(this.opened?"aut o":"0px",false)},_openedChanged:function(){this.setAttribute("aria-expanded",thi s.opened);this.setAttribute("aria-hidden",!this.opened);this.toggleClass("iron-c ollapse-closed",false);this.toggleClass("iron-collapse-opened",false);this.updat eSize(this.opened?"auto":"0px",true);if(this.opened){this.focus()}},_transitionE nd:function(){this.style[this._dimensionMax]=this._desiredSize;this.toggleClass( "iron-collapse-closed",!this.opened);this.toggleClass("iron-collapse-opened",thi s.opened);this._updateTransition(false);this.notifyResize()},get _isDisplayed(){ var rect=this.getBoundingClientRect();for(var prop in rect){if(rect[prop]!==0)re turn true}return false},_calcSize:function(){return this.getBoundingClientRect() [this.dimension]+"px"}}); 1 Polymer({is:"iron-collapse",behaviors:[Polymer.IronResizableBehavior],properties :{horizontal:{type:Boolean,value:false,observer:"_horizontalChanged"},opened:{ty pe:Boolean,value:false,notify:true,observer:"_openedChanged"},noAnimation:{type: Boolean},_desiredSize:{type:String,value:""}},get dimension(){return this.horizo ntal?"width":"height"},get _dimensionMax(){return this.horizontal?"maxWidth":"ma xHeight"},get _dimensionMaxCss(){return this.horizontal?"max-width":"max-height" },hostAttributes:{role:"group","aria-hidden":"true","aria-expanded":"false"},lis teners:{transitionend:"_transitionEnd"},attached:function(){this._transitionEnd( )},toggle:function(){this.opened=!this.opened},show:function(){this.opened=true} ,hide:function(){this.opened=false},updateSize:function(size,animated){size=size ==="auto"?"":size;if(this._desiredSize===size){return}this._desiredSize=size;thi s._updateTransition(false);var willAnimate=animated&&!this.noAnimation&&this._is Displayed;if(willAnimate){var startSize=this._calcSize();if(size===""){this.styl e[this._dimensionMax]="";size=this._calcSize()}this.style[this._dimensionMax]=st artSize;this.scrollTop=this.scrollTop;this._updateTransition(true);willAnimate=s ize!==startSize}this.style[this._dimensionMax]=size;if(!willAnimate){this._trans itionEnd()}},enableTransition:function(enabled){Polymer.Base._warn("`enableTrans ition()` is deprecated, use `noAnimation` instead.");this.noAnimation=!enabled}, _updateTransition:function(enabled){this.style.transitionDuration=enabled&&!this .noAnimation?"":"0s"},_horizontalChanged:function(){this.style.transitionPropert y=this._dimensionMaxCss;var otherDimension=this._dimensionMax==="maxWidth"?"maxH eight":"maxWidth";this.style[otherDimension]="";this.updateSize(this.opened?"aut o":"0px",false)},_openedChanged:function(){this.setAttribute("aria-expanded",thi s.opened);this.setAttribute("aria-hidden",!this.opened);this.toggleClass("iron-c ollapse-closed",false);this.toggleClass("iron-collapse-opened",false);this.updat eSize(this.opened?"auto":"0px",true);if(this.opened){this.focus()}},_transitionE nd:function(){this.style[this._dimensionMax]=this._desiredSize;this.toggleClass( "iron-collapse-closed",!this.opened);this.toggleClass("iron-collapse-opened",thi s.opened);this._updateTransition(false);this.notifyResize()},get _isDisplayed(){ var rect=this.getBoundingClientRect();for(var prop in rect){if(rect[prop]!==0)re turn true}return false},_calcSize:function(){return this.getBoundingClientRect() [this.dimension]+"px"}});
2 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Copyright 2016 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 var HistoryDomain;var HistoryGroup;Polymer({is:"history-grouped-list",behaviors: [HistoryListBehavior],properties:{historyData:{type:Array},groupedHistoryData_:{ type:Array},searchedTerm:{type:String,value:""},range:{type:Number},queryStartTi me:String,queryEndTime:String},observers:["updateGroupedHistoryData_(range, hist oryData)"],addNewResults:function(results,incremental,finished){this.historyData =results},createHistoryDomains_:function(visits){var domainIndexes={};var domain s=[];for(var i=0,visit;visit=visits[i];i++){var domain=visit.domain;if(domainInd exes[domain]==undefined){domainIndexes[domain]=domains.length;domains.push({doma in:domain,visits:[],expanded:false,rendered:false})}domains[domainIndexes[domain ]].visits.push(visit)}var sortByVisits=function(a,b){return b.visits.length-a.vi sits.length};domains.sort(sortByVisits);return domains},updateGroupedHistoryData _:function(){if(this.historyData.length==0){this.groupedHistoryData_=[];return}i f(this.range==HistoryRange.WEEK){var days=[];var currentDayVisits=[this.historyD ata[0]];var pushCurrentDay=function(){days.push({title:this.searchedTerm?current DayVisits[0].dateShort:currentDayVisits[0].dateRelativeDay,domains:this.createHi storyDomains_(currentDayVisits)})}.bind(this);var visitsSameDay=function(a,b){if (this.searchedTerm)return a.dateShort==b.dateShort;return a.dateRelativeDay==b.d ateRelativeDay}.bind(this);for(var i=1;i<this.historyData.length;i++){var visit= this.historyData[i];if(!visitsSameDay(visit,currentDayVisits[0])){pushCurrentDay ();currentDayVisits=[]}currentDayVisits.push(visit)}pushCurrentDay();this.groupe dHistoryData_=days}else if(this.range==HistoryRange.MONTH){this.groupedHistoryDa ta_=[{title:this.queryStartTime+" – "+this.queryEndTime,domains:this.createHisto ryDomains_(this.historyData)}]}},toggleDomainExpanded_:function(e){var collapse= e.currentTarget.parentNode.querySelector("iron-collapse");e.model.set("domain.re ndered",true);setTimeout(function(){collapse.toggle()},0)},needsTimeGap_:functio n(groupIndex,domainIndex,itemIndex){var visits=this.groupedHistoryData_[groupInd ex].domains[domainIndex].visits;return md_history.HistoryItem.needsTimeGap(visit s,itemIndex,this.searchedTerm)},pathForItem_:function(groupIndex,domainIndex,ite mIndex){return["groupedHistoryData_",groupIndex,"domains",domainIndex,"visits",i temIndex].join(".")},getWebsiteIconStyle_:function(domain){return"background-ima ge: "+cr.icon.getFavicon(domain.visits[0].url)},getDropdownIcon_:function(expand ed){return expanded?"cr:expand-less":"cr:expand-more"}}); 5 var HistoryDomain;var HistoryGroup;Polymer({is:"history-grouped-list",behaviors: [HistoryListBehavior],properties:{historyData:{type:Array},groupedHistoryData_:{ type:Array},searchedTerm:{type:String,value:""},range:{type:Number},queryStartTi me:String,queryEndTime:String},observers:["updateGroupedHistoryData_(range, hist oryData)"],addNewResults:function(results,incremental,finished){this.historyData =results},createHistoryDomains_:function(visits){var domainIndexes={};var domain s=[];for(var i=0,visit;visit=visits[i];i++){var domain=visit.domain;if(domainInd exes[domain]==undefined){domainIndexes[domain]=domains.length;domains.push({doma in:domain,visits:[],expanded:false,rendered:false})}domains[domainIndexes[domain ]].visits.push(visit)}var sortByVisits=function(a,b){return b.visits.length-a.vi sits.length};domains.sort(sortByVisits);return domains},updateGroupedHistoryData _:function(){if(this.historyData.length==0){this.groupedHistoryData_=[];return}i f(this.range==HistoryRange.WEEK){var days=[];var currentDayVisits=[this.historyD ata[0]];var pushCurrentDay=()=>{days.push({title:this.searchedTerm?currentDayVis its[0].dateShort:currentDayVisits[0].dateRelativeDay,domains:this.createHistoryD omains_(currentDayVisits)})};var visitsSameDay=(a,b)=>{if(this.searchedTerm)retu rn a.dateShort==b.dateShort;return a.dateRelativeDay==b.dateRelativeDay};for(var i=1;i<this.historyData.length;i++){var visit=this.historyData[i];if(!visitsSame Day(visit,currentDayVisits[0])){pushCurrentDay();currentDayVisits=[]}currentDayV isits.push(visit)}pushCurrentDay();this.groupedHistoryData_=days}else if(this.ra nge==HistoryRange.MONTH){this.groupedHistoryData_=[{title:this.queryStartTime+" – "+this.queryEndTime,domains:this.createHistoryDomains_(this.historyData)}]}},t oggleDomainExpanded_:function(e){var collapse=e.currentTarget.parentNode.querySe lector("iron-collapse");e.model.set("domain.rendered",true);setTimeout(function( ){collapse.toggle()},0)},needsTimeGap_:function(groupIndex,domainIndex,itemIndex ){var visits=this.groupedHistoryData_[groupIndex].domains[domainIndex].visits;re turn md_history.HistoryItem.needsTimeGap(visits,itemIndex,this.searchedTerm)},pa thForItem_:function(groupIndex,domainIndex,itemIndex){return["groupedHistoryData _",groupIndex,"domains",domainIndex,"visits",itemIndex].join(".")},getWebsiteIco nStyle_:function(domain){return"background-image: "+cr.icon.getFavicon(domain.vi sits[0].url)},getDropdownIcon_:function(expanded){return expanded?"cr:expand-les s":"cr:expand-more"}});
6 // Copyright 2014 The Chromium Authors. All rights reserved. 6 // Copyright 2014 The Chromium Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be 7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. 8 // found in the LICENSE file.
9 cr.define("cr.ui",function(){function FocusGrid(){this.rows=[]}FocusGrid.prototy pe={ignoreFocusChange_:false,onFocus:function(row,e){if(this.ignoreFocusChange_) this.ignoreFocusChange_=false;else this.lastFocused_=e.currentTarget;this.rows.f orEach(function(r){r.makeActive(r==row)})},onKeydown:function(row,e){var rowInde x=this.rows.indexOf(row);assert(rowIndex>=0);var newRow=-1;if(e.key=="ArrowUp")n ewRow=rowIndex-1;else if(e.key=="ArrowDown")newRow=rowIndex+1;else if(e.key=="Pa geUp")newRow=0;else if(e.key=="PageDown")newRow=this.rows.length-1;var rowToFocu s=this.rows[newRow];if(rowToFocus){this.ignoreFocusChange_=true;rowToFocus.getEq uivalentElement(this.lastFocused_).focus();e.preventDefault();return true}return false},destroy:function(){this.rows.forEach(function(row){row.destroy()});this. rows.length=0},getRowIndexForTarget:function(target){for(var i=0;i<this.rows.len gth;++i){if(this.rows[i].getElements().indexOf(target)>=0)return i}return-1},get RowForRoot:function(root){for(var i=0;i<this.rows.length;++i){if(this.rows[i].ro ot==root)return this.rows[i]}return null},addRow:function(row){this.addRowBefore (row,null)},addRowBefore:function(row,nextRow){row.delegate=row.delegate||this;v ar nextRowIndex=nextRow?this.rows.indexOf(nextRow):-1;if(nextRowIndex==-1)this.r ows.push(row);else this.rows.splice(nextRowIndex,0,row)},removeRow:function(row) {var nextRowIndex=row?this.rows.indexOf(row):-1;if(nextRowIndex>-1)this.rows.spl ice(nextRowIndex,1)},ensureRowActive:function(){if(this.rows.length==0)return;fo r(var i=0;i<this.rows.length;++i){if(this.rows[i].isActive())return}this.rows[0] .makeActive(true)}};return{FocusGrid:FocusGrid}});Polymer.PaperButtonBehaviorImp l={properties:{elevation:{type:Number,reflectToAttribute:true,readOnly:true}},ob servers:["_calculateElevation(focused, disabled, active, pressed, receivedFocusF romKeyboard)","_computeKeyboardClass(receivedFocusFromKeyboard)"],hostAttributes :{role:"button",tabindex:"0",animated:true},_calculateElevation:function(){var e =1;if(this.disabled){e=0}else if(this.active||this.pressed){e=4}else if(this.rec eivedFocusFromKeyboard){e=3}this._setElevation(e)},_computeKeyboardClass:functio n(receivedFocusFromKeyboard){this.toggleClass("keyboard-focus",receivedFocusFrom Keyboard)},_spaceKeyDownHandler:function(event){Polymer.IronButtonStateImpl._spa ceKeyDownHandler.call(this,event);if(this.hasRipple()&&this.getRipple().ripples. length<1){this._ripple.uiDownAction()}},_spaceKeyUpHandler:function(event){Polym er.IronButtonStateImpl._spaceKeyUpHandler.call(this,event);if(this.hasRipple()){ this._ripple.uiUpAction()}}};Polymer.PaperButtonBehavior=[Polymer.IronButtonStat e,Polymer.IronControlState,Polymer.PaperRippleBehavior,Polymer.PaperButtonBehavi orImpl];Polymer({is:"paper-button",behaviors:[Polymer.PaperButtonBehavior],prope rties:{raised:{type:Boolean,reflectToAttribute:true,value:false,observer:"_calcu lateElevation"}},_calculateElevation:function(){if(!this.raised){this._setElevat ion(0)}else{Polymer.PaperButtonBehaviorImpl._calculateElevation.apply(this)}}}); Polymer.PaperItemBehaviorImpl={hostAttributes:{role:"option",tabindex:"0"}};Poly mer.PaperItemBehavior=[Polymer.IronButtonState,Polymer.IronControlState,Polymer. PaperItemBehaviorImpl];Polymer({is:"paper-item",behaviors:[Polymer.PaperItemBeha vior]});Polymer.IronFitBehavior={properties:{sizingTarget:{type:Object,value:fun ction(){return this}},fitInto:{type:Object,value:window},noOverlap:{type:Boolean },positionTarget:{type:Element},horizontalAlign:{type:String},verticalAlign:{typ e:String},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,value:0,noti fy:true},verticalOffset:{type:Number,value:0,notify:true},autoFitOnAttach:{type: Boolean,value:false},_fitInfo:{type:Object}},get _fitWidth(){var fitWidth;if(thi s.fitInto===window){fitWidth=this.fitInto.innerWidth}else{fitWidth=this.fitInto. getBoundingClientRect().width}return fitWidth},get _fitHeight(){var fitHeight;if (this.fitInto===window){fitHeight=this.fitInto.innerHeight}else{fitHeight=this.f itInto.getBoundingClientRect().height}return fitHeight},get _fitLeft(){var fitLe ft;if(this.fitInto===window){fitLeft=0}else{fitLeft=this.fitInto.getBoundingClie ntRect().left}return fitLeft},get _fitTop(){var fitTop;if(this.fitInto===window) {fitTop=0}else{fitTop=this.fitInto.getBoundingClientRect().top}return fitTop},ge t _defaultPositionTarget(){var parent=Polymer.dom(this).parentNode;if(parent&&pa rent.nodeType===Node.DOCUMENT_FRAGMENT_NODE){parent=parent.host}return parent},g et _localeHorizontalAlign(){if(this._isRTL){if(this.horizontalAlign==="right"){r eturn"left"}if(this.horizontalAlign==="left"){return"right"}}return this.horizon talAlign},attached:function(){this._isRTL=window.getComputedStyle(this).directio n=="rtl";this.positionTarget=this.positionTarget||this._defaultPositionTarget;if (this.autoFitOnAttach){if(window.getComputedStyle(this).display==="none"){setTim eout(function(){this.fit()}.bind(this))}else{this.fit()}}},fit:function(){this.p osition();this.constrain();this.center()},_discoverInfo:function(){if(this._fitI nfo){return}var target=window.getComputedStyle(this);var sizer=window.getCompute dStyle(this.sizingTarget);this._fitInfo={inlineStyle:{top:this.style.top||"",lef t:this.style.left||"",position:this.style.position||""},sizerInlineStyle:{maxWid th:this.sizingTarget.style.maxWidth||"",maxHeight:this.sizingTarget.style.maxHei ght||"",boxSizing:this.sizingTarget.style.boxSizing||""},positionedBy:{verticall y:target.top!=="auto"?"top":target.bottom!=="auto"?"bottom":null,horizontally:ta rget.left!=="auto"?"left":target.right!=="auto"?"right":null},sizedBy:{height:si zer.maxHeight!=="none",width:sizer.maxWidth!=="none",minWidth:parseInt(sizer.min Width,10)||0,minHeight:parseInt(sizer.minHeight,10)||0},margin:{top:parseInt(tar get.marginTop,10)||0,right:parseInt(target.marginRight,10)||0,bottom:parseInt(ta rget.marginBottom,10)||0,left:parseInt(target.marginLeft,10)||0}};if(this.vertic alOffset){this._fitInfo.margin.top=this._fitInfo.margin.bottom=this.verticalOffs et;this._fitInfo.inlineStyle.marginTop=this.style.marginTop||"";this._fitInfo.in lineStyle.marginBottom=this.style.marginBottom||"";this.style.marginTop=this.sty le.marginBottom=this.verticalOffset+"px"}if(this.horizontalOffset){this._fitInfo .margin.left=this._fitInfo.margin.right=this.horizontalOffset;this._fitInfo.inli neStyle.marginLeft=this.style.marginLeft||"";this._fitInfo.inlineStyle.marginRig ht=this.style.marginRight||"";this.style.marginLeft=this.style.marginRight=this. horizontalOffset+"px"}},resetFit:function(){var info=this._fitInfo||{};for(var p roperty in info.sizerInlineStyle){this.sizingTarget.style[property]=info.sizerIn lineStyle[property]}for(var property in info.inlineStyle){this.style[property]=i nfo.inlineStyle[property]}this._fitInfo=null},refit:function(){var scrollLeft=th is.sizingTarget.scrollLeft;var scrollTop=this.sizingTarget.scrollTop;this.resetF it();this.fit();this.sizingTarget.scrollLeft=scrollLeft;this.sizingTarget.scroll Top=scrollTop},position:function(){if(!this.horizontalAlign&&!this.verticalAlign ){return}this._discoverInfo();this.style.position="fixed";this.sizingTarget.styl e.boxSizing="border-box";this.style.left="0px";this.style.top="0px";var rect=thi s.getBoundingClientRect();var positionRect=this.__getNormalizedRect(this.positio nTarget);var fitRect=this.__getNormalizedRect(this.fitInto);var margin=this._fit Info.margin;var size={width:rect.width+margin.left+margin.right,height:rect.heig ht+margin.top+margin.bottom};var position=this.__getPosition(this._localeHorizon talAlign,this.verticalAlign,size,positionRect,fitRect);var left=position.left+ma rgin.left;var top=position.top+margin.top;var right=Math.min(fitRect.right-margi n.right,left+rect.width);var bottom=Math.min(fitRect.bottom-margin.bottom,top+re ct.height);var minWidth=this._fitInfo.sizedBy.minWidth;var minHeight=this._fitIn fo.sizedBy.minHeight;if(left<margin.left){left=margin.left;if(right-left<minWidt h){left=right-minWidth}}if(top<margin.top){top=margin.top;if(bottom-top<minHeigh t){top=bottom-minHeight}}this.sizingTarget.style.maxWidth=right-left+"px";this.s izingTarget.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 info=this._fitInfo;if(!info. positionedBy.vertically){this.style.position="fixed";this.style.top="0px"}if(!in fo.positionedBy.horizontally){this.style.position="fixed";this.style.left="0px"} this.sizingTarget.style.boxSizing="border-box";var rect=this.getBoundingClientRe ct();if(!info.sizedBy.height){this.__sizeDimension(rect,info.positionedBy.vertic ally,"top","bottom","Height")}if(!info.sizedBy.width){this.__sizeDimension(rect, info.positionedBy.horizontally,"left","right","Width")}},_sizeDimension:function (rect,positionedBy,start,end,extent){this.__sizeDimension(rect,positionedBy,star t,end,extent)},__sizeDimension:function(rect,positionedBy,start,end,extent){var info=this._fitInfo;var fitRect=this.__getNormalizedRect(this.fitInto);var max=ex tent==="Width"?fitRect.width:fitRect.height;var flip=positionedBy===end;var offs et=flip?max-rect[end]:rect[start];var margin=info.margin[flip?start:end];var off setExtent="offset"+extent;var sizingOffset=this[offsetExtent]-this.sizingTarget[ offsetExtent];this.sizingTarget.style["max"+extent]=max-margin-offset-sizingOffs et+"px"},center:function(){if(this.horizontalAlign||this.verticalAlign){return}t his._discoverInfo();var positionedBy=this._fitInfo.positionedBy;if(positionedBy. vertically&&positionedBy.horizontally){return}this.style.position="fixed";if(!po sitionedBy.vertically){this.style.top="0px"}if(!positionedBy.horizontally){this. style.left="0px"}var rect=this.getBoundingClientRect();var fitRect=this.__getNor malizedRect(this.fitInto);if(!positionedBy.vertically){var top=fitRect.top-rect. top+(fitRect.height-rect.height)/2;this.style.top=top+"px"}if(!positionedBy.hori zontally){var left=fitRect.left-rect.left+(fitRect.width-rect.width)/2;this.styl e.left=left+"px"}},__getNormalizedRect:function(target){if(target===document.doc umentElement||target===window){return{top:0,left:0,width:window.innerWidth,heigh t:window.innerHeight,right:window.innerWidth,bottom:window.innerHeight}}return t arget.getBoundingClientRect()},__getCroppedArea:function(position,size,fitRect){ var verticalCrop=Math.min(0,position.top)+Math.min(0,fitRect.bottom-(position.to p+size.height));var horizontalCrop=Math.min(0,position.left)+Math.min(0,fitRect. right-(position.left+size.width));return Math.abs(verticalCrop)*size.width+Math. abs(horizontalCrop)*size.height},__getPosition:function(hAlign,vAlign,size,posit ionRect,fitRect){var positions=[{verticalAlign:"top",horizontalAlign:"left",top: positionRect.top,left:positionRect.left},{verticalAlign:"top",horizontalAlign:"r ight",top:positionRect.top,left:positionRect.right-size.width},{verticalAlign:"b ottom",horizontalAlign:"left",top:positionRect.bottom-size.height,left:positionR ect.left},{verticalAlign:"bottom",horizontalAlign:"right",top:positionRect.botto m-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].top=positions[1].top+=posit ionRect.height;positions[2].top=positions[3].top-=positionRect.height;positions[ 4].left=positions[6].left+=positionRect.width;positions[5].left=positions[7].lef t-=positionRect.width}vAlign=vAlign==="auto"?null:vAlign;hAlign=hAlign==="auto"? null:hAlign;var position;for(var i=0;i<positions.length;i++){var pos=positions[i ];if(!this.dynamicAlign&&!this.noOverlap&&pos.verticalAlign===vAlign&&pos.horizo ntalAlign===hAlign){position=pos;break}var alignOk=(!vAlign||pos.verticalAlign== =vAlign)&&(!hAlign||pos.horizontalAlign===hAlign);if(!this.dynamicAlign&&!alignO k){continue}position=position||pos;pos.croppedArea=this.__getCroppedArea(pos,siz e,fitRect);var diff=pos.croppedArea-position.croppedArea;if(diff<0||diff===0&&al ignOk){position=pos}if(position.croppedArea===0&&alignOk){break}}return position }};(function(){"use strict";Polymer({is:"iron-overlay-backdrop",properties:{open ed:{reflectToAttribute:true,type:Boolean,value:false,observer:"_openedChanged"}} ,listeners:{transitionend:"_onTransitionend"},created:function(){this.__openedRa f=null},attached:function(){this.opened&&this._openedChanged(this.opened)},prepa re:function(){if(this.opened&&!this.parentNode){Polymer.dom(document.body).appen dChild(this)}},open:function(){this.opened=true},close:function(){this.opened=fa lse},complete:function(){if(!this.opened&&this.parentNode===document.body){Polym er.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.transiti onDuration==="0s"||cs.opacity==0){this.complete()}}if(!this.isAttached){return}i f(this.__openedRaf){window.cancelAnimationFrame(this.__openedRaf);this.__openedR af=null}this.scrollTop=this.scrollTop;this.__openedRaf=window.requestAnimationFr ame(function(){this.__openedRaf=null;this.toggleClass("opened",this.opened)}.bin d(this))}})})();Polymer.IronOverlayManagerClass=function(){this._overlays=[];thi s._minimumZ=101;this._backdropElement=null;Polymer.Gestures.add(document,"tap",t his._onCaptureClick.bind(this));document.addEventListener("focus",this._onCaptur eFocus.bind(this),true);document.addEventListener("keydown",this._onCaptureKeyDo wn.bind(this),true)};Polymer.IronOverlayManagerClass.prototype={constructor:Poly mer.IronOverlayManagerClass,get backdropElement(){if(!this._backdropElement){thi s._backdropElement=document.createElement("iron-overlay-backdrop")}return this._ backdropElement},get deepActiveElement(){var active=document.activeElement||docu ment.body;while(active.root&&Polymer.dom(active.root).activeElement){active=Poly mer.dom(active.root).activeElement}return active},_bringOverlayAtIndexToFront:fu nction(i){var overlay=this._overlays[i];if(!overlay){return}var lastI=this._over lays.length-1;var currentOverlay=this._overlays[lastI];if(currentOverlay&&this._ shouldBeBehindOverlay(overlay,currentOverlay)){lastI--}if(i>=lastI){return}var m inimumZ=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:funct ion(overlay){if(overlay.opened){this.addOverlay(overlay)}else{this.removeOverlay (overlay)}},addOverlay:function(overlay){var i=this._overlays.indexOf(overlay);i f(i>=0){this._bringOverlayAtIndexToFront(i);this.trackBackdrop();return}var inse rtionIndex=this._overlays.length;var currentOverlay=this._overlays[insertionInde x-1];var minimumZ=Math.max(this._getZ(currentOverlay),this._minimumZ);var newZ=t his._getZ(overlay);if(currentOverlay&&this._shouldBeBehindOverlay(overlay,curren tOverlay)){this._applyOverlayZ(currentOverlay,minimumZ);insertionIndex--;var pre viousOverlay=this._overlays[insertionIndex-1];minimumZ=Math.max(this._getZ(previ ousOverlay),this._minimumZ)}if(newZ<=minimumZ){this._applyOverlayZ(overlay,minim umZ)}this._overlays.splice(insertionIndex,0,overlay);this.trackBackdrop()},remov eOverlay:function(overlay){var i=this._overlays.indexOf(overlay);if(i===-1){retu rn}this._overlays.splice(i,1);this.trackBackdrop()},currentOverlay:function(){va r i=this._overlays.length-1;return this._overlays[i]},currentOverlayZ:function() {return this._getZ(this.currentOverlay())},ensureMinimumZ:function(minimumZ){thi s._minimumZ=Math.max(this._minimumZ,minimumZ)},focusOverlay:function(){var curre nt=this.currentOverlay();if(current){current._applyFocus()}},trackBackdrop:funct ion(){var overlay=this._overlayWithBackdrop();if(!overlay&&!this._backdropElemen t){return}this.backdropElement.style.zIndex=this._getZ(overlay)-1;this.backdropE lement.opened=!!overlay},getBackdrops:function(){var backdrops=[];for(var i=0;i< this._overlays.length;i++){if(this._overlays[i].withBackdrop){backdrops.push(thi s._overlays[i])}}return backdrops},backdropZ:function(){return this._getZ(this._ overlayWithBackdrop())-1},_overlayWithBackdrop:function(){for(var i=0;i<this._ov erlays.length;i++){if(this._overlays[i].withBackdrop){return this._overlays[i]}} },_getZ:function(overlay){var z=this._minimumZ;if(overlay){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(ov erlay,aboveZ){this._setZ(overlay,aboveZ+2)},_overlayInPath:function(path){path=p ath||[];for(var i=0;i<path.length;i++){if(path[i]._manager===this){return path[i ]}}},_onCaptureClick:function(event){var overlay=this.currentOverlay();if(overla y&&this._overlayInPath(Polymer.dom(event).path)!==overlay){overlay._onCaptureCli ck(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.keybo ardEventMatchesKeys(event,"esc")){overlay._onCaptureEsc(event)}else if(Polymer.I ronA11yKeysBehavior.keyboardEventMatchesKeys(event,"tab")){overlay._onCaptureTab (event)}}},_shouldBeBehindOverlay:function(overlay1,overlay2){return!overlay1.al waysOnTop&&overlay2.alwaysOnTop}};Polymer.IronOverlayManager=new Polymer.IronOve rlayManagerClass;(function(){"use strict";Polymer.IronOverlayBehaviorImpl={prope rties:{opened:{observer:"_openedChanged",type:Boolean,value:false,notify:true},c anceled:{observer:"_canceledChanged",readOnly:true,type:Boolean,value:false},wit hBackdrop:{observer:"_withBackdropChanged",type:Boolean},noAutoFocus:{type:Boole an,value:false},noCancelOnEscKey:{type:Boolean,value:false},noCancelOnOutsideCli ck:{type:Boolean,value:false},closingReason:{type:Object},restoreFocusOnClose:{t ype:Boolean,value:false},alwaysOnTop:{type:Boolean},_manager:{type:Object,value: Polymer.IronOverlayManager},_focusedChild:{type:Object}},listeners:{"iron-resize ":"_onIronResize"},get backdropElement(){return this._manager.backdropElement},g et _focusNode(){return this._focusedChild||Polymer.dom(this).querySelector("[aut ofocus]")||this},get _focusableNodes(){var FOCUSABLE_WITH_DISABLED=["a[href]","a rea[href]","iframe","[tabindex]","[contentEditable=true]"];var FOCUSABLE_WITHOUT _DISABLED=["input","select","textarea","button"];var selector=FOCUSABLE_WITH_DIS ABLED.join(':not([tabindex="-1"]),')+':not([tabindex="-1"]),'+FOCUSABLE_WITHOUT_ DISABLED.join(':not([disabled]):not([tabindex="-1"]),')+':not([disabled]):not([t abindex="-1"])';var focusables=Polymer.dom(this).querySelectorAll(selector);if(t his.tabIndex>=0){focusables.splice(0,0,this)}return focusables.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.__isAnimating=false;this.__shouldRem oveTabIndex=false;this.__firstFocusableNode=this.__lastFocusableNode=null;this._ _raf=null;this.__restoreFocusNode=null;this._ensureSetup()},attached:function(){ if(this.opened){this._openedChanged(this.opened)}this._observer=Polymer.dom(this ).observeNodes(this._onNodesChange)},detached:function(){Polymer.dom(this).unobs erveNodes(this._observer);this._observer=null;if(this.__raf){window.cancelAnimat ionFrame(this.__raf);this.__raf=null}this._manager.removeOverlay(this)},toggle:f unction(){this._setCanceled(false);this.opened=!this.opened},open:function(){thi s._setCanceled(false);this.opened=true},close:function(){this._setCanceled(false );this.opened=false},cancel:function(event){var cancelEvent=this.fire("iron-over lay-canceled",event,{cancelable:true});if(cancelEvent.defaultPrevented){return}t his._setCanceled(true);this.opened=false},_ensureSetup:function(){if(this._overl aySetup){return}this._overlaySetup=true;this.style.outline="none";this.style.dis play="none"},_openedChanged:function(opened){if(opened){this.removeAttribute("ar ia-hidden")}else{this.setAttribute("aria-hidden","true")}if(!this.isAttached){re turn}this.__isAnimating=true;this.__onNextAnimationFrame(this.__openedChanged)}, _canceledChanged:function(){this.closingReason=this.closingReason||{};this.closi ngReason.canceled=this.canceled},_withBackdropChanged:function(){if(this.withBac kdrop&&!this.hasAttribute("tabindex")){this.setAttribute("tabindex","-1");this._ _shouldRemoveTabIndex=true}else if(this.__shouldRemoveTabIndex){this.removeAttri bute("tabindex");this.__shouldRemoveTabIndex=false}if(this.opened&&this.isAttach ed){this._manager.trackBackdrop()}},_prepareRenderOpened:function(){this.__resto reFocusNode=this._manager.deepActiveElement;this._preparePositioning();this.refi t();this._finishPositioning();if(this.noAutoFocus&&document.activeElement===this ._focusNode){this._focusNode.blur();this.__restoreFocusNode.focus()}},_renderOpe ned:function(){this._finishRenderOpened()},_renderClosed:function(){this._finish RenderClosed()},_finishRenderOpened:function(){this.notifyResize();this.__isAnim ating=false;var focusableNodes=this._focusableNodes;this.__firstFocusableNode=fo cusableNodes[0];this.__lastFocusableNode=focusableNodes[focusableNodes.length-1] ;this.fire("iron-overlay-opened")},_finishRenderClosed:function(){this.style.dis play="none";this.style.zIndex="";this.notifyResize();this.__isAnimating=false;th is.fire("iron-overlay-closed",this.closingReason)},_preparePositioning:function( ){this.style.transition=this.style.webkitTransition="none";this.style.transform= this.style.webkitTransform="none";this.style.display=""},_finishPositioning:func tion(){this.style.display="none";this.scrollTop=this.scrollTop;this.style.transi tion=this.style.webkitTransition="";this.style.transform=this.style.webkitTransf orm="";this.style.display="";this.scrollTop=this.scrollTop},_applyFocus:function (){if(this.opened){if(!this.noAutoFocus){this._focusNode.focus()}}else{this._foc usNode.blur();this._focusedChild=null;if(this.restoreFocusOnClose&&this.__restor eFocusNode){this.__restoreFocusNode.focus()}this.__restoreFocusNode=null;var cur rentOverlay=this._manager.currentOverlay();if(currentOverlay&&this!==currentOver lay){currentOverlay._applyFocus()}}},_onCaptureClick:function(event){if(!this.no CancelOnOutsideClick){this.cancel(event)}},_onCaptureFocus:function(event){if(!t his.withBackdrop){return}var path=Polymer.dom(event).path;if(path.indexOf(this)= ==-1){event.stopPropagation();this._applyFocus()}else{this._focusedChild=path[0] }},_onCaptureEsc:function(event){if(!this.noCancelOnEscKey){this.cancel(event)}} ,_onCaptureTab:function(event){if(!this.withBackdrop){return}var shift=event.shi ftKey;var nodeToCheck=shift?this.__firstFocusableNode:this.__lastFocusableNode;v ar nodeToSet=shift?this.__lastFocusableNode:this.__firstFocusableNode;var should Wrap=false;if(nodeToCheck===nodeToSet){shouldWrap=true}else{var focusedNode=this ._manager.deepActiveElement;shouldWrap=focusedNode===nodeToCheck||focusedNode=== this}if(shouldWrap){event.preventDefault();this._focusedChild=nodeToSet;this._ap plyFocus()}},_onIronResize:function(){if(this.opened&&!this.__isAnimating){this. __onNextAnimationFrame(this.refit)}},_onNodesChange:function(){if(this.opened&&! this.__isAnimating){this.notifyResize()}},__openedChanged:function(){if(this.ope ned){this._prepareRenderOpened();this._manager.addOverlay(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.reques tAnimationFrame(function nextAnimationFrame(){self.__raf=null;callback.call(self )})}};Polymer.IronOverlayBehavior=[Polymer.IronFitBehavior,Polymer.IronResizable Behavior,Polymer.IronOverlayBehaviorImpl]})();Polymer.NeonAnimatableBehavior={pr operties:{animationConfig:{type:Object},entryAnimation:{observer:"_entryAnimatio nChanged",type:String},exitAnimation:{observer:"_exitAnimationChanged",type:Stri ng}},_entryAnimationChanged:function(){this.animationConfig=this.animationConfig ||{};this.animationConfig["entry"]=[{name:this.entryAnimation,node:this}]},_exit AnimationChanged:function(){this.animationConfig=this.animationConfig||{};this.a nimationConfig["exit"]=[{name:this.exitAnimation,node:this}]},_copyProperties:fu nction(config1,config2){for(var property in config2){config1[property]=config2[p roperty]}},_cloneConfig:function(config){var clone={isClone:true};this._copyProp erties(clone,config);return clone},_getAnimationConfigRecursive:function(type,ma p,allConfigs){if(!this.animationConfig){return}if(this.animationConfig.value&&ty peof this.animationConfig.value==="function"){this._warn(this._logf("playAnimati on","Please put 'animationConfig' inside of your components 'properties' object instead of outside of it."));return}var thisConfig;if(type){thisConfig=this.anim ationConfig[type]}else{thisConfig=this.animationConfig}if(!Array.isArray(thisCon fig)){thisConfig=[thisConfig]}if(thisConfig){for(var config,index=0;config=thisC onfig[index];index++){if(config.animatable){config.animatable._getAnimationConfi gRecursive(config.type||type,map,allConfigs)}else{if(config.id){var cachedConfig =map[config.id];if(cachedConfig){if(!cachedConfig.isClone){map[config.id]=this._ cloneConfig(cachedConfig);cachedConfig=map[config.id]}this._copyProperties(cache dConfig,config)}else{map[config.id]=config}}else{allConfigs.push(config)}}}}},ge tAnimationConfig:function(type){var map={};var allConfigs=[];this._getAnimationC onfigRecursive(type,map,allConfigs);for(var key in map){allConfigs.push(map[key] )}return allConfigs}};Polymer.NeonAnimationRunnerBehaviorImpl={_configureAnimati ons:function(configs){var results=[];if(configs.length>0){for(var config,index=0 ;config=configs[index];index++){var neonAnimation=document.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("Couldnt play","(",config.name, ").",e)}if(result){results.push({neonAnimation:neonAnimation,config:config,anima tion:result})}}else{console.warn(this.is+":",config.name,"not found!")}}}return results},_shouldComplete:function(activeEntries){var finished=true;for(var i=0;i <activeEntries.length;i++){if(activeEntries[i].animation.playState!="finished"){ finished=false;break}}return finished},_complete:function(activeEntries){for(var i=0;i<activeEntries.length;i++){activeEntries[i].neonAnimation.complete(activeE ntries[i].config)}for(var i=0;i<activeEntries.length;i++){activeEntries[i].anima tion.cancel()}},playAnimation:function(type,cookie){var configs=this.getAnimatio nConfig(type);if(!configs){return}this._active=this._active||{};if(this._active[ type]){this._complete(this._active[type]);delete this._active[type]}var activeEn tries=this._configureAnimations(configs);if(activeEntries.length==0){this.fire(" neon-animation-finish",cookie,{bubbles:false});return}this._active[type]=activeE ntries;for(var i=0;i<activeEntries.length;i++){activeEntries[i].animation.onfini sh=function(){if(this._shouldComplete(activeEntries)){this._complete(activeEntri es);delete this._active[type];this.fire("neon-animation-finish",cookie,{bubbles: false})}}.bind(this)}},cancelAnimation:function(){for(var k in this._animations) {this._animations[k].cancel()}this._animations={}}};Polymer.NeonAnimationRunnerB ehavior=[Polymer.NeonAnimatableBehavior,Polymer.NeonAnimationRunnerBehaviorImpl] ;Polymer.NeonAnimationBehavior={properties:{animationTiming:{type:Object,value:f unction(){return{duration:500,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"both"} }}},isNeonAnimation:true,timingFromConfig:function(config){if(config.timing){for (var property in config.timing){this.animationTiming[property]=config.timing[pro perty]}}return this.animationTiming},setPrefixedProperty:function(node,property, value){var map={transform:["webkitTransform"],transformOrigin:["mozTransformOrig in","webkitTransformOrigin"]};var prefixes=map[property];for(var prefix,index=0; prefix=prefixes[index];index++){node.style[prefix]=value}node.style[property]=va lue},complete:function(){}};Polymer({is:"opaque-animation",behaviors:[Polymer.Ne onAnimationBehavior],configure:function(config){var node=config.node;this._effec t=new KeyframeEffect(node,[{opacity:"1"},{opacity:"1"}],this.timingFromConfig(co nfig));node.style.opacity="0";return this._effect},complete:function(config){con fig.node.style.opacity=""}});(function(){"use strict";var LAST_TOUCH_POSITION={p ageX:0,pageY:0};var ROOT_TARGET=null;var SCROLLABLE_NODES=[];Polymer.IronDropdow nScrollManager={get currentLockingElement(){return this._lockingElements[this._l ockingElements.length-1]},elementIsScrollLocked:function(element){var currentLoc kingElement=this.currentLockingElement;if(currentLockingElement===undefined)retu rn false;var scrollLocked;if(this._hasCachedLockedElement(element)){return true} if(this._hasCachedUnlockedElement(element)){return false}scrollLocked=!!currentL ockingElement&&currentLockingElement!==element&&!this._composedTreeContains(curr entLockingElement,element);if(scrollLocked){this._lockedElementCache.push(elemen t)}else{this._unlockedElementCache.push(element)}return scrollLocked},pushScroll Lock:function(element){if(this._lockingElements.indexOf(element)>=0){return}if(t his._lockingElements.length===0){this._lockScrollInteractions()}this._lockingEle ments.push(element);this._lockedElementCache=[];this._unlockedElementCache=[]},r emoveScrollLock:function(element){var index=this._lockingElements.indexOf(elemen t);if(index===-1){return}this._lockingElements.splice(index,1);this._lockedEleme ntCache=[];this._unlockedElementCache=[];if(this._lockingElements.length===0){th is._unlockScrollInteractions()}},_lockingElements:[],_lockedElementCache:null,_u nlockedElementCache:null,_hasCachedLockedElement:function(element){return this._ lockedElementCache.indexOf(element)>-1},_hasCachedUnlockedElement:function(eleme nt){return this._unlockedElementCache.indexOf(element)>-1},_composedTreeContains :function(element,child){var contentElements;var distributedNodes;var contentInd ex;var nodeIndex;if(element.contains(child)){return true}contentElements=Polymer .dom(element).querySelectorAll("content");for(contentIndex=0;contentIndex<conten tElements.length;++contentIndex){distributedNodes=Polymer.dom(contentElements[co ntentIndex]).getDistributedNodes();for(nodeIndex=0;nodeIndex<distributedNodes.le ngth;++nodeIndex){if(this._composedTreeContains(distributedNodes[nodeIndex],chil d)){return true}}}return false},_scrollInteractionHandler:function(event){if(eve nt.cancelable&&this._shouldPreventScrolling(event)){event.preventDefault()}if(ev ent.targetTouches){var touch=event.targetTouches[0];LAST_TOUCH_POSITION.pageX=to uch.pageX;LAST_TOUCH_POSITION.pageY=touch.pageY}},_lockScrollInteractions:functi on(){this._boundScrollHandler=this._boundScrollHandler||this._scrollInteractionH andler.bind(this);document.addEventListener("wheel",this._boundScrollHandler,tru e);document.addEventListener("mousewheel",this._boundScrollHandler,true);documen t.addEventListener("DOMMouseScroll",this._boundScrollHandler,true);document.addE ventListener("touchstart",this._boundScrollHandler,true);document.addEventListen er("touchmove",this._boundScrollHandler,true)},_unlockScrollInteractions:functio n(){document.removeEventListener("wheel",this._boundScrollHandler,true);document .removeEventListener("mousewheel",this._boundScrollHandler,true);document.remove EventListener("DOMMouseScroll",this._boundScrollHandler,true);document.removeEve ntListener("touchstart",this._boundScrollHandler,true);document.removeEventListe ner("touchmove",this._boundScrollHandler,true)},_shouldPreventScrolling:function (event){var target=Polymer.dom(event).rootTarget;if(event.type!=="touchmove"&&RO OT_TARGET!==target){ROOT_TARGET=target;SCROLLABLE_NODES=this._getScrollableNodes (Polymer.dom(event).path)}if(!SCROLLABLE_NODES.length){return true}if(event.type ==="touchstart"){ 9 cr.define("cr.ui",function(){function FocusGrid(){this.rows=[]}FocusGrid.prototy pe={ignoreFocusChange_:false,onFocus:function(row,e){if(this.ignoreFocusChange_) this.ignoreFocusChange_=false;else this.lastFocused_=e.currentTarget;this.rows.f orEach(function(r){r.makeActive(r==row)})},onKeydown:function(row,e){var rowInde x=this.rows.indexOf(row);assert(rowIndex>=0);var newRow=-1;if(e.key=="ArrowUp")n ewRow=rowIndex-1;else if(e.key=="ArrowDown")newRow=rowIndex+1;else if(e.key=="Pa geUp")newRow=0;else if(e.key=="PageDown")newRow=this.rows.length-1;var rowToFocu s=this.rows[newRow];if(rowToFocus){this.ignoreFocusChange_=true;rowToFocus.getEq uivalentElement(this.lastFocused_).focus();e.preventDefault();return true}return false},destroy:function(){this.rows.forEach(function(row){row.destroy()});this. rows.length=0},getRowIndexForTarget:function(target){for(var i=0;i<this.rows.len gth;++i){if(this.rows[i].getElements().indexOf(target)>=0)return i}return-1},get RowForRoot:function(root){for(var i=0;i<this.rows.length;++i){if(this.rows[i].ro ot==root)return this.rows[i]}return null},addRow:function(row){this.addRowBefore (row,null)},addRowBefore:function(row,nextRow){row.delegate=row.delegate||this;v ar nextRowIndex=nextRow?this.rows.indexOf(nextRow):-1;if(nextRowIndex==-1)this.r ows.push(row);else this.rows.splice(nextRowIndex,0,row)},removeRow:function(row) {var nextRowIndex=row?this.rows.indexOf(row):-1;if(nextRowIndex>-1)this.rows.spl ice(nextRowIndex,1)},ensureRowActive:function(){if(this.rows.length==0)return;fo r(var i=0;i<this.rows.length;++i){if(this.rows[i].isActive())return}this.rows[0] .makeActive(true)}};return{FocusGrid:FocusGrid}});Polymer.PaperButtonBehaviorImp l={properties:{elevation:{type:Number,reflectToAttribute:true,readOnly:true}},ob servers:["_calculateElevation(focused, disabled, active, pressed, receivedFocusF romKeyboard)","_computeKeyboardClass(receivedFocusFromKeyboard)"],hostAttributes :{role:"button",tabindex:"0",animated:true},_calculateElevation:function(){var e =1;if(this.disabled){e=0}else if(this.active||this.pressed){e=4}else if(this.rec eivedFocusFromKeyboard){e=3}this._setElevation(e)},_computeKeyboardClass:functio n(receivedFocusFromKeyboard){this.toggleClass("keyboard-focus",receivedFocusFrom Keyboard)},_spaceKeyDownHandler:function(event){Polymer.IronButtonStateImpl._spa ceKeyDownHandler.call(this,event);if(this.hasRipple()&&this.getRipple().ripples. length<1){this._ripple.uiDownAction()}},_spaceKeyUpHandler:function(event){Polym er.IronButtonStateImpl._spaceKeyUpHandler.call(this,event);if(this.hasRipple()){ this._ripple.uiUpAction()}}};Polymer.PaperButtonBehavior=[Polymer.IronButtonStat e,Polymer.IronControlState,Polymer.PaperRippleBehavior,Polymer.PaperButtonBehavi orImpl];Polymer({is:"paper-button",behaviors:[Polymer.PaperButtonBehavior],prope rties:{raised:{type:Boolean,reflectToAttribute:true,value:false,observer:"_calcu lateElevation"}},_calculateElevation:function(){if(!this.raised){this._setElevat ion(0)}else{Polymer.PaperButtonBehaviorImpl._calculateElevation.apply(this)}}}); Polymer.PaperItemBehaviorImpl={hostAttributes:{role:"option",tabindex:"0"}};Poly mer.PaperItemBehavior=[Polymer.IronButtonState,Polymer.IronControlState,Polymer. PaperItemBehaviorImpl];Polymer({is:"paper-item",behaviors:[Polymer.PaperItemBeha vior]});Polymer.IronFitBehavior={properties:{sizingTarget:{type:Object,value:fun ction(){return this}},fitInto:{type:Object,value:window},noOverlap:{type:Boolean },positionTarget:{type:Element},horizontalAlign:{type:String},verticalAlign:{typ e:String},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,value:0,noti fy:true},verticalOffset:{type:Number,value:0,notify:true},autoFitOnAttach:{type: Boolean,value:false},_fitInfo:{type:Object}},get _fitWidth(){var fitWidth;if(thi s.fitInto===window){fitWidth=this.fitInto.innerWidth}else{fitWidth=this.fitInto. getBoundingClientRect().width}return fitWidth},get _fitHeight(){var fitHeight;if (this.fitInto===window){fitHeight=this.fitInto.innerHeight}else{fitHeight=this.f itInto.getBoundingClientRect().height}return fitHeight},get _fitLeft(){var fitLe ft;if(this.fitInto===window){fitLeft=0}else{fitLeft=this.fitInto.getBoundingClie ntRect().left}return fitLeft},get _fitTop(){var fitTop;if(this.fitInto===window) {fitTop=0}else{fitTop=this.fitInto.getBoundingClientRect().top}return fitTop},ge t _defaultPositionTarget(){var parent=Polymer.dom(this).parentNode;if(parent&&pa rent.nodeType===Node.DOCUMENT_FRAGMENT_NODE){parent=parent.host}return parent},g et _localeHorizontalAlign(){if(this._isRTL){if(this.horizontalAlign==="right"){r eturn"left"}if(this.horizontalAlign==="left"){return"right"}}return this.horizon talAlign},attached:function(){this._isRTL=window.getComputedStyle(this).directio n=="rtl";this.positionTarget=this.positionTarget||this._defaultPositionTarget;if (this.autoFitOnAttach){if(window.getComputedStyle(this).display==="none"){setTim eout(function(){this.fit()}.bind(this))}else{this.fit()}}},fit:function(){this.p osition();this.constrain();this.center()},_discoverInfo:function(){if(this._fitI nfo){return}var target=window.getComputedStyle(this);var sizer=window.getCompute dStyle(this.sizingTarget);this._fitInfo={inlineStyle:{top:this.style.top||"",lef t:this.style.left||"",position:this.style.position||""},sizerInlineStyle:{maxWid th:this.sizingTarget.style.maxWidth||"",maxHeight:this.sizingTarget.style.maxHei ght||"",boxSizing:this.sizingTarget.style.boxSizing||""},positionedBy:{verticall y:target.top!=="auto"?"top":target.bottom!=="auto"?"bottom":null,horizontally:ta rget.left!=="auto"?"left":target.right!=="auto"?"right":null},sizedBy:{height:si zer.maxHeight!=="none",width:sizer.maxWidth!=="none",minWidth:parseInt(sizer.min Width,10)||0,minHeight:parseInt(sizer.minHeight,10)||0},margin:{top:parseInt(tar get.marginTop,10)||0,right:parseInt(target.marginRight,10)||0,bottom:parseInt(ta rget.marginBottom,10)||0,left:parseInt(target.marginLeft,10)||0}};if(this.vertic alOffset){this._fitInfo.margin.top=this._fitInfo.margin.bottom=this.verticalOffs et;this._fitInfo.inlineStyle.marginTop=this.style.marginTop||"";this._fitInfo.in lineStyle.marginBottom=this.style.marginBottom||"";this.style.marginTop=this.sty le.marginBottom=this.verticalOffset+"px"}if(this.horizontalOffset){this._fitInfo .margin.left=this._fitInfo.margin.right=this.horizontalOffset;this._fitInfo.inli neStyle.marginLeft=this.style.marginLeft||"";this._fitInfo.inlineStyle.marginRig ht=this.style.marginRight||"";this.style.marginLeft=this.style.marginRight=this. horizontalOffset+"px"}},resetFit:function(){var info=this._fitInfo||{};for(var p roperty in info.sizerInlineStyle){this.sizingTarget.style[property]=info.sizerIn lineStyle[property]}for(var property in info.inlineStyle){this.style[property]=i nfo.inlineStyle[property]}this._fitInfo=null},refit:function(){var scrollLeft=th is.sizingTarget.scrollLeft;var scrollTop=this.sizingTarget.scrollTop;this.resetF it();this.fit();this.sizingTarget.scrollLeft=scrollLeft;this.sizingTarget.scroll Top=scrollTop},position:function(){if(!this.horizontalAlign&&!this.verticalAlign ){return}this._discoverInfo();this.style.position="fixed";this.sizingTarget.styl e.boxSizing="border-box";this.style.left="0px";this.style.top="0px";var rect=thi s.getBoundingClientRect();var positionRect=this.__getNormalizedRect(this.positio nTarget);var fitRect=this.__getNormalizedRect(this.fitInto);var margin=this._fit Info.margin;var size={width:rect.width+margin.left+margin.right,height:rect.heig ht+margin.top+margin.bottom};var position=this.__getPosition(this._localeHorizon talAlign,this.verticalAlign,size,positionRect,fitRect);var left=position.left+ma rgin.left;var top=position.top+margin.top;var right=Math.min(fitRect.right-margi n.right,left+rect.width);var bottom=Math.min(fitRect.bottom-margin.bottom,top+re ct.height);var minWidth=this._fitInfo.sizedBy.minWidth;var minHeight=this._fitIn fo.sizedBy.minHeight;if(left<margin.left){left=margin.left;if(right-left<minWidt h){left=right-minWidth}}if(top<margin.top){top=margin.top;if(bottom-top<minHeigh t){top=bottom-minHeight}}this.sizingTarget.style.maxWidth=right-left+"px";this.s izingTarget.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 info=this._fitInfo;if(!info. positionedBy.vertically){this.style.position="fixed";this.style.top="0px"}if(!in fo.positionedBy.horizontally){this.style.position="fixed";this.style.left="0px"} this.sizingTarget.style.boxSizing="border-box";var rect=this.getBoundingClientRe ct();if(!info.sizedBy.height){this.__sizeDimension(rect,info.positionedBy.vertic ally,"top","bottom","Height")}if(!info.sizedBy.width){this.__sizeDimension(rect, info.positionedBy.horizontally,"left","right","Width")}},_sizeDimension:function (rect,positionedBy,start,end,extent){this.__sizeDimension(rect,positionedBy,star t,end,extent)},__sizeDimension:function(rect,positionedBy,start,end,extent){var info=this._fitInfo;var fitRect=this.__getNormalizedRect(this.fitInto);var max=ex tent==="Width"?fitRect.width:fitRect.height;var flip=positionedBy===end;var offs et=flip?max-rect[end]:rect[start];var margin=info.margin[flip?start:end];var off setExtent="offset"+extent;var sizingOffset=this[offsetExtent]-this.sizingTarget[ offsetExtent];this.sizingTarget.style["max"+extent]=max-margin-offset-sizingOffs et+"px"},center:function(){if(this.horizontalAlign||this.verticalAlign){return}t his._discoverInfo();var positionedBy=this._fitInfo.positionedBy;if(positionedBy. vertically&&positionedBy.horizontally){return}this.style.position="fixed";if(!po sitionedBy.vertically){this.style.top="0px"}if(!positionedBy.horizontally){this. style.left="0px"}var rect=this.getBoundingClientRect();var fitRect=this.__getNor malizedRect(this.fitInto);if(!positionedBy.vertically){var top=fitRect.top-rect. top+(fitRect.height-rect.height)/2;this.style.top=top+"px"}if(!positionedBy.hori zontally){var left=fitRect.left-rect.left+(fitRect.width-rect.width)/2;this.styl e.left=left+"px"}},__getNormalizedRect:function(target){if(target===document.doc umentElement||target===window){return{top:0,left:0,width:window.innerWidth,heigh t:window.innerHeight,right:window.innerWidth,bottom:window.innerHeight}}return t arget.getBoundingClientRect()},__getCroppedArea:function(position,size,fitRect){ var verticalCrop=Math.min(0,position.top)+Math.min(0,fitRect.bottom-(position.to p+size.height));var horizontalCrop=Math.min(0,position.left)+Math.min(0,fitRect. right-(position.left+size.width));return Math.abs(verticalCrop)*size.width+Math. abs(horizontalCrop)*size.height},__getPosition:function(hAlign,vAlign,size,posit ionRect,fitRect){var positions=[{verticalAlign:"top",horizontalAlign:"left",top: positionRect.top,left:positionRect.left},{verticalAlign:"top",horizontalAlign:"r ight",top:positionRect.top,left:positionRect.right-size.width},{verticalAlign:"b ottom",horizontalAlign:"left",top:positionRect.bottom-size.height,left:positionR ect.left},{verticalAlign:"bottom",horizontalAlign:"right",top:positionRect.botto m-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].top=positions[1].top+=posit ionRect.height;positions[2].top=positions[3].top-=positionRect.height;positions[ 4].left=positions[6].left+=positionRect.width;positions[5].left=positions[7].lef t-=positionRect.width}vAlign=vAlign==="auto"?null:vAlign;hAlign=hAlign==="auto"? null:hAlign;var position;for(var i=0;i<positions.length;i++){var pos=positions[i ];if(!this.dynamicAlign&&!this.noOverlap&&pos.verticalAlign===vAlign&&pos.horizo ntalAlign===hAlign){position=pos;break}var alignOk=(!vAlign||pos.verticalAlign== =vAlign)&&(!hAlign||pos.horizontalAlign===hAlign);if(!this.dynamicAlign&&!alignO k){continue}position=position||pos;pos.croppedArea=this.__getCroppedArea(pos,siz e,fitRect);var diff=pos.croppedArea-position.croppedArea;if(diff<0||diff===0&&al ignOk){position=pos}if(position.croppedArea===0&&alignOk){break}}return position }};(function(){"use strict";Polymer({is:"iron-overlay-backdrop",properties:{open ed:{reflectToAttribute:true,type:Boolean,value:false,observer:"_openedChanged"}} ,listeners:{transitionend:"_onTransitionend"},created:function(){this.__openedRa f=null},attached:function(){this.opened&&this._openedChanged(this.opened)},prepa re:function(){if(this.opened&&!this.parentNode){Polymer.dom(document.body).appen dChild(this)}},open:function(){this.opened=true},close:function(){this.opened=fa lse},complete:function(){if(!this.opened&&this.parentNode===document.body){Polym er.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.transiti onDuration==="0s"||cs.opacity==0){this.complete()}}if(!this.isAttached){return}i f(this.__openedRaf){window.cancelAnimationFrame(this.__openedRaf);this.__openedR af=null}this.scrollTop=this.scrollTop;this.__openedRaf=window.requestAnimationFr ame(function(){this.__openedRaf=null;this.toggleClass("opened",this.opened)}.bin d(this))}})})();Polymer.IronOverlayManagerClass=function(){this._overlays=[];thi s._minimumZ=101;this._backdropElement=null;Polymer.Gestures.add(document,"tap",t his._onCaptureClick.bind(this));document.addEventListener("focus",this._onCaptur eFocus.bind(this),true);document.addEventListener("keydown",this._onCaptureKeyDo wn.bind(this),true)};Polymer.IronOverlayManagerClass.prototype={constructor:Poly mer.IronOverlayManagerClass,get backdropElement(){if(!this._backdropElement){thi s._backdropElement=document.createElement("iron-overlay-backdrop")}return this._ backdropElement},get deepActiveElement(){var active=document.activeElement||docu ment.body;while(active.root&&Polymer.dom(active.root).activeElement){active=Poly mer.dom(active.root).activeElement}return active},_bringOverlayAtIndexToFront:fu nction(i){var overlay=this._overlays[i];if(!overlay){return}var lastI=this._over lays.length-1;var currentOverlay=this._overlays[lastI];if(currentOverlay&&this._ shouldBeBehindOverlay(overlay,currentOverlay)){lastI--}if(i>=lastI){return}var m inimumZ=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:funct ion(overlay){if(overlay.opened){this.addOverlay(overlay)}else{this.removeOverlay (overlay)}},addOverlay:function(overlay){var i=this._overlays.indexOf(overlay);i f(i>=0){this._bringOverlayAtIndexToFront(i);this.trackBackdrop();return}var inse rtionIndex=this._overlays.length;var currentOverlay=this._overlays[insertionInde x-1];var minimumZ=Math.max(this._getZ(currentOverlay),this._minimumZ);var newZ=t his._getZ(overlay);if(currentOverlay&&this._shouldBeBehindOverlay(overlay,curren tOverlay)){this._applyOverlayZ(currentOverlay,minimumZ);insertionIndex--;var pre viousOverlay=this._overlays[insertionIndex-1];minimumZ=Math.max(this._getZ(previ ousOverlay),this._minimumZ)}if(newZ<=minimumZ){this._applyOverlayZ(overlay,minim umZ)}this._overlays.splice(insertionIndex,0,overlay);this.trackBackdrop()},remov eOverlay:function(overlay){var i=this._overlays.indexOf(overlay);if(i===-1){retu rn}this._overlays.splice(i,1);this.trackBackdrop()},currentOverlay:function(){va r i=this._overlays.length-1;return this._overlays[i]},currentOverlayZ:function() {return this._getZ(this.currentOverlay())},ensureMinimumZ:function(minimumZ){thi s._minimumZ=Math.max(this._minimumZ,minimumZ)},focusOverlay:function(){var curre nt=this.currentOverlay();if(current){current._applyFocus()}},trackBackdrop:funct ion(){var overlay=this._overlayWithBackdrop();if(!overlay&&!this._backdropElemen t){return}this.backdropElement.style.zIndex=this._getZ(overlay)-1;this.backdropE lement.opened=!!overlay},getBackdrops:function(){var backdrops=[];for(var i=0;i< this._overlays.length;i++){if(this._overlays[i].withBackdrop){backdrops.push(thi s._overlays[i])}}return backdrops},backdropZ:function(){return this._getZ(this._ overlayWithBackdrop())-1},_overlayWithBackdrop:function(){for(var i=0;i<this._ov erlays.length;i++){if(this._overlays[i].withBackdrop){return this._overlays[i]}} },_getZ:function(overlay){var z=this._minimumZ;if(overlay){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(ov erlay,aboveZ){this._setZ(overlay,aboveZ+2)},_overlayInPath:function(path){path=p ath||[];for(var i=0;i<path.length;i++){if(path[i]._manager===this){return path[i ]}}},_onCaptureClick:function(event){var overlay=this.currentOverlay();if(overla y&&this._overlayInPath(Polymer.dom(event).path)!==overlay){overlay._onCaptureCli ck(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.keybo ardEventMatchesKeys(event,"esc")){overlay._onCaptureEsc(event)}else if(Polymer.I ronA11yKeysBehavior.keyboardEventMatchesKeys(event,"tab")){overlay._onCaptureTab (event)}}},_shouldBeBehindOverlay:function(overlay1,overlay2){return!overlay1.al waysOnTop&&overlay2.alwaysOnTop}};Polymer.IronOverlayManager=new Polymer.IronOve rlayManagerClass;(function(){"use strict";Polymer.IronOverlayBehaviorImpl={prope rties:{opened:{observer:"_openedChanged",type:Boolean,value:false,notify:true},c anceled:{observer:"_canceledChanged",readOnly:true,type:Boolean,value:false},wit hBackdrop:{observer:"_withBackdropChanged",type:Boolean},noAutoFocus:{type:Boole an,value:false},noCancelOnEscKey:{type:Boolean,value:false},noCancelOnOutsideCli ck:{type:Boolean,value:false},closingReason:{type:Object},restoreFocusOnClose:{t ype:Boolean,value:false},alwaysOnTop:{type:Boolean},_manager:{type:Object,value: Polymer.IronOverlayManager},_focusedChild:{type:Object}},listeners:{"iron-resize ":"_onIronResize"},get backdropElement(){return this._manager.backdropElement},g et _focusNode(){return this._focusedChild||Polymer.dom(this).querySelector("[aut ofocus]")||this},get _focusableNodes(){var FOCUSABLE_WITH_DISABLED=["a[href]","a rea[href]","iframe","[tabindex]","[contentEditable=true]"];var FOCUSABLE_WITHOUT _DISABLED=["input","select","textarea","button"];var selector=FOCUSABLE_WITH_DIS ABLED.join(':not([tabindex="-1"]),')+':not([tabindex="-1"]),'+FOCUSABLE_WITHOUT_ DISABLED.join(':not([disabled]):not([tabindex="-1"]),')+':not([disabled]):not([t abindex="-1"])';var focusables=Polymer.dom(this).querySelectorAll(selector);if(t his.tabIndex>=0){focusables.splice(0,0,this)}return focusables.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.__isAnimating=false;this.__shouldRem oveTabIndex=false;this.__firstFocusableNode=this.__lastFocusableNode=null;this._ _raf=null;this.__restoreFocusNode=null;this._ensureSetup()},attached:function(){ if(this.opened){this._openedChanged(this.opened)}this._observer=Polymer.dom(this ).observeNodes(this._onNodesChange)},detached:function(){Polymer.dom(this).unobs erveNodes(this._observer);this._observer=null;if(this.__raf){window.cancelAnimat ionFrame(this.__raf);this.__raf=null}this._manager.removeOverlay(this)},toggle:f unction(){this._setCanceled(false);this.opened=!this.opened},open:function(){thi s._setCanceled(false);this.opened=true},close:function(){this._setCanceled(false );this.opened=false},cancel:function(event){var cancelEvent=this.fire("iron-over lay-canceled",event,{cancelable:true});if(cancelEvent.defaultPrevented){return}t his._setCanceled(true);this.opened=false},_ensureSetup:function(){if(this._overl aySetup){return}this._overlaySetup=true;this.style.outline="none";this.style.dis play="none"},_openedChanged:function(opened){if(opened){this.removeAttribute("ar ia-hidden")}else{this.setAttribute("aria-hidden","true")}if(!this.isAttached){re turn}this.__isAnimating=true;this.__onNextAnimationFrame(this.__openedChanged)}, _canceledChanged:function(){this.closingReason=this.closingReason||{};this.closi ngReason.canceled=this.canceled},_withBackdropChanged:function(){if(this.withBac kdrop&&!this.hasAttribute("tabindex")){this.setAttribute("tabindex","-1");this._ _shouldRemoveTabIndex=true}else if(this.__shouldRemoveTabIndex){this.removeAttri bute("tabindex");this.__shouldRemoveTabIndex=false}if(this.opened&&this.isAttach ed){this._manager.trackBackdrop()}},_prepareRenderOpened:function(){this.__resto reFocusNode=this._manager.deepActiveElement;this._preparePositioning();this.refi t();this._finishPositioning();if(this.noAutoFocus&&document.activeElement===this ._focusNode){this._focusNode.blur();this.__restoreFocusNode.focus()}},_renderOpe ned:function(){this._finishRenderOpened()},_renderClosed:function(){this._finish RenderClosed()},_finishRenderOpened:function(){this.notifyResize();this.__isAnim ating=false;var focusableNodes=this._focusableNodes;this.__firstFocusableNode=fo cusableNodes[0];this.__lastFocusableNode=focusableNodes[focusableNodes.length-1] ;this.fire("iron-overlay-opened")},_finishRenderClosed:function(){this.style.dis play="none";this.style.zIndex="";this.notifyResize();this.__isAnimating=false;th is.fire("iron-overlay-closed",this.closingReason)},_preparePositioning:function( ){this.style.transition=this.style.webkitTransition="none";this.style.transform= this.style.webkitTransform="none";this.style.display=""},_finishPositioning:func tion(){this.style.display="none";this.scrollTop=this.scrollTop;this.style.transi tion=this.style.webkitTransition="";this.style.transform=this.style.webkitTransf orm="";this.style.display="";this.scrollTop=this.scrollTop},_applyFocus:function (){if(this.opened){if(!this.noAutoFocus){this._focusNode.focus()}}else{this._foc usNode.blur();this._focusedChild=null;if(this.restoreFocusOnClose&&this.__restor eFocusNode){this.__restoreFocusNode.focus()}this.__restoreFocusNode=null;var cur rentOverlay=this._manager.currentOverlay();if(currentOverlay&&this!==currentOver lay){currentOverlay._applyFocus()}}},_onCaptureClick:function(event){if(!this.no CancelOnOutsideClick){this.cancel(event)}},_onCaptureFocus:function(event){if(!t his.withBackdrop){return}var path=Polymer.dom(event).path;if(path.indexOf(this)= ==-1){event.stopPropagation();this._applyFocus()}else{this._focusedChild=path[0] }},_onCaptureEsc:function(event){if(!this.noCancelOnEscKey){this.cancel(event)}} ,_onCaptureTab:function(event){if(!this.withBackdrop){return}var shift=event.shi ftKey;var nodeToCheck=shift?this.__firstFocusableNode:this.__lastFocusableNode;v ar nodeToSet=shift?this.__lastFocusableNode:this.__firstFocusableNode;var should Wrap=false;if(nodeToCheck===nodeToSet){shouldWrap=true}else{var focusedNode=this ._manager.deepActiveElement;shouldWrap=focusedNode===nodeToCheck||focusedNode=== this}if(shouldWrap){event.preventDefault();this._focusedChild=nodeToSet;this._ap plyFocus()}},_onIronResize:function(){if(this.opened&&!this.__isAnimating){this. __onNextAnimationFrame(this.refit)}},_onNodesChange:function(){if(this.opened&&! this.__isAnimating){this.notifyResize()}},__openedChanged:function(){if(this.ope ned){this._prepareRenderOpened();this._manager.addOverlay(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.reques tAnimationFrame(function nextAnimationFrame(){self.__raf=null;callback.call(self )})}};Polymer.IronOverlayBehavior=[Polymer.IronFitBehavior,Polymer.IronResizable Behavior,Polymer.IronOverlayBehaviorImpl]})();Polymer.NeonAnimatableBehavior={pr operties:{animationConfig:{type:Object},entryAnimation:{observer:"_entryAnimatio nChanged",type:String},exitAnimation:{observer:"_exitAnimationChanged",type:Stri ng}},_entryAnimationChanged:function(){this.animationConfig=this.animationConfig ||{};this.animationConfig["entry"]=[{name:this.entryAnimation,node:this}]},_exit AnimationChanged:function(){this.animationConfig=this.animationConfig||{};this.a nimationConfig["exit"]=[{name:this.exitAnimation,node:this}]},_copyProperties:fu nction(config1,config2){for(var property in config2){config1[property]=config2[p roperty]}},_cloneConfig:function(config){var clone={isClone:true};this._copyProp erties(clone,config);return clone},_getAnimationConfigRecursive:function(type,ma p,allConfigs){if(!this.animationConfig){return}if(this.animationConfig.value&&ty peof this.animationConfig.value==="function"){this._warn(this._logf("playAnimati on","Please put 'animationConfig' inside of your components 'properties' object instead of outside of it."));return}var thisConfig;if(type){thisConfig=this.anim ationConfig[type]}else{thisConfig=this.animationConfig}if(!Array.isArray(thisCon fig)){thisConfig=[thisConfig]}if(thisConfig){for(var config,index=0;config=thisC onfig[index];index++){if(config.animatable){config.animatable._getAnimationConfi gRecursive(config.type||type,map,allConfigs)}else{if(config.id){var cachedConfig =map[config.id];if(cachedConfig){if(!cachedConfig.isClone){map[config.id]=this._ cloneConfig(cachedConfig);cachedConfig=map[config.id]}this._copyProperties(cache dConfig,config)}else{map[config.id]=config}}else{allConfigs.push(config)}}}}},ge tAnimationConfig:function(type){var map={};var allConfigs=[];this._getAnimationC onfigRecursive(type,map,allConfigs);for(var key in map){allConfigs.push(map[key] )}return allConfigs}};Polymer.NeonAnimationRunnerBehaviorImpl={_configureAnimati ons:function(configs){var results=[];if(configs.length>0){for(var config,index=0 ;config=configs[index];index++){var neonAnimation=document.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("Couldnt play","(",config.name, ").",e)}if(result){results.push({neonAnimation:neonAnimation,config:config,anima tion:result})}}else{console.warn(this.is+":",config.name,"not found!")}}}return results},_shouldComplete:function(activeEntries){var finished=true;for(var i=0;i <activeEntries.length;i++){if(activeEntries[i].animation.playState!="finished"){ finished=false;break}}return finished},_complete:function(activeEntries){for(var i=0;i<activeEntries.length;i++){activeEntries[i].neonAnimation.complete(activeE ntries[i].config)}for(var i=0;i<activeEntries.length;i++){activeEntries[i].anima tion.cancel()}},playAnimation:function(type,cookie){var configs=this.getAnimatio nConfig(type);if(!configs){return}this._active=this._active||{};if(this._active[ type]){this._complete(this._active[type]);delete this._active[type]}var activeEn tries=this._configureAnimations(configs);if(activeEntries.length==0){this.fire(" neon-animation-finish",cookie,{bubbles:false});return}this._active[type]=activeE ntries;for(var i=0;i<activeEntries.length;i++){activeEntries[i].animation.onfini sh=function(){if(this._shouldComplete(activeEntries)){this._complete(activeEntri es);delete this._active[type];this.fire("neon-animation-finish",cookie,{bubbles: false})}}.bind(this)}},cancelAnimation:function(){for(var k in this._animations) {this._animations[k].cancel()}this._animations={}}};Polymer.NeonAnimationRunnerB ehavior=[Polymer.NeonAnimatableBehavior,Polymer.NeonAnimationRunnerBehaviorImpl] ;Polymer.NeonAnimationBehavior={properties:{animationTiming:{type:Object,value:f unction(){return{duration:500,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"both"} }}},isNeonAnimation:true,timingFromConfig:function(config){if(config.timing){for (var property in config.timing){this.animationTiming[property]=config.timing[pro perty]}}return this.animationTiming},setPrefixedProperty:function(node,property, value){var map={transform:["webkitTransform"],transformOrigin:["mozTransformOrig in","webkitTransformOrigin"]};var prefixes=map[property];for(var prefix,index=0; prefix=prefixes[index];index++){node.style[prefix]=value}node.style[property]=va lue},complete:function(){}};Polymer({is:"opaque-animation",behaviors:[Polymer.Ne onAnimationBehavior],configure:function(config){var node=config.node;this._effec t=new KeyframeEffect(node,[{opacity:"1"},{opacity:"1"}],this.timingFromConfig(co nfig));node.style.opacity="0";return this._effect},complete:function(config){con fig.node.style.opacity=""}});(function(){"use strict";var LAST_TOUCH_POSITION={p ageX:0,pageY:0};var ROOT_TARGET=null;var SCROLLABLE_NODES=[];Polymer.IronDropdow nScrollManager={get currentLockingElement(){return this._lockingElements[this._l ockingElements.length-1]},elementIsScrollLocked:function(element){var currentLoc kingElement=this.currentLockingElement;if(currentLockingElement===undefined)retu rn false;var scrollLocked;if(this._hasCachedLockedElement(element)){return true} if(this._hasCachedUnlockedElement(element)){return false}scrollLocked=!!currentL ockingElement&&currentLockingElement!==element&&!this._composedTreeContains(curr entLockingElement,element);if(scrollLocked){this._lockedElementCache.push(elemen t)}else{this._unlockedElementCache.push(element)}return scrollLocked},pushScroll Lock:function(element){if(this._lockingElements.indexOf(element)>=0){return}if(t his._lockingElements.length===0){this._lockScrollInteractions()}this._lockingEle ments.push(element);this._lockedElementCache=[];this._unlockedElementCache=[]},r emoveScrollLock:function(element){var index=this._lockingElements.indexOf(elemen t);if(index===-1){return}this._lockingElements.splice(index,1);this._lockedEleme ntCache=[];this._unlockedElementCache=[];if(this._lockingElements.length===0){th is._unlockScrollInteractions()}},_lockingElements:[],_lockedElementCache:null,_u nlockedElementCache:null,_hasCachedLockedElement:function(element){return this._ lockedElementCache.indexOf(element)>-1},_hasCachedUnlockedElement:function(eleme nt){return this._unlockedElementCache.indexOf(element)>-1},_composedTreeContains :function(element,child){var contentElements;var distributedNodes;var contentInd ex;var nodeIndex;if(element.contains(child)){return true}contentElements=Polymer .dom(element).querySelectorAll("content");for(contentIndex=0;contentIndex<conten tElements.length;++contentIndex){distributedNodes=Polymer.dom(contentElements[co ntentIndex]).getDistributedNodes();for(nodeIndex=0;nodeIndex<distributedNodes.le ngth;++nodeIndex){if(this._composedTreeContains(distributedNodes[nodeIndex],chil d)){return true}}}return false},_scrollInteractionHandler:function(event){if(eve nt.cancelable&&this._shouldPreventScrolling(event)){event.preventDefault()}if(ev ent.targetTouches){var touch=event.targetTouches[0];LAST_TOUCH_POSITION.pageX=to uch.pageX;LAST_TOUCH_POSITION.pageY=touch.pageY}},_lockScrollInteractions:functi on(){this._boundScrollHandler=this._boundScrollHandler||this._scrollInteractionH andler.bind(this);document.addEventListener("wheel",this._boundScrollHandler,tru e);document.addEventListener("mousewheel",this._boundScrollHandler,true);documen t.addEventListener("DOMMouseScroll",this._boundScrollHandler,true);document.addE ventListener("touchstart",this._boundScrollHandler,true);document.addEventListen er("touchmove",this._boundScrollHandler,true)},_unlockScrollInteractions:functio n(){document.removeEventListener("wheel",this._boundScrollHandler,true);document .removeEventListener("mousewheel",this._boundScrollHandler,true);document.remove EventListener("DOMMouseScroll",this._boundScrollHandler,true);document.removeEve ntListener("touchstart",this._boundScrollHandler,true);document.removeEventListe ner("touchmove",this._boundScrollHandler,true)},_shouldPreventScrolling:function (event){var target=Polymer.dom(event).rootTarget;if(event.type!=="touchmove"&&RO OT_TARGET!==target){ROOT_TARGET=target;SCROLLABLE_NODES=this._getScrollableNodes (Polymer.dom(event).path)}if(!SCROLLABLE_NODES.length){return true}if(event.type ==="touchstart"){
10 return false}var info=this._getScrollInfo(event);return!this._getScrollingNode(S CROLLABLE_NODES,info.deltaX,info.deltaY)},_getScrollableNodes:function(nodes){va r scrollables=[];var lockingIndex=nodes.indexOf(this.currentLockingElement);for( var i=0;i<=lockingIndex;i++){var node=nodes[i];if(node.nodeType===11){continue}v ar style=node.style;if(style.overflow!=="scroll"&&style.overflow!=="auto"){style =window.getComputedStyle(node)}if(style.overflow==="scroll"||style.overflow==="a uto"){scrollables.push(node)}}return scrollables},_getScrollingNode:function(nod es,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 canScr oll=false;if(verticalScroll){canScroll=deltaY<0?node.scrollTop>0:node.scrollTop< node.scrollHeight-node.clientHeight}else{canScroll=deltaX<0?node.scrollLeft>0:no de.scrollLeft<node.scrollWidth-node.clientWidth}if(canScroll){return node}}},_ge tScrollInfo:function(event){var info={deltaX:event.deltaX,deltaY:event.deltaY};i f("deltaX"in event){}else if("wheelDeltaX"in event){info.deltaX=-event.wheelDelt aX;info.deltaY=-event.wheelDeltaY}else if("axis"in event){info.deltaX=event.axis ===1?event.detail:0;info.deltaY=event.axis===2?event.detail:0}else if(event.targ etTouches){var touch=event.targetTouches[0];info.deltaX=LAST_TOUCH_POSITION.page X-touch.pageX;info.deltaY=LAST_TOUCH_POSITION.pageY-touch.pageY}return info}}})( );(function(){"use strict";Polymer({is:"iron-dropdown",behaviors:[Polymer.IronCo ntrolState,Polymer.IronA11yKeysBehavior,Polymer.IronOverlayBehavior,Polymer.Neon AnimationRunnerBehavior],properties:{horizontalAlign:{type:String,value:"left",r eflectToAttribute:true},verticalAlign:{type:String,value:"top",reflectToAttribut e:true},openAnimationConfig:{type:Object},closeAnimationConfig:{type:Object},foc usTarget:{type:Object},noAnimations:{type:Boolean,value:false},allowOutsideScrol l:{type:Boolean,value:false},_boundOnCaptureScroll:{type:Function,value:function (){return this._onCaptureScroll.bind(this)}}},listeners:{"neon-animation-finish" :"_onNeonAnimationFinish"},observers:["_updateOverlayPosition(positionTarget, ve rticalAlign, horizontalAlign, verticalOffset, horizontalOffset)"],get containedE lement(){return Polymer.dom(this.$.content).getDistributedNodes()[0]},get _focus Target(){return this.focusTarget||this.containedElement},ready:function(){this._ scrollTop=0;this._scrollLeft=0;this._refitOnScrollRAF=null},attached:function(){ if(!this.sizingTarget||this.sizingTarget===this){this.sizingTarget=this.containe dElement}},detached:function(){this.cancelAnimation();document.removeEventListen er("scroll",this._boundOnCaptureScroll);Polymer.IronDropdownScrollManager.remove ScrollLock(this)},_openedChanged:function(){if(this.opened&&this.disabled){this. cancel()}else{this.cancelAnimation();this._updateAnimationConfig();this._saveScr ollPosition();if(this.opened){document.addEventListener("scroll",this._boundOnCa ptureScroll);!this.allowOutsideScroll&&Polymer.IronDropdownScrollManager.pushScr ollLock(this)}else{document.removeEventListener("scroll",this._boundOnCaptureScr oll);Polymer.IronDropdownScrollManager.removeScrollLock(this)}Polymer.IronOverla yBehaviorImpl._openedChanged.apply(this,arguments)}},_renderOpened:function(){if (!this.noAnimations&&this.animationConfig.open){this.$.contentWrapper.classList. add("animating");this.playAnimation("open")}else{Polymer.IronOverlayBehaviorImpl ._renderOpened.apply(this,arguments)}},_renderClosed:function(){if(!this.noAnima tions&&this.animationConfig.close){this.$.contentWrapper.classList.add("animatin g");this.playAnimation("close")}else{Polymer.IronOverlayBehaviorImpl._renderClos ed.apply(this,arguments)}},_onNeonAnimationFinish:function(){this.$.contentWrapp er.classList.remove("animating");if(this.opened){this._finishRenderOpened()}else {this._finishRenderClosed()}},_onCaptureScroll:function(){if(!this.allowOutsideS croll){this._restoreScrollPosition()}else{this._refitOnScrollRAF&&window.cancelA nimationFrame(this._refitOnScrollRAF);this._refitOnScrollRAF=window.requestAnima tionFrame(this.refit.bind(this))}},_saveScrollPosition:function(){if(document.sc rollingElement){this._scrollTop=document.scrollingElement.scrollTop;this._scroll Left=document.scrollingElement.scrollLeft}else{this._scrollTop=Math.max(document .documentElement.scrollTop,document.body.scrollTop);this._scrollLeft=Math.max(do cument.documentElement.scrollLeft,document.body.scrollLeft)}},_restoreScrollPosi tion:function(){if(document.scrollingElement){document.scrollingElement.scrollTo p=this._scrollTop;document.scrollingElement.scrollLeft=this._scrollLeft}else{doc ument.documentElement.scrollTop=this._scrollTop;document.documentElement.scrollL eft=this._scrollLeft;document.body.scrollTop=this._scrollTop;document.body.scrol lLeft=this._scrollLeft}},_updateAnimationConfig:function(){var animations=(this. openAnimationConfig||[]).concat(this.closeAnimationConfig||[]);for(var i=0;i<ani mations.length;i++){animations[i].node=this.containedElement}this.animationConfi g={open:this.openAnimationConfig,close:this.closeAnimationConfig}},_updateOverla yPosition:function(){if(this.isAttached){this.notifyResize()}},_applyFocus:funct ion(){var focusTarget=this.focusTarget||this.containedElement;if(focusTarget&&th is.opened&&!this.noAutoFocus){focusTarget.focus()}else{Polymer.IronOverlayBehavi orImpl._applyFocus.apply(this,arguments)}}})})();Polymer({is:"fade-in-animation" ,behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var node=c onfig.node;this._effect=new KeyframeEffect(node,[{opacity:"0"},{opacity:"1"}],th is.timingFromConfig(config));return this._effect}});Polymer({is:"fade-out-animat ion",behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var no de=config.node;this._effect=new KeyframeEffect(node,[{opacity:"1"},{opacity:"0"} ],this.timingFromConfig(config));return this._effect}});Polymer.IronMenuBehavior Impl={properties:{focusedItem:{observer:"_focusedItemChanged",readOnly:true,type :Object},attrForItemTitle:{type:String}},hostAttributes:{role:"menu",tabindex:"0 "},observers:["_updateMultiselectable(multi)"],listeners:{focus:"_onFocus",keydo wn:"_onKeydown","iron-items-changed":"_onIronItemsChanged"},keyBindings:{up:"_on UpKey",down:"_onDownKey",esc:"_onEscKey","shift+tab:keydown":"_onShiftTabDown"}, attached:function(){this._resetTabindices()},select:function(value){if(this._def aultFocusAsync){this.cancelAsync(this._defaultFocusAsync);this._defaultFocusAsyn c=null}var item=this._valueToItem(value);if(item&&item.hasAttribute("disabled")) return;this._setFocusedItem(item);Polymer.IronMultiSelectableBehaviorImpl.select .apply(this,arguments)},_resetTabindices:function(){var selectedItem=this.multi? this.selectedItems&&this.selectedItems[0]:this.selectedItem;this.items.forEach(f unction(item){item.setAttribute("tabindex",item===selectedItem?"0":"-1")},this)} ,_updateMultiselectable:function(multi){if(multi){this.setAttribute("aria-multis electable","true")}else{this.removeAttribute("aria-multiselectable")}},_focusWit hKeyboardEvent:function(event){for(var i=0,item;item=this.items[i];i++){var attr =this.attrForItemTitle||"textContent";var title=item[attr]||item.getAttribute(at tr);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 curFocusIn dex=Number(this.indexOf(this.focusedItem));for(var i=1;i<length+1;i++){var item= this.items[(curFocusIndex-i+length)%length];if(!item.hasAttribute("disabled")){v ar owner=Polymer.dom(item).getOwnerRoot()||document;this._setFocusedItem(item);i f(Polymer.dom(owner).activeElement==item){return}}}},_focusNext:function(){var l ength=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];if(!i tem.hasAttribute("disabled")){var owner=Polymer.dom(item).getOwnerRoot()||docume nt;this._setFocusedItem(item);if(Polymer.dom(owner).activeElement==item){return} }}},_applySelection:function(item,isSelected){if(isSelected){item.setAttribute(" aria-selected","true")}else{item.removeAttribute("aria-selected")}Polymer.IronSe lectableBehavior._applySelection.apply(this,arguments)},_focusedItemChanged:func tion(focusedItem,old){old&&old.setAttribute("tabindex","-1");if(focusedItem){foc usedItem.setAttribute("tabindex","0");focusedItem.focus()}},_onIronItemsChanged: function(event){if(event.detail.addedNodes.length){this._resetTabindices()}},_on ShiftTabDown:function(event){var oldTabIndex=this.getAttribute("tabindex");Polym er.IronMenuBehaviorImpl._shiftTabPressed=true;this._setFocusedItem(null);this.se tAttribute("tabindex","-1");this.async(function(){this.setAttribute("tabindex",o ldTabIndex);Polymer.IronMenuBehaviorImpl._shiftTabPressed=false},1)},_onFocus:fu nction(event){if(Polymer.IronMenuBehaviorImpl._shiftTabPressed){return}var rootT arget=Polymer.dom(event).rootTarget;if(rootTarget!==this&&typeof rootTarget.tabI ndex!=="undefined"&&!this.isLightDescendant(rootTarget)){return}this._defaultFoc usAsync=this.async(function(){var selectedItem=this.multi?this.selectedItems&&th is.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.prev entDefault()},_onDownKey:function(event){this._focusNext();event.detail.keyboard Event.preventDefault()},_onEscKey:function(event){this.focusedItem.blur()},_onKe ydown:function(event){if(!this.keyboardEventMatchesKeys(event,"up down esc")){th is._focusWithKeyboardEvent(event)}event.stopPropagation()},_activateHandler:func tion(event){Polymer.IronSelectableBehavior._activateHandler.call(this,event);eve nt.stopPropagation()}};Polymer.IronMenuBehaviorImpl._shiftTabPressed=false;Polym er.IronMenuBehavior=[Polymer.IronMultiSelectableBehavior,Polymer.IronA11yKeysBeh avior,Polymer.IronMenuBehaviorImpl];(function(){Polymer({is:"paper-listbox",beha viors:[Polymer.IronMenuBehavior],hostAttributes:{role:"listbox"}})})();Polymer({ is:"paper-menu-grow-height-animation",behaviors:[Polymer.NeonAnimationBehavior], configure:function(config){var node=config.node;var rect=node.getBoundingClientR ect();var height=rect.height;this._effect=new KeyframeEffect(node,[{height:heigh t/2+"px"},{height:height+"px"}],this.timingFromConfig(config));return this._effe ct}});Polymer({is:"paper-menu-grow-width-animation",behaviors:[Polymer.NeonAnima tionBehavior],configure:function(config){var node=config.node;var rect=node.getB oundingClientRect();var width=rect.width;this._effect=new KeyframeEffect(node,[{ width:width/2+"px"},{width:width+"px"}],this.timingFromConfig(config));return th is._effect}});Polymer({is:"paper-menu-shrink-width-animation",behaviors:[Polymer .NeonAnimationBehavior],configure:function(config){var node=config.node;var rect =node.getBoundingClientRect();var width=rect.width;this._effect=new KeyframeEffe ct(node,[{width:width+"px"},{width:width-width/20+"px"}],this.timingFromConfig(c onfig));return this._effect}});Polymer({is:"paper-menu-shrink-height-animation", behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var node=co nfig.node;var rect=node.getBoundingClientRect();var height=rect.height;var top=r ect.top;this.setPrefixedProperty(node,"transformOrigin","0 0");this._effect=new KeyframeEffect(node,[{height:height+"px",transform:"translateY(0)"},{height:heig ht/2+"px",transform:"translateY(-20px)"}],this.timingFromConfig(config));return this._effect}}); 10 return false}var info=this._getScrollInfo(event);return!this._getScrollingNode(S CROLLABLE_NODES,info.deltaX,info.deltaY)},_getScrollableNodes:function(nodes){va r scrollables=[];var lockingIndex=nodes.indexOf(this.currentLockingElement);for( var i=0;i<=lockingIndex;i++){var node=nodes[i];if(node.nodeType===11){continue}v ar style=node.style;if(style.overflow!=="scroll"&&style.overflow!=="auto"){style =window.getComputedStyle(node)}if(style.overflow==="scroll"||style.overflow==="a uto"){scrollables.push(node)}}return scrollables},_getScrollingNode:function(nod es,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 canScr oll=false;if(verticalScroll){canScroll=deltaY<0?node.scrollTop>0:node.scrollTop< node.scrollHeight-node.clientHeight}else{canScroll=deltaX<0?node.scrollLeft>0:no de.scrollLeft<node.scrollWidth-node.clientWidth}if(canScroll){return node}}},_ge tScrollInfo:function(event){var info={deltaX:event.deltaX,deltaY:event.deltaY};i f("deltaX"in event){}else if("wheelDeltaX"in event){info.deltaX=-event.wheelDelt aX;info.deltaY=-event.wheelDeltaY}else if("axis"in event){info.deltaX=event.axis ===1?event.detail:0;info.deltaY=event.axis===2?event.detail:0}else if(event.targ etTouches){var touch=event.targetTouches[0];info.deltaX=LAST_TOUCH_POSITION.page X-touch.pageX;info.deltaY=LAST_TOUCH_POSITION.pageY-touch.pageY}return info}}})( );(function(){"use strict";Polymer({is:"iron-dropdown",behaviors:[Polymer.IronCo ntrolState,Polymer.IronA11yKeysBehavior,Polymer.IronOverlayBehavior,Polymer.Neon AnimationRunnerBehavior],properties:{horizontalAlign:{type:String,value:"left",r eflectToAttribute:true},verticalAlign:{type:String,value:"top",reflectToAttribut e:true},openAnimationConfig:{type:Object},closeAnimationConfig:{type:Object},foc usTarget:{type:Object},noAnimations:{type:Boolean,value:false},allowOutsideScrol l:{type:Boolean,value:false},_boundOnCaptureScroll:{type:Function,value:function (){return this._onCaptureScroll.bind(this)}}},listeners:{"neon-animation-finish" :"_onNeonAnimationFinish"},observers:["_updateOverlayPosition(positionTarget, ve rticalAlign, horizontalAlign, verticalOffset, horizontalOffset)"],get containedE lement(){return Polymer.dom(this.$.content).getDistributedNodes()[0]},get _focus Target(){return this.focusTarget||this.containedElement},ready:function(){this._ scrollTop=0;this._scrollLeft=0;this._refitOnScrollRAF=null},attached:function(){ if(!this.sizingTarget||this.sizingTarget===this){this.sizingTarget=this.containe dElement}},detached:function(){this.cancelAnimation();document.removeEventListen er("scroll",this._boundOnCaptureScroll);Polymer.IronDropdownScrollManager.remove ScrollLock(this)},_openedChanged:function(){if(this.opened&&this.disabled){this. cancel()}else{this.cancelAnimation();this._updateAnimationConfig();this._saveScr ollPosition();if(this.opened){document.addEventListener("scroll",this._boundOnCa ptureScroll);!this.allowOutsideScroll&&Polymer.IronDropdownScrollManager.pushScr ollLock(this)}else{document.removeEventListener("scroll",this._boundOnCaptureScr oll);Polymer.IronDropdownScrollManager.removeScrollLock(this)}Polymer.IronOverla yBehaviorImpl._openedChanged.apply(this,arguments)}},_renderOpened:function(){if (!this.noAnimations&&this.animationConfig.open){this.$.contentWrapper.classList. add("animating");this.playAnimation("open")}else{Polymer.IronOverlayBehaviorImpl ._renderOpened.apply(this,arguments)}},_renderClosed:function(){if(!this.noAnima tions&&this.animationConfig.close){this.$.contentWrapper.classList.add("animatin g");this.playAnimation("close")}else{Polymer.IronOverlayBehaviorImpl._renderClos ed.apply(this,arguments)}},_onNeonAnimationFinish:function(){this.$.contentWrapp er.classList.remove("animating");if(this.opened){this._finishRenderOpened()}else {this._finishRenderClosed()}},_onCaptureScroll:function(){if(!this.allowOutsideS croll){this._restoreScrollPosition()}else{this._refitOnScrollRAF&&window.cancelA nimationFrame(this._refitOnScrollRAF);this._refitOnScrollRAF=window.requestAnima tionFrame(this.refit.bind(this))}},_saveScrollPosition:function(){if(document.sc rollingElement){this._scrollTop=document.scrollingElement.scrollTop;this._scroll Left=document.scrollingElement.scrollLeft}else{this._scrollTop=Math.max(document .documentElement.scrollTop,document.body.scrollTop);this._scrollLeft=Math.max(do cument.documentElement.scrollLeft,document.body.scrollLeft)}},_restoreScrollPosi tion:function(){if(document.scrollingElement){document.scrollingElement.scrollTo p=this._scrollTop;document.scrollingElement.scrollLeft=this._scrollLeft}else{doc ument.documentElement.scrollTop=this._scrollTop;document.documentElement.scrollL eft=this._scrollLeft;document.body.scrollTop=this._scrollTop;document.body.scrol lLeft=this._scrollLeft}},_updateAnimationConfig:function(){var animations=(this. openAnimationConfig||[]).concat(this.closeAnimationConfig||[]);for(var i=0;i<ani mations.length;i++){animations[i].node=this.containedElement}this.animationConfi g={open:this.openAnimationConfig,close:this.closeAnimationConfig}},_updateOverla yPosition:function(){if(this.isAttached){this.notifyResize()}},_applyFocus:funct ion(){var focusTarget=this.focusTarget||this.containedElement;if(focusTarget&&th is.opened&&!this.noAutoFocus){focusTarget.focus()}else{Polymer.IronOverlayBehavi orImpl._applyFocus.apply(this,arguments)}}})})();Polymer({is:"fade-in-animation" ,behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var node=c onfig.node;this._effect=new KeyframeEffect(node,[{opacity:"0"},{opacity:"1"}],th is.timingFromConfig(config));return this._effect}});Polymer({is:"fade-out-animat ion",behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var no de=config.node;this._effect=new KeyframeEffect(node,[{opacity:"1"},{opacity:"0"} ],this.timingFromConfig(config));return this._effect}});Polymer.IronMenuBehavior Impl={properties:{focusedItem:{observer:"_focusedItemChanged",readOnly:true,type :Object},attrForItemTitle:{type:String}},hostAttributes:{role:"menu",tabindex:"0 "},observers:["_updateMultiselectable(multi)"],listeners:{focus:"_onFocus",keydo wn:"_onKeydown","iron-items-changed":"_onIronItemsChanged"},keyBindings:{up:"_on UpKey",down:"_onDownKey",esc:"_onEscKey","shift+tab:keydown":"_onShiftTabDown"}, attached:function(){this._resetTabindices()},select:function(value){if(this._def aultFocusAsync){this.cancelAsync(this._defaultFocusAsync);this._defaultFocusAsyn c=null}var item=this._valueToItem(value);if(item&&item.hasAttribute("disabled")) return;this._setFocusedItem(item);Polymer.IronMultiSelectableBehaviorImpl.select .apply(this,arguments)},_resetTabindices:function(){var selectedItem=this.multi? this.selectedItems&&this.selectedItems[0]:this.selectedItem;this.items.forEach(f unction(item){item.setAttribute("tabindex",item===selectedItem?"0":"-1")},this)} ,_updateMultiselectable:function(multi){if(multi){this.setAttribute("aria-multis electable","true")}else{this.removeAttribute("aria-multiselectable")}},_focusWit hKeyboardEvent:function(event){for(var i=0,item;item=this.items[i];i++){var attr =this.attrForItemTitle||"textContent";var title=item[attr]||item.getAttribute(at tr);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 curFocusIn dex=Number(this.indexOf(this.focusedItem));for(var i=1;i<length+1;i++){var item= this.items[(curFocusIndex-i+length)%length];if(!item.hasAttribute("disabled")){v ar owner=Polymer.dom(item).getOwnerRoot()||document;this._setFocusedItem(item);i f(Polymer.dom(owner).activeElement==item){return}}}},_focusNext:function(){var l ength=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];if(!i tem.hasAttribute("disabled")){var owner=Polymer.dom(item).getOwnerRoot()||docume nt;this._setFocusedItem(item);if(Polymer.dom(owner).activeElement==item){return} }}},_applySelection:function(item,isSelected){if(isSelected){item.setAttribute(" aria-selected","true")}else{item.removeAttribute("aria-selected")}Polymer.IronSe lectableBehavior._applySelection.apply(this,arguments)},_focusedItemChanged:func tion(focusedItem,old){old&&old.setAttribute("tabindex","-1");if(focusedItem){foc usedItem.setAttribute("tabindex","0");focusedItem.focus()}},_onIronItemsChanged: function(event){if(event.detail.addedNodes.length){this._resetTabindices()}},_on ShiftTabDown:function(event){var oldTabIndex=this.getAttribute("tabindex");Polym er.IronMenuBehaviorImpl._shiftTabPressed=true;this._setFocusedItem(null);this.se tAttribute("tabindex","-1");this.async(function(){this.setAttribute("tabindex",o ldTabIndex);Polymer.IronMenuBehaviorImpl._shiftTabPressed=false},1)},_onFocus:fu nction(event){if(Polymer.IronMenuBehaviorImpl._shiftTabPressed){return}var rootT arget=Polymer.dom(event).rootTarget;if(rootTarget!==this&&typeof rootTarget.tabI ndex!=="undefined"&&!this.isLightDescendant(rootTarget)){return}this._defaultFoc usAsync=this.async(function(){var selectedItem=this.multi?this.selectedItems&&th is.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.prev entDefault()},_onDownKey:function(event){this._focusNext();event.detail.keyboard Event.preventDefault()},_onEscKey:function(event){this.focusedItem.blur()},_onKe ydown:function(event){if(!this.keyboardEventMatchesKeys(event,"up down esc")){th is._focusWithKeyboardEvent(event)}event.stopPropagation()},_activateHandler:func tion(event){Polymer.IronSelectableBehavior._activateHandler.call(this,event);eve nt.stopPropagation()}};Polymer.IronMenuBehaviorImpl._shiftTabPressed=false;Polym er.IronMenuBehavior=[Polymer.IronMultiSelectableBehavior,Polymer.IronA11yKeysBeh avior,Polymer.IronMenuBehaviorImpl];(function(){Polymer({is:"paper-listbox",beha viors:[Polymer.IronMenuBehavior],hostAttributes:{role:"listbox"}})})();Polymer({ is:"paper-menu-grow-height-animation",behaviors:[Polymer.NeonAnimationBehavior], configure:function(config){var node=config.node;var rect=node.getBoundingClientR ect();var height=rect.height;this._effect=new KeyframeEffect(node,[{height:heigh t/2+"px"},{height:height+"px"}],this.timingFromConfig(config));return this._effe ct}});Polymer({is:"paper-menu-grow-width-animation",behaviors:[Polymer.NeonAnima tionBehavior],configure:function(config){var node=config.node;var rect=node.getB oundingClientRect();var width=rect.width;this._effect=new KeyframeEffect(node,[{ width:width/2+"px"},{width:width+"px"}],this.timingFromConfig(config));return th is._effect}});Polymer({is:"paper-menu-shrink-width-animation",behaviors:[Polymer .NeonAnimationBehavior],configure:function(config){var node=config.node;var rect =node.getBoundingClientRect();var width=rect.width;this._effect=new KeyframeEffe ct(node,[{width:width+"px"},{width:width-width/20+"px"}],this.timingFromConfig(c onfig));return this._effect}});Polymer({is:"paper-menu-shrink-height-animation", behaviors:[Polymer.NeonAnimationBehavior],configure:function(config){var node=co nfig.node;var rect=node.getBoundingClientRect();var height=rect.height;var top=r ect.top;this.setPrefixedProperty(node,"transformOrigin","0 0");this._effect=new KeyframeEffect(node,[{height:height+"px",transform:"translateY(0)"},{height:heig ht/2+"px",transform:"translateY(-20px)"}],this.timingFromConfig(config));return this._effect}});
11 // Copyright 2016 The Chromium Authors. All rights reserved. 11 // Copyright 2016 The Chromium Authors. All rights reserved.
12 // Use of this source code is governed by a BSD-style license that can be 12 // Use of this source code is governed by a BSD-style license that can be
13 // found in the LICENSE file. 13 // found in the LICENSE file.
14 var SLIDE_CUBIC_BEZIER="cubic-bezier(0.3, 0.95, 0.5, 1)";Polymer({is:"cr-shared- menu",properties:{menuOpen:{type:Boolean,observer:"menuOpenChanged_",value:false ,notify:true},itemData:{type:Object,value:null},openAnimationConfig:{type:Object ,value:function(){return[{name:"fade-in-animation",timing:{delay:50,duration:200 }},{name:"paper-menu-grow-width-animation",timing:{delay:50,duration:150,easing: SLIDE_CUBIC_BEZIER}},{name:"paper-menu-grow-height-animation",timing:{delay:100, duration:275,easing:SLIDE_CUBIC_BEZIER}}]}},closeAnimationConfig:{type:Object,va lue:function(){return[{name:"fade-out-animation",timing:{duration:150}}]}}},list eners:{"dropdown.iron-overlay-canceled":"onOverlayCanceled_"},lastAnchor_:null,k eyHandler_:null,attached:function(){window.addEventListener("resize",this.closeM enu.bind(this));this.keyHandler_=this.onCaptureKeyDown_.bind(this);this.$.menu.a ddEventListener("keydown",this.keyHandler_,true)},detached:function(){this.$.men u.removeEventListener("keydown",this.keyHandler_,true)},closeMenu:function(){if( this.root.activeElement==null){this.$.dropdown.restoreFocusOnClose=false}this.me nuOpen=false},openMenu:function(anchor,opt_itemData){if(this.lastAnchor_==anchor &&this.menuOpen)return;if(this.menuOpen)this.closeMenu();this.itemData=opt_itemD ata||null;this.lastAnchor_=anchor;this.$.dropdown.restoreFocusOnClose=true;this. $.menu.selected=-1;this.$.dropdown.positionTarget=anchor;this.menuOpen=true},tog gleMenu:function(anchor,opt_itemData){if(anchor==this.lastAnchor_&&this.menuOpen )this.closeMenu();else this.openMenu(anchor,opt_itemData)},onCaptureKeyDown_:fun ction(e){if(Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(e,"tab")){this .$.dropdown.restoreFocusOnClose=false;this.lastAnchor_.focus();this.closeMenu()} },menuOpenChanged_:function(){if(!this.menuOpen){this.itemData=null;this.lastAnc hor_=null}},onOverlayCanceled_:function(e){if(e.detail.type=="tap")this.$.dropdo wn.restoreFocusOnClose=false}});Polymer({is:"paper-icon-button-light","extends": "button",behaviors:[Polymer.PaperRippleBehavior],listeners:{down:"_rippleDown",u p:"_rippleUp",focus:"_rippleDown",blur:"_rippleUp"},_rippleDown:function(){this. getRipple().downAction()},_rippleUp:function(){this.getRipple().upAction()},ensu reRipple:function(var_args){var lastRipple=this._ripple;Polymer.PaperRippleBehav ior.ensureRipple.apply(this,arguments);if(this._ripple&&this._ripple!==lastRippl e){this._ripple.center=true;this._ripple.classList.add("circle")}}}); 14 var SLIDE_CUBIC_BEZIER="cubic-bezier(0.3, 0.95, 0.5, 1)";Polymer({is:"cr-shared- menu",properties:{menuOpen:{type:Boolean,observer:"menuOpenChanged_",value:false ,notify:true},itemData:{type:Object,value:null},openAnimationConfig:{type:Object ,value:function(){return[{name:"fade-in-animation",timing:{delay:50,duration:200 }},{name:"paper-menu-grow-width-animation",timing:{delay:50,duration:150,easing: SLIDE_CUBIC_BEZIER}},{name:"paper-menu-grow-height-animation",timing:{delay:100, duration:275,easing:SLIDE_CUBIC_BEZIER}}]}},closeAnimationConfig:{type:Object,va lue:function(){return[{name:"fade-out-animation",timing:{duration:150}}]}}},list eners:{"dropdown.iron-overlay-canceled":"onOverlayCanceled_"},lastAnchor_:null,k eyHandler_:null,attached:function(){window.addEventListener("resize",this.closeM enu.bind(this));this.keyHandler_=this.onCaptureKeyDown_.bind(this);this.$.menu.a ddEventListener("keydown",this.keyHandler_,true)},detached:function(){this.$.men u.removeEventListener("keydown",this.keyHandler_,true)},closeMenu:function(){if( this.root.activeElement==null){this.$.dropdown.restoreFocusOnClose=false}this.me nuOpen=false},openMenu:function(anchor,opt_itemData){if(this.lastAnchor_==anchor &&this.menuOpen)return;if(this.menuOpen)this.closeMenu();this.itemData=opt_itemD ata||null;this.lastAnchor_=anchor;this.$.dropdown.restoreFocusOnClose=true;this. $.menu.selected=-1;this.$.dropdown.positionTarget=anchor;this.menuOpen=true},tog gleMenu:function(anchor,opt_itemData){if(anchor==this.lastAnchor_&&this.menuOpen )this.closeMenu();else this.openMenu(anchor,opt_itemData)},onCaptureKeyDown_:fun ction(e){if(Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(e,"tab")){this .$.dropdown.restoreFocusOnClose=false;this.lastAnchor_.focus();this.closeMenu()} },menuOpenChanged_:function(){if(!this.menuOpen){this.itemData=null;this.lastAnc hor_=null}},onOverlayCanceled_:function(e){if(e.detail.type=="tap")this.$.dropdo wn.restoreFocusOnClose=false}});Polymer({is:"paper-icon-button-light",extends:"b utton",behaviors:[Polymer.PaperRippleBehavior],listeners:{down:"_rippleDown",up: "_rippleUp",focus:"_rippleDown",blur:"_rippleUp"},_rippleDown:function(){this.ge tRipple().downAction()},_rippleUp:function(){this.getRipple().upAction()},ensure Ripple:function(var_args){var lastRipple=this._ripple;Polymer.PaperRippleBehavio r.ensureRipple.apply(this,arguments);if(this._ripple&&this._ripple!==lastRipple) {this._ripple.center=true;this._ripple.classList.add("circle")}}});
15 // Copyright 2016 The Chromium Authors. All rights reserved. 15 // Copyright 2016 The Chromium Authors. All rights reserved.
16 // Use of this source code is governed by a BSD-style license that can be 16 // Use of this source code is governed by a BSD-style license that can be
17 // found in the LICENSE file. 17 // found in the LICENSE file.
18 Polymer({is:"history-synced-device-card",properties:{device:String,lastUpdateTim e:String,tabs:{type:Array,value:function(){return[]},observer:"updateIcons_"},se paratorIndexes:Array,opened:Boolean,searchTerm:String,sessionTag:String},listene rs:{"dom-change":"notifyFocusUpdate_"},createFocusRows:function(){var titleRow=n ew cr.ui.FocusRow(this.$["card-heading"],null);titleRow.addItem("menu","#menu-bu tton");titleRow.addItem("collapse","#collapse-button");var rows=[titleRow];if(th is.opened){Polymer.dom(this.root).querySelectorAll(".item-container").forEach(fu nction(el){var row=new cr.ui.FocusRow(el,null);row.addItem("title",".website-tit le");rows.push(row)})}return rows},openTab_:function(e){var tab=e.model.tab;var browserService=md_history.BrowserService.getInstance();browserService.recordHist ogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.LINK_CLICKED,SyncedTabsHist ogram.LIMIT);browserService.openForeignSessionTab(this.sessionTag,tab.windowId,t ab.sessionId,e);e.preventDefault()},toggleTabCard:function(){var histogramValue= this.$.collapse.opened?SyncedTabsHistogram.COLLAPSE_SESSION:SyncedTabsHistogram. EXPAND_SESSION;md_history.BrowserService.getInstance().recordHistogram(SYNCED_TA BS_HISTOGRAM_NAME,histogramValue,SyncedTabsHistogram.LIMIT);this.$.collapse.togg le();this.$["dropdown-indicator"].icon=this.$.collapse.opened?"cr:expand-less":" cr:expand-more";this.fire("update-focus-grid")},notifyFocusUpdate_:function(){th is.fire("update-focus-grid")},updateIcons_:function(){this.async(function(){var icons=Polymer.dom(this.root).querySelectorAll(".website-icon");for(var i=0;i<thi s.tabs.length;i++){icons[i].style.backgroundImage=cr.icon.getFavicon(this.tabs[i ].url)}})},isWindowSeparatorIndex_:function(index,separatorIndexes){return this. separatorIndexes.indexOf(index)!=-1},getCollapseIcon_:function(opened){return op ened?"cr:expand-less":"cr:expand-more"},getCollapseTitle_:function(opened){retur n opened?loadTimeData.getString("collapseSessionButton"):loadTimeData.getString( "expandSessionButton")},onMenuButtonTap_:function(e){this.fire("toggle-menu",{ta rget:Polymer.dom(e).localTarget,tag:this.sessionTag});e.stopPropagation()},onLin kRightClick_:function(){md_history.BrowserService.getInstance().recordHistogram( SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.LINK_RIGHT_CLICKED,SyncedTabsHist ogram.LIMIT)}}); 18 Polymer({is:"history-synced-device-card",properties:{device:String,lastUpdateTim e:String,tabs:{type:Array,value:()=>[],observer:"updateIcons_"},separatorIndexes :Array,opened:Boolean,searchTerm:String,sessionTag:String},listeners:{"dom-chang e":"notifyFocusUpdate_"},createFocusRows:function(){var titleRow=new cr.ui.Focus Row(this.$["card-heading"],null);titleRow.addItem("menu","#menu-button");titleRo w.addItem("collapse","#collapse-button");var rows=[titleRow];if(this.opened){Pol ymer.dom(this.root).querySelectorAll(".item-container").forEach(function(el){var row=new cr.ui.FocusRow(el,null);row.addItem("title",".website-title");rows.push (row)})}return rows},openTab_:function(e){var tab=e.model.tab;var browserService =md_history.BrowserService.getInstance();browserService.recordHistogram(SYNCED_T ABS_HISTOGRAM_NAME,SyncedTabsHistogram.LINK_CLICKED,SyncedTabsHistogram.LIMIT);b rowserService.openForeignSessionTab(this.sessionTag,tab.windowId,tab.sessionId,e );e.preventDefault()},toggleTabCard:function(){var histogramValue=this.$.collaps e.opened?SyncedTabsHistogram.COLLAPSE_SESSION:SyncedTabsHistogram.EXPAND_SESSION ;md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRAM_N AME,histogramValue,SyncedTabsHistogram.LIMIT);this.$.collapse.toggle();this.$["d ropdown-indicator"].icon=this.$.collapse.opened?"cr:expand-less":"cr:expand-more ";this.fire("update-focus-grid")},notifyFocusUpdate_:function(){this.fire("updat e-focus-grid")},updateIcons_:function(){this.async(function(){var icons=Polymer. dom(this.root).querySelectorAll(".website-icon");for(var i=0;i<this.tabs.length; i++){icons[i].style.backgroundImage=cr.icon.getFavicon(this.tabs[i].url)}})},isW indowSeparatorIndex_:function(index,separatorIndexes){return this.separatorIndex es.indexOf(index)!=-1},getCollapseIcon_:function(opened){return opened?"cr:expan d-less":"cr:expand-more"},getCollapseTitle_:function(opened){return opened?loadT imeData.getString("collapseSessionButton"):loadTimeData.getString("expandSession Button")},onMenuButtonTap_:function(e){this.fire("toggle-menu",{target:Polymer.d om(e).localTarget,tag:this.sessionTag});e.stopPropagation()},onLinkRightClick_:f unction(){md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HI STOGRAM_NAME,SyncedTabsHistogram.LINK_RIGHT_CLICKED,SyncedTabsHistogram.LIMIT)}} );
19 // Copyright 2016 The Chromium Authors. All rights reserved. 19 // Copyright 2016 The Chromium Authors. All rights reserved.
20 // Use of this source code is governed by a BSD-style license that can be 20 // Use of this source code is governed by a BSD-style license that can be
21 // found in the LICENSE file. 21 // found in the LICENSE file.
22 var ForeignDeviceInternal;Polymer({is:"history-synced-device-manager",properties :{sessionList:{type:Array,observer:"updateSyncedDevices"},searchTerm:{type:Strin g,observer:"searchTermChanged"},syncedDevices_:{type:Array,value:function(){retu rn[]}},signInState:{type:Boolean,observer:"signInStateChanged_"},guestSession_:{ type:Boolean,value:loadTimeData.getBoolean("isGuestSession")},fetchingSyncedTabs _:{type:Boolean,value:false},hasSeenForeignData_:Boolean},listeners:{"toggle-men u":"onToggleMenu_",scroll:"onListScroll_","update-focus-grid":"updateFocusGrid_" },focusGrid_:null,attached:function(){this.focusGrid_=new cr.ui.FocusGrid;chrome .send("otherDevicesInitialized");md_history.BrowserService.getInstance().recordH istogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.INITIALIZED,SyncedTabsHi stogram.LIMIT)},detached:function(){this.focusGrid_.destroy()},getContentScrollT arget:function(){return this},createInternalDevice_:function(session){var tabs=[ ];var separatorIndexes=[];for(var i=0;i<session.windows.length;i++){var windowId =session.windows[i].sessionId;var newTabs=session.windows[i].tabs;if(newTabs.len gth==0)continue;newTabs.forEach(function(tab){tab.windowId=windowId});var window Added=false;if(!this.searchTerm){tabs=tabs.concat(newTabs);windowAdded=true}else {var searchText=this.searchTerm.toLowerCase();for(var j=0;j<newTabs.length;j++){ var tab=newTabs[j];if(tab.title.toLowerCase().indexOf(searchText)!=-1){tabs.push (tab);windowAdded=true}}}if(windowAdded&&i!=session.windows.length-1)separatorIn dexes.push(tabs.length-1)}return{device:session.name,lastUpdateTime:"– "+session .modifiedTime,opened:true,separatorIndexes:separatorIndexes,timestamp:session.ti mestamp,tabs:tabs,tag:session.tag}},onSignInTap_:function(){chrome.send("startSi gnInFlow")},onListScroll_:function(){var menu=this.$.menu.getIfExists();if(menu) menu.closeMenu()},onToggleMenu_:function(e){var menu=this.$.menu.get();menu.togg leMenu(e.detail.target,e.detail.tag);if(menu.menuOpen){md_history.BrowserService .getInstance().recordHistogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.SH OW_SESSION_MENU,SyncedTabsHistogram.LIMIT)}},onOpenAllTap_:function(){var menu=a ssert(this.$.menu.getIfExists());var browserService=md_history.BrowserService.ge tInstance();browserService.recordHistogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabs Histogram.OPEN_ALL,SyncedTabsHistogram.LIMIT);browserService.openForeignSessionA llTabs(menu.itemData);menu.closeMenu()},updateFocusGrid_:function(){if(!this.foc usGrid_)return;this.focusGrid_.destroy();this.debounce("updateFocusGrid",functio n(){Polymer.dom(this.root).querySelectorAll("history-synced-device-card").reduce (function(prev,cur){return prev.concat(cur.createFocusRows())},[]).forEach(funct ion(row){this.focusGrid_.addRow(row)}.bind(this));this.focusGrid_.ensureRowActiv e()})},onDeleteSessionTap_:function(){var menu=assert(this.$.menu.getIfExists()) ;var browserService=md_history.BrowserService.getInstance();browserService.recor dHistogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.HIDE_FOR_NOW,SyncedTab sHistogram.LIMIT);browserService.deleteForeignSession(menu.itemData);menu.closeM enu()},clearDisplayedSyncedDevices_:function(){this.syncedDevices_=[]},showNoSyn cedMessage:function(signInState,syncedDevicesLength,guestSession){if(guestSessio n)return true;return signInState&&syncedDevicesLength==0},showSignInGuide:functi on(signInState,guestSession){var show=!signInState&&!guestSession;if(show){md_hi story.BrowserService.getInstance().recordAction("Signin_Impression_FromRecentTab s")}return show},noSyncedTabsMessage:function(){var stringName=this.fetchingSync edTabs_?"loading":"noSyncedResults";if(this.searchTerm!=="")stringName="noSearch Results";return loadTimeData.getString(stringName)},updateSyncedDevices:function (sessionList){this.fetchingSyncedTabs_=false;if(!sessionList)return;if(sessionLi st.length>0&&!this.hasSeenForeignData_){this.hasSeenForeignData_=true;md_history .BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedT absHistogram.HAS_FOREIGN_DATA,SyncedTabsHistogram.LIMIT)}var devices=[];sessionL ist.forEach(function(session){var device=this.createInternalDevice_(session);if( device.tabs.length!=0)devices.push(device)}.bind(this));this.syncedDevices_=devi ces},signInStateChanged_:function(){this.fire("history-view-changed");if(!this.s ignInState){this.clearDisplayedSyncedDevices_();return}this.fetchingSyncedTabs_= true},searchTermChanged:function(searchTerm){this.clearDisplayedSyncedDevices_() ;this.updateSyncedDevices(this.sessionList)}}); 22 var ForeignDeviceInternal;Polymer({is:"history-synced-device-manager",properties :{sessionList:{type:Array,observer:"updateSyncedDevices"},searchTerm:{type:Strin g,observer:"searchTermChanged"},syncedDevices_:{type:Array,value:()=>[]},signInS tate:{type:Boolean,observer:"signInStateChanged_"},guestSession_:{type:Boolean,v alue:loadTimeData.getBoolean("isGuestSession")},fetchingSyncedTabs_:{type:Boolea n,value:false},hasSeenForeignData_:Boolean},listeners:{"toggle-menu":"onToggleMe nu_",scroll:"onListScroll_","update-focus-grid":"updateFocusGrid_"},focusGrid_:n ull,attached:function(){this.focusGrid_=new cr.ui.FocusGrid;chrome.send("otherDe vicesInitialized");md_history.BrowserService.getInstance().recordHistogram(SYNCE D_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.INITIALIZED,SyncedTabsHistogram.LIMIT) },detached:function(){this.focusGrid_.destroy()},getContentScrollTarget:function (){return this},createInternalDevice_:function(session){var tabs=[];var separato rIndexes=[];for(var i=0;i<session.windows.length;i++){var windowId=session.windo ws[i].sessionId;var newTabs=session.windows[i].tabs;if(newTabs.length==0)continu e;newTabs.forEach(function(tab){tab.windowId=windowId});var windowAdded=false;if (!this.searchTerm){tabs=tabs.concat(newTabs);windowAdded=true}else{var searchTex t=this.searchTerm.toLowerCase();for(var j=0;j<newTabs.length;j++){var tab=newTab s[j];if(tab.title.toLowerCase().indexOf(searchText)!=-1){tabs.push(tab);windowAd ded=true}}}if(windowAdded&&i!=session.windows.length-1)separatorIndexes.push(tab s.length-1)}return{device:session.name,lastUpdateTime:"– "+session.modifiedTime, opened:true,separatorIndexes:separatorIndexes,timestamp:session.timestamp,tabs:t abs,tag:session.tag}},onSignInTap_:function(){chrome.send("startSignInFlow")},on ListScroll_:function(){var menu=this.$.menu.getIfExists();if(menu)menu.closeMenu ()},onToggleMenu_:function(e){var menu=this.$.menu.get();menu.toggleMenu(e.detai l.target,e.detail.tag);if(menu.menuOpen){md_history.BrowserService.getInstance() .recordHistogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.SHOW_SESSION_MEN U,SyncedTabsHistogram.LIMIT)}},onOpenAllTap_:function(){var menu=assert(this.$.m enu.getIfExists());var browserService=md_history.BrowserService.getInstance();br owserService.recordHistogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.OPEN _ALL,SyncedTabsHistogram.LIMIT);browserService.openForeignSessionAllTabs(menu.it emData);menu.closeMenu()},updateFocusGrid_:function(){if(!this.focusGrid_)return ;this.focusGrid_.destroy();this.debounce("updateFocusGrid",function(){Polymer.do m(this.root).querySelectorAll("history-synced-device-card").reduce((prev,cur)=>p rev.concat(cur.createFocusRows()),[]).forEach(row=>this.focusGrid_.addRow(row)); this.focusGrid_.ensureRowActive()})},onDeleteSessionTap_:function(){var menu=ass ert(this.$.menu.getIfExists());var browserService=md_history.BrowserService.getI nstance();browserService.recordHistogram(SYNCED_TABS_HISTOGRAM_NAME,SyncedTabsHi stogram.HIDE_FOR_NOW,SyncedTabsHistogram.LIMIT);browserService.deleteForeignSess ion(menu.itemData);menu.closeMenu()},clearDisplayedSyncedDevices_:function(){thi s.syncedDevices_=[]},showNoSyncedMessage:function(signInState,syncedDevicesLengt h,guestSession){if(guestSession)return true;return signInState&&syncedDevicesLen gth==0},showSignInGuide:function(signInState,guestSession){var show=!signInState &&!guestSession;if(show){md_history.BrowserService.getInstance().recordAction("S ignin_Impression_FromRecentTabs")}return show},noSyncedTabsMessage:function(){va r stringName=this.fetchingSyncedTabs_?"loading":"noSyncedResults";if(this.search Term!=="")stringName="noSearchResults";return loadTimeData.getString(stringName) },updateSyncedDevices:function(sessionList){this.fetchingSyncedTabs_=false;if(!s essionList)return;if(sessionList.length>0&&!this.hasSeenForeignData_){this.hasSe enForeignData_=true;md_history.BrowserService.getInstance().recordHistogram(SYNC ED_TABS_HISTOGRAM_NAME,SyncedTabsHistogram.HAS_FOREIGN_DATA,SyncedTabsHistogram. LIMIT)}var devices=[];sessionList.forEach(session=>{var device=this.createIntern alDevice_(session);if(device.tabs.length!=0)devices.push(device)});this.syncedDe vices_=devices},signInStateChanged_:function(){this.fire("history-view-changed") ;if(!this.signInState){this.clearDisplayedSyncedDevices_();return}this.fetchingS yncedTabs_=true},searchTermChanged:function(searchTerm){this.clearDisplayedSynce dDevices_();this.updateSyncedDevices(this.sessionList)}});
23 // Copyright 2016 The Chromium Authors. All rights reserved. 23 // Copyright 2016 The Chromium Authors. All rights reserved.
24 // Use of this source code is governed by a BSD-style license that can be 24 // Use of this source code is governed by a BSD-style license that can be
25 // found in the LICENSE file. 25 // found in the LICENSE file.
26 Polymer({is:"cr-dialog","extends":"dialog",properties:{closeText:String,ignorePo pstate:{type:Boolean,value:false}},ready:function(){window.addEventListener("pop state",function(){if(!this.ignorePopstate&&this.open)this.cancel()}.bind(this))} ,cancel:function(){this.fire("cancel");HTMLDialogElement.prototype.close.call(th is,"")},close:function(opt_returnValue){HTMLDialogElement.prototype.close.call(t his,"success")},getCloseButton:function(){return this.$.close}});Polymer({is:"ap p-drawer",properties:{opened:{type:Boolean,value:false,notify:true,reflectToAttr ibute:true},persistent:{type:Boolean,value:false,reflectToAttribute:true},align: {type:String,value:"left"},position:{type:String,readOnly:true,value:"left",refl ectToAttribute:true},swipeOpen:{type:Boolean,value:false,reflectToAttribute:true },noFocusTrap:{type:Boolean,value:false}},observers:["resetLayout(position)","_r esetPosition(align, isAttached)"],_translateOffset:0,_trackDetails:null,_drawerS tate:0,_boundEscKeydownHandler:null,_firstTabStop:null,_lastTabStop:null,ready:f unction(){this.setScrollDirection("y");this._setTransitionDuration("0s")},attach ed:function(){Polymer.RenderStatus.afterNextRender(this,function(){this._setTran sitionDuration("");this._boundEscKeydownHandler=this._escKeydownHandler.bind(thi s);this._resetDrawerState();this.listen(this,"track","_track");this.addEventList ener("transitionend",this._transitionend.bind(this));this.addEventListener("keyd own",this._tabKeydownHandler.bind(this))})},detached:function(){document.removeE ventListener("keydown",this._boundEscKeydownHandler)},open:function(){this.opene d=true},close:function(){this.opened=false},toggle:function(){this.opened=!this. opened},getWidth:function(){return this.$.contentContainer.offsetWidth},resetLay out:function(){this.debounce("_resetLayout",function(){this.fire("app-drawer-res et-layout")},1)},_isRTL:function(){return window.getComputedStyle(this).directio n==="rtl"},_resetPosition:function(){switch(this.align){case"start":this._setPos ition(this._isRTL()?"right":"left");return;case"end":this._setPosition(this._isR TL()?"left":"right");return}this._setPosition(this.align)},_escKeydownHandler:fu nction(event){var ESC_KEYCODE=27;if(event.keyCode===ESC_KEYCODE){event.preventDe fault();this.close()}},_track:function(event){if(this.persistent){return}event.p reventDefault();switch(event.detail.state){case"start":this._trackStart(event);b reak;case"track":this._trackMove(event);break;case"end":this._trackEnd(event);br eak}},_trackStart:function(event){this._drawerState=this._DRAWER_STATE.TRACKING; this._setTransitionDuration("0s");this.style.visibility="visible";var rect=this. $.contentContainer.getBoundingClientRect();if(this.position==="left"){this._tran slateOffset=rect.left}else{this._translateOffset=rect.right-window.innerWidth}th is._trackDetails=[]},_trackMove:function(event){this._translateDrawer(event.deta il.dx+this._translateOffset);this._trackDetails.push({dx:event.detail.dx,timeSta mp:Date.now()})},_trackEnd:function(event){var x=event.detail.dx+this._translate Offset;var drawerWidth=this.getWidth();var isPositionLeft=this.position==="left" ;var isInEndState=isPositionLeft?x>=0||x<=-drawerWidth:x<=0||x>=drawerWidth;if(! isInEndState){var trackDetails=this._trackDetails;this._trackDetails=null;this._ flingDrawer(event,trackDetails);if(this._drawerState===this._DRAWER_STATE.FLINGI NG){return}}var halfWidth=drawerWidth/2;if(event.detail.dx<-halfWidth){this.open ed=this.position==="right"}else if(event.detail.dx>halfWidth){this.opened=this.p osition==="left"}if(isInEndState){this._resetDrawerState()}this._setTransitionDu ration("");this._resetDrawerTranslate();this.style.visibility=""},_calculateVelo city:function(event,trackDetails){var now=Date.now();var timeLowerBound=now-100; var trackDetail;var min=0;var max=trackDetails.length-1;while(min<=max){var mid= min+max>>1;var d=trackDetails[mid];if(d.timeStamp>=timeLowerBound){trackDetail=d ;max=mid-1}else{min=mid+1}}if(trackDetail){var dx=event.detail.dx-trackDetail.dx ;var dt=now-trackDetail.timeStamp||1;return dx/dt}return 0},_flingDrawer:functio n(event,trackDetails){var velocity=this._calculateVelocity(event,trackDetails);i f(Math.abs(velocity)<this._MIN_FLING_THRESHOLD){return}this._drawerState=this._D RAWER_STATE.FLINGING;var x=event.detail.dx+this._translateOffset;var drawerWidth =this.getWidth();var isPositionLeft=this.position==="left";var isVelocityPositiv e=velocity>0;var isClosingLeft=!isVelocityPositive&&isPositionLeft;var isClosing Right=isVelocityPositive&&!isPositionLeft;var dx;if(isClosingLeft){dx=-(x+drawer Width)}else if(isClosingRight){dx=drawerWidth-x}else{dx=-x}if(isVelocityPositive ){velocity=Math.max(velocity,this._MIN_TRANSITION_VELOCITY);this.opened=this.pos ition==="left"}else{velocity=Math.min(velocity,-this._MIN_TRANSITION_VELOCITY);t his.opened=this.position==="right"}this._setTransitionDuration(this._FLING_INITI AL_SLOPE*dx/velocity+"ms");this._setTransitionTimingFunction(this._FLING_TIMING_ FUNCTION);this._resetDrawerTranslate()},_transitionend:function(event){var targe t=Polymer.dom(event).rootTarget;if(target===this.$.contentContainer||target===th is.$.scrim){if(this._drawerState===this._DRAWER_STATE.FLINGING){this._setTransit ionDuration("");this._setTransitionTimingFunction("");this.style.visibility=""}t his._resetDrawerState()}},_setTransitionDuration:function(duration){this.$.conte ntContainer.style.transitionDuration=duration;this.$.scrim.style.transitionDurat ion=duration},_setTransitionTimingFunction:function(timingFunction){this.$.conte ntContainer.style.transitionTimingFunction=timingFunction;this.$.scrim.style.tra nsitionTimingFunction=timingFunction},_translateDrawer:function(x){var drawerWid th=this.getWidth();if(this.position==="left"){x=Math.max(-drawerWidth,Math.min(x ,0));this.$.scrim.style.opacity=1+x/drawerWidth}else{x=Math.max(0,Math.min(x,dra werWidth));this.$.scrim.style.opacity=1-x/drawerWidth}this.translate3d(x+"px","0 ","0",this.$.contentContainer)},_resetDrawerTranslate:function(){this.$.scrim.st yle.opacity="";this.transform("",this.$.contentContainer)},_resetDrawerState:fun ction(){var oldState=this._drawerState;if(this.opened){this._drawerState=this.pe rsistent?this._DRAWER_STATE.OPENED_PERSISTENT:this._DRAWER_STATE.OPENED}else{thi s._drawerState=this._DRAWER_STATE.CLOSED}if(oldState!==this._drawerState){if(thi s._drawerState===this._DRAWER_STATE.OPENED){this._setKeyboardFocusTrap();documen t.addEventListener("keydown",this._boundEscKeydownHandler);document.body.style.o verflow="hidden"}else{document.removeEventListener("keydown",this._boundEscKeydo wnHandler);document.body.style.overflow=""}if(oldState!==this._DRAWER_STATE.INIT ){this.fire("app-drawer-transitioned")}}},_setKeyboardFocusTrap:function(){if(th is.noFocusTrap){return}var focusableElementsSelector=['a[href]:not([tabindex="-1 "])','area[href]:not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1" ])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not( [tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','iframe:not([tab index="-1"])','[tabindex]:not([tabindex="-1"])','[contentEditable=true]:not([tab index="-1"])'].join(",");var focusableElements=Polymer.dom(this).querySelectorAl l(focusableElementsSelector);if(focusableElements.length>0){this._firstTabStop=f ocusableElements[0];this._lastTabStop=focusableElements[focusableElements.length -1]}else{this._firstTabStop=null;this._lastTabStop=null}var tabindex=this.getAtt ribute("tabindex");if(tabindex&&parseInt(tabindex,10)>-1){this.focus()}else if(t his._firstTabStop){this._firstTabStop.focus()}},_tabKeydownHandler:function(even t){if(this.noFocusTrap){return}var TAB_KEYCODE=9;if(this._drawerState===this._DR AWER_STATE.OPENED&&event.keyCode===TAB_KEYCODE){if(event.shiftKey){if(this._firs tTabStop&&Polymer.dom(event).localTarget===this._firstTabStop){event.preventDefa ult();this._lastTabStop.focus()}}else{if(this._lastTabStop&&Polymer.dom(event).l ocalTarget===this._lastTabStop){event.preventDefault();this._firstTabStop.focus( )}}}},_MIN_FLING_THRESHOLD:.2,_MIN_TRANSITION_VELOCITY:1.2,_FLING_TIMING_FUNCTIO N:"cubic-bezier(0.667, 1, 0.667, 1)",_FLING_INITIAL_SLOPE:1.5,_DRAWER_STATE:{INI T:0,OPENED:1,OPENED_PERSISTENT:2,CLOSED:3,TRACKING:4,FLINGING:5}});Polymer({is:" paper-tab",behaviors:[Polymer.IronControlState,Polymer.IronButtonState,Polymer.P aperRippleBehavior],properties:{link:{type:Boolean,value:false,reflectToAttribut e:true}},hostAttributes:{role:"tab"},listeners:{down:"_updateNoink",tap:"_onTap" },attached:function(){this._updateNoink()},get _parentNoink(){var parent=Polymer .dom(this).parentNode;return!!parent&&!!parent.noink},_updateNoink:function(){th is.noink=!!this.noink||!!this._parentNoink},_onTap:function(event){if(this.link) {var anchor=this.queryEffectiveChildren("a");if(!anchor){return}if(event.target= ==anchor){return}anchor.click()}}});Polymer.IronMenubarBehaviorImpl={hostAttribu tes:{role:"menubar"},keyBindings:{left:"_onLeftKey",right:"_onRightKey"},_onUpKe y:function(event){this.focusedItem.click();event.detail.keyboardEvent.preventDef ault()},_onDownKey:function(event){this.focusedItem.click();event.detail.keyboar dEvent.preventDefault()},get _isRTL(){return window.getComputedStyle(this)["dire ction"]==="rtl"},_onLeftKey:function(event){if(this._isRTL){this._focusNext()}el se{this._focusPrevious()}event.detail.keyboardEvent.preventDefault()},_onRightKe y:function(event){if(this._isRTL){this._focusPrevious()}else{this._focusNext()}e vent.detail.keyboardEvent.preventDefault()},_onKeydown:function(event){if(this.k eyboardEventMatchesKeys(event,"up down left right esc")){return}this._focusWithK eyboardEvent(event)}};Polymer.IronMenubarBehavior=[Polymer.IronMenuBehavior,Poly mer.IronMenubarBehaviorImpl];Polymer({is:"paper-tabs",behaviors:[Polymer.IronRes izableBehavior,Polymer.IronMenubarBehavior],properties:{noink:{type:Boolean,valu e:false,observer:"_noinkChanged"},noBar:{type:Boolean,value:false},noSlide:{type :Boolean,value:false},scrollable:{type:Boolean,value:false},fitContainer:{type:B oolean,value:false},disableDrag:{type:Boolean,value:false},hideScrollButtons:{ty pe:Boolean,value:false},alignBottom:{type:Boolean,value:false},selectable:{type: String,value:"paper-tab"},autoselect:{type:Boolean,value:false},autoselectDelay: {type:Number,value:0},_step:{type:Number,value:10},_holdDelay:{type:Number,value :1},_leftHidden:{type:Boolean,value:false},_rightHidden:{type:Boolean,value:fals e},_previousTab:{type:Object}},hostAttributes:{role:"tablist"},listeners:{"iron- resize":"_onTabSizingChanged","iron-items-changed":"_onTabSizingChanged","iron-s elect":"_onIronSelect","iron-deselect":"_onIronDeselect"},keyBindings:{"left:key up right:keyup":"_onArrowKeyup"},created:function(){this._holdJob=null;this._pen dingActivationItem=undefined;this._pendingActivationTimeout=undefined;this._bind DelayedActivationHandler=this._delayedActivationHandler.bind(this);this.addEvent Listener("blur",this._onBlurCapture.bind(this),true)},ready:function(){this.setS crollDirection("y",this.$.tabsContainer)},detached:function(){this._cancelPendin gActivation()},_noinkChanged:function(noink){var childTabs=Polymer.dom(this).que rySelectorAll("paper-tab");childTabs.forEach(noink?this._setNoinkAttribute:this. _removeNoinkAttribute)},_setNoinkAttribute:function(element){element.setAttribut e("noink","")},_removeNoinkAttribute:function(element){element.removeAttribute(" noink")},_computeScrollButtonClass:function(hideThisButton,scrollable,hideScroll Buttons){if(!scrollable||hideScrollButtons){return"hidden"}if(hideThisButton){re turn"not-visible"}return""},_computeTabsContentClass:function(scrollable,fitCont ainer){return scrollable?"scrollable"+(fitContainer?" fit-container":""):" fit-c ontainer"},_computeSelectionBarClass:function(noBar,alignBottom){if(noBar){retur n"hidden"}else if(alignBottom){return"align-bottom"}return""},_onTabSizingChange d:function(){this.debounce("_onTabSizingChanged",function(){this._scroll();this. _tabChanged(this.selectedItem)},10)},_onIronSelect:function(event){this._tabChan ged(event.detail.item,this._previousTab);this._previousTab=event.detail.item;thi s.cancelDebouncer("tab-changed")},_onIronDeselect:function(event){this.debounce( "tab-changed",function(){this._tabChanged(null,this._previousTab);this._previous Tab=null},1)},_activateHandler:function(){this._cancelPendingActivation();Polyme r.IronMenuBehaviorImpl._activateHandler.apply(this,arguments)},_scheduleActivati on:function(item,delay){this._pendingActivationItem=item;this._pendingActivation Timeout=this.async(this._bindDelayedActivationHandler,delay)},_delayedActivation Handler:function(){var item=this._pendingActivationItem;this._pendingActivationI tem=undefined;this._pendingActivationTimeout=undefined;item.fire(this.activateEv ent,null,{bubbles:true,cancelable:true})},_cancelPendingActivation:function(){if (this._pendingActivationTimeout!==undefined){this.cancelAsync(this._pendingActiv ationTimeout);this._pendingActivationItem=undefined;this._pendingActivationTimeo ut=undefined}},_onArrowKeyup:function(event){if(this.autoselect){this._scheduleA ctivation(this.focusedItem,this.autoselectDelay)}},_onBlurCapture:function(event ){if(event.target===this._pendingActivationItem){this._cancelPendingActivation() }},get _tabContainerScrollSize(){return Math.max(0,this.$.tabsContainer.scrollWi dth-this.$.tabsContainer.offsetWidth)},_scroll:function(e,detail){if(!this.scrol lable){return}var ddx=detail&&-detail.ddx||0;this._affectScroll(ddx)},_down:func tion(e){this.async(function(){if(this._defaultFocusAsync){this.cancelAsync(this. _defaultFocusAsync);this._defaultFocusAsync=null}},1)},_affectScroll:function(dx ){this.$.tabsContainer.scrollLeft+=dx;var scrollLeft=this.$.tabsContainer.scroll Left;this._leftHidden=scrollLeft===0;this._rightHidden=scrollLeft===this._tabCon tainerScrollSize},_onLeftScrollButtonDown:function(){this._scrollToLeft();this._ holdJob=setInterval(this._scrollToLeft.bind(this),this._holdDelay)},_onRightScro llButtonDown:function(){this._scrollToRight();this._holdJob=setInterval(this._sc rollToRight.bind(this),this._holdDelay)},_onScrollButtonUp:function(){clearInter val(this._holdJob);this._holdJob=null},_scrollToLeft:function(){this._affectScro ll(-this._step)},_scrollToRight:function(){this._affectScroll(this._step)},_tabC hanged:function(tab,old){if(!tab){this.$.selectionBar.classList.remove("expand") ;this.$.selectionBar.classList.remove("contract");this._positionBar(0,0);return} var r=this.$.tabsContent.getBoundingClientRect();var w=r.width;var tabRect=tab.g etBoundingClientRect();var tabOffsetLeft=tabRect.left-r.left;this._pos={width:th is._calcPercent(tabRect.width,w),left:this._calcPercent(tabOffsetLeft,w)};if(thi s.noSlide||old==null){this.$.selectionBar.classList.remove("expand");this.$.sele ctionBar.classList.remove("contract");this._positionBar(this._pos.width,this._po s.left);return}var oldRect=old.getBoundingClientRect();var oldIndex=this.items.i ndexOf(old);var index=this.items.indexOf(tab);var m=5;this.$.selectionBar.classL ist.add("expand");var moveRight=oldIndex<index;var isRTL=this._isRTL;if(isRTL){m oveRight=!moveRight}if(moveRight){this._positionBar(this._calcPercent(tabRect.le ft+tabRect.width-oldRect.left,w)-m,this._left)}else{this._positionBar(this._calc Percent(oldRect.left+oldRect.width-tabRect.left,w)-m,this._calcPercent(tabOffset Left,w)+m)}if(this.scrollable){this._scrollToSelectedIfNeeded(tabRect.width,tabO ffsetLeft)}},_scrollToSelectedIfNeeded:function(tabWidth,tabOffsetLeft){var l=ta bOffsetLeft-this.$.tabsContainer.scrollLeft;if(l<0){this.$.tabsContainer.scrollL eft+=l}else{l+=tabWidth-this.$.tabsContainer.offsetWidth;if(l>0){this.$.tabsCont ainer.scrollLeft+=l}}},_calcPercent:function(w,w0){return 100*w/w0},_positionBar :function(width,left){width=width||0;left=left||0;this._width=width;this._left=l eft;this.transform("translateX("+left+"%) scaleX("+width/100+")",this.$.selectio nBar)},_onBarTransitionEnd:function(e){var cl=this.$.selectionBar.classList;if(c l.contains("expand")){cl.remove("expand");cl.add("contract");this._positionBar(t his._pos.width,this._pos.left)}else if(cl.contains("contract")){cl.remove("contr act")}}}); 26 Polymer({is:"cr-dialog",extends:"dialog",properties:{closeText:String,ignorePops tate:{type:Boolean,value:false}},ready:function(){window.addEventListener("popst ate",function(){if(!this.ignorePopstate&&this.open)this.cancel()}.bind(this))},c ancel:function(){this.fire("cancel");HTMLDialogElement.prototype.close.call(this ,"")},close:function(opt_returnValue){HTMLDialogElement.prototype.close.call(thi s,"success")},getCloseButton:function(){return this.$.close}});Polymer({is:"app- drawer",properties:{opened:{type:Boolean,value:false,notify:true,reflectToAttrib ute:true},persistent:{type:Boolean,value:false,reflectToAttribute:true},align:{t ype:String,value:"left"},position:{type:String,readOnly:true,value:"left",reflec tToAttribute:true},swipeOpen:{type:Boolean,value:false,reflectToAttribute:true}, noFocusTrap:{type:Boolean,value:false}},observers:["resetLayout(position)","_res etPosition(align, isAttached)"],_translateOffset:0,_trackDetails:null,_drawerSta te:0,_boundEscKeydownHandler:null,_firstTabStop:null,_lastTabStop:null,ready:fun ction(){this.setScrollDirection("y");this._setTransitionDuration("0s")},attached :function(){Polymer.RenderStatus.afterNextRender(this,function(){this._setTransi tionDuration("");this._boundEscKeydownHandler=this._escKeydownHandler.bind(this) ;this._resetDrawerState();this.listen(this,"track","_track");this.addEventListen er("transitionend",this._transitionend.bind(this));this.addEventListener("keydow n",this._tabKeydownHandler.bind(this))})},detached:function(){document.removeEve ntListener("keydown",this._boundEscKeydownHandler)},open:function(){this.opened= true},close:function(){this.opened=false},toggle:function(){this.opened=!this.op ened},getWidth:function(){return this.$.contentContainer.offsetWidth},resetLayou t:function(){this.debounce("_resetLayout",function(){this.fire("app-drawer-reset -layout")},1)},_isRTL:function(){return window.getComputedStyle(this).direction= =="rtl"},_resetPosition:function(){switch(this.align){case"start":this._setPosit ion(this._isRTL()?"right":"left");return;case"end":this._setPosition(this._isRTL ()?"left":"right");return}this._setPosition(this.align)},_escKeydownHandler:func tion(event){var ESC_KEYCODE=27;if(event.keyCode===ESC_KEYCODE){event.preventDefa ult();this.close()}},_track:function(event){if(this.persistent){return}event.pre ventDefault();switch(event.detail.state){case"start":this._trackStart(event);bre ak;case"track":this._trackMove(event);break;case"end":this._trackEnd(event);brea k}},_trackStart:function(event){this._drawerState=this._DRAWER_STATE.TRACKING;th is._setTransitionDuration("0s");this.style.visibility="visible";var rect=this.$. contentContainer.getBoundingClientRect();if(this.position==="left"){this._transl ateOffset=rect.left}else{this._translateOffset=rect.right-window.innerWidth}this ._trackDetails=[]},_trackMove:function(event){this._translateDrawer(event.detail .dx+this._translateOffset);this._trackDetails.push({dx:event.detail.dx,timeStamp :Date.now()})},_trackEnd:function(event){var x=event.detail.dx+this._translateOf fset;var drawerWidth=this.getWidth();var isPositionLeft=this.position==="left";v ar isInEndState=isPositionLeft?x>=0||x<=-drawerWidth:x<=0||x>=drawerWidth;if(!is InEndState){var trackDetails=this._trackDetails;this._trackDetails=null;this._fl ingDrawer(event,trackDetails);if(this._drawerState===this._DRAWER_STATE.FLINGING ){return}}var halfWidth=drawerWidth/2;if(event.detail.dx<-halfWidth){this.opened =this.position==="right"}else if(event.detail.dx>halfWidth){this.opened=this.pos ition==="left"}if(isInEndState){this._resetDrawerState()}this._setTransitionDura tion("");this._resetDrawerTranslate();this.style.visibility=""},_calculateVeloci ty:function(event,trackDetails){var now=Date.now();var timeLowerBound=now-100;va r trackDetail;var min=0;var max=trackDetails.length-1;while(min<=max){var mid=mi n+max>>1;var d=trackDetails[mid];if(d.timeStamp>=timeLowerBound){trackDetail=d;m ax=mid-1}else{min=mid+1}}if(trackDetail){var dx=event.detail.dx-trackDetail.dx;v ar dt=now-trackDetail.timeStamp||1;return dx/dt}return 0},_flingDrawer:function( event,trackDetails){var velocity=this._calculateVelocity(event,trackDetails);if( Math.abs(velocity)<this._MIN_FLING_THRESHOLD){return}this._drawerState=this._DRA WER_STATE.FLINGING;var x=event.detail.dx+this._translateOffset;var drawerWidth=t his.getWidth();var isPositionLeft=this.position==="left";var isVelocityPositive= velocity>0;var isClosingLeft=!isVelocityPositive&&isPositionLeft;var isClosingRi ght=isVelocityPositive&&!isPositionLeft;var dx;if(isClosingLeft){dx=-(x+drawerWi dth)}else if(isClosingRight){dx=drawerWidth-x}else{dx=-x}if(isVelocityPositive){ velocity=Math.max(velocity,this._MIN_TRANSITION_VELOCITY);this.opened=this.posit ion==="left"}else{velocity=Math.min(velocity,-this._MIN_TRANSITION_VELOCITY);thi s.opened=this.position==="right"}this._setTransitionDuration(this._FLING_INITIAL _SLOPE*dx/velocity+"ms");this._setTransitionTimingFunction(this._FLING_TIMING_FU NCTION);this._resetDrawerTranslate()},_transitionend:function(event){var target= Polymer.dom(event).rootTarget;if(target===this.$.contentContainer||target===this .$.scrim){if(this._drawerState===this._DRAWER_STATE.FLINGING){this._setTransitio nDuration("");this._setTransitionTimingFunction("");this.style.visibility=""}thi s._resetDrawerState()}},_setTransitionDuration:function(duration){this.$.content Container.style.transitionDuration=duration;this.$.scrim.style.transitionDuratio n=duration},_setTransitionTimingFunction:function(timingFunction){this.$.content Container.style.transitionTimingFunction=timingFunction;this.$.scrim.style.trans itionTimingFunction=timingFunction},_translateDrawer:function(x){var drawerWidth =this.getWidth();if(this.position==="left"){x=Math.max(-drawerWidth,Math.min(x,0 ));this.$.scrim.style.opacity=1+x/drawerWidth}else{x=Math.max(0,Math.min(x,drawe rWidth));this.$.scrim.style.opacity=1-x/drawerWidth}this.translate3d(x+"px","0", "0",this.$.contentContainer)},_resetDrawerTranslate:function(){this.$.scrim.styl e.opacity="";this.transform("",this.$.contentContainer)},_resetDrawerState:funct ion(){var oldState=this._drawerState;if(this.opened){this._drawerState=this.pers istent?this._DRAWER_STATE.OPENED_PERSISTENT:this._DRAWER_STATE.OPENED}else{this. _drawerState=this._DRAWER_STATE.CLOSED}if(oldState!==this._drawerState){if(this. _drawerState===this._DRAWER_STATE.OPENED){this._setKeyboardFocusTrap();document. addEventListener("keydown",this._boundEscKeydownHandler);document.body.style.ove rflow="hidden"}else{document.removeEventListener("keydown",this._boundEscKeydown Handler);document.body.style.overflow=""}if(oldState!==this._DRAWER_STATE.INIT){ this.fire("app-drawer-transitioned")}}},_setKeyboardFocusTrap:function(){if(this .noFocusTrap){return}var focusableElementsSelector=['a[href]:not([tabindex="-1"] )','area[href]:not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"]) ','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([t abindex="-1"])','button:not([disabled]):not([tabindex="-1"])','iframe:not([tabin dex="-1"])','[tabindex]:not([tabindex="-1"])','[contentEditable=true]:not([tabin dex="-1"])'].join(",");var focusableElements=Polymer.dom(this).querySelectorAll( focusableElementsSelector);if(focusableElements.length>0){this._firstTabStop=foc usableElements[0];this._lastTabStop=focusableElements[focusableElements.length-1 ]}else{this._firstTabStop=null;this._lastTabStop=null}var tabindex=this.getAttri bute("tabindex");if(tabindex&&parseInt(tabindex,10)>-1){this.focus()}else if(thi s._firstTabStop){this._firstTabStop.focus()}},_tabKeydownHandler:function(event) {if(this.noFocusTrap){return}var TAB_KEYCODE=9;if(this._drawerState===this._DRAW ER_STATE.OPENED&&event.keyCode===TAB_KEYCODE){if(event.shiftKey){if(this._firstT abStop&&Polymer.dom(event).localTarget===this._firstTabStop){event.preventDefaul t();this._lastTabStop.focus()}}else{if(this._lastTabStop&&Polymer.dom(event).loc alTarget===this._lastTabStop){event.preventDefault();this._firstTabStop.focus()} }}},_MIN_FLING_THRESHOLD:.2,_MIN_TRANSITION_VELOCITY:1.2,_FLING_TIMING_FUNCTION: "cubic-bezier(0.667, 1, 0.667, 1)",_FLING_INITIAL_SLOPE:1.5,_DRAWER_STATE:{INIT: 0,OPENED:1,OPENED_PERSISTENT:2,CLOSED:3,TRACKING:4,FLINGING:5}});Polymer({is:"pa per-tab",behaviors:[Polymer.IronControlState,Polymer.IronButtonState,Polymer.Pap erRippleBehavior],properties:{link:{type:Boolean,value:false,reflectToAttribute: true}},hostAttributes:{role:"tab"},listeners:{down:"_updateNoink",tap:"_onTap"}, attached:function(){this._updateNoink()},get _parentNoink(){var parent=Polymer.d om(this).parentNode;return!!parent&&!!parent.noink},_updateNoink:function(){this .noink=!!this.noink||!!this._parentNoink},_onTap:function(event){if(this.link){v ar anchor=this.queryEffectiveChildren("a");if(!anchor){return}if(event.target=== anchor){return}anchor.click()}}});Polymer.IronMenubarBehaviorImpl={hostAttribute s:{role:"menubar"},keyBindings:{left:"_onLeftKey",right:"_onRightKey"},_onUpKey: function(event){this.focusedItem.click();event.detail.keyboardEvent.preventDefau lt()},_onDownKey:function(event){this.focusedItem.click();event.detail.keyboardE vent.preventDefault()},get _isRTL(){return window.getComputedStyle(this)["direct ion"]==="rtl"},_onLeftKey:function(event){if(this._isRTL){this._focusNext()}else {this._focusPrevious()}event.detail.keyboardEvent.preventDefault()},_onRightKey: function(event){if(this._isRTL){this._focusPrevious()}else{this._focusNext()}eve nt.detail.keyboardEvent.preventDefault()},_onKeydown:function(event){if(this.key boardEventMatchesKeys(event,"up down left right esc")){return}this._focusWithKey boardEvent(event)}};Polymer.IronMenubarBehavior=[Polymer.IronMenuBehavior,Polyme r.IronMenubarBehaviorImpl];Polymer({is:"paper-tabs",behaviors:[Polymer.IronResiz ableBehavior,Polymer.IronMenubarBehavior],properties:{noink:{type:Boolean,value: false,observer:"_noinkChanged"},noBar:{type:Boolean,value:false},noSlide:{type:B oolean,value:false},scrollable:{type:Boolean,value:false},fitContainer:{type:Boo lean,value:false},disableDrag:{type:Boolean,value:false},hideScrollButtons:{type :Boolean,value:false},alignBottom:{type:Boolean,value:false},selectable:{type:St ring,value:"paper-tab"},autoselect:{type:Boolean,value:false},autoselectDelay:{t ype:Number,value:0},_step:{type:Number,value:10},_holdDelay:{type:Number,value:1 },_leftHidden:{type:Boolean,value:false},_rightHidden:{type:Boolean,value:false} ,_previousTab:{type:Object}},hostAttributes:{role:"tablist"},listeners:{"iron-re size":"_onTabSizingChanged","iron-items-changed":"_onTabSizingChanged","iron-sel ect":"_onIronSelect","iron-deselect":"_onIronDeselect"},keyBindings:{"left:keyup right:keyup":"_onArrowKeyup"},created:function(){this._holdJob=null;this._pendi ngActivationItem=undefined;this._pendingActivationTimeout=undefined;this._bindDe layedActivationHandler=this._delayedActivationHandler.bind(this);this.addEventLi stener("blur",this._onBlurCapture.bind(this),true)},ready:function(){this.setScr ollDirection("y",this.$.tabsContainer)},detached:function(){this._cancelPendingA ctivation()},_noinkChanged:function(noink){var childTabs=Polymer.dom(this).query SelectorAll("paper-tab");childTabs.forEach(noink?this._setNoinkAttribute:this._r emoveNoinkAttribute)},_setNoinkAttribute:function(element){element.setAttribute( "noink","")},_removeNoinkAttribute:function(element){element.removeAttribute("no ink")},_computeScrollButtonClass:function(hideThisButton,scrollable,hideScrollBu ttons){if(!scrollable||hideScrollButtons){return"hidden"}if(hideThisButton){retu rn"not-visible"}return""},_computeTabsContentClass:function(scrollable,fitContai ner){return scrollable?"scrollable"+(fitContainer?" fit-container":""):" fit-con tainer"},_computeSelectionBarClass:function(noBar,alignBottom){if(noBar){return" hidden"}else if(alignBottom){return"align-bottom"}return""},_onTabSizingChanged: function(){this.debounce("_onTabSizingChanged",function(){this._scroll();this._t abChanged(this.selectedItem)},10)},_onIronSelect:function(event){this._tabChange d(event.detail.item,this._previousTab);this._previousTab=event.detail.item;this. cancelDebouncer("tab-changed")},_onIronDeselect:function(event){this.debounce("t ab-changed",function(){this._tabChanged(null,this._previousTab);this._previousTa b=null},1)},_activateHandler:function(){this._cancelPendingActivation();Polymer. IronMenuBehaviorImpl._activateHandler.apply(this,arguments)},_scheduleActivation :function(item,delay){this._pendingActivationItem=item;this._pendingActivationTi meout=this.async(this._bindDelayedActivationHandler,delay)},_delayedActivationHa ndler:function(){var item=this._pendingActivationItem;this._pendingActivationIte m=undefined;this._pendingActivationTimeout=undefined;item.fire(this.activateEven t,null,{bubbles:true,cancelable:true})},_cancelPendingActivation:function(){if(t his._pendingActivationTimeout!==undefined){this.cancelAsync(this._pendingActivat ionTimeout);this._pendingActivationItem=undefined;this._pendingActivationTimeout =undefined}},_onArrowKeyup:function(event){if(this.autoselect){this._scheduleAct ivation(this.focusedItem,this.autoselectDelay)}},_onBlurCapture:function(event){ if(event.target===this._pendingActivationItem){this._cancelPendingActivation()}} ,get _tabContainerScrollSize(){return Math.max(0,this.$.tabsContainer.scrollWidt h-this.$.tabsContainer.offsetWidth)},_scroll:function(e,detail){if(!this.scrolla ble){return}var ddx=detail&&-detail.ddx||0;this._affectScroll(ddx)},_down:functi on(e){this.async(function(){if(this._defaultFocusAsync){this.cancelAsync(this._d efaultFocusAsync);this._defaultFocusAsync=null}},1)},_affectScroll:function(dx){ this.$.tabsContainer.scrollLeft+=dx;var scrollLeft=this.$.tabsContainer.scrollLe ft;this._leftHidden=scrollLeft===0;this._rightHidden=scrollLeft===this._tabConta inerScrollSize},_onLeftScrollButtonDown:function(){this._scrollToLeft();this._ho ldJob=setInterval(this._scrollToLeft.bind(this),this._holdDelay)},_onRightScroll ButtonDown:function(){this._scrollToRight();this._holdJob=setInterval(this._scro llToRight.bind(this),this._holdDelay)},_onScrollButtonUp:function(){clearInterva l(this._holdJob);this._holdJob=null},_scrollToLeft:function(){this._affectScroll (-this._step)},_scrollToRight:function(){this._affectScroll(this._step)},_tabCha nged:function(tab,old){if(!tab){this.$.selectionBar.classList.remove("expand");t his.$.selectionBar.classList.remove("contract");this._positionBar(0,0);return}va r r=this.$.tabsContent.getBoundingClientRect();var w=r.width;var tabRect=tab.get BoundingClientRect();var tabOffsetLeft=tabRect.left-r.left;this._pos={width:this ._calcPercent(tabRect.width,w),left:this._calcPercent(tabOffsetLeft,w)};if(this. noSlide||old==null){this.$.selectionBar.classList.remove("expand");this.$.select ionBar.classList.remove("contract");this._positionBar(this._pos.width,this._pos. left);return}var oldRect=old.getBoundingClientRect();var oldIndex=this.items.ind exOf(old);var index=this.items.indexOf(tab);var m=5;this.$.selectionBar.classLis t.add("expand");var moveRight=oldIndex<index;var isRTL=this._isRTL;if(isRTL){mov eRight=!moveRight}if(moveRight){this._positionBar(this._calcPercent(tabRect.left +tabRect.width-oldRect.left,w)-m,this._left)}else{this._positionBar(this._calcPe rcent(oldRect.left+oldRect.width-tabRect.left,w)-m,this._calcPercent(tabOffsetLe ft,w)+m)}if(this.scrollable){this._scrollToSelectedIfNeeded(tabRect.width,tabOff setLeft)}},_scrollToSelectedIfNeeded:function(tabWidth,tabOffsetLeft){var l=tabO ffsetLeft-this.$.tabsContainer.scrollLeft;if(l<0){this.$.tabsContainer.scrollLef t+=l}else{l+=tabWidth-this.$.tabsContainer.offsetWidth;if(l>0){this.$.tabsContai ner.scrollLeft+=l}}},_calcPercent:function(w,w0){return 100*w/w0},_positionBar:f unction(width,left){width=width||0;left=left||0;this._width=width;this._left=lef t;this.transform("translateX("+left+"%) scaleX("+width/100+")",this.$.selectionB ar)},_onBarTransitionEnd:function(e){var cl=this.$.selectionBar.classList;if(cl. contains("expand")){cl.remove("expand");cl.add("contract");this._positionBar(thi s._pos.width,this._pos.left)}else if(cl.contains("contract")){cl.remove("contrac t")}}});
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698