OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 function PromiseResolver(){this.resolve_;this.reject_;this.promise_=new Promise(
function(resolve,reject){this.resolve_=resolve;this.reject_=reject}.bind(this))}
PromiseResolver.prototype={get promise(){return this.promise_},set promise(p){as
sertNotReached()},get resolve(){return this.resolve_},set resolve(r){assertNotRe
ached()},get reject(){return this.reject_},set reject(s){assertNotReached()}}; | 4 function PromiseResolver(){this.resolve_;this.reject_;this.promise_=new Promise(
function(resolve,reject){this.resolve_=resolve;this.reject_=reject}.bind(this))}
PromiseResolver.prototype={get promise(){return this.promise_},set promise(p){as
sertNotReached()},get resolve(){return this.resolve_},set resolve(r){assertNotRe
ached()},get reject(){return this.reject_},set reject(s){assertNotReached()}}; |
5 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 5 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
6 // Use of this source code is governed by a BSD-style license that can be | 6 // Use of this source code is governed by a BSD-style license that can be |
7 // found in the LICENSE file. | 7 // found in the LICENSE file. |
8 var global=this;var WebUIListener;var cr=cr||function(){"use strict";function ex
portPath(name,opt_object,opt_objectToExportTo){var parts=name.split(".");var cur
=opt_objectToExportTo||global;for(var part;parts.length&&(part=parts.shift());){
if(!parts.length&&opt_object!==undefined){cur[part]=opt_object}else if(part in c
ur){cur=cur[part]}else{cur=cur[part]={}}}return cur}function dispatchPropertyCha
nge(target,propertyName,newValue,oldValue){var e=new Event(propertyName+"Change"
);e.propertyName=propertyName;e.newValue=newValue;e.oldValue=oldValue;target.dis
patchEvent(e)}function getAttributeName(jsName){return jsName.replace(/([A-Z])/g
,"-$1").toLowerCase()}var PropertyKind={JS:"js",ATTR:"attr",BOOL_ATTR:"boolAttr"
};function getGetter(name,kind){switch(kind){case PropertyKind.JS:var privateNam
e=name+"_";return function(){return this[privateName]};case PropertyKind.ATTR:va
r attributeName=getAttributeName(name);return function(){return this.getAttribut
e(attributeName)};case PropertyKind.BOOL_ATTR:var attributeName=getAttributeName
(name);return function(){return this.hasAttribute(attributeName)}}throw"not reac
hed"}function getSetter(name,kind,opt_setHook){switch(kind){case PropertyKind.JS
:var privateName=name+"_";return function(value){var oldValue=this[name];if(valu
e!==oldValue){this[privateName]=value;if(opt_setHook)opt_setHook.call(this,value
,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};case PropertyKind.
ATTR:var attributeName=getAttributeName(name);return function(value){var oldValu
e=this[name];if(value!==oldValue){if(value==undefined)this.removeAttribute(attri
buteName);else this.setAttribute(attributeName,value);if(opt_setHook)opt_setHook
.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};ca
se PropertyKind.BOOL_ATTR:var attributeName=getAttributeName(name);return functi
on(value){var oldValue=this[name];if(value!==oldValue){if(value)this.setAttribut
e(attributeName,name);else this.removeAttribute(attributeName);if(opt_setHook)op
t_setHook.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldVa
lue)}}}throw"not reached"}function defineProperty(obj,name,opt_kind,opt_setHook)
{if(typeof obj=="function")obj=obj.prototype;var kind=opt_kind||PropertyKind.JS;
if(!obj.__lookupGetter__(name))obj.__defineGetter__(name,getGetter(name,kind));i
f(!obj.__lookupSetter__(name))obj.__defineSetter__(name,getSetter(name,kind,opt_
setHook))}var uidCounter=1;function createUid(){return uidCounter++}function get
Uid(item){if(item.hasOwnProperty("uid"))return item.uid;return item.uid=createUi
d()}function dispatchSimpleEvent(target,type,opt_bubbles,opt_cancelable){var e=n
ew Event(type,{bubbles:opt_bubbles,cancelable:opt_cancelable===undefined||opt_ca
ncelable});return target.dispatchEvent(e)}function define(name,fun){var obj=expo
rtPath(name);var exports=fun();for(var propertyName in exports){var propertyDesc
riptor=Object.getOwnPropertyDescriptor(exports,propertyName);if(propertyDescript
or)Object.defineProperty(obj,propertyName,propertyDescriptor)}}function addSingl
etonGetter(ctor){ctor.getInstance=function(){return ctor.instance_||(ctor.instan
ce_=new ctor)}}function makePublic(ctor,methods,opt_target){methods.forEach(func
tion(method){ctor[method]=function(){var target=opt_target?document.getElementBy
Id(opt_target):ctor.getInstance();return target[method+"_"].apply(target,argumen
ts)}})}var chromeSendResolverMap={};function webUIResponse(id,isSuccess,response
){var resolver=chromeSendResolverMap[id];delete chromeSendResolverMap[id];if(isS
uccess)resolver.resolve(response);else resolver.reject(response)}function sendWi
thPromise(methodName,var_args){var args=Array.prototype.slice.call(arguments,1);
var promiseResolver=new PromiseResolver;var id=methodName+"_"+createUid();chrome
SendResolverMap[id]=promiseResolver;chrome.send(methodName,[id].concat(args));re
turn promiseResolver.promise}var webUIListenerMap={};function webUIListenerCallb
ack(event,var_args){var eventListenersMap=webUIListenerMap[event];if(!eventListe
nersMap){return}var args=Array.prototype.slice.call(arguments,1);for(var listene
rId in eventListenersMap){eventListenersMap[listenerId].apply(null,args)}}functi
on addWebUIListener(eventName,callback){webUIListenerMap[eventName]=webUIListene
rMap[eventName]||{};var uid=createUid();webUIListenerMap[eventName][uid]=callbac
k;return{eventName:eventName,uid:uid}}function removeWebUIListener(listener){var
listenerExists=webUIListenerMap[listener.eventName]&&webUIListenerMap[listener.
eventName][listener.uid];if(listenerExists){delete webUIListenerMap[listener.eve
ntName][listener.uid];return true}return false}return{addSingletonGetter:addSing
letonGetter,createUid:createUid,define:define,defineProperty:defineProperty,disp
atchPropertyChange:dispatchPropertyChange,dispatchSimpleEvent:dispatchSimpleEven
t,exportPath:exportPath,getUid:getUid,makePublic:makePublic,PropertyKind:Propert
yKind,addWebUIListener:addWebUIListener,removeWebUIListener:removeWebUIListener,
sendWithPromise:sendWithPromise,webUIListenerCallback:webUIListenerCallback,webU
IResponse:webUIResponse,get doc(){return document},get isMac(){return/Mac/.test(
navigator.platform)},get isWindows(){return/Win/.test(navigator.platform)},get i
sChromeOS(){return/CrOS/.test(navigator.userAgent)},get isLinux(){return/Linux/.
test(navigator.userAgent)},get isAndroid(){return/Android/.test(navigator.userAg
ent)},get isIOS(){return/iPad|iPhone|iPod/.test(navigator.platform)}}}(); | 8 var global=this;var WebUIListener;var cr=cr||function(){"use strict";function ex
portPath(name,opt_object,opt_objectToExportTo){var parts=name.split(".");var cur
=opt_objectToExportTo||global;for(var part;parts.length&&(part=parts.shift());){
if(!parts.length&&opt_object!==undefined){cur[part]=opt_object}else if(part in c
ur){cur=cur[part]}else{cur=cur[part]={}}}return cur}function dispatchPropertyCha
nge(target,propertyName,newValue,oldValue){var e=new Event(propertyName+"Change"
);e.propertyName=propertyName;e.newValue=newValue;e.oldValue=oldValue;target.dis
patchEvent(e)}function getAttributeName(jsName){return jsName.replace(/([A-Z])/g
,"-$1").toLowerCase()}var PropertyKind={JS:"js",ATTR:"attr",BOOL_ATTR:"boolAttr"
};function getGetter(name,kind){switch(kind){case PropertyKind.JS:var privateNam
e=name+"_";return function(){return this[privateName]};case PropertyKind.ATTR:va
r attributeName=getAttributeName(name);return function(){return this.getAttribut
e(attributeName)};case PropertyKind.BOOL_ATTR:var attributeName=getAttributeName
(name);return function(){return this.hasAttribute(attributeName)}}throw"not reac
hed"}function getSetter(name,kind,opt_setHook){switch(kind){case PropertyKind.JS
:var privateName=name+"_";return function(value){var oldValue=this[name];if(valu
e!==oldValue){this[privateName]=value;if(opt_setHook)opt_setHook.call(this,value
,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};case PropertyKind.
ATTR:var attributeName=getAttributeName(name);return function(value){var oldValu
e=this[name];if(value!==oldValue){if(value==undefined)this.removeAttribute(attri
buteName);else this.setAttribute(attributeName,value);if(opt_setHook)opt_setHook
.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldValue)}};ca
se PropertyKind.BOOL_ATTR:var attributeName=getAttributeName(name);return functi
on(value){var oldValue=this[name];if(value!==oldValue){if(value)this.setAttribut
e(attributeName,name);else this.removeAttribute(attributeName);if(opt_setHook)op
t_setHook.call(this,value,oldValue);dispatchPropertyChange(this,name,value,oldVa
lue)}}}throw"not reached"}function defineProperty(obj,name,opt_kind,opt_setHook)
{if(typeof obj=="function")obj=obj.prototype;var kind=opt_kind||PropertyKind.JS;
if(!obj.__lookupGetter__(name))obj.__defineGetter__(name,getGetter(name,kind));i
f(!obj.__lookupSetter__(name))obj.__defineSetter__(name,getSetter(name,kind,opt_
setHook))}var uidCounter=1;function createUid(){return uidCounter++}function get
Uid(item){if(item.hasOwnProperty("uid"))return item.uid;return item.uid=createUi
d()}function dispatchSimpleEvent(target,type,opt_bubbles,opt_cancelable){var e=n
ew Event(type,{bubbles:opt_bubbles,cancelable:opt_cancelable===undefined||opt_ca
ncelable});return target.dispatchEvent(e)}function define(name,fun){var obj=expo
rtPath(name);var exports=fun();for(var propertyName in exports){var propertyDesc
riptor=Object.getOwnPropertyDescriptor(exports,propertyName);if(propertyDescript
or)Object.defineProperty(obj,propertyName,propertyDescriptor)}}function addSingl
etonGetter(ctor){ctor.getInstance=function(){return ctor.instance_||(ctor.instan
ce_=new ctor)}}function makePublic(ctor,methods,opt_target){methods.forEach(func
tion(method){ctor[method]=function(){var target=opt_target?document.getElementBy
Id(opt_target):ctor.getInstance();return target[method+"_"].apply(target,argumen
ts)}})}var chromeSendResolverMap={};function webUIResponse(id,isSuccess,response
){var resolver=chromeSendResolverMap[id];delete chromeSendResolverMap[id];if(isS
uccess)resolver.resolve(response);else resolver.reject(response)}function sendWi
thPromise(methodName,var_args){var args=Array.prototype.slice.call(arguments,1);
var promiseResolver=new PromiseResolver;var id=methodName+"_"+createUid();chrome
SendResolverMap[id]=promiseResolver;chrome.send(methodName,[id].concat(args));re
turn promiseResolver.promise}var webUIListenerMap={};function webUIListenerCallb
ack(event,var_args){var eventListenersMap=webUIListenerMap[event];if(!eventListe
nersMap){return}var args=Array.prototype.slice.call(arguments,1);for(var listene
rId in eventListenersMap){eventListenersMap[listenerId].apply(null,args)}}functi
on addWebUIListener(eventName,callback){webUIListenerMap[eventName]=webUIListene
rMap[eventName]||{};var uid=createUid();webUIListenerMap[eventName][uid]=callbac
k;return{eventName:eventName,uid:uid}}function removeWebUIListener(listener){var
listenerExists=webUIListenerMap[listener.eventName]&&webUIListenerMap[listener.
eventName][listener.uid];if(listenerExists){delete webUIListenerMap[listener.eve
ntName][listener.uid];return true}return false}return{addSingletonGetter:addSing
letonGetter,createUid:createUid,define:define,defineProperty:defineProperty,disp
atchPropertyChange:dispatchPropertyChange,dispatchSimpleEvent:dispatchSimpleEven
t,exportPath:exportPath,getUid:getUid,makePublic:makePublic,PropertyKind:Propert
yKind,addWebUIListener:addWebUIListener,removeWebUIListener:removeWebUIListener,
sendWithPromise:sendWithPromise,webUIListenerCallback:webUIListenerCallback,webU
IResponse:webUIResponse,get doc(){return document},get isMac(){return/Mac/.test(
navigator.platform)},get isWindows(){return/Win/.test(navigator.platform)},get i
sChromeOS(){return/CrOS/.test(navigator.userAgent)},get isLinux(){return/Linux/.
test(navigator.userAgent)},get isAndroid(){return/Android/.test(navigator.userAg
ent)},get isIOS(){return/iPad|iPhone|iPod/.test(navigator.platform)}}}(); |
9 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 9 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
10 // Use of this source code is governed by a BSD-style license that can be | 10 // Use of this source code is governed by a BSD-style license that can be |
11 // found in the LICENSE file. | 11 // found in the LICENSE file. |
12 cr.define("cr.ui",function(){function decorate(source,constr){var elements;if(ty
peof source=="string")elements=cr.doc.querySelectorAll(source);else elements=[so
urce];for(var i=0,el;el=elements[i];i++){if(!(el instanceof constr))constr.decor
ate(el)}}function createElementHelper(tagName,opt_bag){var doc;if(opt_bag&&opt_b
ag.ownerDocument)doc=opt_bag.ownerDocument;else doc=cr.doc;return doc.createElem
ent(tagName)}function define(tagNameOrFunction){var createFunction,tagName;if(ty
peof tagNameOrFunction=="function"){createFunction=tagNameOrFunction;tagName=""}
else{createFunction=createElementHelper;tagName=tagNameOrFunction}function f(opt
_propertyBag){var el=createFunction(tagName,opt_propertyBag);f.decorate(el);for(
var propertyName in opt_propertyBag){el[propertyName]=opt_propertyBag[propertyNa
me]}return el}f.decorate=function(el){el.__proto__=f.prototype;el.decorate()};re
turn f}function limitInputWidth(el,parentEl,min,opt_scale){el.style.width="10px"
;var doc=el.ownerDocument;var win=doc.defaultView;var computedStyle=win.getCompu
tedStyle(el);var parentComputedStyle=win.getComputedStyle(parentEl);var rtl=comp
utedStyle.direction=="rtl";var inputRect=el.getBoundingClientRect();var parentRe
ct=parentEl.getBoundingClientRect();var startPos=rtl?parentRect.right-inputRect.
right:inputRect.left-parentRect.left;var inner=parseInt(computedStyle.borderLeft
Width,10)+parseInt(computedStyle.paddingLeft,10)+parseInt(computedStyle.paddingR
ight,10)+parseInt(computedStyle.borderRightWidth,10);var parentPadding=rtl?parse
Int(parentComputedStyle.paddingLeft,10):parseInt(parentComputedStyle.paddingRigh
t,10);var max=parentEl.clientWidth-startPos-inner-parentPadding;if(opt_scale)max
*=opt_scale;function limit(){if(el.scrollWidth>max){el.style.width=max+"px"}else
{el.style.width=0;var sw=el.scrollWidth;if(sw<min){el.style.width=min+"px"}else{
el.style.width=sw+"px"}}}el.addEventListener("input",limit);limit()}function toC
ssPx(pixels){if(!window.isFinite(pixels))console.error("Pixel value is not a num
ber: "+pixels);return Math.round(pixels)+"px"}function swallowDoubleClick(e){var
doc=e.target.ownerDocument;var counter=Math.min(1,e.detail);function swallow(e)
{e.stopPropagation();e.preventDefault()}function onclick(e){if(e.detail>counter)
{counter=e.detail;swallow(e)}else{doc.removeEventListener("dblclick",swallow,tru
e);doc.removeEventListener("click",onclick,true)}}setTimeout(function(){doc.addE
ventListener("click",onclick,true);doc.addEventListener("dblclick",swallow,true)
},0)}return{decorate:decorate,define:define,limitInputWidth:limitInputWidth,toCs
sPx:toCssPx,swallowDoubleClick:swallowDoubleClick}}); | 12 cr.define("cr.ui",function(){function decorate(source,constr){var elements;if(ty
peof source=="string")elements=cr.doc.querySelectorAll(source);else elements=[so
urce];for(var i=0,el;el=elements[i];i++){if(!(el instanceof constr))constr.decor
ate(el)}}function createElementHelper(tagName,opt_bag){var doc;if(opt_bag&&opt_b
ag.ownerDocument)doc=opt_bag.ownerDocument;else doc=cr.doc;return doc.createElem
ent(tagName)}function define(tagNameOrFunction){var createFunction,tagName;if(ty
peof tagNameOrFunction=="function"){createFunction=tagNameOrFunction;tagName=""}
else{createFunction=createElementHelper;tagName=tagNameOrFunction}function f(opt
_propertyBag){var el=createFunction(tagName,opt_propertyBag);f.decorate(el);for(
var propertyName in opt_propertyBag){el[propertyName]=opt_propertyBag[propertyNa
me]}return el}f.decorate=function(el){el.__proto__=f.prototype;el.decorate()};re
turn f}function limitInputWidth(el,parentEl,min,opt_scale){el.style.width="10px"
;var doc=el.ownerDocument;var win=doc.defaultView;var computedStyle=win.getCompu
tedStyle(el);var parentComputedStyle=win.getComputedStyle(parentEl);var rtl=comp
utedStyle.direction=="rtl";var inputRect=el.getBoundingClientRect();var parentRe
ct=parentEl.getBoundingClientRect();var startPos=rtl?parentRect.right-inputRect.
right:inputRect.left-parentRect.left;var inner=parseInt(computedStyle.borderLeft
Width,10)+parseInt(computedStyle.paddingLeft,10)+parseInt(computedStyle.paddingR
ight,10)+parseInt(computedStyle.borderRightWidth,10);var parentPadding=rtl?parse
Int(parentComputedStyle.paddingLeft,10):parseInt(parentComputedStyle.paddingRigh
t,10);var max=parentEl.clientWidth-startPos-inner-parentPadding;if(opt_scale)max
*=opt_scale;function limit(){if(el.scrollWidth>max){el.style.width=max+"px"}else
{el.style.width=0;var sw=el.scrollWidth;if(sw<min){el.style.width=min+"px"}else{
el.style.width=sw+"px"}}}el.addEventListener("input",limit);limit()}function toC
ssPx(pixels){if(!window.isFinite(pixels))console.error("Pixel value is not a num
ber: "+pixels);return Math.round(pixels)+"px"}function swallowDoubleClick(e){var
doc=e.target.ownerDocument;var counter=Math.min(1,e.detail);function swallow(e)
{e.stopPropagation();e.preventDefault()}function onclick(e){if(e.detail>counter)
{counter=e.detail;swallow(e)}else{doc.removeEventListener("dblclick",swallow,tru
e);doc.removeEventListener("click",onclick,true)}}setTimeout(function(){doc.addE
ventListener("click",onclick,true);doc.addEventListener("dblclick",swallow,true)
},0)}return{decorate:decorate,define:define,limitInputWidth:limitInputWidth,toCs
sPx:toCssPx,swallowDoubleClick:swallowDoubleClick}}); |
13 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 13 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
14 // Use of this source code is governed by a BSD-style license that can be | 14 // Use of this source code is governed by a BSD-style license that can be |
15 // found in the LICENSE file. | 15 // found in the LICENSE file. |
16 cr.define("cr.ui",function(){function KeyboardShortcut(shortcut){var mods={};var
ident="";shortcut.split("|").forEach(function(part){var partLc=part.toLowerCase
();switch(partLc){case"alt":case"ctrl":case"meta":case"shift":mods[partLc+"Key"]
=true;break;default:if(ident)throw Error("Invalid shortcut");ident=part}});this.
ident_=ident;this.mods_=mods}KeyboardShortcut.prototype={matchesEvent:function(e
){if(e.key==this.ident_){var mods=this.mods_;return["altKey","ctrlKey","metaKey"
,"shiftKey"].every(function(k){return e[k]==!!mods[k]})}return false}};var Comma
nd=cr.ui.define("command");Command.prototype={__proto__:HTMLElement.prototype,de
corate:function(){CommandManager.init(assert(this.ownerDocument));if(this.hasAtt
ribute("shortcut"))this.shortcut=this.getAttribute("shortcut")},execute:function
(opt_element){if(this.disabled)return;var doc=this.ownerDocument;if(doc.activeEl
ement){var e=new Event("command",{bubbles:true});e.command=this;(opt_element||do
c.activeElement).dispatchEvent(e)}},canExecuteChange:function(opt_node){dispatch
CanExecuteEvent(this,opt_node||this.ownerDocument.activeElement)},shortcut_:"",g
et shortcut(){return this.shortcut_},set shortcut(shortcut){var oldShortcut=this
.shortcut_;if(shortcut!==oldShortcut){this.keyboardShortcuts_=shortcut.split(/\s
+/).map(function(shortcut){return new KeyboardShortcut(shortcut)});this.shortcut
_=shortcut;cr.dispatchPropertyChange(this,"shortcut",this.shortcut_,oldShortcut)
}},matchesEvent:function(e){if(!this.keyboardShortcuts_)return false;return this
.keyboardShortcuts_.some(function(keyboardShortcut){return keyboardShortcut.matc
hesEvent(e)})}};cr.defineProperty(Command,"label",cr.PropertyKind.ATTR);cr.defin
eProperty(Command,"disabled",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Comman
d,"hidden",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Command,"checked",cr.Pro
pertyKind.BOOL_ATTR);cr.defineProperty(Command,"hideShortcutText",cr.PropertyKin
d.BOOL_ATTR);function dispatchCanExecuteEvent(command,target){var e=new CanExecu
teEvent(command);target.dispatchEvent(e);command.disabled=!e.canExecute}var comm
andManagers={};function CommandManager(doc){doc.addEventListener("focus",this.ha
ndleFocus_.bind(this),true);doc.addEventListener("keydown",this.handleKeyDown_.b
ind(this),false)}CommandManager.init=function(doc){var uid=cr.getUid(doc);if(!(u
id in commandManagers)){commandManagers[uid]=new CommandManager(doc)}};CommandMa
nager.prototype={handleFocus_:function(e){var target=e.target;if(target.menu||ta
rget.command)return;var commands=Array.prototype.slice.call(target.ownerDocument
.querySelectorAll("command"));commands.forEach(function(command){dispatchCanExec
uteEvent(command,target)})},handleKeyDown_:function(e){var target=e.target;var c
ommands=Array.prototype.slice.call(target.ownerDocument.querySelectorAll("comman
d"));for(var i=0,command;command=commands[i];i++){if(command.matchesEvent(e)){co
mmand.canExecuteChange();if(!command.disabled){e.preventDefault();e.stopPropagat
ion();command.execute();return}}}}};function CanExecuteEvent(command){var e=new
Event("canExecute",{bubbles:true,cancelable:true});e.__proto__=CanExecuteEvent.p
rototype;e.command=command;return e}CanExecuteEvent.prototype={__proto__:Event.p
rototype,command:null,canExecute_:false,get canExecute(){return this.canExecute_
},set canExecute(canExecute){this.canExecute_=!!canExecute;this.stopPropagation(
);this.preventDefault()}};return{Command:Command,CanExecuteEvent:CanExecuteEvent
}}); | 16 cr.define("cr.ui",function(){function KeyboardShortcut(shortcut){var mods={};var
ident="";shortcut.split("|").forEach(function(part){var partLc=part.toLowerCase
();switch(partLc){case"alt":case"ctrl":case"meta":case"shift":mods[partLc+"Key"]
=true;break;default:if(ident)throw Error("Invalid shortcut");ident=part}});this.
ident_=ident;this.mods_=mods}KeyboardShortcut.prototype={matchesEvent:function(e
){if(e.key==this.ident_){var mods=this.mods_;return["altKey","ctrlKey","metaKey"
,"shiftKey"].every(function(k){return e[k]==!!mods[k]})}return false}};var Comma
nd=cr.ui.define("command");Command.prototype={__proto__:HTMLElement.prototype,de
corate:function(){CommandManager.init(assert(this.ownerDocument));if(this.hasAtt
ribute("shortcut"))this.shortcut=this.getAttribute("shortcut")},execute:function
(opt_element){if(this.disabled)return;var doc=this.ownerDocument;if(doc.activeEl
ement){var e=new Event("command",{bubbles:true});e.command=this;(opt_element||do
c.activeElement).dispatchEvent(e)}},canExecuteChange:function(opt_node){dispatch
CanExecuteEvent(this,opt_node||this.ownerDocument.activeElement)},shortcut_:"",g
et shortcut(){return this.shortcut_},set shortcut(shortcut){var oldShortcut=this
.shortcut_;if(shortcut!==oldShortcut){this.keyboardShortcuts_=shortcut.split(/\s
+/).map(function(shortcut){return new KeyboardShortcut(shortcut)});this.shortcut
_=shortcut;cr.dispatchPropertyChange(this,"shortcut",this.shortcut_,oldShortcut)
}},matchesEvent:function(e){if(!this.keyboardShortcuts_)return false;return this
.keyboardShortcuts_.some(function(keyboardShortcut){return keyboardShortcut.matc
hesEvent(e)})}};cr.defineProperty(Command,"label",cr.PropertyKind.ATTR);cr.defin
eProperty(Command,"disabled",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Comman
d,"hidden",cr.PropertyKind.BOOL_ATTR);cr.defineProperty(Command,"checked",cr.Pro
pertyKind.BOOL_ATTR);cr.defineProperty(Command,"hideShortcutText",cr.PropertyKin
d.BOOL_ATTR);function dispatchCanExecuteEvent(command,target){var e=new CanExecu
teEvent(command);target.dispatchEvent(e);command.disabled=!e.canExecute}var comm
andManagers={};function CommandManager(doc){doc.addEventListener("focus",this.ha
ndleFocus_.bind(this),true);doc.addEventListener("keydown",this.handleKeyDown_.b
ind(this),false)}CommandManager.init=function(doc){var uid=cr.getUid(doc);if(!(u
id in commandManagers)){commandManagers[uid]=new CommandManager(doc)}};CommandMa
nager.prototype={handleFocus_:function(e){var target=e.target;if(target.menu||ta
rget.command)return;var commands=Array.prototype.slice.call(target.ownerDocument
.querySelectorAll("command"));commands.forEach(function(command){dispatchCanExec
uteEvent(command,target)})},handleKeyDown_:function(e){var target=e.target;var c
ommands=Array.prototype.slice.call(target.ownerDocument.querySelectorAll("comman
d"));for(var i=0,command;command=commands[i];i++){if(command.matchesEvent(e)){co
mmand.canExecuteChange();if(!command.disabled){e.preventDefault();e.stopPropagat
ion();command.execute();return}}}}};function CanExecuteEvent(command){var e=new
Event("canExecute",{bubbles:true,cancelable:true});e.__proto__=CanExecuteEvent.p
rototype;e.command=command;return e}CanExecuteEvent.prototype={__proto__:Event.p
rototype,command:null,canExecute_:false,get canExecute(){return this.canExecute_
},set canExecute(canExecute){this.canExecute_=!!canExecute;this.stopPropagation(
);this.preventDefault()}};return{Command:Command,CanExecuteEvent:CanExecuteEvent
}}); |
17 // Copyright 2016 The Chromium Authors. All rights reserved. | 17 // Copyright 2016 The Chromium Authors. All rights reserved. |
18 // Use of this source code is governed by a BSD-style license that can be | 18 // Use of this source code is governed by a BSD-style license that can be |
19 // found in the LICENSE file. | 19 // found in the LICENSE file. |
20 var WebUIListenerBehavior={properties:{webUIListeners_:{type:Array,value:functio
n(){return[]}}},addWebUIListener:function(eventName,callback){this.webUIListener
s_.push(cr.addWebUIListener(eventName,callback))},detached:function(){while(this
.webUIListeners_.length>0){cr.removeWebUIListener(this.webUIListeners_.pop())}}}
;Polymer({is:"iron-media-query",properties:{queryMatches:{type:Boolean,value:fal
se,readOnly:true,notify:true},query:{type:String,observer:"queryChanged"},full:{
type:Boolean,value:false},_boundMQHandler:{value:function(){return this.queryHan
dler.bind(this)}},_mq:{value:null}},attached:function(){this.style.display="none
";this.queryChanged()},detached:function(){this._remove()},_add:function(){if(th
is._mq){this._mq.addListener(this._boundMQHandler)}},_remove:function(){if(this.
_mq){this._mq.removeListener(this._boundMQHandler)}this._mq=null},queryChanged:f
unction(){this._remove();var query=this.query;if(!query){return}if(!this.full&&q
uery[0]!=="("){query="("+query+")"}this._mq=window.matchMedia(query);this._add()
;this.queryHandler(this._mq)},queryHandler:function(mq){this._setQueryMatches(mq
.matches)}});Polymer.IronResizableBehavior={properties:{_parentResizable:{type:O
bject,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,val
ue:false}},listeners:{"iron-request-resize-notifications":"_onIronRequestResizeN
otifications"},created:function(){this._interestedResizables=[];this._boundNotif
yResize=this.notifyResize.bind(this)},attached:function(){this.fire("iron-reques
t-resize-notifications",null,{node:this,bubbles:true,cancelable:true});if(!this.
_parentResizable){window.addEventListener("resize",this._boundNotifyResize);this
.notifyResize()}},detached:function(){if(this._parentResizable){this._parentResi
zable.stopResizeNotificationsFor(this)}else{window.removeEventListener("resize",
this._boundNotifyResize)}this._parentResizable=null},notifyResize:function(){if(
!this.isAttached){return}this._interestedResizables.forEach(function(resizable){
if(this.resizerShouldNotify(resizable)){this._notifyDescendant(resizable)}},this
);this._fireResize()},assignParentResizable:function(parentResizable){this._pare
ntResizable=parentResizable},stopResizeNotificationsFor:function(target){var ind
ex=this._interestedResizables.indexOf(target);if(index>-1){this._interestedResiz
ables.splice(index,1);this.unlisten(target,"iron-resize","_onDescendantIronResiz
e")}},resizerShouldNotify:function(element){return true},_onDescendantIronResize
:function(event){if(this._notifyingDescendant){event.stopPropagation();return}if
(!Polymer.Settings.useShadow){this._fireResize()}},_fireResize:function(){this.f
ire("iron-resize",null,{node:this,bubbles:false})},_onIronRequestResizeNotificat
ions:function(event){var target=event.path?event.path[0]:event.target;if(target=
==this){return}if(this._interestedResizables.indexOf(target)===-1){this._interes
tedResizables.push(target);this.listen(target,"iron-resize","_onDescendantIronRe
size")}target.assignParentResizable(this);this._notifyDescendant(target);event.s
topPropagation()},_parentResizableChanged:function(parentResizable){if(parentRes
izable){window.removeEventListener("resize",this._boundNotifyResize)}},_notifyDe
scendant:function(descendant){if(!this.isAttached){return}this._notifyingDescend
ant=true;descendant.notifyResize();this._notifyingDescendant=false}};Polymer.Iro
nSelection=function(selectCallback){this.selection=[];this.selectCallback=select
Callback};Polymer.IronSelection.prototype={get:function(){return this.multi?this
.selection.slice():this.selection[0]},clear:function(excludes){this.selection.sl
ice().forEach(function(item){if(!excludes||excludes.indexOf(item)<0){this.setIte
mSelected(item,false)}},this)},isSelected:function(item){return this.selection.i
ndexOf(item)>=0},setItemSelected:function(item,isSelected){if(item!=null){if(isS
elected!==this.isSelected(item)){if(isSelected){this.selection.push(item)}else{v
ar i=this.selection.indexOf(item);if(i>=0){this.selection.splice(i,1)}}if(this.s
electCallback){this.selectCallback(item,isSelected)}}}},select:function(item){if
(this.multi){this.toggle(item)}else if(this.get()!==item){this.setItemSelected(t
his.get(),false);this.setItemSelected(item,true)}},toggle:function(item){this.se
tItemSelected(item,!this.isSelected(item))}};Polymer.IronSelectableBehavior={pro
perties:{attrForSelected:{type:String,value:null},selected:{type:String,notify:t
rue},selectedItem:{type:Object,readOnly:true,notify:true},activateEvent:{type:St
ring,value:"tap",observer:"_activateEventChanged"},selectable:String,selectedCla
ss:{type:String,value:"iron-selected"},selectedAttribute:{type:String,value:null
},fallbackSelection:{type:String,value:null},items:{type:Array,readOnly:true,not
ify:true,value:function(){return[]}},_excludedLocalNames:{type:Object,value:func
tion(){return{template:1}}}},observers:["_updateAttrForSelected(attrForSelected)
","_updateSelected(selected)","_checkFallback(fallbackSelection)"],created:funct
ion(){this._bindFilterItem=this._filterItem.bind(this);this._selection=new Polym
er.IronSelection(this._applySelection.bind(this))},attached:function(){this._obs
erver=this._observeItems(this);this._updateItems();if(!this._shouldUpdateSelecti
on){this._updateSelected()}this._addListener(this.activateEvent)},detached:funct
ion(){if(this._observer){Polymer.dom(this).unobserveNodes(this._observer)}this._
removeListener(this.activateEvent)},indexOf:function(item){return this.items.ind
exOf(item)},select:function(value){this.selected=value},selectPrevious:function(
){var length=this.items.length;var index=(Number(this._valueToIndex(this.selecte
d))-1+length)%length;this.selected=this._indexToValue(index)},selectNext:functio
n(){var index=(Number(this._valueToIndex(this.selected))+1)%this.items.length;th
is.selected=this._indexToValue(index)},selectIndex:function(index){this.select(t
his._indexToValue(index))},forceSynchronousItemUpdate:function(){this._updateIte
ms()},get _shouldUpdateSelection(){return this.selected!=null},_checkFallback:fu
nction(){if(this._shouldUpdateSelection){this._updateSelected()}},_addListener:f
unction(eventName){this.listen(this,eventName,"_activateHandler")},_removeListen
er:function(eventName){this.unlisten(this,eventName,"_activateHandler")},_activa
teEventChanged:function(eventName,old){this._removeListener(old);this._addListen
er(eventName)},_updateItems:function(){var nodes=Polymer.dom(this).queryDistribu
tedElements(this.selectable||"*");nodes=Array.prototype.filter.call(nodes,this._
bindFilterItem);this._setItems(nodes)},_updateAttrForSelected:function(){if(this
._shouldUpdateSelection){this.selected=this._indexToValue(this.indexOf(this.sele
ctedItem))}},_updateSelected:function(){this._selectSelected(this.selected)},_se
lectSelected:function(selected){this._selection.select(this._valueToItem(this.se
lected));if(this.fallbackSelection&&this.items.length&&this._selection.get()===u
ndefined){this.selected=this.fallbackSelection}},_filterItem:function(node){retu
rn!this._excludedLocalNames[node.localName]},_valueToItem:function(value){return
value==null?null:this.items[this._valueToIndex(value)]},_valueToIndex:function(
value){if(this.attrForSelected){for(var i=0,item;item=this.items[i];i++){if(this
._valueForItem(item)==value){return i}}}else{return Number(value)}},_indexToValu
e:function(index){if(this.attrForSelected){var item=this.items[index];if(item){r
eturn this._valueForItem(item)}}else{return index}},_valueForItem:function(item)
{var propValue=item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)];retur
n propValue!=undefined?propValue:item.getAttribute(this.attrForSelected)},_apply
Selection:function(item,isSelected){if(this.selectedClass){this.toggleClass(this
.selectedClass,isSelected,item)}if(this.selectedAttribute){this.toggleAttribute(
this.selectedAttribute,isSelected,item)}this._selectionChange();this.fire("iron-
"+(isSelected?"select":"deselect"),{item:item})},_selectionChange:function(){thi
s._setSelectedItem(this._selection.get())},_observeItems:function(node){return P
olymer.dom(node).observeNodes(function(mutation){this._updateItems();if(this._sh
ouldUpdateSelection){this._updateSelected()}this.fire("iron-items-changed",mutat
ion,{bubbles:false,cancelable:false})})},_activateHandler:function(e){var t=e.ta
rget;var items=this.items;while(t&&t!=this){var i=items.indexOf(t);if(i>=0){var
value=this._indexToValue(i);this._itemActivate(value,t);return}t=t.parentNode}},
_itemActivate:function(value,item){if(!this.fire("iron-activate",{selected:value
,item:item},{cancelable:true}).defaultPrevented){this.select(value)}}};Polymer({
is:"iron-pages",behaviors:[Polymer.IronResizableBehavior,Polymer.IronSelectableB
ehavior],properties:{activateEvent:{type:String,value:null}},observers:["_select
edPageChanged(selected)"],_selectedPageChanged:function(selected,old){this.async
(this.notifyResize)}});Polymer.IronScrollTargetBehavior={properties:{scrollTarge
t:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observe
rs:["_scrollTargetChanged(scrollTarget, isAttached)"],_scrollTargetChanged:funct
ion(scrollTarget,isAttached){var eventTarget;if(this._oldScrollTarget){eventTarg
et=this._oldScrollTarget===this._doc?window:this._oldScrollTarget;eventTarget.re
moveEventListener("scroll",this._boundScrollHandler);this._oldScrollTarget=null}
if(!isAttached){return}if(scrollTarget==="document"){this.scrollTarget=this._doc
}else if(typeof scrollTarget==="string"){this.scrollTarget=this.domHost?this.dom
Host.$[scrollTarget]:Polymer.dom(this.ownerDocument).querySelector("#"+scrollTar
get)}else if(this._isValidScrollTarget()){eventTarget=scrollTarget===this._doc?w
indow:scrollTarget;this._boundScrollHandler=this._boundScrollHandler||this._scro
llHandler.bind(this);this._oldScrollTarget=scrollTarget;eventTarget.addEventList
ener("scroll",this._boundScrollHandler)}},_scrollHandler:function scrollHandler(
){},get _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDoc
ument.documentElement},get _scrollTop(){if(this._isValidScrollTarget()){return t
his.scrollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop}retu
rn 0},get _scrollLeft(){if(this._isValidScrollTarget()){return this.scrollTarget
===this._doc?window.pageXOffset:this.scrollTarget.scrollLeft}return 0},set _scro
llTop(top){if(this.scrollTarget===this._doc){window.scrollTo(window.pageXOffset,
top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollTop=top}},set
_scrollLeft(left){if(this.scrollTarget===this._doc){window.scrollTo(left,window.
pageYOffset)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=l
eft}},scroll:function(left,top){if(this.scrollTarget===this._doc){window.scrollT
o(left,top)}else if(this._isValidScrollTarget()){this.scrollTarget.scrollLeft=le
ft;this.scrollTarget.scrollTop=top}},get _scrollTargetWidth(){if(this._isValidSc
rollTarget()){return this.scrollTarget===this._doc?window.innerWidth:this.scroll
Target.offsetWidth}return 0},get _scrollTargetHeight(){if(this._isValidScrollTar
get()){return this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget
.offsetHeight}return 0},_isValidScrollTarget:function(){return this.scrollTarget
instanceof HTMLElement}};(function(){var metaDatas={};var metaArrays={};var sin
gleton=null;Polymer.IronMeta=Polymer({is:"iron-meta",properties:{type:{type:Stri
ng,value:"default",observer:"_typeChanged"},key:{type:String,observer:"_keyChang
ed"},value:{type:Object,notify:true,observer:"_valueChanged"},self:{type:Boolean
,observer:"_selfChanged"},list:{type:Array,notify:true}},hostAttributes:{hidden:
true},factoryImpl:function(config){if(config){for(var n in config){switch(n){cas
e"type":case"key":case"value":this[n]=config[n];break}}}},created:function(){thi
s._metaDatas=metaDatas;this._metaArrays=metaArrays},_keyChanged:function(key,old
){this._resetRegistration(old)},_valueChanged:function(value){this._resetRegistr
ation(this.key)},_selfChanged:function(self){if(self){this.value=this}},_typeCha
nged:function(type){this._unregisterKey(this.key);if(!metaDatas[type]){metaDatas
[type]={}}this._metaData=metaDatas[type];if(!metaArrays[type]){metaArrays[type]=
[]}this.list=metaArrays[type];this._registerKeyValue(this.key,this.value)},byKey
:function(key){return this._metaData&&this._metaData[key]},_resetRegistration:fu
nction(oldKey){this._unregisterKey(oldKey);this._registerKeyValue(this.key,this.
value)},_unregisterKey:function(key){this._unregister(key,this._metaData,this.li
st)},_registerKeyValue:function(key,value){this._register(key,value,this._metaDa
ta,this.list)},_register:function(key,value,data,list){if(key&&data&&value!==und
efined){data[key]=value;list.push(value)}},_unregister:function(key,data,list){i
f(key&&data){if(key in data){var value=data[key];delete data[key];this.arrayDele
te(list,value)}}}});Polymer.IronMeta.getIronMeta=function getIronMeta(){if(singl
eton===null){singleton=new Polymer.IronMeta}return singleton};Polymer.IronMetaQu
ery=Polymer({is:"iron-meta-query",properties:{type:{type:String,value:"default",
observer:"_typeChanged"},key:{type:String,observer:"_keyChanged"},value:{type:Ob
ject,notify:true,readOnly:true},list:{type:Array,notify:true}},factoryImpl:funct
ion(config){if(config){for(var n in config){switch(n){case"type":case"key":this[
n]=config[n];break}}}},created:function(){this._metaDatas=metaDatas;this._metaAr
rays=metaArrays},_keyChanged:function(key){this._setValue(this._metaData&&this._
metaData[key])},_typeChanged:function(type){this._metaData=metaDatas[type];this.
list=metaArrays[type];if(this.key){this._keyChanged(this.key)}},byKey:function(k
ey){return this._metaData&&this._metaData[key]}})})();Polymer({is:"iron-icon",pr
operties:{icon:{type:String,observer:"_iconChanged"},theme:{type:String,observer
:"_updateIcon"},src:{type:String,observer:"_srcChanged"},_meta:{value:Polymer.Ba
se.create("iron-meta",{type:"iconset"}),observer:"_updateIcon"}},_DEFAULT_ICONSE
T:"icons",_iconChanged:function(icon){var parts=(icon||"").split(":");this._icon
Name=parts.pop();this._iconsetName=parts.pop()||this._DEFAULT_ICONSET;this._upda
teIcon()},_srcChanged:function(src){this._updateIcon()},_usesIconset:function(){
return this.icon||!this.src},_updateIcon:function(){if(this._usesIconset()){if(t
his._img&&this._img.parentNode){Polymer.dom(this.root).removeChild(this._img)}if
(this._iconName===""){if(this._iconset){this._iconset.removeIcon(this)}}else if(
this._iconsetName&&this._meta){this._iconset=this._meta.byKey(this._iconsetName)
;if(this._iconset){this._iconset.applyIcon(this,this._iconName,this.theme);this.
unlisten(window,"iron-iconset-added","_updateIcon")}else{this.listen(window,"iro
n-iconset-added","_updateIcon")}}}else{if(this._iconset){this._iconset.removeIco
n(this)}if(!this._img){this._img=document.createElement("img");this._img.style.w
idth="100%";this._img.style.height="100%";this._img.draggable=false}this._img.sr
c=this.src;Polymer.dom(this.root).appendChild(this._img)}}});(function(){"use st
rict";var KEY_IDENTIFIER={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+
0020":"space","U+007F":"del"};var KEY_CODE={8:"backspace",9:"tab",13:"enter",27:
"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",
39:"right",40:"down",46:"del",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:
"ctrlKey",alt:"altKey",meta:"metaKey"};var KEY_CHAR=/[a-z0-9*]/;var IDENT_CHAR=/
U\+/;var ARROW_KEY=/^arrow/;var SPACE_KEY=/^space(bar)?/;var ESC_KEY=/^escape$/;
function transformKey(key,noSpecialChars){var validKey="";if(key){var lKey=key.t
oLowerCase();if(lKey===" "||SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_K
EY.test(lKey)){validKey="esc"}else if(lKey.length==1){if(!noSpecialChars||KEY_CH
AR.test(lKey)){validKey=lKey}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replac
e("arrow","")}else if(lKey=="multiply"){validKey="*"}else{validKey=lKey}}return
validKey}function transformKeyIdentifier(keyIdent){var validKey="";if(keyIdent){
if(keyIdent in KEY_IDENTIFIER){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_C
HAR.test(keyIdent)){keyIdent=parseInt(keyIdent.replace("U+","0x"),16);validKey=S
tring.fromCharCode(keyIdent).toLowerCase()}else{validKey=keyIdent.toLowerCase()}
}return validKey}function transformKeyCode(keyCode){var validKey="";if(Number(ke
yCode)){if(keyCode>=65&&keyCode<=90){validKey=String.fromCharCode(32+keyCode)}el
se if(keyCode>=112&&keyCode<=123){validKey="f"+(keyCode-112)}else if(keyCode>=48
&&keyCode<=57){validKey=String(keyCode-48)}else if(keyCode>=96&&keyCode<=105){va
lidKey=String(keyCode-96)}else{validKey=KEY_CODE[keyCode]}}return validKey}funct
ion normalizedKeyForEvent(keyEvent,noSpecialChars){if(keyEvent.key){return trans
formKey(keyEvent.key,noSpecialChars)}if(keyEvent.detail&&keyEvent.detail.key){re
turn transformKey(keyEvent.detail.key,noSpecialChars)}return transformKeyIdentif
ier(keyEvent.keyIdentifier)||transformKeyCode(keyEvent.keyCode)||""}function key
ComboMatchesEvent(keyCombo,event){var keyEvent=normalizedKeyForEvent(event,keyCo
mbo.hasModifiers);return keyEvent===keyCombo.key&&(!keyCombo.hasModifiers||!!eve
nt.shiftKey===!!keyCombo.shiftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event
.altKey===!!keyCombo.altKey&&!!event.metaKey===!!keyCombo.metaKey)}function pars
eKeyComboString(keyComboString){if(keyComboString.length===1){return{combo:keyCo
mboString,key:keyComboString,event:"keydown"}}return keyComboString.split("+").r
educe(function(parsedKeyCombo,keyComboPart){var eventParts=keyComboPart.split(":
");var keyName=eventParts[0];var event=eventParts[1];if(keyName in MODIFIER_KEYS
){parsedKeyCombo[MODIFIER_KEYS[keyName]]=true;parsedKeyCombo.hasModifiers=true}e
lse{parsedKeyCombo.key=keyName;parsedKeyCombo.event=event||"keydown"}return pars
edKeyCombo},{combo:keyComboString.split(":").shift()})}function parseEventString
(eventString){return eventString.trim().split(" ").map(function(keyComboString){
return parseKeyComboString(keyComboString)})}Polymer.IronA11yKeysBehavior={prope
rties:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEv
entPropagation:{type:Boolean,value:false},_boundKeyHandlers:{type:Array,value:fu
nction(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{
}}}},observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],ke
yBindings:{},registered:function(){this._prepKeyBindings()},attached:function(){
this._listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListe
ners()},addOwnKeyBinding:function(eventString,handlerName){this._imperativeKeyBi
ndings[eventString]=handlerName;this._prepKeyBindings();this._resetKeyEventListe
ners()},removeOwnKeyBindings:function(){this._imperativeKeyBindings={};this._pre
pKeyBindings();this._resetKeyEventListeners()},keyboardEventMatchesKeys:function
(event,eventString){var keyCombos=parseEventString(eventString);for(var i=0;i<ke
yCombos.length;++i){if(keyComboMatchesEvent(keyCombos[i],event)){return true}}re
turn false},_collectKeyBindings:function(){var keyBindings=this.behaviors.map(fu
nction(behavior){return behavior.keyBindings});if(keyBindings.indexOf(this.keyBi
ndings)===-1){keyBindings.push(this.keyBindings)}return keyBindings},_prepKeyBin
dings:function(){this._keyBindings={};this._collectKeyBindings().forEach(functio
n(keyBindings){for(var eventString in keyBindings){this._addKeyBinding(eventStri
ng,keyBindings[eventString])}},this);for(var eventString in this._imperativeKeyB
indings){this._addKeyBinding(eventString,this._imperativeKeyBindings[eventString
])}for(var eventName in this._keyBindings){this._keyBindings[eventName].sort(fun
ction(kb1,kb2){var b1=kb1[0].hasModifiers;var b2=kb2[0].hasModifiers;return b1==
=b2?0:b1?-1:1})}},_addKeyBinding:function(eventString,handlerName){parseEventStr
ing(eventString).forEach(function(keyCombo){this._keyBindings[keyCombo.event]=th
is._keyBindings[keyCombo.event]||[];this._keyBindings[keyCombo.event].push([keyC
ombo,handlerName])},this)},_resetKeyEventListeners:function(){this._unlistenKeyE
ventListeners();if(this.isAttached){this._listenKeyEventListeners()}},_listenKey
EventListeners:function(){if(!this.keyEventTarget){return}Object.keys(this._keyB
indings).forEach(function(eventName){var keyBindings=this._keyBindings[eventName
];var boundKeyHandler=this._onKeyBindingEvent.bind(this,keyBindings);this._bound
KeyHandlers.push([this.keyEventTarget,eventName,boundKeyHandler]);this.keyEventT
arget.addEventListener(eventName,boundKeyHandler)},this)},_unlistenKeyEventListe
ners:function(){var keyHandlerTuple;var keyEventTarget;var eventName;var boundKe
yHandler;while(this._boundKeyHandlers.length){keyHandlerTuple=this._boundKeyHand
lers.pop();keyEventTarget=keyHandlerTuple[0];eventName=keyHandlerTuple[1];boundK
eyHandler=keyHandlerTuple[2];keyEventTarget.removeEventListener(eventName,boundK
eyHandler)}},_onKeyBindingEvent:function(keyBindings,event){if(this.stopKeyboard
EventPropagation){event.stopPropagation()}if(event.defaultPrevented){return}for(
var i=0;i<keyBindings.length;i++){var keyCombo=keyBindings[i][0];var handlerName
=keyBindings[i][1];if(keyComboMatchesEvent(keyCombo,event)){this._triggerKeyHand
ler(keyCombo,handlerName,event);if(event.defaultPrevented){return}}}},_triggerKe
yHandler:function(keyCombo,handlerName,keyboardEvent){var detail=Object.create(k
eyCombo);detail.keyboardEvent=keyboardEvent;var event=new CustomEvent(keyCombo.e
vent,{detail:detail,cancelable:true});this[handlerName].call(this,event);if(even
t.defaultPrevented){keyboardEvent.preventDefault()}}}})();Polymer.IronControlSta
te={properties:{focused:{type:Boolean,value:false,notify:true,readOnly:true,refl
ectToAttribute:true},disabled:{type:Boolean,value:false,notify:true,observer:"_d
isabledChanged",reflectToAttribute:true},_oldTabIndex:{type:Number},_boundFocusB
lurHandler:{type:Function,value:function(){return this._focusBlurHandler.bind(th
is)}}},observers:["_changedControlState(focused, disabled)"],ready:function(){th
is.addEventListener("focus",this._boundFocusBlurHandler,true);this.addEventListe
ner("blur",this._boundFocusBlurHandler,true)},_focusBlurHandler:function(event){
if(event.target===this){this._setFocused(event.type==="focus")}else if(!this.sha
dowRoot){var target=Polymer.dom(event).localTarget;if(!this.isLightDescendant(ta
rget)){this.fire(event.type,{sourceEvent:event},{node:this,bubbles:event.bubbles
,cancelable:event.cancelable})}}},_disabledChanged:function(disabled,old){this.s
etAttribute("aria-disabled",disabled?"true":"false");this.style.pointerEvents=di
sabled?"none":"";if(disabled){this._oldTabIndex=this.tabIndex;this._setFocused(f
alse);this.tabIndex=-1;this.blur()}else if(this._oldTabIndex!==undefined){this.t
abIndex=this._oldTabIndex}},_changedControlState:function(){if(this._controlStat
eChanged){this._controlStateChanged()}}};Polymer.IronButtonStateImpl={properties
:{pressed:{type:Boolean,readOnly:true,value:false,reflectToAttribute:true,observ
er:"_pressedChanged"},toggles:{type:Boolean,value:false,reflectToAttribute:true}
,active:{type:Boolean,value:false,notify:true,reflectToAttribute:true},pointerDo
wn:{type:Boolean,readOnly:true,value:false},receivedFocusFromKeyboard:{type:Bool
ean,readOnly:true},ariaActiveAttribute:{type:String,value:"aria-pressed",observe
r:"_ariaActiveAttributeChanged"}},listeners:{down:"_downHandler",up:"_upHandler"
,tap:"_tapHandler"},observers:["_detectKeyboardFocus(focused)","_activeChanged(a
ctive, ariaActiveAttribute)"],keyBindings:{"enter:keydown":"_asyncClick","space:
keydown":"_spaceKeyDownHandler","space:keyup":"_spaceKeyUpHandler"},_mouseEventR
e:/^mouse/,_tapHandler:function(){if(this.toggles){this._userActivate(!this.acti
ve)}else{this.active=false}},_detectKeyboardFocus:function(focused){this._setRec
eivedFocusFromKeyboard(!this.pointerDown&&focused)},_userActivate:function(activ
e){if(this.active!==active){this.active=active;this.fire("change")}},_downHandle
r:function(event){this._setPointerDown(true);this._setPressed(true);this._setRec
eivedFocusFromKeyboard(false)},_upHandler:function(){this._setPointerDown(false)
;this._setPressed(false)},_spaceKeyDownHandler:function(event){var keyboardEvent
=event.detail.keyboardEvent;var target=Polymer.dom(keyboardEvent).localTarget;if
(this.isLightDescendant(target))return;keyboardEvent.preventDefault();keyboardEv
ent.stopImmediatePropagation();this._setPressed(true)},_spaceKeyUpHandler:functi
on(event){var keyboardEvent=event.detail.keyboardEvent;var target=Polymer.dom(ke
yboardEvent).localTarget;if(this.isLightDescendant(target))return;if(this.presse
d){this._asyncClick()}this._setPressed(false)},_asyncClick:function(){this.async
(function(){this.click()},1)},_pressedChanged:function(pressed){this._changedBut
tonState()},_ariaActiveAttributeChanged:function(value,oldValue){if(oldValue&&ol
dValue!=value&&this.hasAttribute(oldValue)){this.removeAttribute(oldValue)}},_ac
tiveChanged:function(active,ariaActiveAttribute){if(this.toggles){this.setAttrib
ute(this.ariaActiveAttribute,active?"true":"false")}else{this.removeAttribute(th
is.ariaActiveAttribute)}this._changedButtonState()},_controlStateChanged:functio
n(){if(this.disabled){this._setPressed(false)}else{this._changedButtonState()}},
_changedButtonState:function(){if(this._buttonStateChanged){this._buttonStateCha
nged()}}};Polymer.IronButtonState=[Polymer.IronA11yKeysBehavior,Polymer.IronButt
onStateImpl];(function(){var Utility={distance:function(x1,y1,x2,y2){var xDelta=
x1-x2;var yDelta=y1-y2;return Math.sqrt(xDelta*xDelta+yDelta*yDelta)},now:window
.performance&&window.performance.now?window.performance.now.bind(window.performa
nce):Date.now};function ElementMetrics(element){this.element=element;this.width=
this.boundingRect.width;this.height=this.boundingRect.height;this.size=Math.max(
this.width,this.height)}ElementMetrics.prototype={get boundingRect(){return this
.element.getBoundingClientRect()},furthestCornerDistanceFrom:function(x,y){var t
opLeft=Utility.distance(x,y,0,0);var topRight=Utility.distance(x,y,this.width,0)
;var bottomLeft=Utility.distance(x,y,0,this.height);var bottomRight=Utility.dist
ance(x,y,this.width,this.height);return Math.max(topLeft,topRight,bottomLeft,bot
tomRight)}};function Ripple(element){this.element=element;this.color=window.getC
omputedStyle(element).color;this.wave=document.createElement("div");this.waveCon
tainer=document.createElement("div");this.wave.style.backgroundColor=this.color;
this.wave.classList.add("wave");this.waveContainer.classList.add("wave-container
");Polymer.dom(this.waveContainer).appendChild(this.wave);this.resetInteractionS
tate()}Ripple.MAX_RADIUS=300;Ripple.prototype={get recenters(){return this.eleme
nt.recenters},get center(){return this.element.center},get mouseDownElapsed(){va
r elapsed;if(!this.mouseDownStart){return 0}elapsed=Utility.now()-this.mouseDown
Start;if(this.mouseUpStart){elapsed-=this.mouseUpElapsed}return elapsed},get mou
seUpElapsed(){return this.mouseUpStart?Utility.now()-this.mouseUpStart:0},get mo
useDownElapsedSeconds(){return this.mouseDownElapsed/1e3},get mouseUpElapsedSeco
nds(){return this.mouseUpElapsed/1e3},get mouseInteractionSeconds(){return this.
mouseDownElapsedSeconds+this.mouseUpElapsedSeconds},get initialOpacity(){return
this.element.initialOpacity},get opacityDecayVelocity(){return this.element.opac
ityDecayVelocity},get radius(){var width2=this.containerMetrics.width*this.conta
inerMetrics.width;var height2=this.containerMetrics.height*this.containerMetrics
.height;var waveRadius=Math.min(Math.sqrt(width2+height2),Ripple.MAX_RADIUS)*1.1
+5;var duration=1.1-.2*(waveRadius/Ripple.MAX_RADIUS);var timeNow=this.mouseInte
ractionSeconds/duration;var size=waveRadius*(1-Math.pow(80,-timeNow));return Mat
h.abs(size)},get opacity(){if(!this.mouseUpStart){return this.initialOpacity}ret
urn Math.max(0,this.initialOpacity-this.mouseUpElapsedSeconds*this.opacityDecayV
elocity)},get outerOpacity(){var outerOpacity=this.mouseUpElapsedSeconds*.3;var
waveOpacity=this.opacity;return Math.max(0,Math.min(outerOpacity,waveOpacity))},
get isOpacityFullyDecayed(){return this.opacity<.01&&this.radius>=Math.min(this.
maxRadius,Ripple.MAX_RADIUS)},get isRestingAtMaxRadius(){return this.opacity>=th
is.initialOpacity&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get
isAnimationComplete(){return this.mouseUpStart?this.isOpacityFullyDecayed:this.i
sRestingAtMaxRadius},get translationFraction(){return Math.min(1,this.radius/thi
s.containerMetrics.size*2/Math.sqrt(2))},get xNow(){if(this.xEnd){return this.xS
tart+this.translationFraction*(this.xEnd-this.xStart)}return this.xStart},get yN
ow(){if(this.yEnd){return this.yStart+this.translationFraction*(this.yEnd-this.y
Start)}return this.yStart},get isMouseDown(){return this.mouseDownStart&&!this.m
ouseUpStart},resetInteractionState:function(){this.maxRadius=0;this.mouseDownSta
rt=0;this.mouseUpStart=0;this.xStart=0;this.yStart=0;this.xEnd=0;this.yEnd=0;thi
s.slideDistance=0;this.containerMetrics=new ElementMetrics(this.element)},draw:f
unction(){var scale;var translateString;var dx;var dy;this.wave.style.opacity=th
is.opacity;scale=this.radius/(this.containerMetrics.size/2);dx=this.xNow-this.co
ntainerMetrics.width/2;dy=this.yNow-this.containerMetrics.height/2;this.waveCont
ainer.style.webkitTransform="translate("+dx+"px, "+dy+"px)";this.waveContainer.s
tyle.transform="translate3d("+dx+"px, "+dy+"px, 0)";this.wave.style.webkitTransf
orm="scale("+scale+","+scale+")";this.wave.style.transform="scale3d("+scale+","+
scale+",1)"},downAction:function(event){var xCenter=this.containerMetrics.width/
2;var yCenter=this.containerMetrics.height/2;this.resetInteractionState();this.m
ouseDownStart=Utility.now();if(this.center){this.xStart=xCenter;this.yStart=yCen
ter;this.slideDistance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.y
End)}else{this.xStart=event?event.detail.x-this.containerMetrics.boundingRect.le
ft:this.containerMetrics.width/2;this.yStart=event?event.detail.y-this.container
Metrics.boundingRect.top:this.containerMetrics.height/2}if(this.recenters){this.
xEnd=xCenter;this.yEnd=yCenter;this.slideDistance=Utility.distance(this.xStart,t
his.yStart,this.xEnd,this.yEnd)}this.maxRadius=this.containerMetrics.furthestCor
nerDistanceFrom(this.xStart,this.yStart);this.waveContainer.style.top=(this.cont
ainerMetrics.height-this.containerMetrics.size)/2+"px";this.waveContainer.style.
left=(this.containerMetrics.width-this.containerMetrics.size)/2+"px";this.waveCo
ntainer.style.width=this.containerMetrics.size+"px";this.waveContainer.style.hei
ght=this.containerMetrics.size+"px"},upAction:function(event){if(!this.isMouseDo
wn){return}this.mouseUpStart=Utility.now()},remove:function(){Polymer.dom(this.w
aveContainer.parentNode).removeChild(this.waveContainer)}};Polymer({is:"paper-ri
pple",behaviors:[Polymer.IronA11yKeysBehavior],properties:{initialOpacity:{type:
Number,value:.25},opacityDecayVelocity:{type:Number,value:.8},recenters:{type:Bo
olean,value:false},center:{type:Boolean,value:false},ripples:{type:Array,value:f
unction(){return[]}},animating:{type:Boolean,readOnly:true,reflectToAttribute:tr
ue,value:false},holdDown:{type:Boolean,value:false,observer:"_holdDownChanged"},
noink:{type:Boolean,value:false},_animating:{type:Boolean},_boundAnimate:{type:F
unction,value:function(){return this.animate.bind(this)}}},get target(){return t
his.keyEventTarget},keyBindings:{"enter:keydown":"_onEnterKeydown","space:keydow
n":"_onSpaceKeydown","space:keyup":"_onSpaceKeyup"},attached:function(){if(this.
parentNode.nodeType==11){this.keyEventTarget=Polymer.dom(this).getOwnerRoot().ho
st}else{this.keyEventTarget=this.parentNode}var keyEventTarget=this.keyEventTarg
et;this.listen(keyEventTarget,"up","uiUpAction");this.listen(keyEventTarget,"dow
n","uiDownAction")},detached:function(){this.unlisten(this.keyEventTarget,"up","
uiUpAction");this.unlisten(this.keyEventTarget,"down","uiDownAction");this.keyEv
entTarget=null},get shouldKeepAnimating(){for(var index=0;index<this.ripples.len
gth;++index){if(!this.ripples[index].isAnimationComplete){return true}}return fa
lse},simulatedRipple:function(){this.downAction(null);this.async(function(){this
.upAction()},1)},uiDownAction:function(event){if(!this.noink){this.downAction(ev
ent)}},downAction:function(event){if(this.holdDown&&this.ripples.length>0){retur
n; | 20 var WebUIListenerBehavior={properties:{webUIListeners_:{type:Array,value:functio
n(){return[]}}},addWebUIListener:function(eventName,callback){this.webUIListener
s_.push(cr.addWebUIListener(eventName,callback))},detached:function(){while(this
.webUIListeners_.length>0){cr.removeWebUIListener(this.webUIListeners_.pop())}}}
;Polymer({is:"iron-media-query",properties:{queryMatches:{type:Boolean,value:fal
se,readOnly:true,notify:true},query:{type:String,observer:"queryChanged"},full:{
type:Boolean,value:false},_boundMQHandler:{value:function(){return this.queryHan
dler.bind(this)}},_mq:{value:null}},attached:function(){this.style.display="none
";this.queryChanged()},detached:function(){this._remove()},_add:function(){if(th
is._mq){this._mq.addListener(this._boundMQHandler)}},_remove:function(){if(this.
_mq){this._mq.removeListener(this._boundMQHandler)}this._mq=null},queryChanged:f
unction(){this._remove();var query=this.query;if(!query){return}if(!this.full&&q
uery[0]!=="("){query="("+query+")"}this._mq=window.matchMedia(query);this._add()
;this.queryHandler(this._mq)},queryHandler:function(mq){this._setQueryMatches(mq
.matches)}});Polymer.IronResizableBehavior={properties:{_parentResizable:{type:O
bject,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,val
ue:false}},listeners:{"iron-request-resize-notifications":"_onIronRequestResizeN
otifications"},created:function(){this._interestedResizables=[];this._boundNotif
yResize=this.notifyResize.bind(this)},attached:function(){this.fire("iron-reques
t-resize-notifications",null,{node:this,bubbles:true,cancelable:true});if(!this.
_parentResizable){window.addEventListener("resize",this._boundNotifyResize);this
.notifyResize()}},detached:function(){if(this._parentResizable){this._parentResi
zable.stopResizeNotificationsFor(this)}else{window.removeEventListener("resize",
this._boundNotifyResize)}this._parentResizable=null},notifyResize:function(){if(
!this.isAttached){return}this._interestedResizables.forEach(function(resizable){
if(this.resizerShouldNotify(resizable)){this._notifyDescendant(resizable)}},this
);this._fireResize()},assignParentResizable:function(parentResizable){this._pare
ntResizable=parentResizable},stopResizeNotificationsFor:function(target){var ind
ex=this._interestedResizables.indexOf(target);if(index>-1){this._interestedResiz
ables.splice(index,1);this.unlisten(target,"iron-resize","_onDescendantIronResiz
e")}},resizerShouldNotify:function(element){return true},_onDescendantIronResize
:function(event){if(this._notifyingDescendant){event.stopPropagation();return}if
(!Polymer.Settings.useShadow){this._fireResize()}},_fireResize:function(){this.f
ire("iron-resize",null,{node:this,bubbles:false})},_onIronRequestResizeNotificat
ions:function(event){var target=event.path?event.path[0]:event.target;if(target=
==this){return}if(this._interestedResizables.indexOf(target)===-1){this._interes
tedResizables.push(target);this.listen(target,"iron-resize","_onDescendantIronRe
size")}target.assignParentResizable(this);this._notifyDescendant(target);event.s
topPropagation()},_parentResizableChanged:function(parentResizable){if(parentRes
izable){window.removeEventListener("resize",this._boundNotifyResize)}},_notifyDe
scendant:function(descendant){if(!this.isAttached){return}this._notifyingDescend
ant=true;descendant.notifyResize();this._notifyingDescendant=false}};Polymer.Iro
nSelection=function(selectCallback){this.selection=[];this.selectCallback=select
Callback};Polymer.IronSelection.prototype={get:function(){return this.multi?this
.selection.slice():this.selection[0]},clear:function(excludes){this.selection.sl
ice().forEach(function(item){if(!excludes||excludes.indexOf(item)<0){this.setIte
mSelected(item,false)}},this)},isSelected:function(item){return this.selection.i
ndexOf(item)>=0},setItemSelected:function(item,isSelected){if(item!=null){if(isS
elected!==this.isSelected(item)){if(isSelected){this.selection.push(item)}else{v
ar i=this.selection.indexOf(item);if(i>=0){this.selection.splice(i,1)}}if(this.s
electCallback){this.selectCallback(item,isSelected)}}}},select:function(item){if
(this.multi){this.toggle(item)}else if(this.get()!==item){this.setItemSelected(t
his.get(),false);this.setItemSelected(item,true)}},toggle:function(item){this.se
tItemSelected(item,!this.isSelected(item))}};Polymer.IronSelectableBehavior={pro
perties:{attrForSelected:{type:String,value:null},selected:{type:String,notify:t
rue},selectedItem:{type:Object,readOnly:true,notify:true},activateEvent:{type:St
ring,value:"tap",observer:"_activateEventChanged"},selectable:String,selectedCla
ss:{type:String,value:"iron-selected"},selectedAttribute:{type:String,value:null
},fallbackSelection:{type:String,value:null},items:{type:Array,readOnly:true,not
ify:true,value:function(){return[]}},_excludedLocalNames:{type:Object,value:func
tion(){return{template:1}}}},observers:["_updateAttrForSelected(attrForSelected)
","_updateSelected(selected)","_checkFallback(fallbackSelection)"],created:funct
ion(){this._bindFilterItem=this._filterItem.bind(this);this._selection=new Polym
er.IronSelection(this._applySelection.bind(this))},attached:function(){this._obs
erver=this._observeItems(this);this._updateItems();if(!this._shouldUpdateSelecti
on){this._updateSelected()}this._addListener(this.activateEvent)},detached:funct
ion(){if(this._observer){Polymer.dom(this).unobserveNodes(this._observer)}this._
removeListener(this.activateEvent)},indexOf:function(item){return this.items.ind
exOf(item)},select:function(value){this.selected=value},selectPrevious:function(
){var length=this.items.length;var index=(Number(this._valueToIndex(this.selecte
d))-1+length)%length;this.selected=this._indexToValue(index)},selectNext:functio
n(){var index=(Number(this._valueToIndex(this.selected))+1)%this.items.length;th
is.selected=this._indexToValue(index)},selectIndex:function(index){this.select(t
his._indexToValue(index))},forceSynchronousItemUpdate:function(){this._updateIte
ms()},get _shouldUpdateSelection(){return this.selected!=null},_checkFallback:fu
nction(){if(this._shouldUpdateSelection){this._updateSelected()}},_addListener:f
unction(eventName){this.listen(this,eventName,"_activateHandler")},_removeListen
er:function(eventName){this.unlisten(this,eventName,"_activateHandler")},_activa
teEventChanged:function(eventName,old){this._removeListener(old);this._addListen
er(eventName)},_updateItems:function(){var nodes=Polymer.dom(this).queryDistribu
tedElements(this.selectable||"*");nodes=Array.prototype.filter.call(nodes,this._
bindFilterItem);this._setItems(nodes)},_updateAttrForSelected:function(){if(this
._shouldUpdateSelection){this.selected=this._indexToValue(this.indexOf(this.sele
ctedItem))}},_updateSelected:function(){this._selectSelected(this.selected)},_se
lectSelected:function(selected){this._selection.select(this._valueToItem(this.se
lected));if(this.fallbackSelection&&this.items.length&&this._selection.get()===u
ndefined){this.selected=this.fallbackSelection}},_filterItem:function(node){retu
rn!this._excludedLocalNames[node.localName]},_valueToItem:function(value){return
value==null?null:this.items[this._valueToIndex(value)]},_valueToIndex:function(
value){if(this.attrForSelected){for(var i=0,item;item=this.items[i];i++){if(this
._valueForItem(item)==value){return i}}}else{return Number(value)}},_indexToValu
e:function(index){if(this.attrForSelected){var item=this.items[index];if(item){r
eturn this._valueForItem(item)}}else{return index}},_valueForItem:function(item)
{var propValue=item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)];retur
n propValue!=undefined?propValue:item.getAttribute(this.attrForSelected)},_apply
Selection:function(item,isSelected){if(this.selectedClass){this.toggleClass(this
.selectedClass,isSelected,item)}if(this.selectedAttribute){this.toggleAttribute(
this.selectedAttribute,isSelected,item)}this._selectionChange();this.fire("iron-
"+(isSelected?"select":"deselect"),{item:item})},_selectionChange:function(){thi
s._setSelectedItem(this._selection.get())},_observeItems:function(node){return P
olymer.dom(node).observeNodes(function(mutation){this._updateItems();if(this._sh
ouldUpdateSelection){this._updateSelected()}this.fire("iron-items-changed",mutat
ion,{bubbles:false,cancelable:false})})},_activateHandler:function(e){var t=e.ta
rget;var items=this.items;while(t&&t!=this){var i=items.indexOf(t);if(i>=0){var
value=this._indexToValue(i);this._itemActivate(value,t);return}t=t.parentNode}},
_itemActivate:function(value,item){if(!this.fire("iron-activate",{selected:value
,item:item},{cancelable:true}).defaultPrevented){this.select(value)}}};Polymer({
is:"iron-pages",behaviors:[Polymer.IronResizableBehavior,Polymer.IronSelectableB
ehavior],properties:{activateEvent:{type:String,value:null}},observers:["_select
edPageChanged(selected)"],_selectedPageChanged:function(selected,old){this.async
(this.notifyResize)}});Polymer.IronScrollTargetBehavior={properties:{scrollTarge
t:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observe
rs:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:true,_
scrollTargetChanged:function(scrollTarget,isAttached){var eventTarget;if(this._o
ldScrollTarget){this._toggleScrollListener(false,this._oldScrollTarget);this._ol
dScrollTarget=null}if(!isAttached){return}if(scrollTarget==="document"){this.scr
ollTarget=this._doc}else if(typeof scrollTarget==="string"){this.scrollTarget=th
is.domHost?this.domHost.$[scrollTarget]:Polymer.dom(this.ownerDocument).querySel
ector("#"+scrollTarget)}else if(this._isValidScrollTarget()){this._boundScrollHa
ndler=this._boundScrollHandler||this._scrollHandler.bind(this);this._oldScrollTa
rget=scrollTarget;this._toggleScrollListener(this._shouldHaveListener,scrollTarg
et)}},_scrollHandler:function scrollHandler(){},get _defaultScrollTarget(){retur
n this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrollTo
p(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?window.
pageYOffset:this.scrollTarget.scrollTop}return 0},get _scrollLeft(){if(this._isV
alidScrollTarget()){return this.scrollTarget===this._doc?window.pageXOffset:this
.scrollTarget.scrollLeft}return 0},set _scrollTop(top){if(this.scrollTarget===th
is._doc){window.scrollTo(window.pageXOffset,top)}else if(this._isValidScrollTarg
et()){this.scrollTarget.scrollTop=top}},set _scrollLeft(left){if(this.scrollTarg
et===this._doc){window.scrollTo(left,window.pageYOffset)}else if(this._isValidSc
rollTarget()){this.scrollTarget.scrollLeft=left}},scroll:function(left,top){if(t
his.scrollTarget===this._doc){window.scrollTo(left,top)}else if(this._isValidScr
ollTarget()){this.scrollTarget.scrollLeft=left;this.scrollTarget.scrollTop=top}}
,get _scrollTargetWidth(){if(this._isValidScrollTarget()){return this.scrollTarg
et===this._doc?window.innerWidth:this.scrollTarget.offsetWidth}return 0},get _sc
rollTargetHeight(){if(this._isValidScrollTarget()){return this.scrollTarget===th
is._doc?window.innerHeight:this.scrollTarget.offsetHeight}return 0},_isValidScro
llTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleScro
llListener:function(yes,scrollTarget){if(!this._boundScrollHandler){return}var e
ventTarget=scrollTarget===this._doc?window:scrollTarget;if(yes){eventTarget.addE
ventListener("scroll",this._boundScrollHandler)}else{eventTarget.removeEventList
ener("scroll",this._boundScrollHandler)}},toggleScrollListener:function(yes){thi
s._shouldHaveListener=yes;this._toggleScrollListener(yes,this.scrollTarget)}};(f
unction(){var metaDatas={};var metaArrays={};var singleton=null;Polymer.IronMeta
=Polymer({is:"iron-meta",properties:{type:{type:String,value:"default",observer:
"_typeChanged"},key:{type:String,observer:"_keyChanged"},value:{type:Object,noti
fy:true,observer:"_valueChanged"},self:{type:Boolean,observer:"_selfChanged"},li
st:{type:Array,notify:true}},hostAttributes:{hidden:true},factoryImpl:function(c
onfig){if(config){for(var n in config){switch(n){case"type":case"key":case"value
":this[n]=config[n];break}}}},created:function(){this._metaDatas=metaDatas;this.
_metaArrays=metaArrays},_keyChanged:function(key,old){this._resetRegistration(ol
d)},_valueChanged:function(value){this._resetRegistration(this.key)},_selfChange
d:function(self){if(self){this.value=this}},_typeChanged:function(type){this._un
registerKey(this.key);if(!metaDatas[type]){metaDatas[type]={}}this._metaData=met
aDatas[type];if(!metaArrays[type]){metaArrays[type]=[]}this.list=metaArrays[type
];this._registerKeyValue(this.key,this.value)},byKey:function(key){return this._
metaData&&this._metaData[key]},_resetRegistration:function(oldKey){this._unregis
terKey(oldKey);this._registerKeyValue(this.key,this.value)},_unregisterKey:funct
ion(key){this._unregister(key,this._metaData,this.list)},_registerKeyValue:funct
ion(key,value){this._register(key,value,this._metaData,this.list)},_register:fun
ction(key,value,data,list){if(key&&data&&value!==undefined){data[key]=value;list
.push(value)}},_unregister:function(key,data,list){if(key&&data){if(key in data)
{var value=data[key];delete data[key];this.arrayDelete(list,value)}}}});Polymer.
IronMeta.getIronMeta=function getIronMeta(){if(singleton===null){singleton=new P
olymer.IronMeta}return singleton};Polymer.IronMetaQuery=Polymer({is:"iron-meta-q
uery",properties:{type:{type:String,value:"default",observer:"_typeChanged"},key
:{type:String,observer:"_keyChanged"},value:{type:Object,notify:true,readOnly:tr
ue},list:{type:Array,notify:true}},factoryImpl:function(config){if(config){for(v
ar n in config){switch(n){case"type":case"key":this[n]=config[n];break}}}},creat
ed:function(){this._metaDatas=metaDatas;this._metaArrays=metaArrays},_keyChanged
:function(key){this._setValue(this._metaData&&this._metaData[key])},_typeChanged
:function(type){this._metaData=metaDatas[type];this.list=metaArrays[type];if(thi
s.key){this._keyChanged(this.key)}},byKey:function(key){return this._metaData&&t
his._metaData[key]}})})();Polymer({is:"iron-icon",properties:{icon:{type:String,
observer:"_iconChanged"},theme:{type:String,observer:"_updateIcon"},src:{type:St
ring,observer:"_srcChanged"},_meta:{value:Polymer.Base.create("iron-meta",{type:
"iconset"}),observer:"_updateIcon"}},_DEFAULT_ICONSET:"icons",_iconChanged:funct
ion(icon){var parts=(icon||"").split(":");this._iconName=parts.pop();this._icons
etName=parts.pop()||this._DEFAULT_ICONSET;this._updateIcon()},_srcChanged:functi
on(src){this._updateIcon()},_usesIconset:function(){return this.icon||!this.src}
,_updateIcon:function(){if(this._usesIconset()){if(this._img&&this._img.parentNo
de){Polymer.dom(this.root).removeChild(this._img)}if(this._iconName===""){if(thi
s._iconset){this._iconset.removeIcon(this)}}else if(this._iconsetName&&this._met
a){this._iconset=this._meta.byKey(this._iconsetName);if(this._iconset){this._ico
nset.applyIcon(this,this._iconName,this.theme);this.unlisten(window,"iron-iconse
t-added","_updateIcon")}else{this.listen(window,"iron-iconset-added","_updateIco
n")}}}else{if(this._iconset){this._iconset.removeIcon(this)}if(!this._img){this.
_img=document.createElement("img");this._img.style.width="100%";this._img.style.
height="100%";this._img.draggable=false}this._img.src=this.src;Polymer.dom(this.
root).appendChild(this._img)}}});(function(){"use strict";var KEY_IDENTIFIER={"U
+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"
};var KEY_CODE={8:"backspace",9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedo
wn",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del
",106:"*"};var MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:
"metaKey"};var KEY_CHAR=/[a-z0-9*]/;var IDENT_CHAR=/U\+/;var ARROW_KEY=/^arrow/;
var SPACE_KEY=/^space(bar)?/;var ESC_KEY=/^escape$/;function transformKey(key,no
SpecialChars){var validKey="";if(key){var lKey=key.toLowerCase();if(lKey===" "||
SPACE_KEY.test(lKey)){validKey="space"}else if(ESC_KEY.test(lKey)){validKey="esc
"}else if(lKey.length==1){if(!noSpecialChars||KEY_CHAR.test(lKey)){validKey=lKey
}}else if(ARROW_KEY.test(lKey)){validKey=lKey.replace("arrow","")}else if(lKey==
"multiply"){validKey="*"}else{validKey=lKey}}return validKey}function transformK
eyIdentifier(keyIdent){var validKey="";if(keyIdent){if(keyIdent in KEY_IDENTIFIE
R){validKey=KEY_IDENTIFIER[keyIdent]}else if(IDENT_CHAR.test(keyIdent)){keyIdent
=parseInt(keyIdent.replace("U+","0x"),16);validKey=String.fromCharCode(keyIdent)
.toLowerCase()}else{validKey=keyIdent.toLowerCase()}}return validKey}function tr
ansformKeyCode(keyCode){var validKey="";if(Number(keyCode)){if(keyCode>=65&&keyC
ode<=90){validKey=String.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode<
=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&keyCode<=57){validKey=Stri
ng(keyCode-48)}else if(keyCode>=96&&keyCode<=105){validKey=String(keyCode-96)}el
se{validKey=KEY_CODE[keyCode]}}return validKey}function normalizedKeyForEvent(ke
yEvent,noSpecialChars){if(keyEvent.key){return transformKey(keyEvent.key,noSpeci
alChars)}if(keyEvent.detail&&keyEvent.detail.key){return transformKey(keyEvent.d
etail.key,noSpecialChars)}return transformKeyIdentifier(keyEvent.keyIdentifier)|
|transformKeyCode(keyEvent.keyCode)||""}function keyComboMatchesEvent(keyCombo,e
vent){var keyEvent=normalizedKeyForEvent(event,keyCombo.hasModifiers);return key
Event===keyCombo.key&&(!keyCombo.hasModifiers||!!event.shiftKey===!!keyCombo.shi
ftKey&&!!event.ctrlKey===!!keyCombo.ctrlKey&&!!event.altKey===!!keyCombo.altKey&
&!!event.metaKey===!!keyCombo.metaKey)}function parseKeyComboString(keyComboStri
ng){if(keyComboString.length===1){return{combo:keyComboString,key:keyComboString
,event:"keydown"}}return keyComboString.split("+").reduce(function(parsedKeyComb
o,keyComboPart){var eventParts=keyComboPart.split(":");var keyName=eventParts[0]
;var event=eventParts[1];if(keyName in MODIFIER_KEYS){parsedKeyCombo[MODIFIER_KE
YS[keyName]]=true;parsedKeyCombo.hasModifiers=true}else{parsedKeyCombo.key=keyNa
me;parsedKeyCombo.event=event||"keydown"}return parsedKeyCombo},{combo:keyComboS
tring.split(":").shift()})}function parseEventString(eventString){return eventSt
ring.trim().split(" ").map(function(keyComboString){return parseKeyComboString(k
eyComboString)})}Polymer.IronA11yKeysBehavior={properties:{keyEventTarget:{type:
Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolean
,value:false},_boundKeyHandlers:{type:Array,value:function(){return[]}},_imperat
iveKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyEv
entListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:func
tion(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListener
s()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:fun
ction(eventString,handlerName){this._imperativeKeyBindings[eventString]=handlerN
ame;this._prepKeyBindings();this._resetKeyEventListeners()},removeOwnKeyBindings
:function(){this._imperativeKeyBindings={};this._prepKeyBindings();this._resetKe
yEventListeners()},keyboardEventMatchesKeys:function(event,eventString){var keyC
ombos=parseEventString(eventString);for(var i=0;i<keyCombos.length;++i){if(keyCo
mboMatchesEvent(keyCombos[i],event)){return true}}return false},_collectKeyBindi
ngs:function(){var keyBindings=this.behaviors.map(function(behavior){return beha
vior.keyBindings});if(keyBindings.indexOf(this.keyBindings)===-1){keyBindings.pu
sh(this.keyBindings)}return keyBindings},_prepKeyBindings:function(){this._keyBi
ndings={};this._collectKeyBindings().forEach(function(keyBindings){for(var event
String in keyBindings){this._addKeyBinding(eventString,keyBindings[eventString])
}},this);for(var eventString in this._imperativeKeyBindings){this._addKeyBinding
(eventString,this._imperativeKeyBindings[eventString])}for(var eventName in this
._keyBindings){this._keyBindings[eventName].sort(function(kb1,kb2){var b1=kb1[0]
.hasModifiers;var b2=kb2[0].hasModifiers;return b1===b2?0:b1?-1:1})}},_addKeyBin
ding:function(eventString,handlerName){parseEventString(eventString).forEach(fun
ction(keyCombo){this._keyBindings[keyCombo.event]=this._keyBindings[keyCombo.eve
nt]||[];this._keyBindings[keyCombo.event].push([keyCombo,handlerName])},this)},_
resetKeyEventListeners:function(){this._unlistenKeyEventListeners();if(this.isAt
tached){this._listenKeyEventListeners()}},_listenKeyEventListeners:function(){if
(!this.keyEventTarget){return}Object.keys(this._keyBindings).forEach(function(ev
entName){var keyBindings=this._keyBindings[eventName];var boundKeyHandler=this._
onKeyBindingEvent.bind(this,keyBindings);this._boundKeyHandlers.push([this.keyEv
entTarget,eventName,boundKeyHandler]);this.keyEventTarget.addEventListener(event
Name,boundKeyHandler)},this)},_unlistenKeyEventListeners:function(){var keyHandl
erTuple;var keyEventTarget;var eventName;var boundKeyHandler;while(this._boundKe
yHandlers.length){keyHandlerTuple=this._boundKeyHandlers.pop();keyEventTarget=ke
yHandlerTuple[0];eventName=keyHandlerTuple[1];boundKeyHandler=keyHandlerTuple[2]
;keyEventTarget.removeEventListener(eventName,boundKeyHandler)}},_onKeyBindingEv
ent:function(keyBindings,event){if(this.stopKeyboardEventPropagation){event.stop
Propagation()}if(event.defaultPrevented){return}for(var i=0;i<keyBindings.length
;i++){var keyCombo=keyBindings[i][0];var handlerName=keyBindings[i][1];if(keyCom
boMatchesEvent(keyCombo,event)){this._triggerKeyHandler(keyCombo,handlerName,eve
nt);if(event.defaultPrevented){return}}}},_triggerKeyHandler:function(keyCombo,h
andlerName,keyboardEvent){var detail=Object.create(keyCombo);detail.keyboardEven
t=keyboardEvent;var event=new CustomEvent(keyCombo.event,{detail:detail,cancelab
le:true});this[handlerName].call(this,event);if(event.defaultPrevented){keyboard
Event.preventDefault()}}}})();Polymer.IronControlState={properties:{focused:{typ
e:Boolean,value:false,notify:true,readOnly:true,reflectToAttribute:true},disable
d:{type:Boolean,value:false,notify:true,observer:"_disabledChanged",reflectToAtt
ribute:true},_oldTabIndex:{type:Number},_boundFocusBlurHandler:{type:Function,va
lue:function(){return this._focusBlurHandler.bind(this)}}},observers:["_changedC
ontrolState(focused, disabled)"],ready:function(){this.addEventListener("focus",
this._boundFocusBlurHandler,true);this.addEventListener("blur",this._boundFocusB
lurHandler,true)},_focusBlurHandler:function(event){if(event.target===this){this
._setFocused(event.type==="focus")}else if(!this.shadowRoot){var target=Polymer.
dom(event).localTarget;if(!this.isLightDescendant(target)){this.fire(event.type,
{sourceEvent:event},{node:this,bubbles:event.bubbles,cancelable:event.cancelable
})}}},_disabledChanged:function(disabled,old){this.setAttribute("aria-disabled",
disabled?"true":"false");this.style.pointerEvents=disabled?"none":"";if(disabled
){this._oldTabIndex=this.tabIndex;this._setFocused(false);this.tabIndex=-1;this.
blur()}else if(this._oldTabIndex!==undefined){this.tabIndex=this._oldTabIndex}},
_changedControlState:function(){if(this._controlStateChanged){this._controlState
Changed()}}};Polymer.IronButtonStateImpl={properties:{pressed:{type:Boolean,read
Only:true,value:false,reflectToAttribute:true,observer:"_pressedChanged"},toggle
s:{type:Boolean,value:false,reflectToAttribute:true},active:{type:Boolean,value:
false,notify:true,reflectToAttribute:true},pointerDown:{type:Boolean,readOnly:tr
ue,value:false},receivedFocusFromKeyboard:{type:Boolean,readOnly:true},ariaActiv
eAttribute:{type:String,value:"aria-pressed",observer:"_ariaActiveAttributeChang
ed"}},listeners:{down:"_downHandler",up:"_upHandler",tap:"_tapHandler"},observer
s:["_detectKeyboardFocus(focused)","_activeChanged(active, ariaActiveAttribute)"
],keyBindings:{"enter:keydown":"_asyncClick","space:keydown":"_spaceKeyDownHandl
er","space:keyup":"_spaceKeyUpHandler"},_mouseEventRe:/^mouse/,_tapHandler:funct
ion(){if(this.toggles){this._userActivate(!this.active)}else{this.active=false}}
,_detectKeyboardFocus:function(focused){this._setReceivedFocusFromKeyboard(!this
.pointerDown&&focused)},_userActivate:function(active){if(this.active!==active){
this.active=active;this.fire("change")}},_downHandler:function(event){this._setP
ointerDown(true);this._setPressed(true);this._setReceivedFocusFromKeyboard(false
)},_upHandler:function(){this._setPointerDown(false);this._setPressed(false)},_s
paceKeyDownHandler:function(event){var keyboardEvent=event.detail.keyboardEvent;
var target=Polymer.dom(keyboardEvent).localTarget;if(this.isLightDescendant(targ
et))return;keyboardEvent.preventDefault();keyboardEvent.stopImmediatePropagation
();this._setPressed(true)},_spaceKeyUpHandler:function(event){var keyboardEvent=
event.detail.keyboardEvent;var target=Polymer.dom(keyboardEvent).localTarget;if(
this.isLightDescendant(target))return;if(this.pressed){this._asyncClick()}this._
setPressed(false)},_asyncClick:function(){this.async(function(){this.click()},1)
},_pressedChanged:function(pressed){this._changedButtonState()},_ariaActiveAttri
buteChanged:function(value,oldValue){if(oldValue&&oldValue!=value&&this.hasAttri
bute(oldValue)){this.removeAttribute(oldValue)}},_activeChanged:function(active,
ariaActiveAttribute){if(this.toggles){this.setAttribute(this.ariaActiveAttribute
,active?"true":"false")}else{this.removeAttribute(this.ariaActiveAttribute)}this
._changedButtonState()},_controlStateChanged:function(){if(this.disabled){this._
setPressed(false)}else{this._changedButtonState()}},_changedButtonState:function
(){if(this._buttonStateChanged){this._buttonStateChanged()}}};Polymer.IronButton
State=[Polymer.IronA11yKeysBehavior,Polymer.IronButtonStateImpl];(function(){var
Utility={distance:function(x1,y1,x2,y2){var xDelta=x1-x2;var yDelta=y1-y2;retur
n Math.sqrt(xDelta*xDelta+yDelta*yDelta)},now:window.performance&&window.perform
ance.now?window.performance.now.bind(window.performance):Date.now};function Elem
entMetrics(element){this.element=element;this.width=this.boundingRect.width;this
.height=this.boundingRect.height;this.size=Math.max(this.width,this.height)}Elem
entMetrics.prototype={get boundingRect(){return this.element.getBoundingClientRe
ct()},furthestCornerDistanceFrom:function(x,y){var topLeft=Utility.distance(x,y,
0,0);var topRight=Utility.distance(x,y,this.width,0);var bottomLeft=Utility.dist
ance(x,y,0,this.height);var bottomRight=Utility.distance(x,y,this.width,this.hei
ght);return Math.max(topLeft,topRight,bottomLeft,bottomRight)}};function Ripple(
element){this.element=element;this.color=window.getComputedStyle(element).color;
this.wave=document.createElement("div");this.waveContainer=document.createElemen
t("div");this.wave.style.backgroundColor=this.color;this.wave.classList.add("wav
e");this.waveContainer.classList.add("wave-container");Polymer.dom(this.waveCont
ainer).appendChild(this.wave);this.resetInteractionState()}Ripple.MAX_RADIUS=300
;Ripple.prototype={get recenters(){return this.element.recenters},get center(){r
eturn this.element.center},get mouseDownElapsed(){var elapsed;if(!this.mouseDown
Start){return 0}elapsed=Utility.now()-this.mouseDownStart;if(this.mouseUpStart){
elapsed-=this.mouseUpElapsed}return elapsed},get mouseUpElapsed(){return this.mo
useUpStart?Utility.now()-this.mouseUpStart:0},get mouseDownElapsedSeconds(){retu
rn this.mouseDownElapsed/1e3},get mouseUpElapsedSeconds(){return this.mouseUpEla
psed/1e3},get mouseInteractionSeconds(){return this.mouseDownElapsedSeconds+this
.mouseUpElapsedSeconds},get initialOpacity(){return this.element.initialOpacity}
,get opacityDecayVelocity(){return this.element.opacityDecayVelocity},get radius
(){var width2=this.containerMetrics.width*this.containerMetrics.width;var height
2=this.containerMetrics.height*this.containerMetrics.height;var waveRadius=Math.
min(Math.sqrt(width2+height2),Ripple.MAX_RADIUS)*1.1+5;var duration=1.1-.2*(wave
Radius/Ripple.MAX_RADIUS);var timeNow=this.mouseInteractionSeconds/duration;var
size=waveRadius*(1-Math.pow(80,-timeNow));return Math.abs(size)},get opacity(){i
f(!this.mouseUpStart){return this.initialOpacity}return Math.max(0,this.initialO
pacity-this.mouseUpElapsedSeconds*this.opacityDecayVelocity)},get outerOpacity()
{var outerOpacity=this.mouseUpElapsedSeconds*.3;var waveOpacity=this.opacity;ret
urn Math.max(0,Math.min(outerOpacity,waveOpacity))},get isOpacityFullyDecayed(){
return this.opacity<.01&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)
},get isRestingAtMaxRadius(){return this.opacity>=this.initialOpacity&&this.radi
us>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isAnimationComplete(){return
this.mouseUpStart?this.isOpacityFullyDecayed:this.isRestingAtMaxRadius},get tra
nslationFraction(){return Math.min(1,this.radius/this.containerMetrics.size*2/Ma
th.sqrt(2))},get xNow(){if(this.xEnd){return this.xStart+this.translationFractio
n*(this.xEnd-this.xStart)}return this.xStart},get yNow(){if(this.yEnd){return th
is.yStart+this.translationFraction*(this.yEnd-this.yStart)}return this.yStart},g
et isMouseDown(){return this.mouseDownStart&&!this.mouseUpStart},resetInteractio
nState:function(){this.maxRadius=0;this.mouseDownStart=0;this.mouseUpStart=0;thi
s.xStart=0;this.yStart=0;this.xEnd=0;this.yEnd=0;this.slideDistance=0;this.conta
inerMetrics=new ElementMetrics(this.element)},draw:function(){var scale;var tran
slateString;var dx;var dy;this.wave.style.opacity=this.opacity;scale=this.radius
/(this.containerMetrics.size/2);dx=this.xNow-this.containerMetrics.width/2;dy=th
is.yNow-this.containerMetrics.height/2;this.waveContainer.style.webkitTransform=
"translate("+dx+"px, "+dy+"px)";this.waveContainer.style.transform="translate3d(
"+dx+"px, "+dy+"px, 0)";this.wave.style.webkitTransform="scale("+scale+","+scale
+")";this.wave.style.transform="scale3d("+scale+","+scale+",1)"},downAction:func
tion(event){var xCenter=this.containerMetrics.width/2;var yCenter=this.container
Metrics.height/2;this.resetInteractionState();this.mouseDownStart=Utility.now();
if(this.center){this.xStart=xCenter;this.yStart=yCenter;this.slideDistance=Utili
ty.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)}else{this.xStart=event?
event.detail.x-this.containerMetrics.boundingRect.left:this.containerMetrics.wid
th/2;this.yStart=event?event.detail.y-this.containerMetrics.boundingRect.top:thi
s.containerMetrics.height/2}if(this.recenters){this.xEnd=xCenter;this.yEnd=yCent
er;this.slideDistance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.yE
nd)}this.maxRadius=this.containerMetrics.furthestCornerDistanceFrom(this.xStart,
this.yStart);this.waveContainer.style.top=(this.containerMetrics.height-this.con
tainerMetrics.size)/2+"px";this.waveContainer.style.left=(this.containerMetrics.
width-this.containerMetrics.size)/2+"px";this.waveContainer.style.width=this.con
tainerMetrics.size+"px";this.waveContainer.style.height=this.containerMetrics.si
ze+"px"},upAction:function(event){if(!this.isMouseDown){return}this.mouseUpStart
=Utility.now()},remove:function(){Polymer.dom(this.waveContainer.parentNode).rem
oveChild(this.waveContainer)}};Polymer({is:"paper-ripple",behaviors:[Polymer.Iro
nA11yKeysBehavior],properties:{initialOpacity:{type:Number,value:.25},opacityDec
ayVelocity:{type:Number,value:.8},recenters:{type:Boolean,value:false},center:{t
ype:Boolean,value:false},ripples:{type:Array,value:function(){return[]}},animati
ng:{type:Boolean,readOnly:true,reflectToAttribute:true,value:false},holdDown:{ty
pe:Boolean,value:false,observer:"_holdDownChanged"},noink:{type:Boolean,value:fa
lse},_animating:{type:Boolean},_boundAnimate:{type:Function,value:function(){ret
urn this.animate.bind(this)}}},get target(){return this.keyEventTarget},keyBindi
ngs:{"enter:keydown":"_onEnterKeydown","space:keydown":"_onSpaceKeydown","space:
keyup":"_onSpaceKeyup"},attached:function(){if(this.parentNode.nodeType==11){thi
s.keyEventTarget=Polymer.dom(this).getOwnerRoot().host}else{this.keyEventTarget=
this.parentNode}var keyEventTarget=this.keyEventTarget;this.listen(keyEventTarge
t,"up","uiUpAction");this.listen(keyEventTarget,"down","uiDownAction")},detached
:function(){this.unlisten(this.keyEventTarget,"up","uiUpAction");this.unlisten(t
his.keyEventTarget,"down","uiDownAction");this.keyEventTarget=null},get shouldKe
epAnimating(){for(var index=0;index<this.ripples.length;++index){if(!this.ripple
s[index].isAnimationComplete){ |
21 | 21 return true}}return false},simulatedRipple:function(){this.downAction(null);this
.async(function(){this.upAction()},1)},uiDownAction:function(event){if(!this.noi
nk){this.downAction(event)}},downAction:function(event){if(this.holdDown&&this.r
ipples.length>0){return}var ripple=this.addRipple();ripple.downAction(event);if(
!this._animating){this._animating=true;this.animate()}},uiUpAction:function(even
t){if(!this.noink){this.upAction(event)}},upAction:function(event){if(this.holdD
own){return}this.ripples.forEach(function(ripple){ripple.upAction(event)});this.
_animating=true;this.animate()},onAnimationComplete:function(){this._animating=f
alse;this.$.background.style.backgroundColor=null;this.fire("transitionend")},ad
dRipple:function(){var ripple=new Ripple(this);Polymer.dom(this.$.waves).appendC
hild(ripple.waveContainer);this.$.background.style.backgroundColor=ripple.color;
this.ripples.push(ripple);this._setAnimating(true);return ripple},removeRipple:f
unction(ripple){var rippleIndex=this.ripples.indexOf(ripple);if(rippleIndex<0){r
eturn}this.ripples.splice(rippleIndex,1);ripple.remove();if(!this.ripples.length
){this._setAnimating(false)}},animate:function(){if(!this._animating){return}var
index;var ripple;for(index=0;index<this.ripples.length;++index){ripple=this.rip
ples[index];ripple.draw();this.$.background.style.opacity=ripple.outerOpacity;if
(ripple.isOpacityFullyDecayed&&!ripple.isRestingAtMaxRadius){this.removeRipple(r
ipple)}}if(!this.shouldKeepAnimating&&this.ripples.length===0){this.onAnimationC
omplete()}else{window.requestAnimationFrame(this._boundAnimate)}},_onEnterKeydow
n:function(){this.uiDownAction();this.async(this.uiUpAction,1)},_onSpaceKeydown:
function(){this.uiDownAction()},_onSpaceKeyup:function(){this.uiUpAction()},_hol
dDownChanged:function(newVal,oldVal){if(oldVal===undefined){return}if(newVal){th
is.downAction()}else{this.upAction()}}})})();Polymer.PaperRippleBehavior={proper
ties:{noink:{type:Boolean,observer:"_noinkChanged"},_rippleContainer:{type:Objec
t}},_buttonStateChanged:function(){if(this.focused){this.ensureRipple()}},_downH
andler:function(event){Polymer.IronButtonStateImpl._downHandler.call(this,event)
;if(this.pressed){this.ensureRipple(event)}},ensureRipple:function(optTriggering
Event){if(!this.hasRipple()){this._ripple=this._createRipple();this._ripple.noin
k=this.noink;var rippleContainer=this._rippleContainer||this.root;if(rippleConta
iner){Polymer.dom(rippleContainer).appendChild(this._ripple)}if(optTriggeringEve
nt){var domContainer=Polymer.dom(this._rippleContainer||this);var target=Polymer
.dom(optTriggeringEvent).rootTarget;if(domContainer.deepContains(target)){this._
ripple.uiDownAction(optTriggeringEvent)}}}},getRipple:function(){this.ensureRipp
le();return this._ripple},hasRipple:function(){return Boolean(this._ripple)},_cr
eateRipple:function(){return document.createElement("paper-ripple")},_noinkChang
ed:function(noink){if(this.hasRipple()){this._ripple.noink=noink}}};Polymer.Pape
rInkyFocusBehaviorImpl={observers:["_focusedChanged(receivedFocusFromKeyboard)"]
,_focusedChanged:function(receivedFocusFromKeyboard){if(receivedFocusFromKeyboar
d){this.ensureRipple()}if(this.hasRipple()){this._ripple.holdDown=receivedFocusF
romKeyboard}},_createRipple:function(){var ripple=Polymer.PaperRippleBehavior._c
reateRipple();ripple.id="ink";ripple.setAttribute("center","");ripple.classList.
add("circle");return ripple}};Polymer.PaperInkyFocusBehavior=[Polymer.IronButton
State,Polymer.IronControlState,Polymer.PaperRippleBehavior,Polymer.PaperInkyFocu
sBehaviorImpl];Polymer({is:"paper-icon-button",hostAttributes:{role:"button",tab
index:"0"},behaviors:[Polymer.PaperInkyFocusBehavior],properties:{src:{type:Stri
ng},icon:{type:String},alt:{type:String,observer:"_altChanged"}},_altChanged:fun
ction(newValue,oldValue){var label=this.getAttribute("aria-label");if(!label||ol
dValue==label){this.setAttribute("aria-label",newValue)}}});Polymer({is:"iron-ic
onset-svg",properties:{name:{type:String,observer:"_nameChanged"},size:{type:Num
ber,value:24}},attached:function(){this.style.display="none"},getIconNames:funct
ion(){this._icons=this._createIconMap();return Object.keys(this._icons).map(func
tion(n){return this.name+":"+n},this)},applyIcon:function(element,iconName){elem
ent=element.root||element;this.removeIcon(element);var svg=this._cloneIcon(iconN
ame);if(svg){var pde=Polymer.dom(element);pde.insertBefore(svg,pde.childNodes[0]
);return element._svgIcon=svg}return null},removeIcon:function(element){if(eleme
nt._svgIcon){Polymer.dom(element).removeChild(element._svgIcon);element._svgIcon
=null}},_nameChanged:function(){new Polymer.IronMeta({type:"iconset",key:this.na
me,value:this});this.async(function(){this.fire("iron-iconset-added",this,{node:
window})})},_createIconMap:function(){var icons=Object.create(null);Polymer.dom(
this).querySelectorAll("[id]").forEach(function(icon){icons[icon.id]=icon});retu
rn icons},_cloneIcon:function(id){this._icons=this._icons||this._createIconMap()
;return this._prepareSvgClone(this._icons[id],this.size)},_prepareSvgClone:funct
ion(sourceSvg,size){if(sourceSvg){var content=sourceSvg.cloneNode(true),svg=docu
ment.createElementNS("http://www.w3.org/2000/svg","svg"),viewBox=content.getAttr
ibute("viewBox")||"0 0 "+size+" "+size;svg.setAttribute("viewBox",viewBox);svg.s
etAttribute("preserveAspectRatio","xMidYMid meet");svg.style.cssText="pointer-ev
ents: none; display: block; width: 100%; height: 100%;";svg.appendChild(content)
.removeAttribute("id");return svg}return null}}); |
22 }var ripple=this.addRipple();ripple.downAction(event);if(!this._animating){this.
_animating=true;this.animate()}},uiUpAction:function(event){if(!this.noink){this
.upAction(event)}},upAction:function(event){if(this.holdDown){return}this.ripple
s.forEach(function(ripple){ripple.upAction(event)});this._animating=true;this.an
imate()},onAnimationComplete:function(){this._animating=false;this.$.background.
style.backgroundColor=null;this.fire("transitionend")},addRipple:function(){var
ripple=new Ripple(this);Polymer.dom(this.$.waves).appendChild(ripple.waveContain
er);this.$.background.style.backgroundColor=ripple.color;this.ripples.push(rippl
e);this._setAnimating(true);return ripple},removeRipple:function(ripple){var rip
pleIndex=this.ripples.indexOf(ripple);if(rippleIndex<0){return}this.ripples.spli
ce(rippleIndex,1);ripple.remove();if(!this.ripples.length){this._setAnimating(fa
lse)}},animate:function(){if(!this._animating){return}var index;var ripple;for(i
ndex=0;index<this.ripples.length;++index){ripple=this.ripples[index];ripple.draw
();this.$.background.style.opacity=ripple.outerOpacity;if(ripple.isOpacityFullyD
ecayed&&!ripple.isRestingAtMaxRadius){this.removeRipple(ripple)}}if(!this.should
KeepAnimating&&this.ripples.length===0){this.onAnimationComplete()}else{window.r
equestAnimationFrame(this._boundAnimate)}},_onEnterKeydown:function(){this.uiDow
nAction();this.async(this.uiUpAction,1)},_onSpaceKeydown:function(){this.uiDownA
ction()},_onSpaceKeyup:function(){this.uiUpAction()},_holdDownChanged:function(n
ewVal,oldVal){if(oldVal===undefined){return}if(newVal){this.downAction()}else{th
is.upAction()}}})})();Polymer.PaperRippleBehavior={properties:{noink:{type:Boole
an,observer:"_noinkChanged"},_rippleContainer:{type:Object}},_buttonStateChanged
:function(){if(this.focused){this.ensureRipple()}},_downHandler:function(event){
Polymer.IronButtonStateImpl._downHandler.call(this,event);if(this.pressed){this.
ensureRipple(event)}},ensureRipple:function(optTriggeringEvent){if(!this.hasRipp
le()){this._ripple=this._createRipple();this._ripple.noink=this.noink;var ripple
Container=this._rippleContainer||this.root;if(rippleContainer){Polymer.dom(rippl
eContainer).appendChild(this._ripple)}if(optTriggeringEvent){var domContainer=Po
lymer.dom(this._rippleContainer||this);var target=Polymer.dom(optTriggeringEvent
).rootTarget;if(domContainer.deepContains(target)){this._ripple.uiDownAction(opt
TriggeringEvent)}}}},getRipple:function(){this.ensureRipple();return this._rippl
e},hasRipple:function(){return Boolean(this._ripple)},_createRipple:function(){r
eturn document.createElement("paper-ripple")},_noinkChanged:function(noink){if(t
his.hasRipple()){this._ripple.noink=noink}}};Polymer.PaperInkyFocusBehaviorImpl=
{observers:["_focusedChanged(receivedFocusFromKeyboard)"],_focusedChanged:functi
on(receivedFocusFromKeyboard){if(receivedFocusFromKeyboard){this.ensureRipple()}
if(this.hasRipple()){this._ripple.holdDown=receivedFocusFromKeyboard}},_createRi
pple:function(){var ripple=Polymer.PaperRippleBehavior._createRipple();ripple.id
="ink";ripple.setAttribute("center","");ripple.classList.add("circle");return ri
pple}};Polymer.PaperInkyFocusBehavior=[Polymer.IronButtonState,Polymer.IronContr
olState,Polymer.PaperRippleBehavior,Polymer.PaperInkyFocusBehaviorImpl];Polymer(
{is:"paper-icon-button",hostAttributes:{role:"button",tabindex:"0"},behaviors:[P
olymer.PaperInkyFocusBehavior],properties:{src:{type:String},icon:{type:String},
alt:{type:String,observer:"_altChanged"}},_altChanged:function(newValue,oldValue
){var label=this.getAttribute("aria-label");if(!label||oldValue==label){this.set
Attribute("aria-label",newValue)}}});Polymer({is:"iron-iconset-svg",properties:{
name:{type:String,observer:"_nameChanged"},size:{type:Number,value:24}},attached
:function(){this.style.display="none"},getIconNames:function(){this._icons=this.
_createIconMap();return Object.keys(this._icons).map(function(n){return this.nam
e+":"+n},this)},applyIcon:function(element,iconName){element=element.root||eleme
nt;this.removeIcon(element);var svg=this._cloneIcon(iconName);if(svg){var pde=Po
lymer.dom(element);pde.insertBefore(svg,pde.childNodes[0]);return element._svgIc
on=svg}return null},removeIcon:function(element){if(element._svgIcon){Polymer.do
m(element).removeChild(element._svgIcon);element._svgIcon=null}},_nameChanged:fu
nction(){new Polymer.IronMeta({type:"iconset",key:this.name,value:this});this.as
ync(function(){this.fire("iron-iconset-added",this,{node:window})})},_createIcon
Map:function(){var icons=Object.create(null);Polymer.dom(this).querySelectorAll(
"[id]").forEach(function(icon){icons[icon.id]=icon});return icons},_cloneIcon:fu
nction(id){this._icons=this._icons||this._createIconMap();return this._prepareSv
gClone(this._icons[id],this.size)},_prepareSvgClone:function(sourceSvg,size){if(
sourceSvg){var content=sourceSvg.cloneNode(true),svg=document.createElementNS("h
ttp://www.w3.org/2000/svg","svg"),viewBox=content.getAttribute("viewBox")||"0 0
"+size+" "+size;svg.setAttribute("viewBox",viewBox);svg.setAttribute("preserveAs
pectRatio","xMidYMid meet");svg.style.cssText="pointer-events: none; display: bl
ock; width: 100%; height: 100%;";svg.appendChild(content).removeAttribute("id");
return svg}return null}}); | |
23 // Copyright 2016 The Chromium Authors. All rights reserved. | 22 // Copyright 2016 The Chromium Authors. All rights reserved. |
24 // Use of this source code is governed by a BSD-style license that can be | 23 // Use of this source code is governed by a BSD-style license that can be |
25 // found in the LICENSE file. | 24 // found in the LICENSE file. |
26 Polymer({is:"cr-lazy-render","extends":"template",behaviors:[Polymer.Templatizer
],child_:null,get:function(){if(!this.child_)this.render_();return this.child_},
getIfExists:function(){return this.child_},render_:function(){if(!this.ctor)this
.templatize(this);var parentNode=this.parentNode;if(parentNode&&!this.child_){va
r instance=this.stamp({});this.child_=instance.root.firstElementChild;parentNode
.insertBefore(instance.root,this)}},_forwardParentProp:function(prop,value){if(t
his.child_)this.child_._templateInstance[prop]=value},_forwardParentPath:functio
n(path,value){if(this.child_)this.child_._templateInstance.notifyPath(path,value
,true)}});(function(){"use strict";Polymer.IronA11yAnnouncer=Polymer({is:"iron-a
11y-announcer",properties:{mode:{type:String,value:"polite"},_text:{type:String,
value:""}},created:function(){if(!Polymer.IronA11yAnnouncer.instance){Polymer.Ir
onA11yAnnouncer.instance=this}document.body.addEventListener("iron-announce",thi
s._onIronAnnounce.bind(this))},announce:function(text){this._text="";this.async(
function(){this._text=text},100)},_onIronAnnounce:function(event){if(event.detai
l&&event.detail.text){this.announce(event.detail.text)}}});Polymer.IronA11yAnnou
ncer.instance=null;Polymer.IronA11yAnnouncer.requestAvailability=function(){if(!
Polymer.IronA11yAnnouncer.instance){Polymer.IronA11yAnnouncer.instance=document.
createElement("iron-a11y-announcer")}document.body.appendChild(Polymer.IronA11yA
nnouncer.instance)}})();Polymer.IronValidatableBehaviorMeta=null;Polymer.IronVal
idatableBehavior={properties:{validator:{type:String},invalid:{notify:true,refle
ctToAttribute:true,type:Boolean,value:false},_validatorMeta:{type:Object},valida
torType:{type:String,value:"validator"},_validator:{type:Object,computed:"__comp
uteValidator(validator)"}},observers:["_invalidChanged(invalid)"],registered:fun
ction(){Polymer.IronValidatableBehaviorMeta=new Polymer.IronMeta({type:"validato
r"})},_invalidChanged:function(){if(this.invalid){this.setAttribute("aria-invali
d","true")}else{this.removeAttribute("aria-invalid")}},hasValidator:function(){r
eturn this._validator!=null},validate:function(value){this.invalid=!this._getVal
idity(value);return!this.invalid},_getValidity:function(value){if(this.hasValida
tor()){return this._validator.validate(value)}return true},__computeValidator:fu
nction(){return Polymer.IronValidatableBehaviorMeta&&Polymer.IronValidatableBeha
viorMeta.byKey(this.validator)}};Polymer({is:"iron-input","extends":"input",beha
viors:[Polymer.IronValidatableBehavior],properties:{bindValue:{observer:"_bindVa
lueChanged",type:String},preventInvalidInput:{type:Boolean},allowedPattern:{type
:String,observer:"_allowedPatternChanged"},_previousValidInput:{type:String,valu
e:""},_patternAlreadyChecked:{type:Boolean,value:false}},listeners:{input:"_onIn
put",keypress:"_onKeypress"},registered:function(){if(!this._canDispatchEventOnD
isabled()){this._origDispatchEvent=this.dispatchEvent;this.dispatchEvent=this._d
ispatchEventFirefoxIE}},created:function(){Polymer.IronA11yAnnouncer.requestAvai
lability()},_canDispatchEventOnDisabled:function(){var input=document.createElem
ent("input");var canDispatch=false;input.disabled=true;input.addEventListener("f
eature-check-dispatch-event",function(){canDispatch=true});try{input.dispatchEve
nt(new Event("feature-check-dispatch-event"))}catch(e){}return canDispatch},_dis
patchEventFirefoxIE:function(){var disabled=this.disabled;this.disabled=false;th
is._origDispatchEvent.apply(this,arguments);this.disabled=disabled},get _pattern
RegExp(){var pattern;if(this.allowedPattern){pattern=new RegExp(this.allowedPatt
ern)}else{switch(this.type){case"number":pattern=/[0-9.,e-]/;break}}return patte
rn},ready:function(){this.bindValue=this.value},_bindValueChanged:function(){if(
this.value!==this.bindValue){this.value=!(this.bindValue||this.bindValue===0||th
is.bindValue===false)?"":this.bindValue}this.fire("bind-value-changed",{value:th
is.bindValue})},_allowedPatternChanged:function(){this.preventInvalidInput=this.
allowedPattern?true:false},_onInput:function(){if(this.preventInvalidInput&&!thi
s._patternAlreadyChecked){var valid=this._checkPatternValidity();if(!valid){this
._announceInvalidCharacter("Invalid string of characters not entered.");this.val
ue=this._previousValidInput}}this.bindValue=this.value;this._previousValidInput=
this.value;this._patternAlreadyChecked=false},_isPrintable:function(event){var a
nyNonPrintable=event.keyCode==8||event.keyCode==9||event.keyCode==13||event.keyC
ode==27;var mozNonPrintable=event.keyCode==19||event.keyCode==20||event.keyCode=
=45||event.keyCode==46||event.keyCode==144||event.keyCode==145||event.keyCode>32
&&event.keyCode<41||event.keyCode>111&&event.keyCode<124;return!anyNonPrintable&
&!(event.charCode==0&&mozNonPrintable)},_onKeypress:function(event){if(!this.pre
ventInvalidInput&&this.type!=="number"){return}var regexp=this._patternRegExp;if
(!regexp){return}if(event.metaKey||event.ctrlKey||event.altKey)return;this._patt
ernAlreadyChecked=true;var thisChar=String.fromCharCode(event.charCode);if(this.
_isPrintable(event)&&!regexp.test(thisChar)){event.preventDefault();this._announ
ceInvalidCharacter("Invalid character "+thisChar+" not entered.")}},_checkPatter
nValidity:function(){var regexp=this._patternRegExp;if(!regexp){return true}for(
var i=0;i<this.value.length;i++){if(!regexp.test(this.value[i])){return false}}r
eturn true},validate:function(){var valid=this.checkValidity();if(valid){if(this
.required&&this.value===""){valid=false}else if(this.hasValidator()){valid=Polym
er.IronValidatableBehavior.validate.call(this,this.value)}}this.invalid=!valid;t
his.fire("iron-input-validate");return valid},_announceInvalidCharacter:function
(message){this.fire("iron-announce",{text:message})}});Polymer({is:"paper-input-
container",properties:{noLabelFloat:{type:Boolean,value:false},alwaysFloatLabel:
{type:Boolean,value:false},attrForValue:{type:String,value:"bind-value"},autoVal
idate:{type:Boolean,value:false},invalid:{observer:"_invalidChanged",type:Boolea
n,value:false},focused:{readOnly:true,type:Boolean,value:false,notify:true},_add
ons:{type:Array},_inputHasContent:{type:Boolean,value:false},_inputSelector:{typ
e:String,value:"input,textarea,.paper-input-input"},_boundOnFocus:{type:Function
,value:function(){return this._onFocus.bind(this)}},_boundOnBlur:{type:Function,
value:function(){return this._onBlur.bind(this)}},_boundOnInput:{type:Function,v
alue:function(){return this._onInput.bind(this)}},_boundValueChanged:{type:Funct
ion,value:function(){return this._onValueChanged.bind(this)}}},listeners:{"addon
-attached":"_onAddonAttached","iron-input-validate":"_onIronInputValidate"},get
_valueChangedEvent(){return this.attrForValue+"-changed"},get _propertyForValue(
){return Polymer.CaseMap.dashToCamelCase(this.attrForValue)},get _inputElement()
{return Polymer.dom(this).querySelector(this._inputSelector)},get _inputElementV
alue(){return this._inputElement[this._propertyForValue]||this._inputElement.val
ue},ready:function(){if(!this._addons){this._addons=[]}this.addEventListener("fo
cus",this._boundOnFocus,true);this.addEventListener("blur",this._boundOnBlur,tru
e)},attached:function(){if(this.attrForValue){this._inputElement.addEventListene
r(this._valueChangedEvent,this._boundValueChanged)}else{this.addEventListener("i
nput",this._onInput)}if(this._inputElementValue!=""){this._handleValueAndAutoVal
idate(this._inputElement)}else{this._handleValue(this._inputElement)}},_onAddonA
ttached:function(event){if(!this._addons){this._addons=[]}var target=event.targe
t;if(this._addons.indexOf(target)===-1){this._addons.push(target);if(this.isAtta
ched){this._handleValue(this._inputElement)}}},_onFocus:function(){this._setFocu
sed(true)},_onBlur:function(){this._setFocused(false);this._handleValueAndAutoVa
lidate(this._inputElement)},_onInput:function(event){this._handleValueAndAutoVal
idate(event.target)},_onValueChanged:function(event){this._handleValueAndAutoVal
idate(event.target)},_handleValue:function(inputElement){var value=this._inputEl
ementValue;if(value||value===0||inputElement.type==="number"&&!inputElement.chec
kValidity()){this._inputHasContent=true}else{this._inputHasContent=false}this.up
dateAddons({inputElement:inputElement,value:value,invalid:this.invalid})},_handl
eValueAndAutoValidate:function(inputElement){if(this.autoValidate){var valid;if(
inputElement.validate){valid=inputElement.validate(this._inputElementValue)}else
{valid=inputElement.checkValidity()}this.invalid=!valid}this._handleValue(inputE
lement)},_onIronInputValidate:function(event){this.invalid=this._inputElement.in
valid},_invalidChanged:function(){if(this._addons){this.updateAddons({invalid:th
is.invalid})}},updateAddons:function(state){for(var addon,index=0;addon=this._ad
dons[index];index++){addon.update(state)}},_computeInputContentClass:function(no
LabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent){var cls="input-con
tent";if(!noLabelFloat){var label=this.querySelector("label");if(alwaysFloatLabe
l||_inputHasContent){cls+=" label-is-floating";this.$.labelAndInputContainer.sty
le.position="static";if(invalid){cls+=" is-invalid"}else if(focused){cls+=" labe
l-is-highlighted"}}else{if(label){this.$.labelAndInputContainer.style.position="
relative"}}}else{if(_inputHasContent){cls+=" label-is-hidden"}}return cls},_comp
uteUnderlineClass:function(focused,invalid){var cls="underline";if(invalid){cls+
=" is-invalid"}else if(focused){cls+=" is-highlighted"}return cls},_computeAddOn
ContentClass:function(focused,invalid){var cls="add-on-content";if(invalid){cls+
=" is-invalid"}else if(focused){cls+=" is-highlighted"}return cls}});Polymer.Pap
erSpinnerBehavior={listeners:{animationend:"__reset",webkitAnimationEnd:"__reset
"},properties:{active:{type:Boolean,value:false,reflectToAttribute:true,observer
:"__activeChanged"},alt:{type:String,value:"loading",observer:"__altChanged"},__
coolingDown:{type:Boolean,value:false}},__computeContainerClasses:function(activ
e,coolingDown){return[active||coolingDown?"active":"",coolingDown?"cooldown":""]
.join(" ")},__activeChanged:function(active,old){this.__setAriaHidden(!active);t
his.__coolingDown=!active&&old},__altChanged:function(alt){if(alt===this.getProp
ertyInfo("alt").value){this.alt=this.getAttribute("aria-label")||alt}else{this._
_setAriaHidden(alt==="");this.setAttribute("aria-label",alt)}},__setAriaHidden:f
unction(hidden){var attr="aria-hidden";if(hidden){this.setAttribute(attr,"true")
}else{this.removeAttribute(attr)}},__reset:function(){this.active=false;this.__c
oolingDown=false}};Polymer({is:"paper-spinner-lite",behaviors:[Polymer.PaperSpin
nerBehavior]}); | 25 Polymer({is:"cr-lazy-render","extends":"template",behaviors:[Polymer.Templatizer
],child_:null,get:function(){if(!this.child_)this.render_();return this.child_},
getIfExists:function(){return this.child_},render_:function(){if(!this.ctor)this
.templatize(this);var parentNode=this.parentNode;if(parentNode&&!this.child_){va
r instance=this.stamp({});this.child_=instance.root.firstElementChild;parentNode
.insertBefore(instance.root,this)}},_forwardParentProp:function(prop,value){if(t
his.child_)this.child_._templateInstance[prop]=value},_forwardParentPath:functio
n(path,value){if(this.child_)this.child_._templateInstance.notifyPath(path,value
,true)}});(function(){"use strict";Polymer.IronA11yAnnouncer=Polymer({is:"iron-a
11y-announcer",properties:{mode:{type:String,value:"polite"},_text:{type:String,
value:""}},created:function(){if(!Polymer.IronA11yAnnouncer.instance){Polymer.Ir
onA11yAnnouncer.instance=this}document.body.addEventListener("iron-announce",thi
s._onIronAnnounce.bind(this))},announce:function(text){this._text="";this.async(
function(){this._text=text},100)},_onIronAnnounce:function(event){if(event.detai
l&&event.detail.text){this.announce(event.detail.text)}}});Polymer.IronA11yAnnou
ncer.instance=null;Polymer.IronA11yAnnouncer.requestAvailability=function(){if(!
Polymer.IronA11yAnnouncer.instance){Polymer.IronA11yAnnouncer.instance=document.
createElement("iron-a11y-announcer")}document.body.appendChild(Polymer.IronA11yA
nnouncer.instance)}})();Polymer.IronValidatableBehaviorMeta=null;Polymer.IronVal
idatableBehavior={properties:{validator:{type:String},invalid:{notify:true,refle
ctToAttribute:true,type:Boolean,value:false},_validatorMeta:{type:Object},valida
torType:{type:String,value:"validator"},_validator:{type:Object,computed:"__comp
uteValidator(validator)"}},observers:["_invalidChanged(invalid)"],registered:fun
ction(){Polymer.IronValidatableBehaviorMeta=new Polymer.IronMeta({type:"validato
r"})},_invalidChanged:function(){if(this.invalid){this.setAttribute("aria-invali
d","true")}else{this.removeAttribute("aria-invalid")}},hasValidator:function(){r
eturn this._validator!=null},validate:function(value){this.invalid=!this._getVal
idity(value);return!this.invalid},_getValidity:function(value){if(this.hasValida
tor()){return this._validator.validate(value)}return true},__computeValidator:fu
nction(){return Polymer.IronValidatableBehaviorMeta&&Polymer.IronValidatableBeha
viorMeta.byKey(this.validator)}};Polymer({is:"iron-input","extends":"input",beha
viors:[Polymer.IronValidatableBehavior],properties:{bindValue:{observer:"_bindVa
lueChanged",type:String},preventInvalidInput:{type:Boolean},allowedPattern:{type
:String,observer:"_allowedPatternChanged"},_previousValidInput:{type:String,valu
e:""},_patternAlreadyChecked:{type:Boolean,value:false}},listeners:{input:"_onIn
put",keypress:"_onKeypress"},registered:function(){if(!this._canDispatchEventOnD
isabled()){this._origDispatchEvent=this.dispatchEvent;this.dispatchEvent=this._d
ispatchEventFirefoxIE}},created:function(){Polymer.IronA11yAnnouncer.requestAvai
lability()},_canDispatchEventOnDisabled:function(){var input=document.createElem
ent("input");var canDispatch=false;input.disabled=true;input.addEventListener("f
eature-check-dispatch-event",function(){canDispatch=true});try{input.dispatchEve
nt(new Event("feature-check-dispatch-event"))}catch(e){}return canDispatch},_dis
patchEventFirefoxIE:function(){var disabled=this.disabled;this.disabled=false;th
is._origDispatchEvent.apply(this,arguments);this.disabled=disabled},get _pattern
RegExp(){var pattern;if(this.allowedPattern){pattern=new RegExp(this.allowedPatt
ern)}else{switch(this.type){case"number":pattern=/[0-9.,e-]/;break}}return patte
rn},ready:function(){this.bindValue=this.value},_bindValueChanged:function(){if(
this.value!==this.bindValue){this.value=!(this.bindValue||this.bindValue===0||th
is.bindValue===false)?"":this.bindValue}this.fire("bind-value-changed",{value:th
is.bindValue})},_allowedPatternChanged:function(){this.preventInvalidInput=this.
allowedPattern?true:false},_onInput:function(){if(this.preventInvalidInput&&!thi
s._patternAlreadyChecked){var valid=this._checkPatternValidity();if(!valid){this
._announceInvalidCharacter("Invalid string of characters not entered.");this.val
ue=this._previousValidInput}}this.bindValue=this.value;this._previousValidInput=
this.value;this._patternAlreadyChecked=false},_isPrintable:function(event){var a
nyNonPrintable=event.keyCode==8||event.keyCode==9||event.keyCode==13||event.keyC
ode==27;var mozNonPrintable=event.keyCode==19||event.keyCode==20||event.keyCode=
=45||event.keyCode==46||event.keyCode==144||event.keyCode==145||event.keyCode>32
&&event.keyCode<41||event.keyCode>111&&event.keyCode<124;return!anyNonPrintable&
&!(event.charCode==0&&mozNonPrintable)},_onKeypress:function(event){if(!this.pre
ventInvalidInput&&this.type!=="number"){return}var regexp=this._patternRegExp;if
(!regexp){return}if(event.metaKey||event.ctrlKey||event.altKey)return;this._patt
ernAlreadyChecked=true;var thisChar=String.fromCharCode(event.charCode);if(this.
_isPrintable(event)&&!regexp.test(thisChar)){event.preventDefault();this._announ
ceInvalidCharacter("Invalid character "+thisChar+" not entered.")}},_checkPatter
nValidity:function(){var regexp=this._patternRegExp;if(!regexp){return true}for(
var i=0;i<this.value.length;i++){if(!regexp.test(this.value[i])){return false}}r
eturn true},validate:function(){var valid=this.checkValidity();if(valid){if(this
.required&&this.value===""){valid=false}else if(this.hasValidator()){valid=Polym
er.IronValidatableBehavior.validate.call(this,this.value)}}this.invalid=!valid;t
his.fire("iron-input-validate");return valid},_announceInvalidCharacter:function
(message){this.fire("iron-announce",{text:message})}});Polymer({is:"paper-input-
container",properties:{noLabelFloat:{type:Boolean,value:false},alwaysFloatLabel:
{type:Boolean,value:false},attrForValue:{type:String,value:"bind-value"},autoVal
idate:{type:Boolean,value:false},invalid:{observer:"_invalidChanged",type:Boolea
n,value:false},focused:{readOnly:true,type:Boolean,value:false,notify:true},_add
ons:{type:Array},_inputHasContent:{type:Boolean,value:false},_inputSelector:{typ
e:String,value:"input,textarea,.paper-input-input"},_boundOnFocus:{type:Function
,value:function(){return this._onFocus.bind(this)}},_boundOnBlur:{type:Function,
value:function(){return this._onBlur.bind(this)}},_boundOnInput:{type:Function,v
alue:function(){return this._onInput.bind(this)}},_boundValueChanged:{type:Funct
ion,value:function(){return this._onValueChanged.bind(this)}}},listeners:{"addon
-attached":"_onAddonAttached","iron-input-validate":"_onIronInputValidate"},get
_valueChangedEvent(){return this.attrForValue+"-changed"},get _propertyForValue(
){return Polymer.CaseMap.dashToCamelCase(this.attrForValue)},get _inputElement()
{return Polymer.dom(this).querySelector(this._inputSelector)},get _inputElementV
alue(){return this._inputElement[this._propertyForValue]||this._inputElement.val
ue},ready:function(){if(!this._addons){this._addons=[]}this.addEventListener("fo
cus",this._boundOnFocus,true);this.addEventListener("blur",this._boundOnBlur,tru
e)},attached:function(){if(this.attrForValue){this._inputElement.addEventListene
r(this._valueChangedEvent,this._boundValueChanged)}else{this.addEventListener("i
nput",this._onInput)}if(this._inputElementValue!=""){this._handleValueAndAutoVal
idate(this._inputElement)}else{this._handleValue(this._inputElement)}},_onAddonA
ttached:function(event){if(!this._addons){this._addons=[]}var target=event.targe
t;if(this._addons.indexOf(target)===-1){this._addons.push(target);if(this.isAtta
ched){this._handleValue(this._inputElement)}}},_onFocus:function(){this._setFocu
sed(true)},_onBlur:function(){this._setFocused(false);this._handleValueAndAutoVa
lidate(this._inputElement)},_onInput:function(event){this._handleValueAndAutoVal
idate(event.target)},_onValueChanged:function(event){this._handleValueAndAutoVal
idate(event.target)},_handleValue:function(inputElement){var value=this._inputEl
ementValue;if(value||value===0||inputElement.type==="number"&&!inputElement.chec
kValidity()){this._inputHasContent=true}else{this._inputHasContent=false}this.up
dateAddons({inputElement:inputElement,value:value,invalid:this.invalid})},_handl
eValueAndAutoValidate:function(inputElement){if(this.autoValidate){var valid;if(
inputElement.validate){valid=inputElement.validate(this._inputElementValue)}else
{valid=inputElement.checkValidity()}this.invalid=!valid}this._handleValue(inputE
lement)},_onIronInputValidate:function(event){this.invalid=this._inputElement.in
valid},_invalidChanged:function(){if(this._addons){this.updateAddons({invalid:th
is.invalid})}},updateAddons:function(state){for(var addon,index=0;addon=this._ad
dons[index];index++){addon.update(state)}},_computeInputContentClass:function(no
LabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent){var cls="input-con
tent";if(!noLabelFloat){var label=this.querySelector("label");if(alwaysFloatLabe
l||_inputHasContent){cls+=" label-is-floating";this.$.labelAndInputContainer.sty
le.position="static";if(invalid){cls+=" is-invalid"}else if(focused){cls+=" labe
l-is-highlighted"}}else{if(label){this.$.labelAndInputContainer.style.position="
relative"}}}else{if(_inputHasContent){cls+=" label-is-hidden"}}return cls},_comp
uteUnderlineClass:function(focused,invalid){var cls="underline";if(invalid){cls+
=" is-invalid"}else if(focused){cls+=" is-highlighted"}return cls},_computeAddOn
ContentClass:function(focused,invalid){var cls="add-on-content";if(invalid){cls+
=" is-invalid"}else if(focused){cls+=" is-highlighted"}return cls}});Polymer.Pap
erSpinnerBehavior={listeners:{animationend:"__reset",webkitAnimationEnd:"__reset
"},properties:{active:{type:Boolean,value:false,reflectToAttribute:true,observer
:"__activeChanged"},alt:{type:String,value:"loading",observer:"__altChanged"},__
coolingDown:{type:Boolean,value:false}},__computeContainerClasses:function(activ
e,coolingDown){return[active||coolingDown?"active":"",coolingDown?"cooldown":""]
.join(" ")},__activeChanged:function(active,old){this.__setAriaHidden(!active);t
his.__coolingDown=!active&&old},__altChanged:function(alt){if(alt===this.getProp
ertyInfo("alt").value){this.alt=this.getAttribute("aria-label")||alt}else{this._
_setAriaHidden(alt==="");this.setAttribute("aria-label",alt)}},__setAriaHidden:f
unction(hidden){var attr="aria-hidden";if(hidden){this.setAttribute(attr,"true")
}else{this.removeAttribute(attr)}},__reset:function(){this.active=false;this.__c
oolingDown=false}};Polymer({is:"paper-spinner-lite",behaviors:[Polymer.PaperSpin
nerBehavior]}); |
27 // Copyright 2016 The Chromium Authors. All rights reserved. | 26 // Copyright 2016 The Chromium Authors. All rights reserved. |
28 // Use of this source code is governed by a BSD-style license that can be | 27 // Use of this source code is governed by a BSD-style license that can be |
29 // found in the LICENSE file. | 28 // found in the LICENSE file. |
30 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{
type:String,value:""},showingSearch:{type:Boolean,value:false,notify:true,observ
er:"showingSearchChanged_",reflectToAttribute:true},lastValue_:{type:String,valu
e:""}},getSearchInput:function(){},getValue:function(){return this.getSearchInpu
t().value},setValue:function(value){this.getSearchInput().bindValue=value;this.o
nValueChanged_(value)},showAndFocus:function(){this.showingSearch=true;this.focu
s_()},focus_:function(){this.getSearchInput().focus()},onSearchTermSearch:functi
on(){this.onValueChanged_(this.getValue())},onValueChanged_:function(newValue){i
f(newValue==this.lastValue_)return;this.fire("search-changed",newValue);this.las
tValue_=newValue},onSearchTermKeydown:function(e){if(e.key=="Escape")this.showin
gSearch=false},showingSearchChanged_:function(){if(this.showingSearch){this.focu
s_();return}this.setValue("");this.getSearchInput().blur()}}; | 29 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{
type:String,value:""},showingSearch:{type:Boolean,value:false,notify:true,observ
er:"showingSearchChanged_",reflectToAttribute:true},lastValue_:{type:String,valu
e:""}},getSearchInput:function(){},getValue:function(){return this.getSearchInpu
t().value},setValue:function(value){this.getSearchInput().bindValue=value;this.o
nValueChanged_(value)},showAndFocus:function(){this.showingSearch=true;this.focu
s_()},focus_:function(){this.getSearchInput().focus()},onSearchTermSearch:functi
on(){this.onValueChanged_(this.getValue())},onValueChanged_:function(newValue){i
f(newValue==this.lastValue_)return;this.fire("search-changed",newValue);this.las
tValue_=newValue},onSearchTermKeydown:function(e){if(e.key=="Escape")this.showin
gSearch=false},showingSearchChanged_:function(){if(this.showingSearch){this.focu
s_();return}this.setValue("");this.getSearchInput().blur()}}; |
31 // Copyright 2016 The Chromium Authors. All rights reserved. | 30 // Copyright 2016 The Chromium Authors. All rights reserved. |
32 // Use of this source code is governed by a BSD-style license that can be | 31 // Use of this source code is governed by a BSD-style license that can be |
33 // found in the LICENSE file. | 32 // found in the LICENSE file. |
34 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti
es:{narrow:{type:Boolean,reflectToAttribute:true},label:String,clearLabel:String
,spinnerActive:{type:Boolean,reflectToAttribute:true},hasSearchText_:Boolean,isS
pinnerShown_:{type:Boolean,computed:"computeIsSpinnerShown_(spinnerActive, showi
ngSearch)"}},listeners:{tap:"showSearch_","searchInput.bind-value-changed":"onBi
ndValueChanged_"},getSearchInput:function(){return this.$.searchInput},isSearchF
ocused:function(){return this.$.searchTerm.focused},computeIconTabIndex_:functio
n(narrow){return narrow?0:-1},computeIsSpinnerShown_:function(){return this.spin
nerActive&&this.showingSearch},onInputBlur_:function(){if(!this.hasSearchText_)t
his.showingSearch=false},onBindValueChanged_:function(){var newValue=this.$.sear
chInput.bindValue;this.hasSearchText_=newValue!="";if(newValue!="")this.showingS
earch=true},showSearch_:function(e){if(e.target!=this.$.clearSearch)this.showing
Search=true},hideSearch_:function(e){this.showingSearch=false;e.stopPropagation(
)}}); | 33 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti
es:{narrow:{type:Boolean,reflectToAttribute:true},label:String,clearLabel:String
,spinnerActive:{type:Boolean,reflectToAttribute:true},hasSearchText_:Boolean,isS
pinnerShown_:{type:Boolean,computed:"computeIsSpinnerShown_(spinnerActive, showi
ngSearch)"}},listeners:{tap:"showSearch_","searchInput.bind-value-changed":"onBi
ndValueChanged_"},getSearchInput:function(){return this.$.searchInput},isSearchF
ocused:function(){return this.$.searchTerm.focused},computeIconTabIndex_:functio
n(narrow){return narrow?0:-1},computeIsSpinnerShown_:function(){return this.spin
nerActive&&this.showingSearch},onInputBlur_:function(){if(!this.hasSearchText_)t
his.showingSearch=false},onBindValueChanged_:function(){var newValue=this.$.sear
chInput.bindValue;this.hasSearchText_=newValue!="";if(newValue!="")this.showingS
earch=true},showSearch_:function(e){if(e.target!=this.$.clearSearch)this.showing
Search=true},hideSearch_:function(e){this.showingSearch=false;e.stopPropagation(
)}}); |
35 // Copyright 2016 The Chromium Authors. All rights reserved. | 34 // Copyright 2016 The Chromium Authors. All rights reserved. |
36 // Use of this source code is governed by a BSD-style license that can be | 35 // Use of this source code is governed by a BSD-style license that can be |
37 // found in the LICENSE file. | 36 // found in the LICENSE file. |
38 Polymer({is:"cr-toolbar",properties:{pageName:String,searchPrompt:String,clearLa
bel:String,menuLabel:String,menuPromo:String,spinnerActive:Boolean,showMenu:{typ
e:Boolean,value:false},showMenuPromo:{type:Boolean,value:false},closeMenuPromo:S
tring,narrow_:{type:Boolean,reflectToAttribute:true},showingSearch_:{type:Boolea
n,reflectToAttribute:true}},observers:["possiblyShowMenuPromo_(showMenu, showMen
uPromo, showingSearch_)"],getSearchField:function(){return this.$.search},onClos
ePromoTap_:function(){this.showMenuPromo=false},onMenuTap_:function(){this.fire(
"cr-menu-tap");this.onClosePromoTap_()},possiblyShowMenuPromo_:function(){Polyme
r.RenderStatus.afterNextRender(this,function(){if(this.showMenu&&this.showMenuPr
omo&&!this.showingSearch_){this.$$("#menuPromo").animate({opacity:[0,.9]},{durat
ion:500,fill:"forwards"});this.fire("cr-menu-promo-shown")}}.bind(this))},titleI
fNotShowMenuPromo_:function(title,showMenuPromo){return showMenuPromo?"":title}}
); | 37 Polymer({is:"cr-toolbar",properties:{pageName:String,searchPrompt:String,clearLa
bel:String,menuLabel:String,menuPromo:String,spinnerActive:Boolean,showMenu:{typ
e:Boolean,value:false},showMenuPromo:{type:Boolean,value:false},closeMenuPromo:S
tring,narrow_:{type:Boolean,reflectToAttribute:true},showingSearch_:{type:Boolea
n,reflectToAttribute:true}},observers:["possiblyShowMenuPromo_(showMenu, showMen
uPromo, showingSearch_)"],getSearchField:function(){return this.$.search},onClos
ePromoTap_:function(){this.showMenuPromo=false},onMenuTap_:function(){this.fire(
"cr-menu-tap");this.onClosePromoTap_()},possiblyShowMenuPromo_:function(){Polyme
r.RenderStatus.afterNextRender(this,function(){if(this.showMenu&&this.showMenuPr
omo&&!this.showingSearch_){this.$$("#menuPromo").animate({opacity:[0,.9]},{durat
ion:500,fill:"forwards"});this.fire("cr-menu-promo-shown")}}.bind(this))},titleI
fNotShowMenuPromo_:function(title,showMenuPromo){return showMenuPromo?"":title}}
); |
39 // Copyright 2016 The Chromium Authors. All rights reserved. | 38 // Copyright 2016 The Chromium Authors. All rights reserved. |
40 // Use of this source code is governed by a BSD-style license that can be | 39 // Use of this source code is governed by a BSD-style license that can be |
41 // found in the LICENSE file. | 40 // found in the LICENSE file. |
42 cr.define("md_history",function(){function BrowserService(){this.pendingDeleteIt
ems_=null;this.pendingDeletePromise_=null}BrowserService.prototype={deleteItems:
function(items){if(this.pendingDeleteItems_!=null){return new Promise(function(r
esolve,reject){reject(items)})}var removalList=items.map(function(item){return{u
rl:item.url,timestamps:item.allTimestamps}});this.pendingDeleteItems_=items;this
.pendingDeletePromise_=new PromiseResolver;chrome.send("removeVisits",removalLis
t);return this.pendingDeletePromise_.promise},removeBookmark:function(url){chrom
e.send("removeBookmark",[url])},openForeignSessionAllTabs:function(sessionTag){c
hrome.send("openForeignSession",[sessionTag])},openForeignSessionTab:function(se
ssionTag,windowId,tabId,e){chrome.send("openForeignSession",[sessionTag,String(w
indowId),String(tabId),e.button||0,e.altKey,e.ctrlKey,e.metaKey,e.shiftKey])},de
leteForeignSession:function(sessionTag){chrome.send("deleteForeignSession",[sess
ionTag])},openClearBrowsingData:function(){chrome.send("clearBrowsingData")},rec
ordHistogram:function(histogram,value,max){chrome.send("metricsHandler:recordInH
istogram",[histogram,value,max])},recordAction:function(action){if(action.indexO
f("_")==-1)action="HistoryPage_"+action;chrome.send("metricsHandler:recordAction
",[action])},resolveDelete_:function(successful){if(this.pendingDeleteItems_==nu
ll||this.pendingDeletePromise_==null){return}if(successful)this.pendingDeletePro
mise_.resolve(this.pendingDeleteItems_);else this.pendingDeletePromise_.reject(t
his.pendingDeleteItems_);this.pendingDeleteItems_=null;this.pendingDeletePromise
_=null},menuPromoShown:function(){chrome.send("menuPromoShown")}};cr.addSingleto
nGetter(BrowserService);return{BrowserService:BrowserService}});function deleteC
omplete(){md_history.BrowserService.getInstance().resolveDelete_(true)}function
deleteFailed(){md_history.BrowserService.getInstance().resolveDelete_(false)} | 41 cr.define("md_history",function(){function BrowserService(){this.pendingDeleteIt
ems_=null;this.pendingDeletePromise_=null}BrowserService.prototype={deleteItems:
function(items){if(this.pendingDeleteItems_!=null){return new Promise(function(r
esolve,reject){reject(items)})}var removalList=items.map(function(item){return{u
rl:item.url,timestamps:item.allTimestamps}});this.pendingDeleteItems_=items;this
.pendingDeletePromise_=new PromiseResolver;chrome.send("removeVisits",removalLis
t);return this.pendingDeletePromise_.promise},removeBookmark:function(url){chrom
e.send("removeBookmark",[url])},openForeignSessionAllTabs:function(sessionTag){c
hrome.send("openForeignSession",[sessionTag])},openForeignSessionTab:function(se
ssionTag,windowId,tabId,e){chrome.send("openForeignSession",[sessionTag,String(w
indowId),String(tabId),e.button||0,e.altKey,e.ctrlKey,e.metaKey,e.shiftKey])},de
leteForeignSession:function(sessionTag){chrome.send("deleteForeignSession",[sess
ionTag])},openClearBrowsingData:function(){chrome.send("clearBrowsingData")},rec
ordHistogram:function(histogram,value,max){chrome.send("metricsHandler:recordInH
istogram",[histogram,value,max])},recordAction:function(action){if(action.indexO
f("_")==-1)action="HistoryPage_"+action;chrome.send("metricsHandler:recordAction
",[action])},resolveDelete_:function(successful){if(this.pendingDeleteItems_==nu
ll||this.pendingDeletePromise_==null){return}if(successful)this.pendingDeletePro
mise_.resolve(this.pendingDeleteItems_);else this.pendingDeletePromise_.reject(t
his.pendingDeleteItems_);this.pendingDeleteItems_=null;this.pendingDeletePromise
_=null},menuPromoShown:function(){chrome.send("menuPromoShown")}};cr.addSingleto
nGetter(BrowserService);return{BrowserService:BrowserService}});function deleteC
omplete(){md_history.BrowserService.getInstance().resolveDelete_(true)}function
deleteFailed(){md_history.BrowserService.getInstance().resolveDelete_(false)} |
43 // Copyright 2015 The Chromium Authors. All rights reserved. | 42 // Copyright 2015 The Chromium Authors. All rights reserved. |
44 // Use of this source code is governed by a BSD-style license that can be | 43 // Use of this source code is governed by a BSD-style license that can be |
45 // found in the LICENSE file. | 44 // found in the LICENSE file. |
46 Polymer({is:"history-toolbar",properties:{count:{type:Number,value:0,observer:"c
hangeToolbarView_"},itemsSelected_:{type:Boolean,value:false,reflectToAttribute:
true},searchTerm:{type:String,observer:"searchTermChanged_",notify:true},spinner
Active:{type:Boolean,value:false},hasDrawer:{type:Boolean,observer:"hasDrawerCha
nged_",reflectToAttribute:true},showSyncNotice:Boolean,isGroupedMode:{type:Boole
an,reflectToAttribute:true},groupedRange:{type:Number,value:0,reflectToAttribute
:true,notify:true},queryStartTime:String,queryEndTime:String,showMenuPromo_:{typ
e:Boolean,value:function(){return loadTimeData.getBoolean("showMenuPromo")}}},ge
t searchField(){return this.$["main-toolbar"].getSearchField()},showSearchField:
function(){this.searchField.showAndFocus()},changeToolbarView_:function(){this.i
temsSelected_=this.count>0},searchTermChanged_:function(){if(this.searchField.ge
tValue()!=this.searchTerm){this.searchField.showAndFocus();this.searchField.setV
alue(this.searchTerm)}},onMenuPromoShown_:function(){md_history.BrowserService.g
etInstance().menuPromoShown()},onSearchChanged_:function(event){this.searchTerm=
event.detail},onInfoButtonTap_:function(){var dropdown=this.$.syncNotice.get();d
ropdown.positionTarget=this.$$("#info-button-icon");if(dropdown.style.display=="
none")dropdown.open()},onClearSelectionTap_:function(){this.fire("unselect-all")
},onDeleteTap_:function(){this.fire("delete-selected")},deletingAllowed_:functio
n(){return loadTimeData.getBoolean("allowDeletingHistory")},numberOfItemsSelecte
d_:function(count){return count>0?loadTimeData.getStringF("itemsSelected",count)
:""},getHistoryInterval_:function(queryStartTime,queryEndTime){return loadTimeDa
ta.getStringF("historyInterval",queryStartTime,queryEndTime)},hasDrawerChanged_:
function(){this.updateStyles()}});(function(){var IOS=navigator.userAgent.match(
/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;va
r DEFAULT_PHYSICAL_COUNT=3;var HIDDEN_Y="-10000px";var DEFAULT_GRID_SIZE=200;var
SECRET_TABINDEX=-100;Polymer({is:"iron-list",properties:{items:{type:Array},max
PhysicalCount:{type:Number,value:500},as:{type:String,value:"item"},indexAs:{typ
e:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:Boo
lean,value:false,reflectToAttribute:true},selectionEnabled:{type:Boolean,value:f
alse},selectedItem:{type:Object,notify:true},selectedItems:{type:Object,notify:t
rue},multiSelection:{type:Boolean,value:false}},observers:["_itemsChanged(items.
*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(multiSe
lection)","_setOverflow(scrollTarget)"],behaviors:[Polymer.Templatizer,Polymer.I
ronResizableBehavior,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTargetBehavi
or],keyBindings:{up:"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"},_ratio:.
5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_ph
ysicalAverageCount:0,_physicalTop:0,_virtualCount:0,_physicalIndexForKey:null,_e
stScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalIte
ms:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null
,_collection:null,_maxPages:3,_focusedItem:null,_focusedIndex:-1,_offscreenFocus
edItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_te
mplateCost:0,get _physicalBottom(){return this._physicalTop+this._physicalSize},
get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _virtu
alEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSize(
){var size=this.grid?this._physicalRows*this._rowHeight:this._physicalSize;retur
n size-this._viewportHeight},get _maxScrollTop(){return this._estScrollHeight-th
is._viewportHeight+this._scrollerPaddingTop},_minVirtualStart:0,get _maxVirtualS
tart(){return Math.max(0,this._virtualCount-this._physicalCount)},_virtualStartV
al:0,set _virtualStart(val){this._virtualStartVal=Math.min(this._maxVirtualStart
,Math.max(this._minVirtualStart,val))},get _virtualStart(){return this._virtualS
tartVal||0},_physicalStartVal:0,set _physicalStart(val){this._physicalStartVal=v
al%this._physicalCount;if(this._physicalStartVal<0){this._physicalStartVal=this.
_physicalCount+this._physicalStartVal}this._physicalEnd=(this._physicalStart+thi
s._physicalCount-1)%this._physicalCount},get _physicalStart(){return this._physi
calStartVal||0},_physicalCountVal:0,set _physicalCount(val){this._physicalCountV
al=val;this._physicalEnd=(this._physicalStart+this._physicalCount-1)%this._physi
calCount},get _physicalCount(){return this._physicalCountVal},_physicalEnd:0,get
_optPhysicalSize(){if(this.grid){return this._estRowsInView*this._rowHeight*thi
s._maxPages}return this._viewportHeight*this._maxPages},get _optPhysicalCount(){
return this._estRowsInView*this._itemsPerRow*this._maxPages},get _isVisible(){re
turn Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){if(th
is._firstVisibleIndexVal===null){var physicalOffset=Math.floor(this._physicalTop
+this._scrollerPaddingTop);this._firstVisibleIndexVal=this._iterateItems(functio
n(pidx,vidx){physicalOffset+=this._getPhysicalSizeIncrement(pidx);if(physicalOff
set>this._scrollPosition){return this.grid?vidx-vidx%this._itemsPerRow:vidx}if(t
his.grid&&this._virtualCount-1===vidx){return vidx-vidx%this._itemsPerRow}})||0}
return this._firstVisibleIndexVal},get lastVisibleIndex(){if(this._lastVisibleIn
dexVal===null){if(this.grid){var lastIndex=this.firstVisibleIndex+this._estRowsI
nView*this._itemsPerRow-1;this._lastVisibleIndexVal=Math.min(this._virtualCount,
lastIndex)}else{var physicalOffset=this._physicalTop;this._iterateItems(function
(pidx,vidx){if(physicalOffset<this._scrollBottom){this._lastVisibleIndexVal=vidx
}else{return true}physicalOffset+=this._getPhysicalSizeIncrement(pidx)})}}return
this._lastVisibleIndexVal},get _defaultScrollTarget(){return this},get _virtual
RowCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsI
nView(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRow
s(){return Math.ceil(this._physicalCount/this._itemsPerRow)},ready:function(){th
is.addEventListener("focus",this._didFocus.bind(this),true)},attached:function()
{this.updateViewportBoundaries();if(this._physicalCount===0){this._debounceTempl
ate(this._render)}this.listen(this,"iron-resize","_resizeHandler")},detached:fun
ction(){this.unlisten(this,"iron-resize","_resizeHandler")},_setOverflow:functio
n(scrollTarget){this.style.webkitOverflowScrolling=scrollTarget===this?"touch":"
";this.style.overflow=scrollTarget===this?"auto":""},updateViewportBoundaries:fu
nction(){this._scrollerPaddingTop=this.scrollTarget===this?0:parseInt(window.get
ComputedStyle(this)["padding-top"],10);this._viewportHeight=this._scrollTargetHe
ight;if(this.grid){this._updateGridMetrics()}},_scrollHandler:function(){var scr
ollTop=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop));var delta=scroll
Top-this._scrollPosition;var tileHeight,tileTop,kth,recycledTileSet,scrollBottom
,physicalBottom;var ratio=this._ratio;var recycledTiles=0;var hiddenContentSize=
this._hiddenContentSize;var currentRatio=ratio;var movingUp=[];this._scrollPosit
ion=scrollTop;this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;scr
ollBottom=this._scrollBottom;physicalBottom=this._physicalBottom;if(Math.abs(del
ta)>this._physicalSize){this._physicalTop+=delta;recycledTiles=Math.round(delta/
this._physicalAverage)}else if(delta<0){var topSpace=scrollTop-this._physicalTop
;var virtualStart=this._virtualStart;recycledTileSet=[];kth=this._physicalEnd;cu
rrentRatio=topSpace/hiddenContentSize;while(currentRatio<ratio&&recycledTiles<th
is._physicalCount&&virtualStart-recycledTiles>0&&physicalBottom-this._getPhysica
lSizeIncrement(kth)>scrollBottom){tileHeight=this._getPhysicalSizeIncrement(kth)
;currentRatio+=tileHeight/hiddenContentSize;physicalBottom-=tileHeight;recycledT
ileSet.push(kth);recycledTiles++;kth=kth===0?this._physicalCount-1:kth-1}movingU
p=recycledTileSet;recycledTiles=-recycledTiles}else if(delta>0){var bottomSpace=
physicalBottom-scrollBottom;var virtualEnd=this._virtualEnd;var lastVirtualItemI
ndex=this._virtualCount-1;recycledTileSet=[];kth=this._physicalStart;currentRati
o=bottomSpace/hiddenContentSize;while(currentRatio<ratio&&recycledTiles<this._ph
ysicalCount&&virtualEnd+recycledTiles<lastVirtualItemIndex&&this._physicalTop+th
is._getPhysicalSizeIncrement(kth)<scrollTop){tileHeight=this._getPhysicalSizeInc
rement(kth);currentRatio+=tileHeight/hiddenContentSize;this._physicalTop+=tileHe
ight;recycledTileSet.push(kth);recycledTiles++;kth=(kth+1)%this._physicalCount}}
if(recycledTiles===0){if(physicalBottom<scrollBottom||this._physicalTop>scrollTo
p){this._increasePoolIfNeeded()}}else{this._virtualStart=this._virtualStart+recy
cledTiles;this._physicalStart=this._physicalStart+recycledTiles;this._update(rec
ycledTileSet,movingUp)}},_update:function(itemSet,movingUp){this._manageFocus();
this._assignModels(itemSet);this._updateMetrics(itemSet);if(movingUp){while(movi
ngUp.length){var idx=movingUp.pop();this._physicalTop-=this._getPhysicalSizeIncr
ement(idx)}}this._positionItems();this._updateScrollerSize();this._increasePoolI
fNeeded()},_createPool:function(size){var physicalItems=new Array(size);this._en
sureTemplatized();for(var i=0;i<size;i++){var inst=this.stamp(null);physicalItem
s[i]=inst.root.querySelector("*");Polymer.dom(this).appendChild(inst.root)}retur
n physicalItems},_increasePoolIfNeeded:function(){if(this._viewportHeight===0){r
eturn false}var self=this;var isClientFull=this._physicalBottom>=this._scrollBot
tom&&this._physicalTop<=this._scrollPosition;if(this._physicalSize>=this._optPhy
sicalSize&&isClientFull){return false}var maxPoolSize=Math.round(this._physicalC
ount*.5);if(!isClientFull){this._debounceTemplate(this._increasePool.bind(this,m
axPoolSize));return true}this._yield(function(){self._increasePool(Math.min(maxP
oolSize,Math.max(1,Math.round(50/self._templateCost))))});return true},_yield:fu
nction(cb){var g=window;var handle=g.requestIdleCallback?g.requestIdleCallback(c
b):g.setTimeout(cb,16);Polymer.dom.addDebouncer({complete:function(){g.cancelIdl
eCallback?g.cancelIdleCallback(handle):g.clearTimeout(handle);cb()}})},_increase
Pool:function(missingItems){var nextPhysicalCount=Math.min(this._physicalCount+m
issingItems,this._virtualCount-this._virtualStart,Math.max(this.maxPhysicalCount
,DEFAULT_PHYSICAL_COUNT));var prevPhysicalCount=this._physicalCount;var delta=ne
xtPhysicalCount-prevPhysicalCount;var ts=window.performance.now();if(delta<=0){r
eturn}[].push.apply(this._physicalItems,this._createPool(delta));[].push.apply(t
his._physicalSizes,new Array(delta));this._physicalCount=prevPhysicalCount+delta
;if(this._physicalStart>this._physicalEnd&&this._isIndexRendered(this._focusedIn
dex)&&this._getPhysicalIndex(this._focusedIndex)<this._physicalEnd){this._physic
alStart=this._physicalStart+delta}this._update();this._templateCost=(window.perf
ormance.now()-ts)/delta},_render:function(){if(this.isAttached&&this._isVisible)
{if(this._physicalCount===0){this._increasePool(DEFAULT_PHYSICAL_COUNT)}else{thi
s._update()}}},_ensureTemplatized:function(){if(!this.ctor){var props={};props._
_key__=true;props[this.as]=true;props[this.indexAs]=true;props[this.selectedAs]=
true;props.tabIndex=true;this._instanceProps=props;this._userTemplate=Polymer.do
m(this).querySelector("template");if(this._userTemplate){this.templatize(this._u
serTemplate)}else{console.warn("iron-list requires a template to be provided in
light-dom")}}},_getStampedChildren:function(){return this._physicalItems},_forwa
rdInstancePath:function(inst,path,value){if(path.indexOf(this.as+".")===0){this.
notifyPath("items."+inst.__key__+"."+path.slice(this.as.length+1),value)}},_forw
ardParentProp:function(prop,value){if(this._physicalItems){this._physicalItems.f
orEach(function(item){item._templateInstance[prop]=value},this)}},_forwardParent
Path:function(path,value){if(this._physicalItems){this._physicalItems.forEach(fu
nction(item){item._templateInstance.notifyPath(path,value,true)},this)}},_forwar
dItemPath:function(path,value){if(!this._physicalIndexForKey){return}var dot=pat
h.indexOf(".");var key=path.substring(0,dot<0?path.length:dot);var idx=this._phy
sicalIndexForKey[key];var offscreenItem=this._offscreenFocusedItem;var el=offscr
eenItem&&offscreenItem._templateInstance.__key__===key?offscreenItem:this._physi
calItems[idx];if(!el||el._templateInstance.__key__!==key){return}if(dot>=0){path
=this.as+"."+path.substring(dot+1);el._templateInstance.notifyPath(path,value,tr
ue)}else{var currentItem=el._templateInstance[this.as];if(Array.isArray(this.sel
ectedItems)){for(var i=0;i<this.selectedItems.length;i++){if(this.selectedItems[
i]===currentItem){this.set("selectedItems."+i,value);break}}}else if(this.select
edItem===currentItem){this.set("selectedItem",value)}el._templateInstance[this.a
s]=value}},_itemsChanged:function(change){if(change.path==="items"){this._virtua
lStart=0;this._physicalTop=0;this._virtualCount=this.items?this.items.length:0;t
his._collection=this.items?Polymer.Collection.get(this.items):null;this._physica
lIndexForKey={};this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null;t
his._physicalCount=this._physicalCount||0;this._physicalItems=this._physicalItem
s||[];this._physicalSizes=this._physicalSizes||[];this._physicalStart=0;this._re
setScrollPosition(0);this._removeFocusedItem();this._debounceTemplate(this._rend
er)}else if(change.path==="items.splices"){this._adjustVirtualIndex(change.value
.indexSplices);this._virtualCount=this.items?this.items.length:0;this._debounceT
emplate(this._render)}else{this._forwardItemPath(change.path.split(".").slice(1)
.join("."),change.value)}},_adjustVirtualIndex:function(splices){splices.forEach
(function(splice){splice.removed.forEach(this._removeItem,this);if(splice.index<
this._virtualStart){var delta=Math.max(splice.addedCount-splice.removed.length,s
plice.index-this._virtualStart);this._virtualStart=this._virtualStart+delta;if(t
his._focusedIndex>=0){this._focusedIndex=this._focusedIndex+delta}}},this)},_rem
oveItem:function(item){this.$.selector.deselect(item);if(this._focusedItem&&this
._focusedItem._templateInstance[this.as]===item){this._removeFocusedItem()}},_it
erateItems:function(fn,itemSet){var pidx,vidx,rtn,i;if(arguments.length===2&&ite
mSet){for(i=0;i<itemSet.length;i++){pidx=itemSet[i];vidx=this._computeVidx(pidx)
;if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}else{pidx=this._physicalSt
art;vidx=this._virtualStart;for(;pidx<this._physicalCount;pidx++,vidx++){if((rtn
=fn.call(this,pidx,vidx))!=null){return rtn}}for(pidx=0;pidx<this._physicalStart
;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=null){return rtn}}}},_computeV
idx:function(pidx){if(pidx>=this._physicalStart){return this._virtualStart+(pidx
-this._physicalStart)}return this._virtualStart+(this._physicalCount-this._physi
calStart)+pidx},_assignModels:function(itemSet){this._iterateItems(function(pidx
,vidx){var el=this._physicalItems[pidx];var inst=el._templateInstance;var item=t
his.items&&this.items[vidx];if(item!=null){inst[this.as]=item;inst.__key__=this.
_collection.getKey(item);inst[this.selectedAs]=this.$.selector.isSelected(item);
inst[this.indexAs]=vidx;inst.tabIndex=this._focusedIndex===vidx?0:-1;this._physi
calIndexForKey[inst.__key__]=pidx;el.removeAttribute("hidden")}else{inst.__key__
=null;el.setAttribute("hidden","")}},itemSet)},_updateMetrics:function(itemSet){
Polymer.dom.flush();var newPhysicalSize=0;var oldPhysicalSize=0;var prevAvgCount
=this._physicalAverageCount;var prevPhysicalAvg=this._physicalAverage;this._iter
ateItems(function(pidx,vidx){oldPhysicalSize+=this._physicalSizes[pidx]||0;this.
_physicalSizes[pidx]=this._physicalItems[pidx].offsetHeight;newPhysicalSize+=thi
s._physicalSizes[pidx];this._physicalAverageCount+=this._physicalSizes[pidx]?1:0
},itemSet);this._viewportHeight=this._scrollTargetHeight;if(this.grid){this._upd
ateGridMetrics();this._physicalSize=Math.ceil(this._physicalCount/this._itemsPer
Row)*this._rowHeight}else{this._physicalSize=this._physicalSize+newPhysicalSize-
oldPhysicalSize}if(this._physicalAverageCount!==prevAvgCount){this._physicalAver
age=Math.round((prevPhysicalAvg*prevAvgCount+newPhysicalSize)/this._physicalAver
ageCount)}},_updateGridMetrics:function(){this._viewportWidth=this.$.items.offse
tWidth;this._itemWidth=this._physicalCount>0?this._physicalItems[0].getBoundingC
lientRect().width:DEFAULT_GRID_SIZE;this._rowHeight=this._physicalCount>0?this._
physicalItems[0].offsetHeight:DEFAULT_GRID_SIZE;this._itemsPerRow=this._itemWidt
h?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_positionIt
ems:function(){this._adjustScrollPosition();var y=this._physicalTop;if(this.grid
){var totalItemWidth=this._itemsPerRow*this._itemWidth;var rowOffset=(this._view
portWidth-totalItemWidth)/2;this._iterateItems(function(pidx,vidx){var modulus=v
idx%this._itemsPerRow;var x=Math.floor(modulus*this._itemWidth+rowOffset);this.t
ranslate3d(x+"px",y+"px",0,this._physicalItems[pidx]);if(this._shouldRenderNextR
ow(vidx)){y+=this._rowHeight}})}else{this._iterateItems(function(pidx,vidx){this
.translate3d(0,y+"px",0,this._physicalItems[pidx]);y+=this._physicalSizes[pidx]}
)}},_getPhysicalSizeIncrement:function(pidx){if(!this.grid){return this._physica
lSizes[pidx]}if(this._computeVidx(pidx)%this._itemsPerRow!==this._itemsPerRow-1)
{return 0}return this._rowHeight},_shouldRenderNextRow:function(vidx){return vid
x%this._itemsPerRow===this._itemsPerRow-1},_adjustScrollPosition:function(){var
deltaHeight=this._virtualStart===0?this._physicalTop:Math.min(this._scrollPositi
on+this._physicalTop,0);if(deltaHeight){this._physicalTop=this._physicalTop-delt
aHeight;if(!IOS_TOUCH_SCROLLING&&this._physicalTop!==0){this._resetScrollPositio
n(this._scrollTop-deltaHeight)}}},_resetScrollPosition:function(pos){if(this.scr
ollTarget){this._scrollTop=pos;this._scrollPosition=this._scrollTop}},_updateScr
ollerSize:function(forceUpdate){if(this.grid){this._estScrollHeight=this._virtua
lRowCount*this._rowHeight}else{this._estScrollHeight=this._physicalBottom+Math.m
ax(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._physicalAv
erage}forceUpdate=forceUpdate||this._scrollHeight===0;forceUpdate=forceUpdate||t
his._scrollPosition>=this._estScrollHeight-this._physicalSize;forceUpdate=forceU
pdate||this.grid&&this.$.items.style.height<this._estScrollHeight;if(forceUpdate
||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._optPhysicalSize){thi
s.$.items.style.height=this._estScrollHeight+"px";this._scrollHeight=this._estSc
rollHeight}},scrollToItem:function(item){return this.scrollToIndex(this.items.in
dexOf(item))},scrollToIndex:function(idx){if(typeof idx!=="number"||idx<0||idx>t
his.items.length-1){return}Polymer.dom.flush();if(this._physicalCount===0){retur
n}idx=Math.min(Math.max(idx,0),this._virtualCount-1);if(!this._isIndexRendered(i
dx)||idx>=this._maxVirtualStart){this._virtualStart=this.grid?idx-this._itemsPer
Row*2:idx-1}this._manageFocus();this._assignModels();this._updateMetrics();this.
_physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAver
age;var currentTopItem=this._physicalStart;var currentVirtualItem=this._virtualS
tart;var targetOffsetTop=0;var hiddenContentSize=this._hiddenContentSize;while(c
urrentVirtualItem<idx&&targetOffsetTop<=hiddenContentSize){targetOffsetTop=targe
tOffsetTop+this._getPhysicalSizeIncrement(currentTopItem);currentTopItem=(curren
tTopItem+1)%this._physicalCount;currentVirtualItem++}this._updateScrollerSize(tr
ue);this._positionItems();this._resetScrollPosition(this._physicalTop+this._scro
llerPaddingTop+targetOffsetTop);this._increasePoolIfNeeded();this._firstVisibleI
ndexVal=null;this._lastVisibleIndexVal=null},_resetAverage:function(){this._phys
icalAverage=0;this._physicalAverageCount=0},_resizeHandler:function(){if(IOS&&Ma
th.abs(this._viewportHeight-this._scrollTargetHeight)<100){return}Polymer.dom.ad
dDebouncer(this.debounce("_debounceTemplate",function(){this.updateViewportBound
aries();this._render();if(this._physicalCount>0&&this._isVisible){this._resetAve
rage();this.scrollToIndex(this.firstVisibleIndex)}}.bind(this),1))},_getModelFro
mItem:function(item){var key=this._collection.getKey(item);var pidx=this._physic
alIndexForKey[key];if(pidx!=null){return this._physicalItems[pidx]._templateInst
ance}return null},_getNormalizedItem:function(item){if(this._collection.getKey(i
tem)===undefined){if(typeof item==="number"){item=this.items[item];if(!item){thr
ow new RangeError("<item> not found")}return item}throw new TypeError("<item> sh
ould be a valid item")}return item},selectItem:function(item){item=this._getNorm
alizedItem(item);var model=this._getModelFromItem(item);if(!this.multiSelection&
&this.selectedItem){this.deselectItem(this.selectedItem)}if(model){model[this.se
lectedAs]=true}this.$.selector.select(item);this.updateSizeForItem(item)},desele
ctItem:function(item){item=this._getNormalizedItem(item);var model=this._getMode
lFromItem(item);if(model){model[this.selectedAs]=false}this.$.selector.deselect(
item);this.updateSizeForItem(item)},toggleSelectionForItem:function(item){item=t
his._getNormalizedItem(item);if(this.$.selector.isSelected(item)){this.deselectI
tem(item)}else{this.selectItem(item)}},clearSelection:function(){function unsele
ct(item){var model=this._getModelFromItem(item);if(model){model[this.selectedAs]
=false}}if(Array.isArray(this.selectedItems)){this.selectedItems.forEach(unselec
t,this)}else if(this.selectedItem){unselect.call(this,this.selectedItem)}this.$.
selector.clearSelection()},_selectionEnabledChanged:function(selectionEnabled){v
ar handler=selectionEnabled?this.listen:this.unlisten;handler.call(this,this,"ta
p","_selectionHandler")},_selectionHandler:function(e){var model=this.modelForEl
ement(e.target);if(!model){return}var modelTabIndex,activeElTabIndex;var target=
Polymer.dom(e).path[0];var activeEl=Polymer.dom(this.domHost?this.domHost.root:d
ocument).activeElement;var physicalItem=this._physicalItems[this._getPhysicalInd
ex(model[this.indexAs])];if(target.localName==="input"||target.localName==="butt
on"||target.localName==="select"){return}modelTabIndex=model.tabIndex;model.tabI
ndex=SECRET_TABINDEX;activeElTabIndex=activeEl?activeEl.tabIndex:-1;model.tabInd
ex=modelTabIndex;if(activeEl&&physicalItem!==activeEl&&physicalItem.contains(act
iveEl)&&activeElTabIndex!==SECRET_TABINDEX){return}this.toggleSelectionForItem(m
odel[this.as])},_multiSelectionChanged:function(multiSelection){this.clearSelect
ion();this.$.selector.multi=multiSelection},updateSizeForItem:function(item){ite
m=this._getNormalizedItem(item);var key=this._collection.getKey(item);var pidx=t
his._physicalIndexForKey[key];if(pidx!=null){this._updateMetrics([pidx]);this._p
ositionItems()}},_manageFocus:function(){var fidx=this._focusedIndex;if(fidx>=0&
&fidx<this._virtualCount){if(this._isIndexRendered(fidx)){this._restoreFocusedIt
em()}else{this._createFocusBackfillItem()}}else if(this._virtualCount>0&&this._p
hysicalCount>0){this._focusedIndex=this._virtualStart;this._focusedItem=this._ph
ysicalItems[this._physicalStart]}},_isIndexRendered:function(idx){return idx>=th
is._virtualStart&&idx<=this._virtualEnd},_isIndexVisible:function(idx){return id
x>=this.firstVisibleIndex&&idx<=this.lastVisibleIndex},_getPhysicalIndex:functio
n(idx){return this._physicalIndexForKey[this._collection.getKey(this._getNormali
zedItem(idx))]},_focusPhysicalItem:function(idx){if(idx<0||idx>=this._virtualCou
nt){return}this._restoreFocusedItem();if(!this._isIndexRendered(idx)){this.scrol
lToIndex(idx)}var physicalItem=this._physicalItems[this._getPhysicalIndex(idx)];
var model=physicalItem._templateInstance;var focusable;model.tabIndex=SECRET_TAB
INDEX;if(physicalItem.tabIndex===SECRET_TABINDEX){focusable=physicalItem}if(!foc
usable){focusable=Polymer.dom(physicalItem).querySelector('[tabindex="'+SECRET_T
ABINDEX+'"]')}model.tabIndex=0;this._focusedIndex=idx;focusable&&focusable.focus
()},_removeFocusedItem:function(){if(this._offscreenFocusedItem){Polymer.dom(thi
s).removeChild(this._offscreenFocusedItem)}this._offscreenFocusedItem=null;this.
_focusBackfillItem=null;this._focusedItem=null;this._focusedIndex=-1},_createFoc
usBackfillItem:function(){var pidx,fidx=this._focusedIndex;if(this._offscreenFoc
usedItem||fidx<0){return}if(!this._focusBackfillItem){var stampedTemplate=this.s
tamp(null);this._focusBackfillItem=stampedTemplate.root.querySelector("*");Polym
er.dom(this).appendChild(stampedTemplate.root)}pidx=this._getPhysicalIndex(fidx)
;if(pidx!=null){this._offscreenFocusedItem=this._physicalItems[pidx];this._physi
calItems[pidx]=this._focusBackfillItem;this.translate3d(0,HIDDEN_Y,0,this._offsc
reenFocusedItem)}},_restoreFocusedItem:function(){var pidx,fidx=this._focusedInd
ex;if(!this._offscreenFocusedItem||this._focusedIndex<0){return}this._assignMode
ls();pidx=this._getPhysicalIndex(fidx);if(pidx!=null){this._focusBackfillItem=th
is._physicalItems[pidx];this._physicalItems[pidx]=this._offscreenFocusedItem;thi
s._offscreenFocusedItem=null;this.translate3d(0,HIDDEN_Y,0,this._focusBackfillIt
em)}},_didFocus:function(e){var targetModel=this.modelForElement(e.target);var f
ocusedModel=this._focusedItem?this._focusedItem._templateInstance:null;var hasOf
fscreenFocusedItem=this._offscreenFocusedItem!==null;var fidx=this._focusedIndex
;if(!targetModel||!focusedModel){return}if(focusedModel===targetModel){if(!this.
_isIndexVisible(fidx)){this.scrollToIndex(fidx)}}else{this._restoreFocusedItem()
;focusedModel.tabIndex=-1;targetModel.tabIndex=0;fidx=targetModel[this.indexAs];
this._focusedIndex=fidx;this._focusedItem=this._physicalItems[this._getPhysicalI
ndex(fidx)];if(hasOffscreenFocusedItem&&!this._offscreenFocusedItem){this._updat
e()}}},_didMoveUp:function(){this._focusPhysicalItem(this._focusedIndex-1)},_did
MoveDown:function(e){e.detail.keyboardEvent.preventDefault();this._focusPhysical
Item(this._focusedIndex+1)},_didEnter:function(e){this._focusPhysicalItem(this._
focusedIndex);this._selectionHandler(e.detail.keyboardEvent)}})})();Polymer({is:
"iron-scroll-threshold",properties:{upperThreshold:{type:Number,value:100},lower
Threshold:{type:Number,value:100},upperTriggered:{type:Boolean,value:false,notif
y:true,readOnly:true},lowerTriggered:{type:Boolean,value:false,notify:true,readO
nly:true},horizontal:{type:Boolean,value:false}},behaviors:[Polymer.IronScrollTa
rgetBehavior],observers:["_setOverflow(scrollTarget)","_initCheck(horizontal, is
Attached)"],get _defaultScrollTarget(){return this},_setOverflow:function(scroll
Target){this.style.overflow=scrollTarget===this?"auto":""},_scrollHandler:functi
on(){var THROTTLE_THRESHOLD=200;if(!this.isDebouncerActive("_checkTheshold")){th
is.debounce("_checkTheshold",function(){this.checkScrollThesholds()},THROTTLE_TH
RESHOLD)}},_initCheck:function(horizontal,isAttached){if(isAttached){this.deboun
ce("_init",function(){this.clearTriggers();this.checkScrollThesholds()})}},check
ScrollThesholds:function(){if(!this.scrollTarget||this.lowerTriggered&&this.uppe
rTriggered){return}var upperScrollValue=this.horizontal?this._scrollLeft:this._s
crollTop;var lowerScrollValue=this.horizontal?this.scrollTarget.scrollWidth-this
._scrollTargetWidth-this._scrollLeft:this.scrollTarget.scrollHeight-this._scroll
TargetHeight-this._scrollTop;if(upperScrollValue<=this.upperThreshold&&!this.upp
erTriggered){this._setUpperTriggered(true);this.fire("upper-threshold")}if(lower
ScrollValue<=this.lowerThreshold&&!this.lowerTriggered){this._setLowerTriggered(
true);this.fire("lower-threshold")}},clearTriggers:function(){this._setUpperTrig
gered(false);this._setLowerTriggered(false)}}); | 45 Polymer({is:"history-toolbar",properties:{count:{type:Number,value:0,observer:"c
hangeToolbarView_"},itemsSelected_:{type:Boolean,value:false,reflectToAttribute:
true},searchTerm:{type:String,observer:"searchTermChanged_",notify:true},spinner
Active:{type:Boolean,value:false},hasDrawer:{type:Boolean,observer:"hasDrawerCha
nged_",reflectToAttribute:true},showSyncNotice:Boolean,isGroupedMode:{type:Boole
an,reflectToAttribute:true},groupedRange:{type:Number,value:0,reflectToAttribute
:true,notify:true},queryStartTime:String,queryEndTime:String,showMenuPromo_:{typ
e:Boolean,value:function(){return loadTimeData.getBoolean("showMenuPromo")}}},ge
t searchField(){return this.$["main-toolbar"].getSearchField()},showSearchField:
function(){this.searchField.showAndFocus()},changeToolbarView_:function(){this.i
temsSelected_=this.count>0},searchTermChanged_:function(){if(this.searchField.ge
tValue()!=this.searchTerm){this.searchField.showAndFocus();this.searchField.setV
alue(this.searchTerm)}},onMenuPromoShown_:function(){md_history.BrowserService.g
etInstance().menuPromoShown()},onSearchChanged_:function(event){this.searchTerm=
event.detail},onInfoButtonTap_:function(){var dropdown=this.$.syncNotice.get();d
ropdown.positionTarget=this.$$("#info-button-icon");if(dropdown.style.display=="
none")dropdown.open()},onClearSelectionTap_:function(){this.fire("unselect-all")
},onDeleteTap_:function(){this.fire("delete-selected")},deletingAllowed_:functio
n(){return loadTimeData.getBoolean("allowDeletingHistory")},numberOfItemsSelecte
d_:function(count){return count>0?loadTimeData.getStringF("itemsSelected",count)
:""},getHistoryInterval_:function(queryStartTime,queryEndTime){return loadTimeDa
ta.getStringF("historyInterval",queryStartTime,queryEndTime)},hasDrawerChanged_:
function(){this.updateStyles()}});(function(){var IOS=navigator.userAgent.match(
/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;va
r DEFAULT_PHYSICAL_COUNT=3;var HIDDEN_Y="-10000px";var ITEM_WIDTH=0;var ITEM_HEI
GHT=1;var SECRET_TABINDEX=-100;Polymer({is:"iron-list",properties:{items:{type:A
rray},maxPhysicalCount:{type:Number,value:500},as:{type:String,value:"item"},ind
exAs:{type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:
{type:Boolean,value:false,reflectToAttribute:true},selectionEnabled:{type:Boolea
n,value:false},selectedItem:{type:Object,notify:true},selectedItems:{type:Object
,notify:true},multiSelection:{type:Boolean,value:false}},observers:["_itemsChang
ed(items.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChange
d(multiSelection)","_setOverflow(scrollTarget)"],behaviors:[Polymer.Templatizer,
Polymer.IronResizableBehavior,Polymer.IronA11yKeysBehavior,Polymer.IronScrollTar
getBehavior],keyBindings:{up:"_didMoveUp",down:"_didMoveDown",enter:"_didEnter"}
,_ratio:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAver
age:0,_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_physicalIndexForKe
y:null,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_ph
ysicalItems:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleInde
xVal:null,_collection:null,_maxPages:2,_focusedItem:null,_focusedIndex:-1,_offsc
reenFocusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHei
ght:0,_templateCost:0,get _physicalBottom(){return this._physicalTop+this._physi
calSize},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},g
et _virtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenCon
tentSize(){var size=this.grid?this._physicalRows*this._rowHeight:this._physicalS
ize;return size-this._viewportHeight},get _maxScrollTop(){return this._estScroll
Height-this._viewportHeight+this._scrollerPaddingTop},_minVirtualStart:0,get _ma
xVirtualStart(){return Math.max(0,this._virtualCount-this._physicalCount)},_virt
ualStartVal:0,set _virtualStart(val){this._virtualStartVal=Math.min(this._maxVir
tualStart,Math.max(this._minVirtualStart,val))},get _virtualStart(){return this.
_virtualStartVal||0},_physicalStartVal:0,set _physicalStart(val){this._physicalS
tartVal=val%this._physicalCount;if(this._physicalStartVal<0){this._physicalStart
Val=this._physicalCount+this._physicalStartVal}this._physicalEnd=(this._physical
Start+this._physicalCount-1)%this._physicalCount},get _physicalStart(){return th
is._physicalStartVal||0},_physicalCountVal:0,set _physicalCount(val){this._physi
calCountVal=val;this._physicalEnd=(this._physicalStart+this._physicalCount-1)%th
is._physicalCount},get _physicalCount(){return this._physicalCountVal},_physical
End:0,get _optPhysicalSize(){if(this.grid){return this._estRowsInView*this._rowH
eight*this._maxPages}return this._viewportHeight*this._maxPages},get _isVisible(
){return Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){i
f(this._firstVisibleIndexVal===null){var physicalOffset=Math.floor(this._physica
lTop+this._scrollerPaddingTop);this._firstVisibleIndexVal=this._iterateItems(fun
ction(pidx,vidx){physicalOffset+=this._getPhysicalSizeIncrement(pidx);if(physica
lOffset>this._scrollPosition){return this.grid?vidx-vidx%this._itemsPerRow:vidx}
if(this.grid&&this._virtualCount-1===vidx){return vidx-vidx%this._itemsPerRow}})
||0}return this._firstVisibleIndexVal},get lastVisibleIndex(){if(this._lastVisib
leIndexVal===null){if(this.grid){var lastIndex=this.firstVisibleIndex+this._estR
owsInView*this._itemsPerRow-1;this._lastVisibleIndexVal=Math.min(this._virtualCo
unt,lastIndex)}else{var physicalOffset=this._physicalTop;this._iterateItems(func
tion(pidx,vidx){if(physicalOffset<this._scrollBottom){this._lastVisibleIndexVal=
vidx}else{return true}physicalOffset+=this._getPhysicalSizeIncrement(pidx)})}}re
turn this._lastVisibleIndexVal},get _defaultScrollTarget(){return this},get _vir
tualRowCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estR
owsInView(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physica
lRows(){return Math.ceil(this._physicalCount/this._itemsPerRow)},ready:function(
){this.addEventListener("focus",this._didFocus.bind(this),true)},attached:functi
on(){if(this._physicalCount===0){this._debounceTemplate(this._render)}this.liste
n(this,"iron-resize","_resizeHandler")},detached:function(){this.unlisten(this,"
iron-resize","_resizeHandler")},_setOverflow:function(scrollTarget){this.style.w
ebkitOverflowScrolling=scrollTarget===this?"touch":"";this.style.overflow=scroll
Target===this?"auto":""},updateViewportBoundaries:function(){this._scrollerPaddi
ngTop=this.scrollTarget===this?0:parseInt(window.getComputedStyle(this)["padding
-top"],10);this._viewportWidth=this.$.items.offsetWidth;this._viewportHeight=thi
s._scrollTargetHeight;this.grid&&this._updateGridMetrics()},_scrollHandler:funct
ion(){var scrollTop=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop));var
delta=scrollTop-this._scrollPosition;var isScrollingDown=delta>=0;this._scrollP
osition=scrollTop;this._firstVisibleIndexVal=null;this._lastVisibleIndexVal=null
;if(Math.abs(delta)>this._physicalSize){var idxAdjustment=Math.round(delta/this.
_physicalAverage)*this._itemsPerRow;this._physicalTop=this._physicalTop+delta;th
is._virtualStart=this._virtualStart+idxAdjustment;this._physicalStart=this._phys
icalStart+idxAdjustment;this._update()}else{var reusables=this._getReusables(isS
crollingDown);if(isScrollingDown){this._physicalTop=reusables.physicalTop;this._
virtualStart=this._virtualStart+reusables.indexes.length;this._physicalStart=thi
s._physicalStart+reusables.indexes.length}else{this._virtualStart=this._virtualS
tart-reusables.indexes.length;this._physicalStart=this._physicalStart-reusables.
indexes.length}if(reusables.indexes.length===0){this._increasePoolIfNeeded()}els
e{this._update(reusables.indexes,isScrollingDown?null:reusables.indexes)}}},_get
Reusables:function(fromTop){var ith,lastIth,offsetContent,physicalItemHeight;var
idxs=[];var protectedOffsetContent=this._hiddenContentSize*this._ratio;var virt
ualStart=this._virtualStart;var virtualEnd=this._virtualEnd;var physicalCount=th
is._physicalCount;var physicalTop=this._physicalTop;var scrollTop=this._scrollTo
p;var scrollBottom=this._scrollBottom;if(fromTop){ith=this._physicalStart;lastIt
h=this._physicalEnd;offsetContent=scrollTop-physicalTop}else{ith=this._physicalE
nd;lastIth=this._physicalStart;offsetContent=this._physicalBottom-scrollBottom}w
hile(true){physicalItemHeight=this._getPhysicalSizeIncrement(ith);offsetContent=
offsetContent-physicalItemHeight;if(idxs.length>=physicalCount||offsetContent<=p
rotectedOffsetContent){break}if(fromTop){if(virtualEnd+idxs.length+1>=this._virt
ualCount){break}if(physicalTop+physicalItemHeight>=scrollTop){break}idxs.push(it
h);physicalTop=physicalTop+physicalItemHeight;ith=(ith+1)%physicalCount}else{if(
virtualStart-idxs.length<=0){break}if(physicalTop+this._physicalSize-physicalIte
mHeight<=scrollBottom){break}idxs.push(ith);physicalTop=physicalTop-physicalItem
Height;ith=ith===0?physicalCount-1:ith-1}}return{indexes:idxs,physicalTop:physic
alTop}},_update:function(itemSet,movingUp){if(itemSet&&itemSet.length===0){retur
n}this._manageFocus();this._assignModels(itemSet);this._updateMetrics(itemSet);i
f(movingUp){while(movingUp.length){var idx=movingUp.pop();this._physicalTop-=thi
s._getPhysicalSizeIncrement(idx)}}this._positionItems();this._updateScrollerSize
();this._increasePoolIfNeeded()},_createPool:function(size){var physicalItems=ne
w Array(size);this._ensureTemplatized();for(var i=0;i<size;i++){var inst=this.st
amp(null);physicalItems[i]=inst.root.querySelector("*");Polymer.dom(this).append
Child(inst.root)}return physicalItems},_increasePoolIfNeeded:function(){if(this.
_viewportHeight===0){return false}var self=this;var isClientFull=this._physicalB
ottom>=this._scrollBottom&&this._physicalTop<=this._scrollPosition;if(this._phys
icalSize>=this._optPhysicalSize&&isClientFull){return false}var maxPoolSize=Math
.round(this._physicalCount*.5);if(!isClientFull){this._debounceTemplate(this._in
creasePool.bind(this,maxPoolSize));return true}this._yield(function(){self._incr
easePool(Math.min(maxPoolSize,Math.max(1,Math.round(50/self._templateCost))))});
return true},_yield:function(cb){var g=window;var handle=g.requestIdleCallback?g
.requestIdleCallback(cb):g.setTimeout(cb,16);Polymer.dom.addDebouncer({complete:
function(){g.cancelIdleCallback?g.cancelIdleCallback(handle):g.clearTimeout(hand
le);cb()}})},_increasePool:function(missingItems){var nextPhysicalCount=Math.min
(this._physicalCount+missingItems,this._virtualCount-this._virtualStart,Math.max
(this.maxPhysicalCount,DEFAULT_PHYSICAL_COUNT));var prevPhysicalCount=this._phys
icalCount;var delta=nextPhysicalCount-prevPhysicalCount;var ts=window.performanc
e.now();if(delta<=0){return}[].push.apply(this._physicalItems,this._createPool(d
elta));[].push.apply(this._physicalSizes,new Array(delta));this._physicalCount=p
revPhysicalCount+delta;if(this._physicalStart>this._physicalEnd&&this._isIndexRe
ndered(this._focusedIndex)&&this._getPhysicalIndex(this._focusedIndex)<this._phy
sicalEnd){this._physicalStart=this._physicalStart+delta}this._update();this._tem
plateCost=(window.performance.now()-ts)/delta},_render:function(){if(this.isAtta
ched&&this._isVisible){if(this._physicalCount===0){this.updateViewportBoundaries
();this._increasePool(DEFAULT_PHYSICAL_COUNT)}else{var reusables=this._getReusab
les(true);this._physicalTop=reusables.physicalTop;this._virtualStart=this._virtu
alStart+reusables.indexes.length;this._physicalStart=this._physicalStart+reusabl
es.indexes.length;this._update(reusables.indexes);this._update()}}},_ensureTempl
atized:function(){if(!this.ctor){var props={};props.__key__=true;props[this.as]=
true;props[this.indexAs]=true;props[this.selectedAs]=true;props.tabIndex=true;th
is._instanceProps=props;this._userTemplate=Polymer.dom(this).querySelector("temp
late");if(this._userTemplate){this.templatize(this._userTemplate)}else{console.w
arn("iron-list requires a template to be provided in light-dom")}}},_getStampedC
hildren:function(){return this._physicalItems},_forwardInstancePath:function(ins
t,path,value){if(path.indexOf(this.as+".")===0){this.notifyPath("items."+inst.__
key__+"."+path.slice(this.as.length+1),value)}},_forwardParentProp:function(prop
,value){if(this._physicalItems){this._physicalItems.forEach(function(item){item.
_templateInstance[prop]=value},this)}},_forwardParentPath:function(path,value){i
f(this._physicalItems){this._physicalItems.forEach(function(item){item._template
Instance.notifyPath(path,value,true)},this)}},_forwardItemPath:function(path,val
ue){if(!this._physicalIndexForKey){return}var dot=path.indexOf(".");var key=path
.substring(0,dot<0?path.length:dot);var idx=this._physicalIndexForKey[key];var o
ffscreenItem=this._offscreenFocusedItem;var el=offscreenItem&&offscreenItem._tem
plateInstance.__key__===key?offscreenItem:this._physicalItems[idx];if(!el||el._t
emplateInstance.__key__!==key){return}if(dot>=0){path=this.as+"."+path.substring
(dot+1);el._templateInstance.notifyPath(path,value,true)}else{var currentItem=el
._templateInstance[this.as];if(Array.isArray(this.selectedItems)){for(var i=0;i<
this.selectedItems.length;i++){if(this.selectedItems[i]===currentItem){this.set(
"selectedItems."+i,value);break}}}else if(this.selectedItem===currentItem){this.
set("selectedItem",value)}el._templateInstance[this.as]=value}},_itemsChanged:fu
nction(change){if(change.path==="items"){this._virtualStart=0;this._physicalTop=
0;this._virtualCount=this.items?this.items.length:0;this._collection=this.items?
Polymer.Collection.get(this.items):null;this._physicalIndexForKey={};this._first
VisibleIndexVal=null;this._lastVisibleIndexVal=null;this._physicalCount=this._ph
ysicalCount||0;this._physicalItems=this._physicalItems||[];this._physicalSizes=t
his._physicalSizes||[];this._physicalStart=0;this._resetScrollPosition(0);this._
removeFocusedItem();this._debounceTemplate(this._render)}else if(change.path==="
items.splices"){this._adjustVirtualIndex(change.value.indexSplices);this._virtua
lCount=this.items?this.items.length:0;this._debounceTemplate(this._render)}else{
this._forwardItemPath(change.path.split(".").slice(1).join("."),change.value)}},
_adjustVirtualIndex:function(splices){splices.forEach(function(splice){splice.re
moved.forEach(this._removeItem,this);if(splice.index<this._virtualStart){var del
ta=Math.max(splice.addedCount-splice.removed.length,splice.index-this._virtualSt
art);this._virtualStart=this._virtualStart+delta;if(this._focusedIndex>=0){this.
_focusedIndex=this._focusedIndex+delta}}},this)},_removeItem:function(item){this
.$.selector.deselect(item);if(this._focusedItem&&this._focusedItem._templateInst
ance[this.as]===item){this._removeFocusedItem()}},_iterateItems:function(fn,item
Set){var pidx,vidx,rtn,i;if(arguments.length===2&&itemSet){for(i=0;i<itemSet.len
gth;i++){pidx=itemSet[i];vidx=this._computeVidx(pidx);if((rtn=fn.call(this,pidx,
vidx))!=null){return rtn}}}else{pidx=this._physicalStart;vidx=this._virtualStart
;for(;pidx<this._physicalCount;pidx++,vidx++){if((rtn=fn.call(this,pidx,vidx))!=
null){return rtn}}for(pidx=0;pidx<this._physicalStart;pidx++,vidx++){if((rtn=fn.
call(this,pidx,vidx))!=null){return rtn}}}},_computeVidx:function(pidx){if(pidx>
=this._physicalStart){return this._virtualStart+(pidx-this._physicalStart)}retur
n this._virtualStart+(this._physicalCount-this._physicalStart)+pidx},_assignMode
ls:function(itemSet){this._iterateItems(function(pidx,vidx){var el=this._physica
lItems[pidx];var inst=el._templateInstance;var item=this.items&&this.items[vidx]
;if(item!=null){inst[this.as]=item;inst.__key__=this._collection.getKey(item);in
st[this.selectedAs]=this.$.selector.isSelected(item);inst[this.indexAs]=vidx;ins
t.tabIndex=this._focusedIndex===vidx?0:-1;this._physicalIndexForKey[inst.__key__
]=pidx;el.removeAttribute("hidden")}else{inst.__key__=null;el.setAttribute("hidd
en","")}},itemSet)},_updateMetrics:function(itemSet){Polymer.dom.flush();var new
PhysicalSize=0;var oldPhysicalSize=0;var prevAvgCount=this._physicalAverageCount
;var prevPhysicalAvg=this._physicalAverage;this._iterateItems(function(pidx,vidx
){oldPhysicalSize+=this._physicalSizes[pidx]||0;this._physicalSizes[pidx]=this._
physicalItems[pidx].offsetHeight;newPhysicalSize+=this._physicalSizes[pidx];this
._physicalAverageCount+=this._physicalSizes[pidx]?1:0},itemSet);if(this.grid){th
is._updateGridMetrics();this._physicalSize=Math.ceil(this._physicalCount/this._i
temsPerRow)*this._rowHeight}else{this._physicalSize=this._physicalSize+newPhysic
alSize-oldPhysicalSize}if(this._physicalAverageCount!==prevAvgCount){this._physi
calAverage=Math.round((prevPhysicalAvg*prevAvgCount+newPhysicalSize)/this._physi
calAverageCount)}},_updateGridMetrics:function(){this._itemWidth=this._physicalC
ount>0?this._physicalItems[0].getBoundingClientRect().width:200;this._rowHeight=
this._physicalCount>0?this._physicalItems[0].offsetHeight:200;this._itemsPerRow=
this._itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRo
w},_positionItems:function(){this._adjustScrollPosition();var y=this._physicalTo
p;if(this.grid){var totalItemWidth=this._itemsPerRow*this._itemWidth;var rowOffs
et=(this._viewportWidth-totalItemWidth)/2;this._iterateItems(function(pidx,vidx)
{var modulus=vidx%this._itemsPerRow;var x=Math.floor(modulus*this._itemWidth+row
Offset);this.translate3d(x+"px",y+"px",0,this._physicalItems[pidx]);if(this._sho
uldRenderNextRow(vidx)){y+=this._rowHeight}})}else{this._iterateItems(function(p
idx,vidx){this.translate3d(0,y+"px",0,this._physicalItems[pidx]);y+=this._physic
alSizes[pidx]})}},_getPhysicalSizeIncrement:function(pidx){if(!this.grid){return
this._physicalSizes[pidx]}if(this._computeVidx(pidx)%this._itemsPerRow!==this._
itemsPerRow-1){return 0}return this._rowHeight},_shouldRenderNextRow:function(vi
dx){return vidx%this._itemsPerRow===this._itemsPerRow-1},_adjustScrollPosition:f
unction(){var deltaHeight=this._virtualStart===0?this._physicalTop:Math.min(this
._scrollPosition+this._physicalTop,0);if(deltaHeight){this._physicalTop=this._ph
ysicalTop-deltaHeight;if(!IOS_TOUCH_SCROLLING&&this._physicalTop!==0){this._rese
tScrollPosition(this._scrollTop-deltaHeight)}}},_resetScrollPosition:function(po
s){if(this.scrollTarget){this._scrollTop=pos;this._scrollPosition=this._scrollTo
p}},_updateScrollerSize:function(forceUpdate){if(this.grid){this._estScrollHeigh
t=this._virtualRowCount*this._rowHeight}else{this._estScrollHeight=this._physica
lBottom+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*th
is._physicalAverage}forceUpdate=forceUpdate||this._scrollHeight===0;forceUpdate=
forceUpdate||this._scrollPosition>=this._estScrollHeight-this._physicalSize;forc
eUpdate=forceUpdate||this.grid&&this.$.items.style.height<this._estScrollHeight;
if(forceUpdate||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._optPhy
sicalSize){this.$.items.style.height=this._estScrollHeight+"px";this._scrollHeig
ht=this._estScrollHeight}},scrollToItem:function(item){return this.scrollToIndex
(this.items.indexOf(item))},scrollToIndex:function(idx){if(typeof idx!=="number"
||idx<0||idx>this.items.length-1){return}Polymer.dom.flush();if(this._physicalCo
unt===0){return}idx=Math.min(Math.max(idx,0),this._virtualCount-1);if(!this._isI
ndexRendered(idx)||idx>=this._maxVirtualStart){this._virtualStart=this.grid?idx-
this._itemsPerRow*2:idx-1}this._manageFocus();this._assignModels();this._updateM
etrics();this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this
._physicalAverage;var currentTopItem=this._physicalStart;var currentVirtualItem=
this._virtualStart;var targetOffsetTop=0;var hiddenContentSize=this._hiddenConte
ntSize;while(currentVirtualItem<idx&&targetOffsetTop<=hiddenContentSize){targetO
ffsetTop=targetOffsetTop+this._getPhysicalSizeIncrement(currentTopItem);currentT
opItem=(currentTopItem+1)%this._physicalCount;currentVirtualItem++}this._updateS
crollerSize(true);this._positionItems();this._resetScrollPosition(this._physical
Top+this._scrollerPaddingTop+targetOffsetTop);this._increasePoolIfNeeded();this.
_firstVisibleIndexVal=null;this._lastVisibleIndexVal=null},_resetAverage:functio
n(){this._physicalAverage=0;this._physicalAverageCount=0},_resizeHandler:functio
n(){if(IOS&&Math.abs(this._viewportHeight-this._scrollTargetHeight)<100){return}
Polymer.dom.addDebouncer(this.debounce("_debounceTemplate",function(){this.updat
eViewportBoundaries();this._render();if(this._isVisible){this.toggleScrollListen
er(true);if(this._physicalCount>0){this._resetAverage();this.scrollToIndex(this.
firstVisibleIndex)}}else{this.toggleScrollListener(false)}}.bind(this),1))},_get
ModelFromItem:function(item){var key=this._collection.getKey(item);var pidx=this
._physicalIndexForKey[key];if(pidx!=null){return this._physicalItems[pidx]._temp
lateInstance}return null},_getNormalizedItem:function(item){if(this._collection.
getKey(item)===undefined){if(typeof item==="number"){item=this.items[item];if(!i
tem){throw new RangeError("<item> not found")}return item}throw new TypeError("<
item> should be a valid item")}return item},selectItem:function(item){item=this.
_getNormalizedItem(item);var model=this._getModelFromItem(item);if(!this.multiSe
lection&&this.selectedItem){this.deselectItem(this.selectedItem)}if(model){model
[this.selectedAs]=true}this.$.selector.select(item);this.updateSizeForItem(item)
},deselectItem:function(item){item=this._getNormalizedItem(item);var model=this.
_getModelFromItem(item);if(model){model[this.selectedAs]=false}this.$.selector.d
eselect(item);this.updateSizeForItem(item)},toggleSelectionForItem:function(item
){item=this._getNormalizedItem(item);if(this.$.selector.isSelected(item)){this.d
eselectItem(item)}else{this.selectItem(item)}},clearSelection:function(){functio
n unselect(item){var model=this._getModelFromItem(item);if(model){model[this.sel
ectedAs]=false}}if(Array.isArray(this.selectedItems)){this.selectedItems.forEach
(unselect,this)}else if(this.selectedItem){unselect.call(this,this.selectedItem)
}this.$.selector.clearSelection()},_selectionEnabledChanged:function(selectionEn
abled){var handler=selectionEnabled?this.listen:this.unlisten;handler.call(this,
this,"tap","_selectionHandler")},_selectionHandler:function(e){var model=this.mo
delForElement(e.target);if(!model){return}var modelTabIndex,activeElTabIndex;var
target=Polymer.dom(e).path[0];var activeEl=Polymer.dom(this.domHost?this.domHos
t.root:document).activeElement;var physicalItem=this._physicalItems[this._getPhy
sicalIndex(model[this.indexAs])];if(target.localName==="input"||target.localName
==="button"||target.localName==="select"){return}modelTabIndex=model.tabIndex;mo
del.tabIndex=SECRET_TABINDEX;activeElTabIndex=activeEl?activeEl.tabIndex:-1;mode
l.tabIndex=modelTabIndex;if(activeEl&&physicalItem!==activeEl&&physicalItem.cont
ains(activeEl)&&activeElTabIndex!==SECRET_TABINDEX){return}this.toggleSelectionF
orItem(model[this.as])},_multiSelectionChanged:function(multiSelection){this.cle
arSelection();this.$.selector.multi=multiSelection},updateSizeForItem:function(i
tem){item=this._getNormalizedItem(item);var key=this._collection.getKey(item);va
r pidx=this._physicalIndexForKey[key];if(pidx!=null){this._updateMetrics([pidx])
;this._positionItems()}},_manageFocus:function(){var fidx=this._focusedIndex;if(
fidx>=0&&fidx<this._virtualCount){if(this._isIndexRendered(fidx)){this._restoreF
ocusedItem()}else{this._createFocusBackfillItem()}}else if(this._virtualCount>0&
&this._physicalCount>0){this._focusedIndex=this._virtualStart;this._focusedItem=
this._physicalItems[this._physicalStart]}},_isIndexRendered:function(idx){return
idx>=this._virtualStart&&idx<=this._virtualEnd},_isIndexVisible:function(idx){r
eturn idx>=this.firstVisibleIndex&&idx<=this.lastVisibleIndex},_getPhysicalIndex
:function(idx){return this._physicalIndexForKey[this._collection.getKey(this._ge
tNormalizedItem(idx))]},_focusPhysicalItem:function(idx){if(idx<0||idx>=this._vi
rtualCount){return}this._restoreFocusedItem();if(!this._isIndexRendered(idx)){th
is.scrollToIndex(idx)}var physicalItem=this._physicalItems[this._getPhysicalInde
x(idx)];var model=physicalItem._templateInstance;var focusable;model.tabIndex=SE
CRET_TABINDEX;if(physicalItem.tabIndex===SECRET_TABINDEX){focusable=physicalItem
}if(!focusable){focusable=Polymer.dom(physicalItem).querySelector('[tabindex="'+
SECRET_TABINDEX+'"]')}model.tabIndex=0;this._focusedIndex=idx;focusable&&focusab
le.focus()},_removeFocusedItem:function(){if(this._offscreenFocusedItem){Polymer
.dom(this).removeChild(this._offscreenFocusedItem)}this._offscreenFocusedItem=nu
ll;this._focusBackfillItem=null;this._focusedItem=null;this._focusedIndex=-1},_c
reateFocusBackfillItem:function(){var pidx,fidx=this._focusedIndex;if(this._offs
creenFocusedItem||fidx<0){return}if(!this._focusBackfillItem){var stampedTemplat
e=this.stamp(null);this._focusBackfillItem=stampedTemplate.root.querySelector("*
");Polymer.dom(this).appendChild(stampedTemplate.root)}pidx=this._getPhysicalInd
ex(fidx);if(pidx!=null){this._offscreenFocusedItem=this._physicalItems[pidx];thi
s._physicalItems[pidx]=this._focusBackfillItem;this.translate3d(0,HIDDEN_Y,0,thi
s._offscreenFocusedItem)}},_restoreFocusedItem:function(){var pidx,fidx=this._fo
cusedIndex;if(!this._offscreenFocusedItem||this._focusedIndex<0){return}this._as
signModels();pidx=this._getPhysicalIndex(fidx);if(pidx!=null){this._focusBackfil
lItem=this._physicalItems[pidx];this._physicalItems[pidx]=this._offscreenFocused
Item;this._offscreenFocusedItem=null;this.translate3d(0,HIDDEN_Y,0,this._focusBa
ckfillItem)}},_didFocus:function(e){var targetModel=this.modelForElement(e.targe
t);var focusedModel=this._focusedItem?this._focusedItem._templateInstance:null;v
ar hasOffscreenFocusedItem=this._offscreenFocusedItem!==null;var fidx=this._focu
sedIndex;if(!targetModel||!focusedModel){return}if(focusedModel===targetModel){i
f(!this._isIndexVisible(fidx)){this.scrollToIndex(fidx)}}else{this._restoreFocus
edItem();focusedModel.tabIndex=-1;targetModel.tabIndex=0;fidx=targetModel[this.i
ndexAs];this._focusedIndex=fidx;this._focusedItem=this._physicalItems[this._getP
hysicalIndex(fidx)];if(hasOffscreenFocusedItem&&!this._offscreenFocusedItem){thi
s._update()}}},_didMoveUp:function(){this._focusPhysicalItem(this._focusedIndex-
1)},_didMoveDown:function(e){e.detail.keyboardEvent.preventDefault();this._focus
PhysicalItem(this._focusedIndex+1)},_didEnter:function(e){this._focusPhysicalIte
m(this._focusedIndex);this._selectionHandler(e.detail.keyboardEvent)}})})();Poly
mer({is:"iron-scroll-threshold",properties:{upperThreshold:{type:Number,value:10
0},lowerThreshold:{type:Number,value:100},upperTriggered:{type:Boolean,value:fal
se,notify:true,readOnly:true},lowerTriggered:{type:Boolean,value:false,notify:tr
ue,readOnly:true},horizontal:{type:Boolean,value:false}},behaviors:[Polymer.Iron
ScrollTargetBehavior],observers:["_setOverflow(scrollTarget)","_initCheck(horizo
ntal, isAttached)"],get _defaultScrollTarget(){return this},_setOverflow:functio
n(scrollTarget){this.style.overflow=scrollTarget===this?"auto":""},_scrollHandle
r:function(){var THROTTLE_THRESHOLD=200;if(!this.isDebouncerActive("_checkThesho
ld")){this.debounce("_checkTheshold",function(){this.checkScrollThesholds()},THR
OTTLE_THRESHOLD)}},_initCheck:function(horizontal,isAttached){if(isAttached){thi
s.debounce("_init",function(){this.clearTriggers();this.checkScrollThesholds()})
}},checkScrollThesholds:function(){if(!this.scrollTarget||this.lowerTriggered&&t
his.upperTriggered){return}var upperScrollValue=this.horizontal?this._scrollLeft
:this._scrollTop;var lowerScrollValue=this.horizontal?this.scrollTarget.scrollWi
dth-this._scrollTargetWidth-this._scrollLeft:this.scrollTarget.scrollHeight-this
._scrollTargetHeight-this._scrollTop;if(upperScrollValue<=this.upperThreshold&&!
this.upperTriggered){this._setUpperTriggered(true);this.fire("upper-threshold")}
if(lowerScrollValue<=this.lowerThreshold&&!this.lowerTriggered){this._setLowerTr
iggered(true);this.fire("lower-threshold")}},clearTriggers:function(){this._setU
pperTriggered(false);this._setLowerTriggered(false)}}); |
47 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 46 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
48 // Use of this source code is governed by a BSD-style license that can be | 47 // Use of this source code is governed by a BSD-style license that can be |
49 // found in the LICENSE file. | 48 // found in the LICENSE file. |
50 var EventTrackerEntry;function EventTracker(){this.listeners_=[]}EventTracker.pr
ototype={add:function(target,eventType,listener,opt_capture){var capture=!!opt_c
apture;var h={target:target,eventType:eventType,listener:listener,capture:captur
e};this.listeners_.push(h);target.addEventListener(eventType,listener,capture)},
remove:function(target,eventType){this.listeners_=this.listeners_.filter(functio
n(h){if(h.target==target&&(!eventType||h.eventType==eventType)){EventTracker.rem
oveEventListener_(h);return false}return true})},removeAll:function(){this.liste
ners_.forEach(EventTracker.removeEventListener_);this.listeners_=[]}};EventTrack
er.removeEventListener_=function(h){h.target.removeEventListener(h.eventType,h.l
istener,h.capture)}; | 49 var EventTrackerEntry;function EventTracker(){this.listeners_=[]}EventTracker.pr
ototype={add:function(target,eventType,listener,opt_capture){var capture=!!opt_c
apture;var h={target:target,eventType:eventType,listener:listener,capture:captur
e};this.listeners_.push(h);target.addEventListener(eventType,listener,capture)},
remove:function(target,eventType){this.listeners_=this.listeners_.filter(functio
n(h){if(h.target==target&&(!eventType||h.eventType==eventType)){EventTracker.rem
oveEventListener_(h);return false}return true})},removeAll:function(){this.liste
ners_.forEach(EventTracker.removeEventListener_);this.listeners_=[]}};EventTrack
er.removeEventListener_=function(h){h.target.removeEventListener(h.eventType,h.l
istener,h.capture)}; |
51 // Copyright 2014 The Chromium Authors. All rights reserved. | 50 // Copyright 2014 The Chromium Authors. All rights reserved. |
52 // Use of this source code is governed by a BSD-style license that can be | 51 // Use of this source code is governed by a BSD-style license that can be |
53 // found in the LICENSE file. | 52 // found in the LICENSE file. |
54 cr.define("cr.ui",function(){function FocusRow(root,boundary,opt_delegate){this.
root=root;this.boundary_=boundary||document.documentElement;this.delegate=opt_de
legate;this.eventTracker=new EventTracker}FocusRow.Delegate=function(){};FocusRo
w.Delegate.prototype={onKeydown:assertNotReached,onFocus:assertNotReached};Focus
Row.ACTIVE_CLASS="focus-row-active";FocusRow.isFocusable=function(element){if(!e
lement||element.disabled)return false;function isVisible(element){assertInstance
of(element,Element);var style=window.getComputedStyle(element);if(style.visibili
ty=="hidden"||style.display=="none")return false;var parent=element.parentNode;i
f(!parent)return false;if(parent==element.ownerDocument||parent instanceof Docum
entFragment)return true;return isVisible(parent)}return isVisible(element)};Focu
sRow.prototype={addItem:function(type,query){assert(type);var element=this.root.
querySelector(query);if(!element)return false;element.setAttribute("focus-type",
type);element.tabIndex=this.isActive()?0:-1;this.eventTracker.add(element,"blur"
,this.onBlur_.bind(this));this.eventTracker.add(element,"focus",this.onFocus_.bi
nd(this));this.eventTracker.add(element,"keydown",this.onKeydown_.bind(this));th
is.eventTracker.add(element,"mousedown",this.onMousedown_.bind(this));return tru
e},destroy:function(){this.eventTracker.removeAll()},getCustomEquivalent:functio
n(sampleElement){return assert(this.getFirstFocusable())},getElements:function()
{var elements=this.root.querySelectorAll("[focus-type]");return Array.prototype.
slice.call(elements)},getEquivalentElement:function(sampleElement){if(this.getFo
cusableElements().indexOf(sampleElement)>=0)return sampleElement;var sampleFocus
Type=this.getTypeForElement(sampleElement);if(sampleFocusType){var sameType=this
.getFirstFocusable(sampleFocusType);if(sameType)return sameType}return this.getC
ustomEquivalent(sampleElement)},getFirstFocusable:function(opt_type){var filter=
opt_type?'="'+opt_type+'"':"";var elements=this.root.querySelectorAll("[focus-ty
pe"+filter+"]");for(var i=0;i<elements.length;++i){if(cr.ui.FocusRow.isFocusable
(elements[i]))return elements[i]}return null},getFocusableElements:function(){re
turn this.getElements().filter(cr.ui.FocusRow.isFocusable)},getTypeForElement:fu
nction(element){return element.getAttribute("focus-type")||""},isActive:function
(){return this.root.classList.contains(FocusRow.ACTIVE_CLASS)},makeActive:functi
on(active){if(active==this.isActive())return;this.getElements().forEach(function
(element){element.tabIndex=active?0:-1});this.root.classList.toggle(FocusRow.ACT
IVE_CLASS,active)},onBlur_:function(e){if(!this.boundary_.contains(e.relatedTarg
et))return;var currentTarget=e.currentTarget;if(this.getFocusableElements().inde
xOf(currentTarget)>=0)this.makeActive(false)},onFocus_:function(e){if(this.deleg
ate)this.delegate.onFocus(this,e)},onMousedown_:function(e){if(e.button)return;i
f(!e.currentTarget.disabled)e.currentTarget.tabIndex=0},onKeydown_:function(e){v
ar elements=this.getFocusableElements();var currentElement=e.currentTarget;var e
lementIndex=elements.indexOf(currentElement);assert(elementIndex>=0);if(this.del
egate&&this.delegate.onKeydown(this,e))return;if(e.altKey||e.ctrlKey||e.metaKey|
|e.shiftKey)return;var index=-1;if(e.key=="ArrowLeft")index=elementIndex+(isRTL(
)?1:-1);else if(e.key=="ArrowRight")index=elementIndex+(isRTL()?-1:1);else if(e.
key=="Home")index=0;else if(e.key=="End")index=elements.length-1;var elementToFo
cus=elements[index];if(elementToFocus){this.getEquivalentElement(elementToFocus)
.focus();e.preventDefault()}}};return{FocusRow:FocusRow}}); | 53 cr.define("cr.ui",function(){function FocusRow(root,boundary,opt_delegate){this.
root=root;this.boundary_=boundary||document.documentElement;this.delegate=opt_de
legate;this.eventTracker=new EventTracker}FocusRow.Delegate=function(){};FocusRo
w.Delegate.prototype={onKeydown:assertNotReached,onFocus:assertNotReached};Focus
Row.ACTIVE_CLASS="focus-row-active";FocusRow.isFocusable=function(element){if(!e
lement||element.disabled)return false;function isVisible(element){assertInstance
of(element,Element);var style=window.getComputedStyle(element);if(style.visibili
ty=="hidden"||style.display=="none")return false;var parent=element.parentNode;i
f(!parent)return false;if(parent==element.ownerDocument||parent instanceof Docum
entFragment)return true;return isVisible(parent)}return isVisible(element)};Focu
sRow.prototype={addItem:function(type,query){assert(type);var element=this.root.
querySelector(query);if(!element)return false;element.setAttribute("focus-type",
type);element.tabIndex=this.isActive()?0:-1;this.eventTracker.add(element,"blur"
,this.onBlur_.bind(this));this.eventTracker.add(element,"focus",this.onFocus_.bi
nd(this));this.eventTracker.add(element,"keydown",this.onKeydown_.bind(this));th
is.eventTracker.add(element,"mousedown",this.onMousedown_.bind(this));return tru
e},destroy:function(){this.eventTracker.removeAll()},getCustomEquivalent:functio
n(sampleElement){return assert(this.getFirstFocusable())},getElements:function()
{var elements=this.root.querySelectorAll("[focus-type]");return Array.prototype.
slice.call(elements)},getEquivalentElement:function(sampleElement){if(this.getFo
cusableElements().indexOf(sampleElement)>=0)return sampleElement;var sampleFocus
Type=this.getTypeForElement(sampleElement);if(sampleFocusType){var sameType=this
.getFirstFocusable(sampleFocusType);if(sameType)return sameType}return this.getC
ustomEquivalent(sampleElement)},getFirstFocusable:function(opt_type){var filter=
opt_type?'="'+opt_type+'"':"";var elements=this.root.querySelectorAll("[focus-ty
pe"+filter+"]");for(var i=0;i<elements.length;++i){if(cr.ui.FocusRow.isFocusable
(elements[i]))return elements[i]}return null},getFocusableElements:function(){re
turn this.getElements().filter(cr.ui.FocusRow.isFocusable)},getTypeForElement:fu
nction(element){return element.getAttribute("focus-type")||""},isActive:function
(){return this.root.classList.contains(FocusRow.ACTIVE_CLASS)},makeActive:functi
on(active){if(active==this.isActive())return;this.getElements().forEach(function
(element){element.tabIndex=active?0:-1});this.root.classList.toggle(FocusRow.ACT
IVE_CLASS,active)},onBlur_:function(e){if(!this.boundary_.contains(e.relatedTarg
et))return;var currentTarget=e.currentTarget;if(this.getFocusableElements().inde
xOf(currentTarget)>=0)this.makeActive(false)},onFocus_:function(e){if(this.deleg
ate)this.delegate.onFocus(this,e)},onMousedown_:function(e){if(e.button)return;i
f(!e.currentTarget.disabled)e.currentTarget.tabIndex=0},onKeydown_:function(e){v
ar elements=this.getFocusableElements();var currentElement=e.currentTarget;var e
lementIndex=elements.indexOf(currentElement);assert(elementIndex>=0);if(this.del
egate&&this.delegate.onKeydown(this,e))return;if(e.altKey||e.ctrlKey||e.metaKey|
|e.shiftKey)return;var index=-1;if(e.key=="ArrowLeft")index=elementIndex+(isRTL(
)?1:-1);else if(e.key=="ArrowRight")index=elementIndex+(isRTL()?-1:1);else if(e.
key=="Home")index=0;else if(e.key=="End")index=elements.length-1;var elementToFo
cus=elements[index];if(elementToFocus){this.getEquivalentElement(elementToFocus)
.focus();e.preventDefault()}}};return{FocusRow:FocusRow}}); |
55 // Copyright 2016 The Chromium Authors. All rights reserved. | 54 // Copyright 2016 The Chromium Authors. All rights reserved. |
56 // Use of this source code is governed by a BSD-style license that can be | 55 // Use of this source code is governed by a BSD-style license that can be |
(...skipping 24 matching lines...) Expand all Loading... |
81 // found in the LICENSE file. | 80 // found in the LICENSE file. |
82 Polymer({is:"history-router",properties:{selectedPage:{type:String,observer:"ser
ializePath_",notify:true},queryState:{type:Object,notify:true},path_:{type:Strin
g,observer:"pathChanged_"},queryParams_:Object},observers:["queryParamsChanged_(
queryParams_.*)","searchTermChanged_(queryState.searchTerm)"],attached:function(
){if(window.location.hash){window.location.href=window.location.href.split("#")[
0]+"?"+window.location.hash.substr(1)}},serializePath_:function(){var page=this.
selectedPage=="history"?"":this.selectedPage;this.path_="/"+page},pathChanged_:f
unction(){var sections=this.path_.substr(1).split("/");this.selectedPage=section
s[0]||"history"},queryParamsChanged_:function(){this.set("queryState.searchTerm"
,this.queryParams_.q||"")},searchTermChanged_:function(){this.set("queryParams_.
q",this.queryState.searchTerm||null)}});Polymer.IronMultiSelectableBehaviorImpl=
{properties:{multi:{type:Boolean,value:false,observer:"multiChanged"},selectedVa
lues:{type:Array,notify:true},selectedItems:{type:Array,readOnly:true,notify:tru
e}},observers:["_updateSelected(selectedValues.splices)"],select:function(value)
{if(this.multi){if(this.selectedValues){this._toggleSelected(value)}else{this.se
lectedValues=[value]}}else{this.selected=value}},multiChanged:function(multi){th
is._selection.multi=multi},get _shouldUpdateSelection(){return this.selected!=nu
ll||this.selectedValues!=null&&this.selectedValues.length},_updateAttrForSelecte
d:function(){if(!this.multi){Polymer.IronSelectableBehavior._updateAttrForSelect
ed.apply(this)}else if(this._shouldUpdateSelection){this.selectedValues=this.sel
ectedItems.map(function(selectedItem){return this._indexToValue(this.indexOf(sel
ectedItem))},this).filter(function(unfilteredValue){return unfilteredValue!=null
},this)}},_updateSelected:function(){if(this.multi){this._selectMulti(this.selec
tedValues)}else{this._selectSelected(this.selected)}},_selectMulti:function(valu
es){if(values){var selectedItems=this._valuesToItems(values);this._selection.cle
ar(selectedItems);for(var i=0;i<selectedItems.length;i++){this._selection.setIte
mSelected(selectedItems[i],true)}if(this.fallbackSelection&&this.items.length&&!
this._selection.get().length){var fallback=this._valueToItem(this.fallbackSelect
ion);if(fallback){this.selectedValues=[this.fallbackSelection]}}}else{this._sele
ction.clear()}},_selectionChange:function(){var s=this._selection.get();if(this.
multi){this._setSelectedItems(s)}else{this._setSelectedItems([s]);this._setSelec
tedItem(s)}},_toggleSelected:function(value){var i=this.selectedValues.indexOf(v
alue);var unselected=i<0;if(unselected){this.push("selectedValues",value)}else{t
his.splice("selectedValues",i,1)}},_valuesToItems:function(values){return values
==null?null:values.map(function(value){return this._valueToItem(value)},this)}};
Polymer.IronMultiSelectableBehavior=[Polymer.IronSelectableBehavior,Polymer.Iron
MultiSelectableBehaviorImpl];Polymer({is:"iron-selector",behaviors:[Polymer.Iron
MultiSelectableBehavior]}); | 81 Polymer({is:"history-router",properties:{selectedPage:{type:String,observer:"ser
ializePath_",notify:true},queryState:{type:Object,notify:true},path_:{type:Strin
g,observer:"pathChanged_"},queryParams_:Object},observers:["queryParamsChanged_(
queryParams_.*)","searchTermChanged_(queryState.searchTerm)"],attached:function(
){if(window.location.hash){window.location.href=window.location.href.split("#")[
0]+"?"+window.location.hash.substr(1)}},serializePath_:function(){var page=this.
selectedPage=="history"?"":this.selectedPage;this.path_="/"+page},pathChanged_:f
unction(){var sections=this.path_.substr(1).split("/");this.selectedPage=section
s[0]||"history"},queryParamsChanged_:function(){this.set("queryState.searchTerm"
,this.queryParams_.q||"")},searchTermChanged_:function(){this.set("queryParams_.
q",this.queryState.searchTerm||null)}});Polymer.IronMultiSelectableBehaviorImpl=
{properties:{multi:{type:Boolean,value:false,observer:"multiChanged"},selectedVa
lues:{type:Array,notify:true},selectedItems:{type:Array,readOnly:true,notify:tru
e}},observers:["_updateSelected(selectedValues.splices)"],select:function(value)
{if(this.multi){if(this.selectedValues){this._toggleSelected(value)}else{this.se
lectedValues=[value]}}else{this.selected=value}},multiChanged:function(multi){th
is._selection.multi=multi},get _shouldUpdateSelection(){return this.selected!=nu
ll||this.selectedValues!=null&&this.selectedValues.length},_updateAttrForSelecte
d:function(){if(!this.multi){Polymer.IronSelectableBehavior._updateAttrForSelect
ed.apply(this)}else if(this._shouldUpdateSelection){this.selectedValues=this.sel
ectedItems.map(function(selectedItem){return this._indexToValue(this.indexOf(sel
ectedItem))},this).filter(function(unfilteredValue){return unfilteredValue!=null
},this)}},_updateSelected:function(){if(this.multi){this._selectMulti(this.selec
tedValues)}else{this._selectSelected(this.selected)}},_selectMulti:function(valu
es){if(values){var selectedItems=this._valuesToItems(values);this._selection.cle
ar(selectedItems);for(var i=0;i<selectedItems.length;i++){this._selection.setIte
mSelected(selectedItems[i],true)}if(this.fallbackSelection&&this.items.length&&!
this._selection.get().length){var fallback=this._valueToItem(this.fallbackSelect
ion);if(fallback){this.selectedValues=[this.fallbackSelection]}}}else{this._sele
ction.clear()}},_selectionChange:function(){var s=this._selection.get();if(this.
multi){this._setSelectedItems(s)}else{this._setSelectedItems([s]);this._setSelec
tedItem(s)}},_toggleSelected:function(value){var i=this.selectedValues.indexOf(v
alue);var unselected=i<0;if(unselected){this.push("selectedValues",value)}else{t
his.splice("selectedValues",i,1)}},_valuesToItems:function(values){return values
==null?null:values.map(function(value){return this._valueToItem(value)},this)}};
Polymer.IronMultiSelectableBehavior=[Polymer.IronSelectableBehavior,Polymer.Iron
MultiSelectableBehaviorImpl];Polymer({is:"iron-selector",behaviors:[Polymer.Iron
MultiSelectableBehavior]}); |
83 // Copyright 2016 The Chromium Authors. All rights reserved. | 82 // Copyright 2016 The Chromium Authors. All rights reserved. |
84 // Use of this source code is governed by a BSD-style license that can be | 83 // Use of this source code is governed by a BSD-style license that can be |
85 // found in the LICENSE file. | 84 // found in the LICENSE file. |
86 Polymer({is:"history-side-bar",behaviors:[Polymer.IronA11yKeysBehavior],properti
es:{selectedPage:{type:String,notify:true},showFooter:Boolean,drawer:{type:Boole
an,reflectToAttribute:true}},keyBindings:{"space:keydown":"onSpacePressed_"},onS
pacePressed_:function(e){e.detail.keyboardEvent.path[0].click()},onSelectorActiv
ate_:function(){this.fire("history-close-drawer")},onClearBrowsingDataTap_:funct
ion(e){var browserService=md_history.BrowserService.getInstance();browserService
.recordAction("InitClearBrowsingData");browserService.openClearBrowsingData();th
is.$["cbd-ripple"].upAction();e.preventDefault()},onItemClick_:function(e){e.pre
ventDefault()}}); | 85 Polymer({is:"history-side-bar",behaviors:[Polymer.IronA11yKeysBehavior],properti
es:{selectedPage:{type:String,notify:true},showFooter:Boolean,drawer:{type:Boole
an,reflectToAttribute:true}},keyBindings:{"space:keydown":"onSpacePressed_"},onS
pacePressed_:function(e){e.detail.keyboardEvent.path[0].click()},onSelectorActiv
ate_:function(){this.fire("history-close-drawer")},onClearBrowsingDataTap_:funct
ion(e){var browserService=md_history.BrowserService.getInstance();browserService
.recordAction("InitClearBrowsingData");browserService.openClearBrowsingData();th
is.$["cbd-ripple"].upAction();e.preventDefault()},onItemClick_:function(e){e.pre
ventDefault()}}); |
87 // Copyright 2016 The Chromium Authors. All rights reserved. | 86 // Copyright 2016 The Chromium Authors. All rights reserved. |
88 // Use of this source code is governed by a BSD-style license that can be | 87 // Use of this source code is governed by a BSD-style license that can be |
89 // found in the LICENSE file. | 88 // found in the LICENSE file. |
90 cr.define("md_history",function(){var lazyLoadPromise=null;function ensureLazyLo
aded(){if(!lazyLoadPromise){lazyLoadPromise=new Promise(function(resolve,reject)
{Polymer.Base.importHref("chrome://history/lazy_load.html",resolve,reject,true)}
)}return lazyLoadPromise}return{ensureLazyLoaded:ensureLazyLoaded}});Polymer({is
:"history-app",behaviors:[Polymer.IronScrollTargetBehavior,WebUIListenerBehavior
],properties:{showSidebarFooter:Boolean,hasSyncedResults:Boolean,selectedPage_:{
type:String,observer:"selectedPageChanged_"},grouped_:{type:Boolean,reflectToAtt
ribute:true},queryState_:{type:Object,value:function(){return{incremental:false,
querying:true,queryingDisabled:false,_range:HistoryRange.ALL_TIME,searchTerm:"",
groupedOffset:0,set range(val){this._range=Number(val)},get range(){return this.
_range}}}},queryResult_:{type:Object,value:function(){return{info:null,results:n
ull,sessionList:null}}},hasDrawer_:Boolean,isUserSignedIn_:{type:Boolean,value:l
oadTimeData.getBoolean("isUserSignedIn")},toolbarShadow_:{type:Boolean,reflectTo
Attribute:true,notify:true}},listeners:{"cr-menu-tap":"onMenuTap_","history-chec
kbox-select":"checkboxSelected","unselect-all":"unselectAll","delete-selected":"
deleteSelected","history-close-drawer":"closeDrawer_","history-view-changed":"hi
storyViewChanged_"},ready:function(){this.grouped_=loadTimeData.getBoolean("grou
pByDomain");cr.ui.decorate("command",cr.ui.Command);document.addEventListener("c
anExecute",this.onCanExecute_.bind(this));document.addEventListener("command",th
is.onCommand_.bind(this))},attached:function(){this.addWebUIListener("sign-in-st
ate-updated",this.updateSignInState.bind(this))},onFirstRender:function(){setTim
eout(function(){chrome.send("metricsHandler:recordTime",["History.ResultsRendere
dTime",window.performance.now()])});var searchField=this.$.toolbar.searchField;i
f(!searchField.narrow){searchField.getSearchInput().focus()}md_history.ensureLaz
yLoaded()},_scrollHandler:function(){if(this.scrollTarget)this.toolbarShadow_=th
is.scrollTarget.scrollTop!=0},onMenuTap_:function(){var drawer=this.$$("#drawer"
);if(drawer)drawer.toggle()},checkboxSelected:function(e){var toolbar=this.$.too
lbar;toolbar.count=this.$.history.getSelectedItemCount()},unselectAll:function()
{var listContainer=this.$.history;var toolbar=this.$.toolbar;listContainer.unsel
ectAllItems(toolbar.count);toolbar.count=0},deleteSelected:function(){this.$.his
tory.deleteSelectedWithPrompt()},historyResult:function(info,results){this.set("
queryState_.querying",false);this.set("queryResult_.info",info);this.set("queryR
esult_.results",results);var listContainer=this.$["history"];listContainer.histo
ryResult(info,results)},focusToolbarSearchField:function(){this.$.toolbar.showSe
archField()},onCanExecute_:function(e){e=e;switch(e.command.id){case"find-comman
d":e.canExecute=true;break;case"slash-command":e.canExecute=!this.$.toolbar.sear
chField.isSearchFocused();break;case"delete-command":e.canExecute=this.$.toolbar
.count>0;break}},onCommand_:function(e){if(e.command.id=="find-command"||e.comma
nd.id=="slash-command")this.focusToolbarSearchField();if(e.command.id=="delete-c
ommand")this.deleteSelected()},setForeignSessions:function(sessionList,isTabSync
Enabled){if(!isTabSyncEnabled){var syncedDeviceManagerElem=this.$$("history-sync
ed-device-manager");if(syncedDeviceManagerElem)syncedDeviceManagerElem.tabSyncDi
sabled();return}this.set("queryResult_.sessionList",sessionList)},historyDeleted
:function(){this.$.history.historyDeleted()},updateSignInState:function(isUserSi
gnedIn){this.isUserSignedIn_=isUserSignedIn},syncedTabsSelected_:function(select
edPage){return selectedPage=="syncedTabs"},shouldShowSpinner_:function(querying,
incremental,searchTerm){return querying&&!incremental&&searchTerm!=""},showSyncN
otice_:function(hasSyncedResults,selectedPage){return hasSyncedResults&&selected
Page!="syncedTabs"},selectedPageChanged_:function(){this.unselectAll();this.hist
oryViewChanged_()},historyViewChanged_:function(){requestAnimationFrame(function
(){if(!this.$.content.selectedItem)return;this.scrollTarget=this.$.content.selec
tedItem.getContentScrollTarget();this._scrollHandler()}.bind(this));this.recordH
istoryPageView_()},getSelectedPage_:function(selectedPage,items){return selected
Page},closeDrawer_:function(){var drawer=this.$$("#drawer");if(drawer)drawer.clo
se()},recordHistoryPageView_:function(){var histogramValue=HistoryPageViewHistog
ram.END;switch(this.selectedPage_){case"syncedTabs":histogramValue=this.isUserSi
gnedIn_?HistoryPageViewHistogram.SYNCED_TABS:HistoryPageViewHistogram.SIGNIN_PRO
MO;break;default:switch(this.queryState_.range){case HistoryRange.ALL_TIME:histo
gramValue=HistoryPageViewHistogram.HISTORY;break;case HistoryRange.WEEK:histogra
mValue=HistoryPageViewHistogram.GROUPED_WEEK;break;case HistoryRange.MONTH:histo
gramValue=HistoryPageViewHistogram.GROUPED_MONTH;break}break}md_history.BrowserS
ervice.getInstance().recordHistogram("History.HistoryPageView",histogramValue,Hi
storyPageViewHistogram.END)}}); | 89 cr.define("md_history",function(){var lazyLoadPromise=null;function ensureLazyLo
aded(){if(!lazyLoadPromise){lazyLoadPromise=new Promise(function(resolve,reject)
{Polymer.Base.importHref("chrome://history/lazy_load.html",resolve,reject,true)}
)}return lazyLoadPromise}return{ensureLazyLoaded:ensureLazyLoaded}});Polymer({is
:"history-app",behaviors:[Polymer.IronScrollTargetBehavior,WebUIListenerBehavior
],properties:{showSidebarFooter:Boolean,hasSyncedResults:Boolean,selectedPage_:{
type:String,observer:"selectedPageChanged_"},grouped_:{type:Boolean,reflectToAtt
ribute:true},queryState_:{type:Object,value:function(){return{incremental:false,
querying:true,queryingDisabled:false,_range:HistoryRange.ALL_TIME,searchTerm:"",
groupedOffset:0,set range(val){this._range=Number(val)},get range(){return this.
_range}}}},queryResult_:{type:Object,value:function(){return{info:null,results:n
ull,sessionList:null}}},hasDrawer_:Boolean,isUserSignedIn_:{type:Boolean,value:l
oadTimeData.getBoolean("isUserSignedIn")},toolbarShadow_:{type:Boolean,reflectTo
Attribute:true,notify:true}},listeners:{"cr-menu-tap":"onMenuTap_","history-chec
kbox-select":"checkboxSelected","unselect-all":"unselectAll","delete-selected":"
deleteSelected","history-close-drawer":"closeDrawer_","history-view-changed":"hi
storyViewChanged_"},ready:function(){this.grouped_=loadTimeData.getBoolean("grou
pByDomain");cr.ui.decorate("command",cr.ui.Command);document.addEventListener("c
anExecute",this.onCanExecute_.bind(this));document.addEventListener("command",th
is.onCommand_.bind(this))},attached:function(){this.addWebUIListener("sign-in-st
ate-updated",this.updateSignInState.bind(this))},onFirstRender:function(){setTim
eout(function(){chrome.send("metricsHandler:recordTime",["History.ResultsRendere
dTime",window.performance.now()])});var searchField=this.$.toolbar.searchField;i
f(!searchField.narrow){searchField.getSearchInput().focus()}md_history.ensureLaz
yLoaded()},_scrollHandler:function(){if(this.scrollTarget)this.toolbarShadow_=th
is.scrollTarget.scrollTop!=0},onMenuTap_:function(){var drawer=this.$$("#drawer"
);if(drawer)drawer.toggle()},checkboxSelected:function(e){var toolbar=this.$.too
lbar;toolbar.count=this.$.history.getSelectedItemCount()},unselectAll:function()
{var listContainer=this.$.history;var toolbar=this.$.toolbar;listContainer.unsel
ectAllItems(toolbar.count);toolbar.count=0},deleteSelected:function(){this.$.his
tory.deleteSelectedWithPrompt()},historyResult:function(info,results){this.set("
queryState_.querying",false);this.set("queryResult_.info",info);this.set("queryR
esult_.results",results);var listContainer=this.$["history"];listContainer.histo
ryResult(info,results)},focusToolbarSearchField:function(){this.$.toolbar.showSe
archField()},onCanExecute_:function(e){e=e;switch(e.command.id){case"find-comman
d":e.canExecute=true;break;case"slash-command":e.canExecute=!this.$.toolbar.sear
chField.isSearchFocused();break;case"delete-command":e.canExecute=this.$.toolbar
.count>0;break}},onCommand_:function(e){if(e.command.id=="find-command"||e.comma
nd.id=="slash-command")this.focusToolbarSearchField();if(e.command.id=="delete-c
ommand")this.deleteSelected()},setForeignSessions:function(sessionList,isTabSync
Enabled){if(!isTabSyncEnabled){var syncedDeviceManagerElem=this.$$("history-sync
ed-device-manager");if(syncedDeviceManagerElem)syncedDeviceManagerElem.tabSyncDi
sabled();return}this.set("queryResult_.sessionList",sessionList)},historyDeleted
:function(){this.$.history.historyDeleted()},updateSignInState:function(isUserSi
gnedIn){this.isUserSignedIn_=isUserSignedIn},syncedTabsSelected_:function(select
edPage){return selectedPage=="syncedTabs"},shouldShowSpinner_:function(querying,
incremental,searchTerm){return querying&&!incremental&&searchTerm!=""},showSyncN
otice_:function(hasSyncedResults,selectedPage){return hasSyncedResults&&selected
Page!="syncedTabs"},selectedPageChanged_:function(){this.unselectAll();this.hist
oryViewChanged_()},historyViewChanged_:function(){requestAnimationFrame(function
(){if(!this.$.content.selectedItem)return;this.scrollTarget=this.$.content.selec
tedItem.getContentScrollTarget();this._scrollHandler()}.bind(this));this.recordH
istoryPageView_()},getSelectedPage_:function(selectedPage,items){return selected
Page},closeDrawer_:function(){var drawer=this.$$("#drawer");if(drawer)drawer.clo
se()},recordHistoryPageView_:function(){var histogramValue=HistoryPageViewHistog
ram.END;switch(this.selectedPage_){case"syncedTabs":histogramValue=this.isUserSi
gnedIn_?HistoryPageViewHistogram.SYNCED_TABS:HistoryPageViewHistogram.SIGNIN_PRO
MO;break;default:switch(this.queryState_.range){case HistoryRange.ALL_TIME:histo
gramValue=HistoryPageViewHistogram.HISTORY;break;case HistoryRange.WEEK:histogra
mValue=HistoryPageViewHistogram.GROUPED_WEEK;break;case HistoryRange.MONTH:histo
gramValue=HistoryPageViewHistogram.GROUPED_MONTH;break}break}md_history.BrowserS
ervice.getInstance().recordHistogram("History.HistoryPageView",histogramValue,Hi
storyPageViewHistogram.END)}}); |
OLD | NEW |