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
}});Polymer({is:"iron-media-query",properties:{queryMatches:{type:Boolean,value:
false,readOnly:true,notify:true},query:{type:String,observer:"queryChanged"},ful
l:{type:Boolean,value:false},_boundMQHandler:{value:function(){return this.query
Handler.bind(this)}},_mq:{value:null}},attached:function(){this.style.display="n
one";this.queryChanged()},detached:function(){this._remove()},_add:function(){if
(this._mq){this._mq.addListener(this._boundMQHandler)}},_remove:function(){if(th
is._mq){this._mq.removeListener(this._boundMQHandler)}this._mq=null},queryChange
d:function(){this._remove();var query=this.query;if(!query){return}if(!this.full
&&query[0]!=="("){query="("+query+")"}this._mq=window.matchMedia(query);this._ad
d();this.queryHandler(this._mq)},queryHandler:function(mq){this._setQueryMatches
(mq.matches)}});Polymer.IronResizableBehavior={properties:{_parentResizable:{typ
e:Object,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,
value:false}},listeners:{"iron-request-resize-notifications":"_onIronRequestResi
zeNotifications"},created:function(){this._interestedResizables=[];this._boundNo
tifyResize=this.notifyResize.bind(this)},attached:function(){this.fire("iron-req
uest-resize-notifications",null,{node:this,bubbles:true,cancelable:true});if(!th
is._parentResizable){window.addEventListener("resize",this._boundNotifyResize);t
his.notifyResize()}},detached:function(){if(this._parentResizable){this._parentR
esizable.stopResizeNotificationsFor(this)}else{window.removeEventListener("resiz
e",this._boundNotifyResize)}this._parentResizable=null},notifyResize:function(){
if(!this.isAttached){return}this._interestedResizables.forEach(function(resizabl
e){if(this.resizerShouldNotify(resizable)){this._notifyDescendant(resizable)}},t
his);this._fireResize()},assignParentResizable:function(parentResizable){this._p
arentResizable=parentResizable},stopResizeNotificationsFor:function(target){var
index=this._interestedResizables.indexOf(target);if(index>-1){this._interestedRe
sizables.splice(index,1);this.unlisten(target,"iron-resize","_onDescendantIronRe
size")}},resizerShouldNotify:function(element){return true},_onDescendantIronRes
ize:function(event){if(this._notifyingDescendant){event.stopPropagation();return
}if(!Polymer.Settings.useShadow){this._fireResize()}},_fireResize:function(){thi
s.fire("iron-resize",null,{node:this,bubbles:false})},_onIronRequestResizeNotifi
cations:function(event){var target=event.path?event.path[0]:event.target;if(targ
et===this){return}if(this._interestedResizables.indexOf(target)===-1){this._inte
restedResizables.push(target);this.listen(target,"iron-resize","_onDescendantIro
nResize")}target.assignParentResizable(this);this._notifyDescendant(target);even
t.stopPropagation()},_parentResizableChanged:function(parentResizable){if(parent
Resizable){window.removeEventListener("resize",this._boundNotifyResize)}},_notif
yDescendant:function(descendant){if(!this.isAttached){return}this._notifyingDesc
endant=true;descendant.notifyResize();this._notifyingDescendant=false}};Polymer.
IronSelection=function(selectCallback){this.selection=[];this.selectCallback=sel
ectCallback};Polymer.IronSelection.prototype={get:function(){return this.multi?t
his.selection.slice():this.selection[0]},clear:function(excludes){this.selection
.slice().forEach(function(item){if(!excludes||excludes.indexOf(item)<0){this.set
ItemSelected(item,false)}},this)},isSelected:function(item){return this.selectio
n.indexOf(item)>=0},setItemSelected:function(item,isSelected){if(item!=null){if(
isSelected!==this.isSelected(item)){if(isSelected){this.selection.push(item)}els
e{var i=this.selection.indexOf(item);if(i>=0){this.selection.splice(i,1)}}if(thi
s.selectCallback){this.selectCallback(item,isSelected)}}}},select:function(item)
{if(this.multi){this.toggle(item)}else if(this.get()!==item){this.setItemSelecte
d(this.get(),false);this.setItemSelected(item,true)}},toggle:function(item){this
.setItemSelected(item,!this.isSelected(item))}};Polymer.IronSelectableBehavior={
properties:{attrForSelected:{type:String,value:null},selected:{type:String,notif
y:true},selectedItem:{type:Object,readOnly:true,notify:true},activateEvent:{type
:String,value:"tap",observer:"_activateEventChanged"},selectable:String,selected
Class:{type:String,value:"iron-selected"},selectedAttribute:{type:String,value:n
ull},fallbackSelection:{type:String,value:null},items:{type:Array,readOnly:true,
notify:true,value:function(){return[]}},_excludedLocalNames:{type:Object,value:f
unction(){return{template:1}}}},observers:["_updateAttrForSelected(attrForSelect
ed)","_updateSelected(selected)","_checkFallback(fallbackSelection)"],created:fu
nction(){this._bindFilterItem=this._filterItem.bind(this);this._selection=new Po
lymer.IronSelection(this._applySelection.bind(this))},attached:function(){this._
observer=this._observeItems(this);this._updateItems();if(!this._shouldUpdateSele
ction){this._updateSelected()}this._addListener(this.activateEvent)},detached:fu
nction(){if(this._observer){Polymer.dom(this).unobserveNodes(this._observer)}thi
s._removeListener(this.activateEvent)},indexOf:function(item){return this.items.
indexOf(item)},select:function(value){this.selected=value},selectPrevious:functi
on(){var length=this.items.length;var index=(Number(this._valueToIndex(this.sele
cted))-1+length)%length;this.selected=this._indexToValue(index)},selectNext:func
tion(){var index=(Number(this._valueToIndex(this.selected))+1)%this.items.length
;this.selected=this._indexToValue(index)},selectIndex:function(index){this.selec
t(this._indexToValue(index))},forceSynchronousItemUpdate:function(){this._update
Items()},get _shouldUpdateSelection(){return this.selected!=null},_checkFallback
:function(){if(this._shouldUpdateSelection){this._updateSelected()}},_addListene
r:function(eventName){this.listen(this,eventName,"_activateHandler")},_removeLis
tener:function(eventName){this.unlisten(this,eventName,"_activateHandler")},_act
ivateEventChanged:function(eventName,old){this._removeListener(old);this._addLis
tener(eventName)},_updateItems:function(){var nodes=Polymer.dom(this).queryDistr
ibutedElements(this.selectable||"*");nodes=Array.prototype.filter.call(nodes,thi
s._bindFilterItem);this._setItems(nodes)},_updateAttrForSelected:function(){if(t
his._shouldUpdateSelection){this.selected=this._indexToValue(this.indexOf(this.s
electedItem))}},_updateSelected:function(){this._selectSelected(this.selected)},
_selectSelected:function(selected){this._selection.select(this._valueToItem(this
.selected));if(this.fallbackSelection&&this.items.length&&this._selection.get()=
==undefined){this.selected=this.fallbackSelection}},_filterItem:function(node){r
eturn!this._excludedLocalNames[node.localName]},_valueToItem:function(value){ret
urn value==null?null:this.items[this._valueToIndex(value)]},_valueToIndex:functi
on(value){if(this.attrForSelected){for(var i=0,item;item=this.items[i];i++){if(t
his._valueForItem(item)==value){return i}}}else{return Number(value)}},_indexToV
alue:function(index){if(this.attrForSelected){var item=this.items[index];if(item
){return this._valueForItem(item)}}else{return index}},_valueForItem:function(it
em){var propValue=item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)];re
turn propValue!=undefined?propValue:item.getAttribute(this.attrForSelected)},_ap
plySelection:function(item,isSelected){if(this.selectedClass){this.toggleClass(t
his.selectedClass,isSelected,item)}if(this.selectedAttribute){this.toggleAttribu
te(this.selectedAttribute,isSelected,item)}this._selectionChange();this.fire("ir
on-"+(isSelected?"select":"deselect"),{item:item})},_selectionChange:function(){
this._setSelectedItem(this._selection.get())},_observeItems:function(node){retur
n Polymer.dom(node).observeNodes(function(mutation){this._updateItems();if(this.
_shouldUpdateSelection){this._updateSelected()}this.fire("iron-items-changed",mu
tation,{bubbles:false,cancelable:false})})},_activateHandler:function(e){var t=e
.target;var items=this.items;while(t&&t!=this){var i=items.indexOf(t);if(i>=0){v
ar value=this._indexToValue(i);this._itemActivate(value,t);return}t=t.parentNode
}},_itemActivate:function(value,item){if(!this.fire("iron-activate",{selected:va
lue,item:item},{cancelable:true}).defaultPrevented){this.select(value)}}};Polyme
r({is:"iron-pages",behaviors:[Polymer.IronResizableBehavior,Polymer.IronSelectab
leBehavior],properties:{activateEvent:{type:String,value:null}},observers:["_sel
ectedPageChanged(selected)"],_selectedPageChanged:function(selected,old){this.as
ync(this.notifyResize)}});Polymer.IronScrollTargetBehavior={properties:{scrollTa
rget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},obse
rvers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:tru
e,_scrollTargetChanged:function(scrollTarget,isAttached){var eventTarget;if(this
._oldScrollTarget){this._toggleScrollListener(false,this._oldScrollTarget);this.
_oldScrollTarget=null}if(!isAttached){return}if(scrollTarget==="document"){this.
scrollTarget=this._doc}else if(typeof scrollTarget==="string"){this.scrollTarget
=this.domHost?this.domHost.$[scrollTarget]:Polymer.dom(this.ownerDocument).query
Selector("#"+scrollTarget)}else if(this._isValidScrollTarget()){this._boundScrol
lHandler=this._boundScrollHandler||this._scrollHandler.bind(this);this._oldScrol
lTarget=scrollTarget;this._toggleScrollListener(this._shouldHaveListener,scrollT
arget)}},_scrollHandler:function scrollHandler(){},get _defaultScrollTarget(){re
turn this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrol
lTop(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?wind
ow.pageYOffset:this.scrollTarget.scrollTop}return 0},get _scrollLeft(){if(this._
isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageXOffset:t
his.scrollTarget.scrollLeft}return 0},set _scrollTop(top){if(this.scrollTarget==
=this._doc){window.scrollTo(window.pageXOffset,top)}else if(this._isValidScrollT
arget()){this.scrollTarget.scrollTop=top}},set _scrollLeft(left){if(this.scrollT
arget===this._doc){window.scrollTo(left,window.pageYOffset)}else if(this._isVali
dScrollTarget()){this.scrollTarget.scrollLeft=left}},scroll:function(left,top){i
f(this.scrollTarget===this._doc){window.scrollTo(left,top)}else if(this._isValid
ScrollTarget()){this.scrollTarget.scrollLeft=left;this.scrollTarget.scrollTop=to
p}},get _scrollTargetWidth(){if(this._isValidScrollTarget()){return this.scrollT
arget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth}return 0},get
_scrollTargetHeight(){if(this._isValidScrollTarget()){return this.scrollTarget==
=this._doc?window.innerHeight:this.scrollTarget.offsetHeight}return 0},_isValidS
crollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleS
crollListener:function(yes,scrollTarget){if(!this._boundScrollHandler){return}va
r eventTarget=scrollTarget===this._doc?window:scrollTarget;if(yes){eventTarget.a
ddEventListener("scroll",this._boundScrollHandler)}else{eventTarget.removeEventL
istener("scroll",this._boundScrollHandler)}},toggleScrollListener:function(yes){
this._shouldHaveListener=yes;this._toggleScrollListener(yes,this.scrollTarget)}}
;(function(){var metaDatas={};var metaArrays={};var singleton=null;Polymer.IronM
eta=Polymer({is:"iron-meta",properties:{type:{type:String,value:"default",observ
er:"_typeChanged"},key:{type:String,observer:"_keyChanged"},value:{type:Object,n
otify:true,observer:"_valueChanged"},self:{type:Boolean,observer:"_selfChanged"}
,list:{type:Array,notify:true}},hostAttributes:{hidden:true},factoryImpl:functio
n(config){if(config){for(var n in config){switch(n){case"type":case"key":case"va
lue":this[n]=config[n];break}}}},created:function(){this._metaDatas=metaDatas;th
is._metaArrays=metaArrays},_keyChanged:function(key,old){this._resetRegistration
(old)},_valueChanged:function(value){this._resetRegistration(this.key)},_selfCha
nged:function(self){if(self){this.value=this}},_typeChanged:function(type){this.
_unregisterKey(this.key);if(!metaDatas[type]){metaDatas[type]={}}this._metaData=
metaDatas[type];if(!metaArrays[type]){metaArrays[type]=[]}this.list=metaArrays[t
ype];this._registerKeyValue(this.key,this.value)},byKey:function(key){return thi
s._metaData&&this._metaData[key]},_resetRegistration:function(oldKey){this._unre
gisterKey(oldKey);this._registerKeyValue(this.key,this.value)},_unregisterKey:fu
nction(key){this._unregister(key,this._metaData,this.list)},_registerKeyValue:fu
nction(key,value){this._register(key,value,this._metaData,this.list)},_register:
function(key,value,data,list){if(key&&data&&value!==undefined){data[key]=value;l
ist.push(value)}},_unregister:function(key,data,list){if(key&&data){if(key in da
ta){var value=data[key];delete data[key];this.arrayDelete(list,value)}}}});Polym
er.IronMeta.getIronMeta=function getIronMeta(){if(singleton===null){singleton=ne
w Polymer.IronMeta}return singleton};Polymer.IronMetaQuery=Polymer({is:"iron-met
a-query",properties:{type:{type:String,value:"default",observer:"_typeChanged"},
key:{type:String,observer:"_keyChanged"},value:{type:Object,notify:true,readOnly
:true},list:{type:Array,notify:true}},factoryImpl:function(config){if(config){fo
r(var n in config){switch(n){case"type":case"key":this[n]=config[n];break}}}},cr
eated:function(){this._metaDatas=metaDatas;this._metaArrays=metaArrays},_keyChan
ged:function(key){this._setValue(this._metaData&&this._metaData[key])},_typeChan
ged:function(type){this._metaData=metaDatas[type];this.list=metaArrays[type];if(
this.key){this._keyChanged(this.key)}},byKey:function(key){return this._metaData
&&this._metaData[key]}})})();Polymer({is:"iron-icon",properties:{icon:{type:Stri
ng,observer:"_iconChanged"},theme:{type:String,observer:"_updateIcon"},src:{type
:String,observer:"_srcChanged"},_meta:{value:Polymer.Base.create("iron-meta",{ty
pe:"iconset"}),observer:"_updateIcon"}},_DEFAULT_ICONSET:"icons",_iconChanged:fu
nction(icon){var parts=(icon||"").split(":");this._iconName=parts.pop();this._ic
onsetName=parts.pop()||this._DEFAULT_ICONSET;this._updateIcon()},_srcChanged:fun
ction(src){this._updateIcon()},_usesIconset:function(){return this.icon||!this.s
rc},_updateIcon:function(){if(this._usesIconset()){if(this._img&&this._img.paren
tNode){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-ico
nset-added","_updateIcon")}else{this.listen(window,"iron-iconset-added","_update
Icon")}}}else{if(this._iconset){this._iconset.removeIcon(this)}if(!this._img){th
is._img=document.createElement("img");this._img.style.width="100%";this._img.sty
le.height="100%";this._img.draggable=false}this._img.src=this.src;Polymer.dom(th
is.root).appendChild(this._img)}}});Polymer({is:"iron-iconset-svg",properties:{n
ame:{type:String,observer:"_nameChanged"},size:{type:Number,value:24},rtlMirrori
ng:{type:Boolean,value:false}},_targetIsRTL:function(target){if(target&&target.n
odeType!==Node.ELEMENT_NODE){target=target.host}return target&&window.getCompute
dStyle(target)["direction"]==="rtl"},attached:function(){this.style.display="non
e"},getIconNames:function(){this._icons=this._createIconMap();return Object.keys
(this._icons).map(function(n){return this.name+":"+n},this)},applyIcon:function(
element,iconName){element=element.root||element;this.removeIcon(element);var svg
=this._cloneIcon(iconName,this.rtlMirroring&&this._targetIsRTL(element));if(svg)
{var pde=Polymer.dom(element);pde.insertBefore(svg,pde.childNodes[0]);return ele
ment._svgIcon=svg}return null},removeIcon:function(element){element=element.root
||element;if(element._svgIcon){Polymer.dom(element).removeChild(element._svgIcon
);element._svgIcon=null}},_nameChanged:function(){new Polymer.IronMeta({type:"ic
onset",key:this.name,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[ic
on.id]=icon});return icons},_cloneIcon:function(id,mirrorAllowed){this._icons=th
is._icons||this._createIconMap();return this._prepareSvgClone(this._icons[id],th
is.size,mirrorAllowed)},_prepareSvgClone:function(sourceSvg,size,mirrorAllowed){
if(sourceSvg){var content=sourceSvg.cloneNode(true),svg=document.createElementNS
("http://www.w3.org/2000/svg","svg"),viewBox=content.getAttribute("viewBox")||"0
0 "+size+" "+size,cssText="pointer-events: none; display: block; width: 100%; h
eight: 100%;";if(mirrorAllowed&&content.hasAttribute("mirror-in-rtl")){cssText+=
"-webkit-transform:scale(-1,1);transform:scale(-1,1);"}svg.setAttribute("viewBox
",viewBox);svg.setAttribute("preserveAspectRatio","xMidYMid meet");svg.style.css
Text=cssText;svg.appendChild(content).removeAttribute("id");return svg}return nu
ll}}); | 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
}});Polymer({is:"iron-media-query",properties:{queryMatches:{type:Boolean,value:
false,readOnly:true,notify:true},query:{type:String,observer:"queryChanged"},ful
l:{type:Boolean,value:false},_boundMQHandler:{value:function(){return this.query
Handler.bind(this)}},_mq:{value:null}},attached:function(){this.style.display="n
one";this.queryChanged()},detached:function(){this._remove()},_add:function(){if
(this._mq){this._mq.addListener(this._boundMQHandler)}},_remove:function(){if(th
is._mq){this._mq.removeListener(this._boundMQHandler)}this._mq=null},queryChange
d:function(){this._remove();var query=this.query;if(!query){return}if(!this.full
&&query[0]!=="("){query="("+query+")"}this._mq=window.matchMedia(query);this._ad
d();this.queryHandler(this._mq)},queryHandler:function(mq){this._setQueryMatches
(mq.matches)}});Polymer.IronResizableBehavior={properties:{_parentResizable:{typ
e:Object,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,
value:false}},listeners:{"iron-request-resize-notifications":"_onIronRequestResi
zeNotifications"},created:function(){this._interestedResizables=[];this._boundNo
tifyResize=this.notifyResize.bind(this)},attached:function(){this.fire("iron-req
uest-resize-notifications",null,{node:this,bubbles:true,cancelable:true});if(!th
is._parentResizable){window.addEventListener("resize",this._boundNotifyResize);t
his.notifyResize()}},detached:function(){if(this._parentResizable){this._parentR
esizable.stopResizeNotificationsFor(this)}else{window.removeEventListener("resiz
e",this._boundNotifyResize)}this._parentResizable=null},notifyResize:function(){
if(!this.isAttached){return}this._interestedResizables.forEach(function(resizabl
e){if(this.resizerShouldNotify(resizable)){this._notifyDescendant(resizable)}},t
his);this._fireResize()},assignParentResizable:function(parentResizable){this._p
arentResizable=parentResizable},stopResizeNotificationsFor:function(target){var
index=this._interestedResizables.indexOf(target);if(index>-1){this._interestedRe
sizables.splice(index,1);this.unlisten(target,"iron-resize","_onDescendantIronRe
size")}},resizerShouldNotify:function(element){return true},_onDescendantIronRes
ize:function(event){if(this._notifyingDescendant){event.stopPropagation();return
}if(!Polymer.Settings.useShadow){this._fireResize()}},_fireResize:function(){thi
s.fire("iron-resize",null,{node:this,bubbles:false})},_onIronRequestResizeNotifi
cations:function(event){var target=event.path?event.path[0]:event.target;if(targ
et===this){return}if(this._interestedResizables.indexOf(target)===-1){this._inte
restedResizables.push(target);this.listen(target,"iron-resize","_onDescendantIro
nResize")}target.assignParentResizable(this);this._notifyDescendant(target);even
t.stopPropagation()},_parentResizableChanged:function(parentResizable){if(parent
Resizable){window.removeEventListener("resize",this._boundNotifyResize)}},_notif
yDescendant:function(descendant){if(!this.isAttached){return}this._notifyingDesc
endant=true;descendant.notifyResize();this._notifyingDescendant=false}};Polymer.
IronSelection=function(selectCallback){this.selection=[];this.selectCallback=sel
ectCallback};Polymer.IronSelection.prototype={get:function(){return this.multi?t
his.selection.slice():this.selection[0]},clear:function(excludes){this.selection
.slice().forEach(function(item){if(!excludes||excludes.indexOf(item)<0){this.set
ItemSelected(item,false)}},this)},isSelected:function(item){return this.selectio
n.indexOf(item)>=0},setItemSelected:function(item,isSelected){if(item!=null){if(
isSelected!==this.isSelected(item)){if(isSelected){this.selection.push(item)}els
e{var i=this.selection.indexOf(item);if(i>=0){this.selection.splice(i,1)}}if(thi
s.selectCallback){this.selectCallback(item,isSelected)}}}},select:function(item)
{if(this.multi){this.toggle(item)}else if(this.get()!==item){this.setItemSelecte
d(this.get(),false);this.setItemSelected(item,true)}},toggle:function(item){this
.setItemSelected(item,!this.isSelected(item))}};Polymer.IronSelectableBehavior={
properties:{attrForSelected:{type:String,value:null},selected:{type:String,notif
y:true},selectedItem:{type:Object,readOnly:true,notify:true},activateEvent:{type
:String,value:"tap",observer:"_activateEventChanged"},selectable:String,selected
Class:{type:String,value:"iron-selected"},selectedAttribute:{type:String,value:n
ull},fallbackSelection:{type:String,value:null},items:{type:Array,readOnly:true,
notify:true,value:function(){return[]}},_excludedLocalNames:{type:Object,value:f
unction(){return{template:1}}}},observers:["_updateAttrForSelected(attrForSelect
ed)","_updateSelected(selected)","_checkFallback(fallbackSelection)"],created:fu
nction(){this._bindFilterItem=this._filterItem.bind(this);this._selection=new Po
lymer.IronSelection(this._applySelection.bind(this))},attached:function(){this._
observer=this._observeItems(this);this._updateItems();if(!this._shouldUpdateSele
ction){this._updateSelected()}this._addListener(this.activateEvent)},detached:fu
nction(){if(this._observer){Polymer.dom(this).unobserveNodes(this._observer)}thi
s._removeListener(this.activateEvent)},indexOf:function(item){return this.items.
indexOf(item)},select:function(value){this.selected=value},selectPrevious:functi
on(){var length=this.items.length;var index=(Number(this._valueToIndex(this.sele
cted))-1+length)%length;this.selected=this._indexToValue(index)},selectNext:func
tion(){var index=(Number(this._valueToIndex(this.selected))+1)%this.items.length
;this.selected=this._indexToValue(index)},selectIndex:function(index){this.selec
t(this._indexToValue(index))},forceSynchronousItemUpdate:function(){this._update
Items()},get _shouldUpdateSelection(){return this.selected!=null},_checkFallback
:function(){if(this._shouldUpdateSelection){this._updateSelected()}},_addListene
r:function(eventName){this.listen(this,eventName,"_activateHandler")},_removeLis
tener:function(eventName){this.unlisten(this,eventName,"_activateHandler")},_act
ivateEventChanged:function(eventName,old){this._removeListener(old);this._addLis
tener(eventName)},_updateItems:function(){var nodes=Polymer.dom(this).queryDistr
ibutedElements(this.selectable||"*");nodes=Array.prototype.filter.call(nodes,thi
s._bindFilterItem);this._setItems(nodes)},_updateAttrForSelected:function(){if(t
his._shouldUpdateSelection){this.selected=this._indexToValue(this.indexOf(this.s
electedItem))}},_updateSelected:function(){this._selectSelected(this.selected)},
_selectSelected:function(selected){this._selection.select(this._valueToItem(this
.selected));if(this.fallbackSelection&&this.items.length&&this._selection.get()=
==undefined){this.selected=this.fallbackSelection}},_filterItem:function(node){r
eturn!this._excludedLocalNames[node.localName]},_valueToItem:function(value){ret
urn value==null?null:this.items[this._valueToIndex(value)]},_valueToIndex:functi
on(value){if(this.attrForSelected){for(var i=0,item;item=this.items[i];i++){if(t
his._valueForItem(item)==value){return i}}}else{return Number(value)}},_indexToV
alue:function(index){if(this.attrForSelected){var item=this.items[index];if(item
){return this._valueForItem(item)}}else{return index}},_valueForItem:function(it
em){var propValue=item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)];re
turn propValue!=undefined?propValue:item.getAttribute(this.attrForSelected)},_ap
plySelection:function(item,isSelected){if(this.selectedClass){this.toggleClass(t
his.selectedClass,isSelected,item)}if(this.selectedAttribute){this.toggleAttribu
te(this.selectedAttribute,isSelected,item)}this._selectionChange();this.fire("ir
on-"+(isSelected?"select":"deselect"),{item:item})},_selectionChange:function(){
this._setSelectedItem(this._selection.get())},_observeItems:function(node){retur
n Polymer.dom(node).observeNodes(function(mutation){this._updateItems();if(this.
_shouldUpdateSelection){this._updateSelected()}this.fire("iron-items-changed",mu
tation,{bubbles:false,cancelable:false})})},_activateHandler:function(e){var t=e
.target;var items=this.items;while(t&&t!=this){var i=items.indexOf(t);if(i>=0){v
ar value=this._indexToValue(i);this._itemActivate(value,t);return}t=t.parentNode
}},_itemActivate:function(value,item){if(!this.fire("iron-activate",{selected:va
lue,item:item},{cancelable:true}).defaultPrevented){this.select(value)}}};Polyme
r({is:"iron-pages",behaviors:[Polymer.IronResizableBehavior,Polymer.IronSelectab
leBehavior],properties:{activateEvent:{type:String,value:null}},observers:["_sel
ectedPageChanged(selected)"],_selectedPageChanged:function(selected,old){this.as
ync(this.notifyResize)}});Polymer.IronScrollTargetBehavior={properties:{scrollTa
rget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},obse
rvers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:tru
e,_scrollTargetChanged:function(scrollTarget,isAttached){var eventTarget;if(this
._oldScrollTarget){this._toggleScrollListener(false,this._oldScrollTarget);this.
_oldScrollTarget=null}if(!isAttached){return}if(scrollTarget==="document"){this.
scrollTarget=this._doc}else if(typeof scrollTarget==="string"){this.scrollTarget
=this.domHost?this.domHost.$[scrollTarget]:Polymer.dom(this.ownerDocument).query
Selector("#"+scrollTarget)}else if(this._isValidScrollTarget()){this._boundScrol
lHandler=this._boundScrollHandler||this._scrollHandler.bind(this);this._oldScrol
lTarget=scrollTarget;this._toggleScrollListener(this._shouldHaveListener,scrollT
arget)}},_scrollHandler:function scrollHandler(){},get _defaultScrollTarget(){re
turn this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrol
lTop(){if(this._isValidScrollTarget()){return this.scrollTarget===this._doc?wind
ow.pageYOffset:this.scrollTarget.scrollTop}return 0},get _scrollLeft(){if(this._
isValidScrollTarget()){return this.scrollTarget===this._doc?window.pageXOffset:t
his.scrollTarget.scrollLeft}return 0},set _scrollTop(top){if(this.scrollTarget==
=this._doc){window.scrollTo(window.pageXOffset,top)}else if(this._isValidScrollT
arget()){this.scrollTarget.scrollTop=top}},set _scrollLeft(left){if(this.scrollT
arget===this._doc){window.scrollTo(left,window.pageYOffset)}else if(this._isVali
dScrollTarget()){this.scrollTarget.scrollLeft=left}},scroll:function(left,top){i
f(this.scrollTarget===this._doc){window.scrollTo(left,top)}else if(this._isValid
ScrollTarget()){this.scrollTarget.scrollLeft=left;this.scrollTarget.scrollTop=to
p}},get _scrollTargetWidth(){if(this._isValidScrollTarget()){return this.scrollT
arget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth}return 0},get
_scrollTargetHeight(){if(this._isValidScrollTarget()){return this.scrollTarget==
=this._doc?window.innerHeight:this.scrollTarget.offsetHeight}return 0},_isValidS
crollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleS
crollListener:function(yes,scrollTarget){if(!this._boundScrollHandler){return}va
r eventTarget=scrollTarget===this._doc?window:scrollTarget;if(yes){eventTarget.a
ddEventListener("scroll",this._boundScrollHandler)}else{eventTarget.removeEventL
istener("scroll",this._boundScrollHandler)}},toggleScrollListener:function(yes){
this._shouldHaveListener=yes;this._toggleScrollListener(yes,this.scrollTarget)}}
;(function(){var metaDatas={};var metaArrays={};var singleton=null;Polymer.IronM
eta=Polymer({is:"iron-meta",properties:{type:{type:String,value:"default",observ
er:"_typeChanged"},key:{type:String,observer:"_keyChanged"},value:{type:Object,n
otify:true,observer:"_valueChanged"},self:{type:Boolean,observer:"_selfChanged"}
,list:{type:Array,notify:true}},hostAttributes:{hidden:true},factoryImpl:functio
n(config){if(config){for(var n in config){switch(n){case"type":case"key":case"va
lue":this[n]=config[n];break}}}},created:function(){this._metaDatas=metaDatas;th
is._metaArrays=metaArrays},_keyChanged:function(key,old){this._resetRegistration
(old)},_valueChanged:function(value){this._resetRegistration(this.key)},_selfCha
nged:function(self){if(self){this.value=this}},_typeChanged:function(type){this.
_unregisterKey(this.key);if(!metaDatas[type]){metaDatas[type]={}}this._metaData=
metaDatas[type];if(!metaArrays[type]){metaArrays[type]=[]}this.list=metaArrays[t
ype];this._registerKeyValue(this.key,this.value)},byKey:function(key){return thi
s._metaData&&this._metaData[key]},_resetRegistration:function(oldKey){this._unre
gisterKey(oldKey);this._registerKeyValue(this.key,this.value)},_unregisterKey:fu
nction(key){this._unregister(key,this._metaData,this.list)},_registerKeyValue:fu
nction(key,value){this._register(key,value,this._metaData,this.list)},_register:
function(key,value,data,list){if(key&&data&&value!==undefined){data[key]=value;l
ist.push(value)}},_unregister:function(key,data,list){if(key&&data){if(key in da
ta){var value=data[key];delete data[key];this.arrayDelete(list,value)}}}});Polym
er.IronMeta.getIronMeta=function getIronMeta(){if(singleton===null){singleton=ne
w Polymer.IronMeta}return singleton};Polymer.IronMetaQuery=Polymer({is:"iron-met
a-query",properties:{type:{type:String,value:"default",observer:"_typeChanged"},
key:{type:String,observer:"_keyChanged"},value:{type:Object,notify:true,readOnly
:true},list:{type:Array,notify:true}},factoryImpl:function(config){if(config){fo
r(var n in config){switch(n){case"type":case"key":this[n]=config[n];break}}}},cr
eated:function(){this._metaDatas=metaDatas;this._metaArrays=metaArrays},_keyChan
ged:function(key){this._setValue(this._metaData&&this._metaData[key])},_typeChan
ged:function(type){this._metaData=metaDatas[type];this.list=metaArrays[type];if(
this.key){this._keyChanged(this.key)}},byKey:function(key){return this._metaData
&&this._metaData[key]}})})();Polymer({is:"iron-icon",properties:{icon:{type:Stri
ng,observer:"_iconChanged"},theme:{type:String,observer:"_updateIcon"},src:{type
:String,observer:"_srcChanged"},_meta:{value:Polymer.Base.create("iron-meta",{ty
pe:"iconset"}),observer:"_updateIcon"}},_DEFAULT_ICONSET:"icons",_iconChanged:fu
nction(icon){var parts=(icon||"").split(":");this._iconName=parts.pop();this._ic
onsetName=parts.pop()||this._DEFAULT_ICONSET;this._updateIcon()},_srcChanged:fun
ction(src){this._updateIcon()},_usesIconset:function(){return this.icon||!this.s
rc},_updateIcon:function(){if(this._usesIconset()){if(this._img&&this._img.paren
tNode){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-ico
nset-added","_updateIcon")}else{this.listen(window,"iron-iconset-added","_update
Icon")}}}else{if(this._iconset){this._iconset.removeIcon(this)}if(!this._img){th
is._img=document.createElement("img");this._img.style.width="100%";this._img.sty
le.height="100%";this._img.draggable=false}this._img.src=this.src;Polymer.dom(th
is.root).appendChild(this._img)}}});Polymer({is:"iron-iconset-svg",properties:{n
ame:{type:String,observer:"_nameChanged"},size:{type:Number,value:24},rtlMirrori
ng:{type:Boolean,value:false}},_targetIsRTL:function(target){if(target&&target.n
odeType!==Node.ELEMENT_NODE){target=target.host}return target&&window.getCompute
dStyle(target)["direction"]==="rtl"},attached:function(){this.style.display="non
e"},getIconNames:function(){this._icons=this._createIconMap();return Object.keys
(this._icons).map(function(n){return this.name+":"+n},this)},applyIcon:function(
element,iconName){element=element.root||element;this.removeIcon(element);var svg
=this._cloneIcon(iconName,this.rtlMirroring&&this._targetIsRTL(element));if(svg)
{var pde=Polymer.dom(element);pde.insertBefore(svg,pde.childNodes[0]);return ele
ment._svgIcon=svg}return null},removeIcon:function(element){element=element.root
||element;if(element._svgIcon){Polymer.dom(element).removeChild(element._svgIcon
);element._svgIcon=null}},_nameChanged:function(){new Polymer.IronMeta({type:"ic
onset",key:this.name,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[ic
on.id]=icon});return icons},_cloneIcon:function(id,mirrorAllowed){this._icons=th
is._icons||this._createIconMap();return this._prepareSvgClone(this._icons[id],th
is.size,mirrorAllowed)},_prepareSvgClone:function(sourceSvg,size,mirrorAllowed){
if(sourceSvg){var content=sourceSvg.cloneNode(true),svg=document.createElementNS
("http://www.w3.org/2000/svg","svg"),viewBox=content.getAttribute("viewBox")||"0
0 "+size+" "+size,cssText="pointer-events: none; display: block; width: 100%; h
eight: 100%;";if(mirrorAllowed&&content.hasAttribute("mirror-in-rtl")){cssText+=
"-webkit-transform:scale(-1,1);transform:scale(-1,1);"}svg.setAttribute("viewBox
",viewBox);svg.setAttribute("preserveAspectRatio","xMidYMid meet");svg.style.css
Text=cssText;svg.appendChild(content).removeAttribute("id");return svg}return nu
ll}}); |
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 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";var KEY_IDENTIFIER={"U+0008":"backspace","U+0
009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"};var KEY_CODE={8:"back
space",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(b
ar)?/;var ESC_KEY=/^escape$/;function transformKey(key,noSpecialChars){var valid
Key="";if(key){var lKey=key.toLowerCase();if(lKey===" "||SPACE_KEY.test(lKey)){v
alidKey="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.tes
t(lKey)){validKey=lKey.replace("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_IDENTIF
IER[keyIdent]}else if(IDENT_CHAR.test(keyIdent)){keyIdent=parseInt(keyIdent.repl
ace("U+","0x"),16);validKey=String.fromCharCode(keyIdent).toLowerCase()}else{val
idKey=keyIdent.toLowerCase()}}return validKey}function transformKeyCode(keyCode)
{var validKey="";if(Number(keyCode)){if(keyCode>=65&&keyCode<=90){validKey=Strin
g.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode<=123){validKey="f"+(key
Code-112)}else if(keyCode>=48&&keyCode<=57){validKey=String(keyCode-48)}else if(
keyCode>=96&&keyCode<=105){validKey=String(keyCode-96)}else{validKey=KEY_CODE[ke
yCode]}}return validKey}function normalizedKeyForEvent(keyEvent,noSpecialChars){
if(keyEvent.key){return transformKey(keyEvent.key,noSpecialChars)}if(keyEvent.de
tail&&keyEvent.detail.key){return transformKey(keyEvent.detail.key,noSpecialChar
s)}return transformKeyIdentifier(keyEvent.keyIdentifier)||transformKeyCode(keyEv
ent.keyCode)||""}function keyComboMatchesEvent(keyCombo,event){var keyEvent=norm
alizedKeyForEvent(event,keyCombo.hasModifiers);return keyEvent===keyCombo.key&&(
!keyCombo.hasModifiers||!!event.shiftKey===!!keyCombo.shiftKey&&!!event.ctrlKey=
==!!keyCombo.ctrlKey&&!!event.altKey===!!keyCombo.altKey&&!!event.metaKey===!!ke
yCombo.metaKey)}function parseKeyComboString(keyComboString){if(keyComboString.l
ength===1){return{combo:keyComboString,key:keyComboString,event:"keydown"}}retur
n keyComboString.split("+").reduce(function(parsedKeyCombo,keyComboPart){var eve
ntParts=keyComboPart.split(":");var keyName=eventParts[0];var event=eventParts[1
];if(keyName in MODIFIER_KEYS){parsedKeyCombo[MODIFIER_KEYS[keyName]]=true;parse
dKeyCombo.hasModifiers=true}else{parsedKeyCombo.key=keyName;parsedKeyCombo.event
=event||"keydown"}return parsedKeyCombo},{combo:keyComboString.split(":").shift(
)})}function parseEventString(eventString){return eventString.trim().split(" ").
map(function(keyComboString){return parseKeyComboString(keyComboString)})}Polyme
r.IronA11yKeysBehavior={properties:{keyEventTarget:{type:Object,value:function()
{return this}},stopKeyboardEventPropagation:{type:Boolean,value:false},_boundKey
Handlers:{type:Array,value:function(){return[]}},_imperativeKeyBindings:{type:Ob
ject,value:function(){return{}}}},observers:["_resetKeyEventListeners(keyEventTa
rget, _boundKeyHandlers)"],keyBindings:{},registered:function(){this._prepKeyBin
dings()},attached:function(){this._listenKeyEventListeners()},detached:function(
){this._unlistenKeyEventListeners()},addOwnKeyBinding:function(eventString,handl
erName){this._imperativeKeyBindings[eventString]=handlerName;this._prepKeyBindin
gs();this._resetKeyEventListeners()},removeOwnKeyBindings:function(){this._imper
ativeKeyBindings={};this._prepKeyBindings();this._resetKeyEventListeners()},keyb
oardEventMatchesKeys:function(event,eventString){var keyCombos=parseEventString(
eventString);for(var i=0;i<keyCombos.length;++i){if(keyComboMatchesEvent(keyComb
os[i],event)){return true}}return false},_collectKeyBindings:function(){var keyB
indings=this.behaviors.map(function(behavior){return behavior.keyBindings});if(k
eyBindings.indexOf(this.keyBindings)===-1){keyBindings.push(this.keyBindings)}re
turn keyBindings},_prepKeyBindings:function(){this._keyBindings={};this._collect
KeyBindings().forEach(function(keyBindings){for(var eventString in keyBindings){
this._addKeyBinding(eventString,keyBindings[eventString])}},this);for(var eventS
tring in this._imperativeKeyBindings){this._addKeyBinding(eventString,this._impe
rativeKeyBindings[eventString])}for(var eventName in this._keyBindings){this._ke
yBindings[eventName].sort(function(kb1,kb2){var b1=kb1[0].hasModifiers;var b2=kb
2[0].hasModifiers;return b1===b2?0:b1?-1:1})}},_addKeyBinding:function(eventStri
ng,handlerName){parseEventString(eventString).forEach(function(keyCombo){this._k
eyBindings[keyCombo.event]=this._keyBindings[keyCombo.event]||[];this._keyBindin
gs[keyCombo.event].push([keyCombo,handlerName])},this)},_resetKeyEventListeners:
function(){this._unlistenKeyEventListeners();if(this.isAttached){this._listenKey
EventListeners()}},_listenKeyEventListeners:function(){if(!this.keyEventTarget){
return}Object.keys(this._keyBindings).forEach(function(eventName){var keyBinding
s=this._keyBindings[eventName];var boundKeyHandler=this._onKeyBindingEvent.bind(
this,keyBindings);this._boundKeyHandlers.push([this.keyEventTarget,eventName,bou
ndKeyHandler]);this.keyEventTarget.addEventListener(eventName,boundKeyHandler)},
this)},_unlistenKeyEventListeners:function(){var keyHandlerTuple;var keyEventTar
get;var eventName;var boundKeyHandler;while(this._boundKeyHandlers.length){keyHa
ndlerTuple=this._boundKeyHandlers.pop();keyEventTarget=keyHandlerTuple[0];eventN
ame=keyHandlerTuple[1];boundKeyHandler=keyHandlerTuple[2];keyEventTarget.removeE
ventListener(eventName,boundKeyHandler)}},_onKeyBindingEvent:function(keyBinding
s,event){if(this.stopKeyboardEventPropagation){event.stopPropagation()}if(event.
defaultPrevented){return}for(var i=0;i<keyBindings.length;i++){var keyCombo=keyB
indings[i][0];var handlerName=keyBindings[i][1];if(keyComboMatchesEvent(keyCombo
,event)){this._triggerKeyHandler(keyCombo,handlerName,event);if(event.defaultPre
vented){return}}}},_triggerKeyHandler:function(keyCombo,handlerName,keyboardEven
t){var detail=Object.create(keyCombo);detail.keyboardEvent=keyboardEvent;var eve
nt=new CustomEvent(keyCombo.event,{detail:detail,cancelable:true});this[handlerN
ame].call(this,event);if(event.defaultPrevented){keyboardEvent.preventDefault()}
}}})();Polymer.IronControlState={properties:{focused:{type:Boolean,value:false,n
otify:true,readOnly:true,reflectToAttribute:true},disabled:{type:Boolean,value:f
alse,notify:true,observer:"_disabledChanged",reflectToAttribute:true},_oldTabInd
ex:{type:Number},_boundFocusBlurHandler:{type:Function,value:function(){return t
his._focusBlurHandler.bind(this)}}},observers:["_changedControlState(focused, di
sabled)"],ready:function(){this.addEventListener("focus",this._boundFocusBlurHan
dler,true);this.addEventListener("blur",this._boundFocusBlurHandler,true)},_focu
sBlurHandler: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},{no
de: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=thi
s.tabIndex;this._setFocused(false);this.tabIndex=-1;this.blur()}else if(this._ol
dTabIndex!==undefined){this.tabIndex=this._oldTabIndex}},_changedControlState:fu
nction(){if(this._controlStateChanged){this._controlStateChanged()}}};Polymer.Ir
onButtonStateImpl={properties:{pressed:{type:Boolean,readOnly:true,value:false,r
eflectToAttribute:true,observer:"_pressedChanged"},toggles:{type:Boolean,value:f
alse,reflectToAttribute:true},active:{type:Boolean,value:false,notify:true,refle
ctToAttribute:true},pointerDown:{type:Boolean,readOnly:true,value:false},receive
dFocusFromKeyboard:{type:Boolean,readOnly:true},ariaActiveAttribute:{type:String
,value:"aria-pressed",observer:"_ariaActiveAttributeChanged"}},listeners:{down:"
_downHandler",up:"_upHandler",tap:"_tapHandler"},observers:["_detectKeyboardFocu
s(focused)","_activeChanged(active, ariaActiveAttribute)"],keyBindings:{"enter:k
eydown":"_asyncClick","space:keydown":"_spaceKeyDownHandler","space:keyup":"_spa
ceKeyUpHandler"},_mouseEventRe:/^mouse/,_tapHandler:function(){if(this.toggles){
this._userActivate(!this.active)}else{this.active=false}},_detectKeyboardFocus:f
unction(focused){this._setReceivedFocusFromKeyboard(!this.pointerDown&&focused)}
,_userActivate:function(active){if(this.active!==active){this.active=active;this
.fire("change")}},_downHandler:function(event){this._setPointerDown(true);this._
setPressed(true);this._setReceivedFocusFromKeyboard(false)},_upHandler:function(
){this._setPointerDown(false);this._setPressed(false)},_spaceKeyDownHandler:func
tion(event){var keyboardEvent=event.detail.keyboardEvent;var target=Polymer.dom(
keyboardEvent).localTarget;if(this.isLightDescendant(target))return;keyboardEven
t.preventDefault();keyboardEvent.stopImmediatePropagation();this._setPressed(tru
e)},_spaceKeyUpHandler:function(event){var keyboardEvent=event.detail.keyboardEv
ent;var target=Polymer.dom(keyboardEvent).localTarget;if(this.isLightDescendant(
target))return;if(this.pressed){this._asyncClick()}this._setPressed(false)},_asy
ncClick:function(){this.async(function(){this.click()},1)},_pressedChanged:funct
ion(pressed){this._changedButtonState()},_ariaActiveAttributeChanged:function(va
lue,oldValue){if(oldValue&&oldValue!=value&&this.hasAttribute(oldValue)){this.re
moveAttribute(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._buttonState
Changed){this._buttonStateChanged()}}};Polymer.IronButtonState=[Polymer.IronA11y
KeysBehavior,Polymer.IronButtonStateImpl];(function(){var Utility={distance:func
tion(x1,y1,x2,y2){var xDelta=x1-x2;var yDelta=y1-y2;return Math.sqrt(xDelta*xDel
ta+yDelta*yDelta)},now:window.performance&&window.performance.now?window.perform
ance.now.bind(window.performance):Date.now};function ElementMetrics(element){thi
s.element=element;this.width=this.boundingRect.width;this.height=this.boundingRe
ct.height;this.size=Math.max(this.width,this.height)}ElementMetrics.prototype={g
et boundingRect(){return this.element.getBoundingClientRect()},furthestCornerDis
tanceFrom:function(x,y){var topLeft=Utility.distance(x,y,0,0);var topRight=Utili
ty.distance(x,y,this.width,0);var bottomLeft=Utility.distance(x,y,0,this.height)
;var bottomRight=Utility.distance(x,y,this.width,this.height);return Math.max(to
pLeft,topRight,bottomLeft,bottomRight)}};function Ripple(element){this.element=e
lement;this.color=window.getComputedStyle(element).color;this.wave=document.crea
teElement("div");this.waveContainer=document.createElement("div");this.wave.styl
e.backgroundColor=this.color;this.wave.classList.add("wave");this.waveContainer.
classList.add("wave-container");Polymer.dom(this.waveContainer).appendChild(this
.wave);this.resetInteractionState()}Ripple.MAX_RADIUS=300;Ripple.prototype={get
recenters(){return this.element.recenters},get center(){return this.element.cent
er},get mouseDownElapsed(){var elapsed;if(!this.mouseDownStart){return 0}elapsed
=Utility.now()-this.mouseDownStart;if(this.mouseUpStart){elapsed-=this.mouseUpEl
apsed}return elapsed},get mouseUpElapsed(){return this.mouseUpStart?Utility.now(
)-this.mouseUpStart:0},get mouseDownElapsedSeconds(){return this.mouseDownElapse
d/1e3},get mouseUpElapsedSeconds(){return this.mouseUpElapsed/1e3},get mouseInte
ractionSeconds(){return this.mouseDownElapsedSeconds+this.mouseUpElapsedSeconds}
,get initialOpacity(){return this.element.initialOpacity},get opacityDecayVeloci
ty(){return this.element.opacityDecayVelocity},get radius(){var width2=this.cont
ainerMetrics.width*this.containerMetrics.width;var height2=this.containerMetrics
.height*this.containerMetrics.height;var waveRadius=Math.min(Math.sqrt(width2+he
ight2),Ripple.MAX_RADIUS)*1.1+5;var duration=1.1-.2*(waveRadius/Ripple.MAX_RADIU
S);var timeNow=this.mouseInteractionSeconds/duration;var size=waveRadius*(1-Math
.pow(80,-timeNow));return Math.abs(size)},get opacity(){if(!this.mouseUpStart){r
eturn this.initialOpacity}return Math.max(0,this.initialOpacity-this.mouseUpElap
sedSeconds*this.opacityDecayVelocity)},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 isRestingAtMaxRad
ius(){return this.opacity>=this.initialOpacity&&this.radius>=Math.min(this.maxRa
dius,Ripple.MAX_RADIUS)},get isAnimationComplete(){return this.mouseUpStart?this
.isOpacityFullyDecayed:this.isRestingAtMaxRadius},get translationFraction(){retu
rn Math.min(1,this.radius/this.containerMetrics.size*2/Math.sqrt(2))},get xNow()
{if(this.xEnd){return this.xStart+this.translationFraction*(this.xEnd-this.xStar
t)}return this.xStart},get yNow(){if(this.yEnd){return this.yStart+this.translat
ionFraction*(this.yEnd-this.yStart)}return this.yStart},get isMouseDown(){return
this.mouseDownStart&&!this.mouseUpStart},resetInteractionState:function(){this.
maxRadius=0;this.mouseDownStart=0;this.mouseUpStart=0;this.xStart=0;this.yStart=
0;this.xEnd=0;this.yEnd=0;this.slideDistance=0;this.containerMetrics=new Element
Metrics(this.element)},draw:function(){var scale;var translateString;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=this.yNow-this.containerM
etrics.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.tr
ansform="scale3d("+scale+","+scale+",1)"},downAction:function(event){var xCenter
=this.containerMetrics.width/2;var yCenter=this.containerMetrics.height/2;this.r
esetInteractionState();this.mouseDownStart=Utility.now();if(this.center){this.xS
tart=xCenter;this.yStart=yCenter;this.slideDistance=Utility.distance(this.xStart
,this.yStart,this.xEnd,this.yEnd)}else{this.xStart=event?event.detail.x-this.con
tainerMetrics.boundingRect.left:this.containerMetrics.width/2;this.yStart=event?
event.detail.y-this.containerMetrics.boundingRect.top:this.containerMetrics.heig
ht/2}if(this.recenters){this.xEnd=xCenter;this.yEnd=yCenter;this.slideDistance=U
tility.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)}this.maxRadius=this
.containerMetrics.furthestCornerDistanceFrom(this.xStart,this.yStart);this.waveC
ontainer.style.top=(this.containerMetrics.height-this.containerMetrics.size)/2+"
px";this.waveContainer.style.left=(this.containerMetrics.width-this.containerMet
rics.size)/2+"px";this.waveContainer.style.width=this.containerMetrics.size+"px"
;this.waveContainer.style.height=this.containerMetrics.size+"px"},upAction:funct
ion(event){if(!this.isMouseDown){return}this.mouseUpStart=Utility.now()},remove:
function(){Polymer.dom(this.waveContainer.parentNode).removeChild(this.waveConta
iner)}};Polymer({is:"paper-ripple",behaviors:[Polymer.IronA11yKeysBehavior],prop
erties:{initialOpacity:{type:Number,value:.25},opacityDecayVelocity:{type:Number
,value:.8},recenters:{type:Boolean,value:false},center:{type:Boolean,value:false
},ripples:{type:Array,value:function(){return[]}},animating:{type:Boolean,readOn
ly:true,reflectToAttribute:true,value:false},holdDown:{type:Boolean,value:false,
observer:"_holdDownChanged"},noink:{type:Boolean,value:false},_animating:{type:B
oolean},_boundAnimate:{type:Function,value:function(){return this.animate.bind(t
his)}}},get target(){return this.keyEventTarget},keyBindings:{"enter:keydown":"_
onEnterKeydown","space:keydown":"_onSpaceKeydown","space:keyup":"_onSpaceKeyup"}
,attached:function(){if(this.parentNode.nodeType==11){this.keyEventTarget=Polyme
r.dom(this).getOwnerRoot().host}else{this.keyEventTarget=this.parentNode}var key
EventTarget=this.keyEventTarget;this.listen(keyEventTarget,"up","uiUpAction");th
is.listen(keyEventTarget,"down","uiDownAction")},detached:function(){this.unlist
en(this.keyEventTarget,"up","uiUpAction");this.unlisten(this.keyEventTarget,"dow
n","uiDownAction");this.keyEventTarget=null},get shouldKeepAnimating(){for(var i
ndex=0;index<this.ripples.length;++index){if(!this.ripples[index].isAnimationCom
plete){return true}}return false},simulatedRipple:function(){this.downAction(nul
l);this.async(function(){this.upAction()},1)},uiDownAction:function(event){if(!t
his.noink){this.downAction(event)}},downAction:function(event){if(this.holdDown&
&this.ripples.length>0){return}var ripple=this.addRipple();ripple.downAction(eve
nt);if(!this._animating){this._animating=true;this.animate()}},uiUpAction:functi
on(event){if(!this.noink){this.upAction(event)}},upAction:function(event){if(thi
s.holdDown){return}this.ripples.forEach(function(ripple){ripple.upAction(event)}
);this._animating=true;this.animate()},onAnimationComplete:function(){this._anim
ating=false;this.$.background.style.backgroundColor=null;this.fire("transitionen
d")},addRipple:function(){var ripple=new Ripple(this);Polymer.dom(this.$.waves).
appendChild(ripple.waveContainer);this.$.background.style.backgroundColor=ripple
.color;this.ripples.push(ripple);this._setAnimating(true);return ripple},removeR
ipple:function(ripple){var rippleIndex=this.ripples.indexOf(ripple);if(rippleInd
ex<0){return}this.ripples.splice(rippleIndex,1);ripple.remove();if(!this.ripples
.length){this._setAnimating(false)}},animate:function(){if(!this._animating){ret
urn}var index;var ripple;for(index=0;index<this.ripples.length;++index){ripple=t
his.ripples[index];ripple.draw();this.$.background.style.opacity=ripple.outerOpa
city;if(ripple.isOpacityFullyDecayed&&!ripple.isRestingAtMaxRadius){this.removeR
ipple(ripple)}}if(!this.shouldKeepAnimating&&this.ripples.length===0){this.onAni
mationComplete()}else{window.requestAnimationFrame(this._boundAnimate)}},_onEnte
rKeydown:function(){this.uiDownAction();this.async(this.uiUpAction,1)},_onSpaceK
eydown:function(){this.uiDownAction()},_onSpaceKeyup:function(){this.uiUpAction(
)},_holdDownChanged:function(newVal,oldVal){if(oldVal===undefined){return}if(new
Val){this.downAction()}else{this.upAction()}}})})();Polymer.PaperRippleBehavior=
{properties:{noink:{type:Boolean,observer:"_noinkChanged"},_rippleContainer:{typ
e: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(optTri
ggeringEvent){if(!this.hasRipple()){this._ripple=this._createRipple();this._ripp
le.noink=this.noink;var rippleContainer=this._rippleContainer||this.root;if(ripp
leContainer){Polymer.dom(rippleContainer).appendChild(this._ripple)}if(optTrigge
ringEvent){var domContainer=Polymer.dom(this._rippleContainer||this);var target=
Polymer.dom(optTriggeringEvent).rootTarget;if(domContainer.deepContains(target))
{this._ripple.uiDownAction(optTriggeringEvent)}}}},getRipple:function(){this.ens
ureRipple();return this._ripple},hasRipple:function(){return Boolean(this._rippl
e)},_createRipple:function(){return document.createElement("paper-ripple")},_noi
nkChanged:function(noink){if(this.hasRipple()){this._ripple.noink=noink}}};Polym
er.PaperInkyFocusBehaviorImpl={observers:["_focusedChanged(receivedFocusFromKeyb
oard)"],_focusedChanged:function(receivedFocusFromKeyboard){if(receivedFocusFrom
Keyboard){this.ensureRipple()}if(this.hasRipple()){this._ripple.holdDown=receive
dFocusFromKeyboard}},_createRipple:function(){var ripple=Polymer.PaperRippleBeha
vior._createRipple();ripple.id="ink";ripple.setAttribute("center","");ripple.cla
ssList.add("circle");return ripple}};Polymer.PaperInkyFocusBehavior=[Polymer.Iro
nButtonState,Polymer.IronControlState,Polymer.PaperRippleBehavior,Polymer.PaperI
nkyFocusBehaviorImpl];Polymer({is:"paper-icon-button",hostAttributes:{role:"butt
on",tabindex:"0"},behaviors:[Polymer.PaperInkyFocusBehavior],properties:{src:{ty
pe:String},icon:{type:String},alt:{type:String,observer:"_altChanged"}},_altChan
ged:function(newValue,oldValue){var label=this.getAttribute("aria-label");if(!la
bel||oldValue==label){this.setAttribute("aria-label",newValue)}}});Polymer.Paper
SpinnerBehavior={listeners:{animationend:"__reset",webkitAnimationEnd:"__reset"}
,properties:{active:{type:Boolean,value:false,reflectToAttribute:true,observer:"
__activeChanged"},alt:{type:String,value:"loading",observer:"__altChanged"},__co
olingDown:{type:Boolean,value:false}},__computeContainerClasses:function(active,
coolingDown){return[active||coolingDown?"active":"",coolingDown?"cooldown":""].j
oin(" ")},__activeChanged:function(active,old){this.__setAriaHidden(!active);thi
s.__coolingDown=!active&&old},__altChanged:function(alt){if(alt===this.getProper
tyInfo("alt").value){this.alt=this.getAttribute("aria-label")||alt}else{this.__s
etAriaHidden(alt==="");this.setAttribute("aria-label",alt)}},__setAriaHidden:fun
ction(hidden){var attr="aria-hidden";if(hidden){this.setAttribute(attr,"true")}e
lse{this.removeAttribute(attr)}},__reset:function(){this.active=false;this.__coo
lingDown=false}};Polymer({is:"paper-spinner-lite",behaviors:[Polymer.PaperSpinne
rBehavior]}); | 20 Polymer({is:"cr-lazy-render",extends:"template",behaviors:[Polymer.Templatizer],
child_:null,get:function(){if(!this.child_)this.render_();return this.child_},ge
tIfExists:function(){return this.child_},render_:function(){if(!this.ctor)this.t
emplatize(this);var parentNode=this.parentNode;if(parentNode&&!this.child_){var
instance=this.stamp({});this.child_=instance.root.firstElementChild;parentNode.i
nsertBefore(instance.root,this)}},_forwardParentProp:function(prop,value){if(thi
s.child_)this.child_._templateInstance[prop]=value},_forwardParentPath:function(
path,value){if(this.child_)this.child_._templateInstance.notifyPath(path,value,t
rue)}});(function(){"use strict";var KEY_IDENTIFIER={"U+0008":"backspace","U+000
9":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"};var KEY_CODE={8:"backsp
ace",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_K
EYS={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 validKe
y="";if(key){var lKey=key.toLowerCase();if(lKey===" "||SPACE_KEY.test(lKey)){val
idKey="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 transformKeyIdentifier(keyIdent){va
r validKey="";if(keyIdent){if(keyIdent in KEY_IDENTIFIER){validKey=KEY_IDENTIFIE
R[keyIdent]}else if(IDENT_CHAR.test(keyIdent)){keyIdent=parseInt(keyIdent.replac
e("U+","0x"),16);validKey=String.fromCharCode(keyIdent).toLowerCase()}else{valid
Key=keyIdent.toLowerCase()}}return validKey}function transformKeyCode(keyCode){v
ar validKey="";if(Number(keyCode)){if(keyCode>=65&&keyCode<=90){validKey=String.
fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode<=123){validKey="f"+(keyCo
de-112)}else if(keyCode>=48&&keyCode<=57){validKey=String(keyCode-48)}else if(ke
yCode>=96&&keyCode<=105){validKey=String(keyCode-96)}else{validKey=KEY_CODE[keyC
ode]}}return validKey}function normalizedKeyForEvent(keyEvent,noSpecialChars){if
(keyEvent.key){return transformKey(keyEvent.key,noSpecialChars)}if(keyEvent.deta
il&&keyEvent.detail.key){return transformKey(keyEvent.detail.key,noSpecialChars)
}return transformKeyIdentifier(keyEvent.keyIdentifier)||transformKeyCode(keyEven
t.keyCode)||""}function keyComboMatchesEvent(keyCombo,event){var keyEvent=normal
izedKeyForEvent(event,keyCombo.hasModifiers);return keyEvent===keyCombo.key&&(!k
eyCombo.hasModifiers||!!event.shiftKey===!!keyCombo.shiftKey&&!!event.ctrlKey===
!!keyCombo.ctrlKey&&!!event.altKey===!!keyCombo.altKey&&!!event.metaKey===!!keyC
ombo.metaKey)}function parseKeyComboString(keyComboString){if(keyComboString.len
gth===1){return{combo:keyComboString,key:keyComboString,event:"keydown"}}return
keyComboString.split("+").reduce(function(parsedKeyCombo,keyComboPart){var event
Parts=keyComboPart.split(":");var keyName=eventParts[0];var event=eventParts[1];
if(keyName in MODIFIER_KEYS){parsedKeyCombo[MODIFIER_KEYS[keyName]]=true;parsedK
eyCombo.hasModifiers=true}else{parsedKeyCombo.key=keyName;parsedKeyCombo.event=e
vent||"keydown"}return parsedKeyCombo},{combo:keyComboString.split(":").shift()}
)}function parseEventString(eventString){return eventString.trim().split(" ").ma
p(function(keyComboString){return parseKeyComboString(keyComboString)})}Polymer.
IronA11yKeysBehavior={properties:{keyEventTarget:{type:Object,value:function(){r
eturn this}},stopKeyboardEventPropagation:{type:Boolean,value:false},_boundKeyHa
ndlers:{type:Array,value:function(){return[]}},_imperativeKeyBindings:{type:Obje
ct,value:function(){return{}}}},observers:["_resetKeyEventListeners(keyEventTarg
et, _boundKeyHandlers)"],keyBindings:{},registered:function(){this._prepKeyBindi
ngs()},attached:function(){this._listenKeyEventListeners()},detached:function(){
this._unlistenKeyEventListeners()},addOwnKeyBinding:function(eventString,handler
Name){this._imperativeKeyBindings[eventString]=handlerName;this._prepKeyBindings
();this._resetKeyEventListeners()},removeOwnKeyBindings:function(){this._imperat
iveKeyBindings={};this._prepKeyBindings();this._resetKeyEventListeners()},keyboa
rdEventMatchesKeys:function(event,eventString){var keyCombos=parseEventString(ev
entString);for(var i=0;i<keyCombos.length;++i){if(keyComboMatchesEvent(keyCombos
[i],event)){return true}}return false},_collectKeyBindings:function(){var keyBin
dings=this.behaviors.map(function(behavior){return behavior.keyBindings});if(key
Bindings.indexOf(this.keyBindings)===-1){keyBindings.push(this.keyBindings)}retu
rn keyBindings},_prepKeyBindings:function(){this._keyBindings={};this._collectKe
yBindings().forEach(function(keyBindings){for(var eventString in keyBindings){th
is._addKeyBinding(eventString,keyBindings[eventString])}},this);for(var eventStr
ing in this._imperativeKeyBindings){this._addKeyBinding(eventString,this._impera
tiveKeyBindings[eventString])}for(var eventName in this._keyBindings){this._keyB
indings[eventName].sort(function(kb1,kb2){var b1=kb1[0].hasModifiers;var b2=kb2[
0].hasModifiers;return b1===b2?0:b1?-1:1})}},_addKeyBinding:function(eventString
,handlerName){parseEventString(eventString).forEach(function(keyCombo){this._key
Bindings[keyCombo.event]=this._keyBindings[keyCombo.event]||[];this._keyBindings
[keyCombo.event].push([keyCombo,handlerName])},this)},_resetKeyEventListeners:fu
nction(){this._unlistenKeyEventListeners();if(this.isAttached){this._listenKeyEv
entListeners()}},_listenKeyEventListeners:function(){if(!this.keyEventTarget){re
turn}Object.keys(this._keyBindings).forEach(function(eventName){var keyBindings=
this._keyBindings[eventName];var boundKeyHandler=this._onKeyBindingEvent.bind(th
is,keyBindings);this._boundKeyHandlers.push([this.keyEventTarget,eventName,bound
KeyHandler]);this.keyEventTarget.addEventListener(eventName,boundKeyHandler)},th
is)},_unlistenKeyEventListeners:function(){var keyHandlerTuple;var keyEventTarge
t;var eventName;var boundKeyHandler;while(this._boundKeyHandlers.length){keyHand
lerTuple=this._boundKeyHandlers.pop();keyEventTarget=keyHandlerTuple[0];eventNam
e=keyHandlerTuple[1];boundKeyHandler=keyHandlerTuple[2];keyEventTarget.removeEve
ntListener(eventName,boundKeyHandler)}},_onKeyBindingEvent:function(keyBindings,
event){if(this.stopKeyboardEventPropagation){event.stopPropagation()}if(event.de
faultPrevented){return}for(var i=0;i<keyBindings.length;i++){var keyCombo=keyBin
dings[i][0];var handlerName=keyBindings[i][1];if(keyComboMatchesEvent(keyCombo,e
vent)){this._triggerKeyHandler(keyCombo,handlerName,event);if(event.defaultPreve
nted){return}}}},_triggerKeyHandler:function(keyCombo,handlerName,keyboardEvent)
{var detail=Object.create(keyCombo);detail.keyboardEvent=keyboardEvent;var event
=new CustomEvent(keyCombo.event,{detail:detail,cancelable:true});this[handlerNam
e].call(this,event);if(event.defaultPrevented){keyboardEvent.preventDefault()}}}
})();Polymer.IronControlState={properties:{focused:{type:Boolean,value:false,not
ify:true,readOnly:true,reflectToAttribute:true},disabled:{type:Boolean,value:fal
se,notify:true,observer:"_disabledChanged",reflectToAttribute:true},_oldTabIndex
:{type:Number},_boundFocusBlurHandler:{type:Function,value:function(){return thi
s._focusBlurHandler.bind(this)}}},observers:["_changedControlState(focused, disa
bled)"],ready:function(){this.addEventListener("focus",this._boundFocusBlurHandl
er,true);this.addEventListener("blur",this._boundFocusBlurHandler,true)},_focusB
lurHandler: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:fu
nction(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._oldT
abIndex!==undefined){this.tabIndex=this._oldTabIndex}},_changedControlState:func
tion(){if(this._controlStateChanged){this._controlStateChanged()}}};Polymer.Iron
ButtonStateImpl={properties:{pressed:{type:Boolean,readOnly:true,value:false,ref
lectToAttribute:true,observer:"_pressedChanged"},toggles:{type:Boolean,value:fal
se,reflectToAttribute:true},active:{type:Boolean,value:false,notify:true,reflect
ToAttribute:true},pointerDown:{type:Boolean,readOnly:true,value:false},receivedF
ocusFromKeyboard:{type:Boolean,readOnly:true},ariaActiveAttribute:{type:String,v
alue:"aria-pressed",observer:"_ariaActiveAttributeChanged"}},listeners:{down:"_d
ownHandler",up:"_upHandler",tap:"_tapHandler"},observers:["_detectKeyboardFocus(
focused)","_activeChanged(active, ariaActiveAttribute)"],keyBindings:{"enter:key
down":"_asyncClick","space:keydown":"_spaceKeyDownHandler","space:keyup":"_space
KeyUpHandler"},_mouseEventRe:/^mouse/,_tapHandler:function(){if(this.toggles){th
is._userActivate(!this.active)}else{this.active=false}},_detectKeyboardFocus:fun
ction(focused){this._setReceivedFocusFromKeyboard(!this.pointerDown&&focused)},_
userActivate:function(active){if(this.active!==active){this.active=active;this.f
ire("change")}},_downHandler:function(event){this._setPointerDown(true);this._se
tPressed(true);this._setReceivedFocusFromKeyboard(false)},_upHandler:function(){
this._setPointerDown(false);this._setPressed(false)},_spaceKeyDownHandler:functi
on(event){var keyboardEvent=event.detail.keyboardEvent;var target=Polymer.dom(ke
yboardEvent).localTarget;if(this.isLightDescendant(target))return;keyboardEvent.
preventDefault();keyboardEvent.stopImmediatePropagation();this._setPressed(true)
},_spaceKeyUpHandler:function(event){var keyboardEvent=event.detail.keyboardEven
t;var target=Polymer.dom(keyboardEvent).localTarget;if(this.isLightDescendant(ta
rget))return;if(this.pressed){this._asyncClick()}this._setPressed(false)},_async
Click:function(){this.async(function(){this.click()},1)},_pressedChanged:functio
n(pressed){this._changedButtonState()},_ariaActiveAttributeChanged:function(valu
e,oldValue){if(oldValue&&oldValue!=value&&this.hasAttribute(oldValue)){this.remo
veAttribute(oldValue)}},_activeChanged:function(active,ariaActiveAttribute){if(t
his.toggles){this.setAttribute(this.ariaActiveAttribute,active?"true":"false")}e
lse{this.removeAttribute(this.ariaActiveAttribute)}this._changedButtonState()},_
controlStateChanged:function(){if(this.disabled){this._setPressed(false)}else{th
is._changedButtonState()}},_changedButtonState:function(){if(this._buttonStateCh
anged){this._buttonStateChanged()}}};Polymer.IronButtonState=[Polymer.IronA11yKe
ysBehavior,Polymer.IronButtonStateImpl];(function(){var Utility={distance:functi
on(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.performan
ce.now.bind(window.performance):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()},furthestCornerDista
nceFrom:function(x,y){var topLeft=Utility.distance(x,y,0,0);var topRight=Utility
.distance(x,y,this.width,0);var bottomLeft=Utility.distance(x,y,0,this.height);v
ar bottomRight=Utility.distance(x,y,this.width,this.height);return Math.max(topL
eft,topRight,bottomLeft,bottomRight)}};function Ripple(element){this.element=ele
ment;this.color=window.getComputedStyle(element).color;this.wave=document.create
Element("div");this.waveContainer=document.createElement("div");this.wave.style.
backgroundColor=this.color;this.wave.classList.add("wave");this.waveContainer.cl
assList.add("wave-container");Polymer.dom(this.waveContainer).appendChild(this.w
ave);this.resetInteractionState()}Ripple.MAX_RADIUS=300;Ripple.prototype={get re
centers(){return this.element.recenters},get center(){return this.element.center
},get mouseDownElapsed(){var elapsed;if(!this.mouseDownStart){return 0}elapsed=U
tility.now()-this.mouseDownStart;if(this.mouseUpStart){elapsed-=this.mouseUpElap
sed}return elapsed},get mouseUpElapsed(){return this.mouseUpStart?Utility.now()-
this.mouseUpStart:0},get mouseDownElapsedSeconds(){return this.mouseDownElapsed/
1e3},get mouseUpElapsedSeconds(){return this.mouseUpElapsed/1e3},get mouseIntera
ctionSeconds(){return this.mouseDownElapsedSeconds+this.mouseUpElapsedSeconds},g
et initialOpacity(){return this.element.initialOpacity},get opacityDecayVelocity
(){return this.element.opacityDecayVelocity},get radius(){var width2=this.contai
nerMetrics.width*this.containerMetrics.width;var height2=this.containerMetrics.h
eight*this.containerMetrics.height;var waveRadius=Math.min(Math.sqrt(width2+heig
ht2),Ripple.MAX_RADIUS)*1.1+5;var duration=1.1-.2*(waveRadius/Ripple.MAX_RADIUS)
;var timeNow=this.mouseInteractionSeconds/duration;var size=waveRadius*(1-Math.p
ow(80,-timeNow));return Math.abs(size)},get opacity(){if(!this.mouseUpStart){ret
urn this.initialOpacity}return Math.max(0,this.initialOpacity-this.mouseUpElapse
dSeconds*this.opacityDecayVelocity)},get outerOpacity(){var outerOpacity=this.mo
useUpElapsedSeconds*.3;var waveOpacity=this.opacity;return Math.max(0,Math.min(o
uterOpacity,waveOpacity))},get isOpacityFullyDecayed(){return this.opacity<.01&&
this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isRestingAtMaxRadiu
s(){return this.opacity>=this.initialOpacity&&this.radius>=Math.min(this.maxRadi
us,Ripple.MAX_RADIUS)},get isAnimationComplete(){return this.mouseUpStart?this.i
sOpacityFullyDecayed:this.isRestingAtMaxRadius},get translationFraction(){return
Math.min(1,this.radius/this.containerMetrics.size*2/Math.sqrt(2))},get xNow(){i
f(this.xEnd){return this.xStart+this.translationFraction*(this.xEnd-this.xStart)
}return this.xStart},get yNow(){if(this.yEnd){return this.yStart+this.translatio
nFraction*(this.yEnd-this.yStart)}return this.yStart},get isMouseDown(){return t
his.mouseDownStart&&!this.mouseUpStart},resetInteractionState:function(){this.ma
xRadius=0;this.mouseDownStart=0;this.mouseUpStart=0;this.xStart=0;this.yStart=0;
this.xEnd=0;this.yEnd=0;this.slideDistance=0;this.containerMetrics=new ElementMe
trics(this.element)},draw:function(){var scale;var translateString;var dx;var dy
;this.wave.style.opacity=this.opacity;scale=this.radius/(this.containerMetrics.s
ize/2);dx=this.xNow-this.containerMetrics.width/2;dy=this.yNow-this.containerMet
rics.height/2;this.waveContainer.style.webkitTransform="translate("+dx+"px, "+dy
+"px)";this.waveContainer.style.transform="translate3d("+dx+"px, "+dy+"px, 0)";t
his.wave.style.webkitTransform="scale("+scale+","+scale+")";this.wave.style.tran
sform="scale3d("+scale+","+scale+",1)"},downAction:function(event){var xCenter=t
his.containerMetrics.width/2;var yCenter=this.containerMetrics.height/2;this.res
etInteractionState();this.mouseDownStart=Utility.now();if(this.center){this.xSta
rt=xCenter;this.yStart=yCenter;this.slideDistance=Utility.distance(this.xStart,t
his.yStart,this.xEnd,this.yEnd)}else{this.xStart=event?event.detail.x-this.conta
inerMetrics.boundingRect.left:this.containerMetrics.width/2;this.yStart=event?ev
ent.detail.y-this.containerMetrics.boundingRect.top:this.containerMetrics.height
/2}if(this.recenters){this.xEnd=xCenter;this.yEnd=yCenter;this.slideDistance=Uti
lity.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)}this.maxRadius=this.c
ontainerMetrics.furthestCornerDistanceFrom(this.xStart,this.yStart);this.waveCon
tainer.style.top=(this.containerMetrics.height-this.containerMetrics.size)/2+"px
";this.waveContainer.style.left=(this.containerMetrics.width-this.containerMetri
cs.size)/2+"px";this.waveContainer.style.width=this.containerMetrics.size+"px";t
his.waveContainer.style.height=this.containerMetrics.size+"px"},upAction:functio
n(event){if(!this.isMouseDown){return}this.mouseUpStart=Utility.now()},remove:fu
nction(){Polymer.dom(this.waveContainer.parentNode).removeChild(this.waveContain
er)}};Polymer({is:"paper-ripple",behaviors:[Polymer.IronA11yKeysBehavior],proper
ties:{initialOpacity:{type:Number,value:.25},opacityDecayVelocity:{type:Number,v
alue:.8},recenters:{type:Boolean,value:false},center:{type:Boolean,value:false},
ripples:{type:Array,value:function(){return[]}},animating:{type:Boolean,readOnly
:true,reflectToAttribute:true,value:false},holdDown:{type:Boolean,value:false,ob
server:"_holdDownChanged"},noink:{type:Boolean,value:false},_animating:{type:Boo
lean},_boundAnimate:{type:Function,value:function(){return this.animate.bind(thi
s)}}},get target(){return this.keyEventTarget},keyBindings:{"enter:keydown":"_on
EnterKeydown","space:keydown":"_onSpaceKeydown","space:keyup":"_onSpaceKeyup"},a
ttached:function(){if(this.parentNode.nodeType==11){this.keyEventTarget=Polymer.
dom(this).getOwnerRoot().host}else{this.keyEventTarget=this.parentNode}var keyEv
entTarget=this.keyEventTarget;this.listen(keyEventTarget,"up","uiUpAction");this
.listen(keyEventTarget,"down","uiDownAction")},detached:function(){this.unlisten
(this.keyEventTarget,"up","uiUpAction");this.unlisten(this.keyEventTarget,"down"
,"uiDownAction");this.keyEventTarget=null},get shouldKeepAnimating(){for(var ind
ex=0;index<this.ripples.length;++index){if(!this.ripples[index].isAnimationCompl
ete){return true}}return false},simulatedRipple:function(){this.downAction(null)
;this.async(function(){this.upAction()},1)},uiDownAction:function(event){if(!thi
s.noink){this.downAction(event)}},downAction:function(event){if(this.holdDown&&t
his.ripples.length>0){return}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.ripples.forEach(function(ripple){ripple.upAction(event)});
this._animating=true;this.animate()},onAnimationComplete:function(){this._animat
ing=false;this.$.background.style.backgroundColor=null;this.fire("transitionend"
)},addRipple:function(){var ripple=new Ripple(this);Polymer.dom(this.$.waves).ap
pendChild(ripple.waveContainer);this.$.background.style.backgroundColor=ripple.c
olor;this.ripples.push(ripple);this._setAnimating(true);return ripple},removeRip
ple:function(ripple){var rippleIndex=this.ripples.indexOf(ripple);if(rippleIndex
<0){return}this.ripples.splice(rippleIndex,1);ripple.remove();if(!this.ripples.l
ength){this._setAnimating(false)}},animate:function(){if(!this._animating){retur
n}var index;var ripple;for(index=0;index<this.ripples.length;++index){ripple=thi
s.ripples[index];ripple.draw();this.$.background.style.opacity=ripple.outerOpaci
ty;if(ripple.isOpacityFullyDecayed&&!ripple.isRestingAtMaxRadius){this.removeRip
ple(ripple)}}if(!this.shouldKeepAnimating&&this.ripples.length===0){this.onAnima
tionComplete()}else{window.requestAnimationFrame(this._boundAnimate)}},_onEnterK
eydown:function(){this.uiDownAction();this.async(this.uiUpAction,1)},_onSpaceKey
down:function(){this.uiDownAction()},_onSpaceKeyup:function(){this.uiUpAction()}
,_holdDownChanged:function(newVal,oldVal){if(oldVal===undefined){return}if(newVa
l){this.downAction()}else{this.upAction()}}})})();Polymer.PaperRippleBehavior={p
roperties:{noink:{type:Boolean,observer:"_noinkChanged"},_rippleContainer:{type:
Object}},_buttonStateChanged:function(){if(this.focused){this.ensureRipple()}},_
downHandler:function(event){Polymer.IronButtonStateImpl._downHandler.call(this,e
vent);if(this.pressed){this.ensureRipple(event)}},ensureRipple:function(optTrigg
eringEvent){if(!this.hasRipple()){this._ripple=this._createRipple();this._ripple
.noink=this.noink;var rippleContainer=this._rippleContainer||this.root;if(ripple
Container){Polymer.dom(rippleContainer).appendChild(this._ripple)}if(optTriggeri
ngEvent){var domContainer=Polymer.dom(this._rippleContainer||this);var target=Po
lymer.dom(optTriggeringEvent).rootTarget;if(domContainer.deepContains(target)){t
his._ripple.uiDownAction(optTriggeringEvent)}}}},getRipple:function(){this.ensur
eRipple();return this._ripple},hasRipple:function(){return Boolean(this._ripple)
},_createRipple:function(){return document.createElement("paper-ripple")},_noink
Changed:function(noink){if(this.hasRipple()){this._ripple.noink=noink}}};Polymer
.PaperInkyFocusBehaviorImpl={observers:["_focusedChanged(receivedFocusFromKeyboa
rd)"],_focusedChanged:function(receivedFocusFromKeyboard){if(receivedFocusFromKe
yboard){this.ensureRipple()}if(this.hasRipple()){this._ripple.holdDown=receivedF
ocusFromKeyboard}},_createRipple:function(){var ripple=Polymer.PaperRippleBehavi
or._createRipple();ripple.id="ink";ripple.setAttribute("center","");ripple.class
List.add("circle");return ripple}};Polymer.PaperInkyFocusBehavior=[Polymer.IronB
uttonState,Polymer.IronControlState,Polymer.PaperRippleBehavior,Polymer.PaperInk
yFocusBehaviorImpl];Polymer({is:"paper-icon-button",hostAttributes:{role:"button
",tabindex:"0"},behaviors:[Polymer.PaperInkyFocusBehavior],properties:{src:{type
:String},icon:{type:String},alt:{type:String,observer:"_altChanged"}},_altChange
d:function(newValue,oldValue){var label=this.getAttribute("aria-label");if(!labe
l||oldValue==label){this.setAttribute("aria-label",newValue)}}});Polymer.PaperSp
innerBehavior={listeners:{animationend:"__reset",webkitAnimationEnd:"__reset"},p
roperties:{active:{type:Boolean,value:false,reflectToAttribute:true,observer:"__
activeChanged"},alt:{type:String,value:"loading",observer:"__altChanged"},__cool
ingDown:{type:Boolean,value:false}},__computeContainerClasses:function(active,co
olingDown){return[active||coolingDown?"active":"",coolingDown?"cooldown":""].joi
n(" ")},__activeChanged:function(active,old){this.__setAriaHidden(!active);this.
__coolingDown=!active&&old},__altChanged:function(alt){if(alt===this.getProperty
Info("alt").value){this.alt=this.getAttribute("aria-label")||alt}else{this.__set
AriaHidden(alt==="");this.setAttribute("aria-label",alt)}},__setAriaHidden:funct
ion(hidden){var attr="aria-hidden";if(hidden){this.setAttribute(attr,"true")}els
e{this.removeAttribute(attr)}},__reset:function(){this.active=false;this.__cooli
ngDown=false}};Polymer({is:"paper-spinner-lite",behaviors:[Polymer.PaperSpinnerB
ehavior]}); |
21 // Copyright 2016 The Chromium Authors. All rights reserved. | 21 // Copyright 2016 The Chromium Authors. All rights reserved. |
22 // Use of this source code is governed by a BSD-style license that can be | 22 // Use of this source code is governed by a BSD-style license that can be |
23 // found in the LICENSE file. | 23 // found in the LICENSE file. |
24 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{
type:String,value:""},lastValue_:{type:String,value:""}},getSearchInput:function
(){},getValue:function(){return this.getSearchInput().value},setValue:function(v
alue,opt_noEvent){var searchInput=this.getSearchInput();searchInput.value=value;
this.onValueChanged_(value,!!opt_noEvent)},onSearchTermSearch:function(){this.on
ValueChanged_(this.getValue(),false)},onValueChanged_:function(newValue,noEvent)
{if(newValue==this.lastValue_)return;this.lastValue_=newValue;if(!noEvent)this.f
ire("search-changed",newValue)}}; | 24 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{
type:String,value:""},lastValue_:{type:String,value:""}},getSearchInput:function
(){},getValue:function(){return this.getSearchInput().value},setValue:function(v
alue,opt_noEvent){var searchInput=this.getSearchInput();searchInput.value=value;
this.onValueChanged_(value,!!opt_noEvent)},onSearchTermSearch:function(){this.on
ValueChanged_(this.getValue(),false)},onValueChanged_:function(newValue,noEvent)
{if(newValue==this.lastValue_)return;this.lastValue_=newValue;if(!noEvent)this.f
ire("search-changed",newValue)}}; |
25 // Copyright 2016 The Chromium Authors. All rights reserved. | 25 // Copyright 2016 The Chromium Authors. All rights reserved. |
26 // Use of this source code is governed by a BSD-style license that can be | 26 // Use of this source code is governed by a BSD-style license that can be |
27 // found in the LICENSE file. | 27 // found in the LICENSE file. |
28 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti
es:{narrow:{type:Boolean,reflectToAttribute:true},showingSearch:{type:Boolean,va
lue:false,notify:true,observer:"showingSearchChanged_",reflectToAttribute:true},
label:String,clearLabel:String,spinnerActive:{type:Boolean,reflectToAttribute:tr
ue},hasSearchText_:{type:Boolean,reflectToAttribute:true},isSpinnerShown_:{type:
Boolean,computed:"computeIsSpinnerShown_(spinnerActive, showingSearch)"},searchF
ocused_:{type:Boolean,value:false}},listeners:{click:"showSearch_"},getSearchInp
ut:function(){return this.$.searchInput},setValue:function(value,opt_noEvent){Cr
SearchFieldBehavior.setValue.call(this,value,opt_noEvent);this.onSearchInput_()}
,isSearchFocused:function(){return this.searchFocused_},showAndFocus:function(){
this.showingSearch=true;this.focus_()},focus_:function(){this.getSearchInput().f
ocus()},computeIconTabIndex_:function(narrow){return narrow?0:-1},computeIsSpinn
erShown_:function(){return this.spinnerActive&&this.showingSearch},onInputFocus_
:function(){this.searchFocused_=true},onInputBlur_:function(){this.searchFocused
_=false;if(!this.hasSearchText_)this.showingSearch=false},onSearchInput_:functio
n(){var newValue=this.$.searchInput.value;this.hasSearchText_=newValue!="";if(ne
wValue!="")this.showingSearch=true},onSearchTermKeydown_:function(e){if(e.key=="
Escape")this.showingSearch=false},showSearch_:function(e){if(e.target!=this.$.cl
earSearch)this.showingSearch=true},clearSearch_:function(e){this.setValue("");th
is.focus_()},showingSearchChanged_:function(current,previous){if(previous==undef
ined)return;if(this.showingSearch){this.focus_();return}this.setValue("");this.g
etSearchInput().blur()}}); | 28 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti
es:{narrow:{type:Boolean,reflectToAttribute:true},showingSearch:{type:Boolean,va
lue:false,notify:true,observer:"showingSearchChanged_",reflectToAttribute:true},
label:String,clearLabel:String,spinnerActive:{type:Boolean,reflectToAttribute:tr
ue},hasSearchText_:{type:Boolean,reflectToAttribute:true},isSpinnerShown_:{type:
Boolean,computed:"computeIsSpinnerShown_(spinnerActive, showingSearch)"},searchF
ocused_:{type:Boolean,value:false}},listeners:{click:"showSearch_"},getSearchInp
ut:function(){return this.$.searchInput},setValue:function(value,opt_noEvent){Cr
SearchFieldBehavior.setValue.call(this,value,opt_noEvent);this.onSearchInput_()}
,isSearchFocused:function(){return this.searchFocused_},showAndFocus:function(){
this.showingSearch=true;this.focus_()},focus_:function(){this.getSearchInput().f
ocus()},computeIconTabIndex_:function(narrow){return narrow?0:-1},computeIsSpinn
erShown_:function(){return this.spinnerActive&&this.showingSearch},onInputFocus_
:function(){this.searchFocused_=true},onInputBlur_:function(){this.searchFocused
_=false;if(!this.hasSearchText_)this.showingSearch=false},onSearchInput_:functio
n(){var newValue=this.$.searchInput.value;this.hasSearchText_=newValue!="";if(ne
wValue!="")this.showingSearch=true},onSearchTermKeydown_:function(e){if(e.key=="
Escape")this.showingSearch=false},showSearch_:function(e){if(e.target!=this.$.cl
earSearch)this.showingSearch=true},clearSearch_:function(e){this.setValue("");th
is.focus_()},showingSearchChanged_:function(current,previous){if(previous==undef
ined)return;if(this.showingSearch){this.focus_();return}this.setValue("");this.g
etSearchInput().blur()}}); |
29 // Copyright 2016 The Chromium Authors. All rights reserved. | 29 // Copyright 2016 The Chromium Authors. All rights reserved. |
30 // Use of this source code is governed by a BSD-style license that can be | 30 // Use of this source code is governed by a BSD-style license that can be |
(...skipping 23 matching lines...) Expand all Loading... |
54 // Use of this source code is governed by a BSD-style license that can be | 54 // Use of this source code is governed by a BSD-style license that can be |
55 // found in the LICENSE file. | 55 // found in the LICENSE file. |
56 Polymer({is:"history-searched-label",properties:{title:String,searchTerm:String}
,observers:["setSearchedTextToBold_(title, searchTerm)"],setSearchedTextToBold_:
function(){var i=0;var titleText=this.title;if(this.searchTerm==""||this.searchT
erm==null){this.textContent=titleText;return}var re=new RegExp(quoteString(this.
searchTerm),"gim");var match;this.textContent="";while(match=re.exec(titleText))
{if(match.index>i)this.appendChild(document.createTextNode(titleText.slice(i,mat
ch.index)));i=re.lastIndex;var b=document.createElement("b");b.textContent=title
Text.substring(match.index,i);this.appendChild(b)}if(i<titleText.length)this.app
endChild(document.createTextNode(titleText.slice(i)))}}); | 56 Polymer({is:"history-searched-label",properties:{title:String,searchTerm:String}
,observers:["setSearchedTextToBold_(title, searchTerm)"],setSearchedTextToBold_:
function(){var i=0;var titleText=this.title;if(this.searchTerm==""||this.searchT
erm==null){this.textContent=titleText;return}var re=new RegExp(quoteString(this.
searchTerm),"gim");var match;this.textContent="";while(match=re.exec(titleText))
{if(match.index>i)this.appendChild(document.createTextNode(titleText.slice(i,mat
ch.index)));i=re.lastIndex;var b=document.createElement("b");b.textContent=title
Text.substring(match.index,i);this.appendChild(b)}if(i<titleText.length)this.app
endChild(document.createTextNode(titleText.slice(i)))}}); |
57 // Copyright 2015 The Chromium Authors. All rights reserved. | 57 // Copyright 2015 The Chromium Authors. All rights reserved. |
58 // Use of this source code is governed by a BSD-style license that can be | 58 // Use of this source code is governed by a BSD-style license that can be |
59 // found in the LICENSE file. | 59 // found in the LICENSE file. |
60 function HistoryFocusRow(root,boundary,delegate){cr.ui.FocusRow.call(this,root,b
oundary,delegate);this.addItems()}HistoryFocusRow.prototype={__proto__:cr.ui.Foc
usRow.prototype,getCustomEquivalent:function(sampleElement){var equivalent;if(th
is.getTypeForElement(sampleElement)=="star")equivalent=this.getFirstFocusable("t
itle");return equivalent||cr.ui.FocusRow.prototype.getCustomEquivalent.call(this
,sampleElement)},addItems:function(){this.destroy();assert(this.addItem("checkbo
x","#checkbox"));assert(this.addItem("title","#title"));assert(this.addItem("men
u-button","#menu-button"));this.addItem("star","#bookmark-star")}};cr.define("md
_history",function(){function FocusRowDelegate(historyItemElement){this.historyI
temElement=historyItemElement}FocusRowDelegate.prototype={onFocus:function(row,e
){this.historyItemElement.lastFocused=e.path[0]},onKeydown:function(row,e){if(e.
key=="Enter")e.stopPropagation();return false}};var HistoryItem=Polymer({is:"his
tory-item",properties:{item:{type:Object,observer:"showIcon_"},searchTerm:{type:
String},selected:{type:Boolean,reflectToAttribute:true},isCardStart:{type:Boolea
n,reflectToAttribute:true},isCardEnd:{type:Boolean,reflectToAttribute:true},embe
dded:{type:Boolean,reflectToAttribute:true},hasTimeGap:{type:Boolean},numberOfIt
ems:{type:Number},path:String,index:Number,lastFocused:{type:Object,notify:true}
,ironListTabIndex:{type:Number,observer:"ironListTabIndexChanged_"}},row_:null,a
ttached:function(){Polymer.RenderStatus.afterNextRender(this,function(){this.row
_=new HistoryFocusRow(this.$["main-container"],null,new FocusRowDelegate(this));
this.row_.makeActive(this.ironListTabIndex==0);this.listen(this,"focus","onFocus
_");this.listen(this,"dom-change","onDomChange_")})},detached:function(){this.un
listen(this,"focus","onFocus_");this.unlisten(this,"dom-change","onDomChange_");
if(this.row_)this.row_.destroy()},onFocus_:function(){if(this.lastFocused)this.r
ow_.getEquivalentElement(this.lastFocused).focus();else this.row_.getFirstFocusa
ble().focus();this.tabIndex=-1},ironListTabIndexChanged_:function(){if(this.row_
)this.row_.makeActive(this.ironListTabIndex==0)},onDomChange_:function(){if(this
.row_)this.row_.addItems()},onItemClick_:function(e){for(var i=0;i<e.path.length
;i++){var elem=e.path[i];if(elem.id!="checkbox"&&(elem.nodeName=="A"||elem.nodeN
ame=="BUTTON")){return}}if(this.selectionNotAllowed_())return;this.$.checkbox.fo
cus();this.fire("history-checkbox-select",{element:this,shiftKey:e.shiftKey})},o
nItemMousedown_:function(e){if(e.shiftKey)e.preventDefault()},getEntrySummary_:f
unction(){var item=this.item;return loadTimeData.getStringF("entrySummary",item.
dateTimeOfDay,item.starred?loadTimeData.getString("bookmarked"):"",item.title,it
em.domain)},getAriaChecked_:function(selected){return selected?"true":"false"},o
nRemoveBookmarkTap_:function(){if(!this.item.starred)return;if(this.$$("#bookmar
k-star")==this.root.activeElement)this.$["menu-button"].focus();var browserServi
ce=md_history.BrowserService.getInstance();browserService.removeBookmark(this.it
em.url);browserService.recordAction("BookmarkStarClicked");this.fire("remove-boo
kmark-stars",this.item.url)},onMenuButtonTap_:function(e){this.fire("toggle-menu
",{target:Polymer.dom(e).localTarget,index:this.index,item:this.item,path:this.p
ath});e.stopPropagation()},onLinkClick_:function(){var browserService=md_history
.BrowserService.getInstance();browserService.recordAction("EntryLinkClick");if(t
his.searchTerm)browserService.recordAction("SearchResultClick");if(this.index==u
ndefined)return;browserService.recordHistogram("HistoryPage.ClickPosition",Math.
min(this.index,UMA_MAX_BUCKET_VALUE),UMA_MAX_BUCKET_VALUE);if(this.index<=UMA_MA
X_SUBSET_BUCKET_VALUE){browserService.recordHistogram("HistoryPage.ClickPosition
Subset",this.index,UMA_MAX_SUBSET_BUCKET_VALUE)}},onLinkRightClick_:function(){m
d_history.BrowserService.getInstance().recordAction("EntryLinkRightClick")},show
Icon_:function(){this.$.icon.style.backgroundImage=cr.icon.getFavicon(this.item.
url)},selectionNotAllowed_:function(){return!loadTimeData.getBoolean("allowDelet
ingHistory")},cardTitle_:function(numberOfItems,historyDate,search){if(!search)r
eturn this.item.dateRelativeDay;return HistoryItem.searchResultsTitle(numberOfIt
ems,search)},addTimeTitle_:function(){var el=this.$["time-accessed"];el.setAttri
bute("title",new Date(this.item.time).toString());this.unlisten(el,"mouseover","
addTimeTitle_")}});HistoryItem.needsTimeGap=function(visits,currentIndex,searche
dTerm){if(currentIndex>=visits.length-1||visits.length==0)return false;var curre
ntItem=visits[currentIndex];var nextItem=visits[currentIndex+1];if(searchedTerm)
return currentItem.dateShort!=nextItem.dateShort;return currentItem.time-nextIte
m.time>BROWSING_GAP_TIME&¤tItem.dateRelativeDay==nextItem.dateRelativeDay}
;HistoryItem.searchResultsTitle=function(numberOfResults,searchTerm){var resultI
d=numberOfResults==1?"searchResult":"searchResults";return loadTimeData.getStrin
gF("foundSearchResults",numberOfResults,loadTimeData.getString(resultId),searchT
erm)};return{HistoryItem:HistoryItem}}); | 60 function HistoryFocusRow(root,boundary,delegate){cr.ui.FocusRow.call(this,root,b
oundary,delegate);this.addItems()}HistoryFocusRow.prototype={__proto__:cr.ui.Foc
usRow.prototype,getCustomEquivalent:function(sampleElement){var equivalent;if(th
is.getTypeForElement(sampleElement)=="star")equivalent=this.getFirstFocusable("t
itle");return equivalent||cr.ui.FocusRow.prototype.getCustomEquivalent.call(this
,sampleElement)},addItems:function(){this.destroy();assert(this.addItem("checkbo
x","#checkbox"));assert(this.addItem("title","#title"));assert(this.addItem("men
u-button","#menu-button"));this.addItem("star","#bookmark-star")}};cr.define("md
_history",function(){function FocusRowDelegate(historyItemElement){this.historyI
temElement=historyItemElement}FocusRowDelegate.prototype={onFocus:function(row,e
){this.historyItemElement.lastFocused=e.path[0]},onKeydown:function(row,e){if(e.
key=="Enter")e.stopPropagation();return false}};var HistoryItem=Polymer({is:"his
tory-item",properties:{item:{type:Object,observer:"showIcon_"},searchTerm:{type:
String},selected:{type:Boolean,reflectToAttribute:true},isCardStart:{type:Boolea
n,reflectToAttribute:true},isCardEnd:{type:Boolean,reflectToAttribute:true},embe
dded:{type:Boolean,reflectToAttribute:true},hasTimeGap:{type:Boolean},numberOfIt
ems:{type:Number},path:String,index:Number,lastFocused:{type:Object,notify:true}
,ironListTabIndex:{type:Number,observer:"ironListTabIndexChanged_"}},row_:null,a
ttached:function(){Polymer.RenderStatus.afterNextRender(this,function(){this.row
_=new HistoryFocusRow(this.$["main-container"],null,new FocusRowDelegate(this));
this.row_.makeActive(this.ironListTabIndex==0);this.listen(this,"focus","onFocus
_");this.listen(this,"dom-change","onDomChange_")})},detached:function(){this.un
listen(this,"focus","onFocus_");this.unlisten(this,"dom-change","onDomChange_");
if(this.row_)this.row_.destroy()},onFocus_:function(){if(this.lastFocused)this.r
ow_.getEquivalentElement(this.lastFocused).focus();else this.row_.getFirstFocusa
ble().focus();this.tabIndex=-1},ironListTabIndexChanged_:function(){if(this.row_
)this.row_.makeActive(this.ironListTabIndex==0)},onDomChange_:function(){if(this
.row_)this.row_.addItems()},onItemClick_:function(e){for(var i=0;i<e.path.length
;i++){var elem=e.path[i];if(elem.id!="checkbox"&&(elem.nodeName=="A"||elem.nodeN
ame=="BUTTON")){return}}if(this.selectionNotAllowed_())return;this.$.checkbox.fo
cus();this.fire("history-checkbox-select",{element:this,shiftKey:e.shiftKey})},o
nItemMousedown_:function(e){if(e.shiftKey)e.preventDefault()},getEntrySummary_:f
unction(){var item=this.item;return loadTimeData.getStringF("entrySummary",item.
dateTimeOfDay,item.starred?loadTimeData.getString("bookmarked"):"",item.title,it
em.domain)},getAriaChecked_:function(selected){return selected?"true":"false"},o
nRemoveBookmarkTap_:function(){if(!this.item.starred)return;if(this.$$("#bookmar
k-star")==this.root.activeElement)this.$["menu-button"].focus();var browserServi
ce=md_history.BrowserService.getInstance();browserService.removeBookmark(this.it
em.url);browserService.recordAction("BookmarkStarClicked");this.fire("remove-boo
kmark-stars",this.item.url)},onMenuButtonTap_:function(e){this.fire("toggle-menu
",{target:Polymer.dom(e).localTarget,index:this.index,item:this.item,path:this.p
ath});e.stopPropagation()},onLinkClick_:function(){var browserService=md_history
.BrowserService.getInstance();browserService.recordAction("EntryLinkClick");if(t
his.searchTerm)browserService.recordAction("SearchResultClick");if(this.index==u
ndefined)return;browserService.recordHistogram("HistoryPage.ClickPosition",Math.
min(this.index,UMA_MAX_BUCKET_VALUE),UMA_MAX_BUCKET_VALUE);if(this.index<=UMA_MA
X_SUBSET_BUCKET_VALUE){browserService.recordHistogram("HistoryPage.ClickPosition
Subset",this.index,UMA_MAX_SUBSET_BUCKET_VALUE)}},onLinkRightClick_:function(){m
d_history.BrowserService.getInstance().recordAction("EntryLinkRightClick")},show
Icon_:function(){this.$.icon.style.backgroundImage=cr.icon.getFavicon(this.item.
url)},selectionNotAllowed_:function(){return!loadTimeData.getBoolean("allowDelet
ingHistory")},cardTitle_:function(numberOfItems,historyDate,search){if(!search)r
eturn this.item.dateRelativeDay;return HistoryItem.searchResultsTitle(numberOfIt
ems,search)},addTimeTitle_:function(){var el=this.$["time-accessed"];el.setAttri
bute("title",new Date(this.item.time).toString());this.unlisten(el,"mouseover","
addTimeTitle_")}});HistoryItem.needsTimeGap=function(visits,currentIndex,searche
dTerm){if(currentIndex>=visits.length-1||visits.length==0)return false;var curre
ntItem=visits[currentIndex];var nextItem=visits[currentIndex+1];if(searchedTerm)
return currentItem.dateShort!=nextItem.dateShort;return currentItem.time-nextIte
m.time>BROWSING_GAP_TIME&¤tItem.dateRelativeDay==nextItem.dateRelativeDay}
;HistoryItem.searchResultsTitle=function(numberOfResults,searchTerm){var resultI
d=numberOfResults==1?"searchResult":"searchResults";return loadTimeData.getStrin
gF("foundSearchResults",numberOfResults,loadTimeData.getString(resultId),searchT
erm)};return{HistoryItem:HistoryItem}}); |
61 // Copyright 2016 The Chromium Authors. All rights reserved. | 61 // Copyright 2016 The Chromium Authors. All rights reserved. |
62 // Use of this source code is governed by a BSD-style license that can be | 62 // Use of this source code is governed by a BSD-style license that can be |
63 // found in the LICENSE file. | 63 // found in the LICENSE file. |
64 var SelectionTreeNode=function(currentPath){this.currentPath=currentPath;this.le
af=false;this.indexes=[];this.children=[]};SelectionTreeNode.prototype.addChild=
function(index,path){this.indexes.push(index);this.children[index]=new Selection
TreeNode(path)};var HistoryListBehavior={properties:{selectedPaths:{type:Object,
value:function(){return new Set}},lastSelectedPath:String},listeners:{"history-c
heckbox-select":"itemSelected_"},addNewResults:function(results,incremental,fini
shed){},hasResults:function(historyDataLength){return historyDataLength>0},noRes
ultsMessage:function(searchedTerm,isLoading){if(isLoading)return"";var messageId
=searchedTerm!==""?"noSearchResults":"noResults";return loadTimeData.getString(m
essageId)},unselectAllItems:function(){this.selectedPaths.forEach(function(path)
{this.set(path+".selected",false)}.bind(this));this.selectedPaths.clear()},delet
eSelected:function(){var toBeRemoved=Array.from(this.selectedPaths.values()).map
(function(path){return this.get(path)}.bind(this));md_history.BrowserService.get
Instance().deleteItems(toBeRemoved).then(function(){this.removeItemsByPath(Array
.from(this.selectedPaths));this.fire("unselect-all")}.bind(this))},removeItemsBy
Path:function(paths){if(paths.length==0)return;this.removeItemsBeneathNode_(this
.buildRemovalTree_(paths))},buildRemovalTree_:function(paths){var rootNode=new S
electionTreeNode(paths[0].split(".")[0]);paths.forEach(function(path){var compon
ents=path.split(".");var node=rootNode;components.shift();while(components.lengt
h>1){var index=Number(components.shift());var arrayName=components.shift();if(!n
ode.children[index])node.addChild(index,[node.currentPath,index,arrayName].join(
"."));node=node.children[index]}node.leaf=true;node.indexes.push(Number(componen
ts.shift()))});return rootNode},removeItemsBeneathNode_:function(node){var array
=this.get(node.currentPath);var splices=[];node.indexes.sort(function(a,b){retur
n b-a});node.indexes.forEach(function(index){if(node.leaf||this.removeItemsBenea
thNode_(node.children[index])){var item=array.splice(index,1)[0];splices.push({i
ndex:index,removed:[item],addedCount:0,object:array,type:"splice"})}}.bind(this)
);if(array.length==0&&node.currentPath.indexOf(".")!=-1)return true;this.notifyS
plices(node.currentPath,splices);return false},itemSelected_:function(e){var ite
m=e.detail.element;var paths=[];var itemPath=item.path;if(e.detail.shiftKey&&thi
s.lastSelectedPath){var itemPathComponents=itemPath.split(".");var itemIndex=Num
ber(itemPathComponents.pop());var itemArrayPath=itemPathComponents.join(".");var
lastItemPathComponents=this.lastSelectedPath.split(".");var lastItemIndex=Numbe
r(lastItemPathComponents.pop());if(itemArrayPath==lastItemPathComponents.join(".
")){for(var i=Math.min(itemIndex,lastItemIndex);i<=Math.max(itemIndex,lastItemIn
dex);i++){paths.push(itemArrayPath+"."+i)}}}if(paths.length==0)paths.push(item.p
ath);var selected=!this.selectedPaths.has(item.path);paths.forEach(function(path
){this.set(path+".selected",selected);if(selected){this.selectedPaths.add(path);
return}this.selectedPaths.delete(path)}.bind(this));this.lastSelectedPath=itemPa
th}}; | 64 var SelectionTreeNode=function(currentPath){this.currentPath=currentPath;this.le
af=false;this.indexes=[];this.children=[]};SelectionTreeNode.prototype.addChild=
function(index,path){this.indexes.push(index);this.children[index]=new Selection
TreeNode(path)};var HistoryListBehavior={properties:{selectedPaths:{type:Object,
value:()=>new Set},lastSelectedPath:String},listeners:{"history-checkbox-select"
:"itemSelected_"},addNewResults:function(results,incremental,finished){},hasResu
lts:function(historyDataLength){return historyDataLength>0},noResultsMessage:fun
ction(searchedTerm,isLoading){if(isLoading)return"";var messageId=searchedTerm!=
=""?"noSearchResults":"noResults";return loadTimeData.getString(messageId)},unse
lectAllItems:function(){this.selectedPaths.forEach(path=>this.set(path+".selecte
d",false));this.selectedPaths.clear()},deleteSelected:function(){var toBeRemoved
=Array.from(this.selectedPaths.values()).map(path=>this.get(path));md_history.Br
owserService.getInstance().deleteItems(toBeRemoved).then(()=>{this.removeItemsBy
Path(Array.from(this.selectedPaths));this.fire("unselect-all")})},removeItemsByP
ath:function(paths){if(paths.length==0)return;this.removeItemsBeneathNode_(this.
buildRemovalTree_(paths))},buildRemovalTree_:function(paths){var rootNode=new Se
lectionTreeNode(paths[0].split(".")[0]);paths.forEach(function(path){var compone
nts=path.split(".");var node=rootNode;components.shift();while(components.length
>1){var index=Number(components.shift());var arrayName=components.shift();if(!no
de.children[index])node.addChild(index,[node.currentPath,index,arrayName].join("
."));node=node.children[index]}node.leaf=true;node.indexes.push(Number(component
s.shift()))});return rootNode},removeItemsBeneathNode_:function(node){var array=
this.get(node.currentPath);var splices=[];node.indexes.sort(function(a,b){return
b-a});node.indexes.forEach(index=>{if(node.leaf||this.removeItemsBeneathNode_(n
ode.children[index])){var item=array.splice(index,1)[0];splices.push({index:inde
x,removed:[item],addedCount:0,object:array,type:"splice"})}});if(array.length==0
&&node.currentPath.indexOf(".")!=-1)return true;this.notifySplices(node.currentP
ath,splices);return false},itemSelected_:function(e){var item=e.detail.element;v
ar paths=[];var itemPath=item.path;if(e.detail.shiftKey&&this.lastSelectedPath){
var itemPathComponents=itemPath.split(".");var itemIndex=Number(itemPathComponen
ts.pop());var itemArrayPath=itemPathComponents.join(".");var lastItemPathCompone
nts=this.lastSelectedPath.split(".");var lastItemIndex=Number(lastItemPathCompon
ents.pop());if(itemArrayPath==lastItemPathComponents.join(".")){for(var i=Math.m
in(itemIndex,lastItemIndex);i<=Math.max(itemIndex,lastItemIndex);i++){paths.push
(itemArrayPath+"."+i)}}}if(paths.length==0)paths.push(item.path);var selected=!t
his.selectedPaths.has(item.path);paths.forEach(path=>{this.set(path+".selected",
selected);if(selected){this.selectedPaths.add(path);return}this.selectedPaths.de
lete(path)});this.lastSelectedPath=itemPath}}; |
65 // Copyright 2015 The Chromium Authors. All rights reserved. | 65 // Copyright 2015 The Chromium Authors. All rights reserved. |
66 // Use of this source code is governed by a BSD-style license that can be | 66 // Use of this source code is governed by a BSD-style license that can be |
67 // found in the LICENSE file. | 67 // found in the LICENSE file. |
68 Polymer({is:"history-list",behaviors:[HistoryListBehavior],properties:{searchedT
erm:{type:String,value:""},querying:Boolean,historyData_:Array,resultLoadingDisa
bled_:{type:Boolean,value:false},lastFocused_:Object},listeners:{scroll:"notifyL
istScroll_","remove-bookmark-stars":"removeBookmarkStars_"},attached:function(){
this.$["infinite-list"].notifyResize();this.$["infinite-list"].scrollTarget=this
;this.$["scroll-threshold"].scrollTarget=this},removeBookmarkStars_:function(e){
var url=e.detail;if(this.historyData_===undefined)return;for(var i=0;i<this.hist
oryData_.length;i++){if(this.historyData_[i].url==url)this.set("historyData_."+i
+".starred",false)}},addNewResults:function(historyResults,incremental,finished)
{var results=historyResults.slice();this.$["scroll-threshold"].clearTriggers();i
f(!incremental){this.resultLoadingDisabled_=false;if(this.historyData_)this.spli
ce("historyData_",0,this.historyData_.length);this.fire("unselect-all")}if(this.
historyData_){results.unshift("historyData_");this.push.apply(this,results)}else
{this.set("historyData_",results)}this.resultLoadingDisabled_=finished},loadMore
Data_:function(){if(this.resultLoadingDisabled_||this.querying)return;this.fire(
"load-more-history")},needsTimeGap_:function(item,index,length){return md_histor
y.HistoryItem.needsTimeGap(this.historyData_,index,this.searchedTerm)},isCardSta
rt_:function(item,i,length){if(length==0||i>length-1)return false;return i==0||t
his.historyData_[i].dateRelativeDay!=this.historyData_[i-1].dateRelativeDay},isC
ardEnd_:function(item,i,length){if(length==0||i>length-1)return false;return i==
length-1||this.historyData_[i].dateRelativeDay!=this.historyData_[i+1].dateRelat
iveDay},notifyListScroll_:function(){this.fire("history-list-scrolled")},pathFor
Item_:function(index){return"historyData_."+index}}); | 68 Polymer({is:"history-list",behaviors:[HistoryListBehavior],properties:{searchedT
erm:{type:String,value:""},querying:Boolean,historyData_:Array,resultLoadingDisa
bled_:{type:Boolean,value:false},lastFocused_:Object},listeners:{scroll:"notifyL
istScroll_","remove-bookmark-stars":"removeBookmarkStars_"},attached:function(){
this.$["infinite-list"].notifyResize();this.$["infinite-list"].scrollTarget=this
;this.$["scroll-threshold"].scrollTarget=this},removeBookmarkStars_:function(e){
var url=e.detail;if(this.historyData_===undefined)return;for(var i=0;i<this.hist
oryData_.length;i++){if(this.historyData_[i].url==url)this.set("historyData_."+i
+".starred",false)}},addNewResults:function(historyResults,incremental,finished)
{var results=historyResults.slice();this.$["scroll-threshold"].clearTriggers();i
f(!incremental){this.resultLoadingDisabled_=false;if(this.historyData_)this.spli
ce("historyData_",0,this.historyData_.length);this.fire("unselect-all")}if(this.
historyData_){results.unshift("historyData_");this.push.apply(this,results)}else
{this.set("historyData_",results)}this.resultLoadingDisabled_=finished},loadMore
Data_:function(){if(this.resultLoadingDisabled_||this.querying)return;this.fire(
"load-more-history")},needsTimeGap_:function(item,index,length){return md_histor
y.HistoryItem.needsTimeGap(this.historyData_,index,this.searchedTerm)},isCardSta
rt_:function(item,i,length){if(length==0||i>length-1)return false;return i==0||t
his.historyData_[i].dateRelativeDay!=this.historyData_[i-1].dateRelativeDay},isC
ardEnd_:function(item,i,length){if(length==0||i>length-1)return false;return i==
length-1||this.historyData_[i].dateRelativeDay!=this.historyData_[i+1].dateRelat
iveDay},notifyListScroll_:function(){this.fire("history-list-scrolled")},pathFor
Item_:function(index){return"historyData_."+index}}); |
69 // Copyright 2016 The Chromium Authors. All rights reserved. | 69 // Copyright 2016 The Chromium Authors. All rights reserved. |
70 // Use of this source code is governed by a BSD-style license that can be | 70 // Use of this source code is governed by a BSD-style license that can be |
71 // found in the LICENSE file. | 71 // found in the LICENSE file. |
72 Polymer({is:"history-list-container",properties:{selectedPage_:String,grouped:Bo
olean,groupedRange:{type:Number,observer:"groupedRangeChanged_"},queryState:Obje
ct,queryResult:Object},observers:["searchTermChanged_(queryState.searchTerm)","g
roupedOffsetChanged_(queryState.groupedOffset)"],listeners:{"history-list-scroll
ed":"closeMenu_","load-more-history":"loadMoreHistory_","toggle-menu":"toggleMen
u_"},historyResult:function(info,results){this.initializeResults_(info,results);
this.closeMenu_();if(info.term&&!this.queryState.incremental){Polymer.IronA11yAn
nouncer.requestAvailability();this.fire("iron-announce",{text:md_history.History
Item.searchResultsTitle(results.length,info.term)})}var list=this.getSelectedLis
t_();list.addNewResults(results,this.queryState.incremental,info.finished)},quer
yHistory:function(incremental){var queryState=this.queryState;var noResults=!thi
s.queryResult||this.queryResult.results==null;if(queryState.queryingDisabled||!t
his.queryState.searchTerm&&noResults){return}var dialog=this.$.dialog.getIfExist
s();if(!incremental&&dialog&&dialog.open)dialog.close();this.set("queryState.que
rying",true);this.set("queryState.incremental",incremental);var lastVisitTime=0;
if(incremental){var lastVisit=this.queryResult.results.slice(-1)[0];lastVisitTim
e=lastVisit?Math.floor(lastVisit.time):0}var maxResults=this.groupedRange==Histo
ryRange.ALL_TIME?RESULTS_PER_PAGE:0;chrome.send("queryHistory",[queryState.searc
hTerm,queryState.groupedOffset,queryState.range,lastVisitTime,maxResults])},hist
oryDeleted:function(){if(this.getSelectedItemCount()>0)return;this.queryHistory(
false)},getContentScrollTarget:function(){return this.getSelectedList_()},getSel
ectedItemCount:function(){return this.getSelectedList_().selectedPaths.size},uns
electAllItems:function(count){var selectedList=this.getSelectedList_();if(select
edList)selectedList.unselectAllItems(count)},deleteSelectedWithPrompt:function()
{if(!loadTimeData.getBoolean("allowDeletingHistory"))return;var browserService=m
d_history.BrowserService.getInstance();browserService.recordAction("RemoveSelect
ed");if(this.queryState.searchTerm!="")browserService.recordAction("SearchResult
Remove");this.$.dialog.get().showModal();this.$$(".action-button").focus()},grou
pedRangeChanged_:function(range,oldRange){this.selectedPage_=range==HistoryRange
.ALL_TIME?"infinite-list":"grouped-list";if(oldRange==undefined)return;this.set(
"queryState.groupedOffset",0);if(this.queryResult.info){this.set("queryResult.re
sults",[]);this.historyResult(this.queryResult.info,[])}this.queryHistory(false)
;this.fire("history-view-changed")},searchTermChanged_:function(){this.queryHist
ory(false);if(this.queryState.searchTerm)md_history.BrowserService.getInstance()
.recordAction("Search")},groupedOffsetChanged_:function(){this.queryHistory(fals
e)},loadMoreHistory_:function(){this.queryHistory(true)},initializeResults_:func
tion(info,results){if(results.length==0)return;var currentDate=results[0].dateRe
lativeDay;for(var i=0;i<results.length;i++){results[i].selected=false;results[i]
.readableTimestamp=info.term==""?results[i].dateTimeOfDay:results[i].dateShort;i
f(results[i].dateRelativeDay!=currentDate){currentDate=results[i].dateRelativeDa
y}}},onDialogConfirmTap_:function(){md_history.BrowserService.getInstance().reco
rdAction("ConfirmRemoveSelected");this.getSelectedList_().deleteSelected();var d
ialog=assert(this.$.dialog.getIfExists());dialog.close()},onDialogCancelTap_:fun
ction(){md_history.BrowserService.getInstance().recordAction("CancelRemoveSelect
ed");var dialog=assert(this.$.dialog.getIfExists());dialog.close()},closeMenu_:f
unction(){var menu=this.$.sharedMenu.getIfExists();if(menu)menu.closeMenu()},tog
gleMenu_:function(e){var target=e.detail.target;var menu=this.$.sharedMenu.get()
;menu.toggleMenu(target,e.detail)},onMoreFromSiteTap_:function(){md_history.Brow
serService.getInstance().recordAction("EntryMenuShowMoreFromSite");var menu=asse
rt(this.$.sharedMenu.getIfExists());this.set("queryState.searchTerm",menu.itemDa
ta.item.domain);menu.closeMenu()},onRemoveFromHistoryTap_:function(){var browser
Service=md_history.BrowserService.getInstance();browserService.recordAction("Ent
ryMenuRemoveFromHistory");var menu=assert(this.$.sharedMenu.getIfExists());var i
temData=menu.itemData;browserService.deleteItems([itemData.item]).then(function(
items){this.fire("unselect-all");this.getSelectedList_().removeItemsByPath([item
Data.path]);var index=itemData.index;if(index==undefined)return;var browserServi
ce=md_history.BrowserService.getInstance();browserService.recordHistogram("Histo
ryPage.RemoveEntryPosition",Math.min(index,UMA_MAX_BUCKET_VALUE),UMA_MAX_BUCKET_
VALUE);if(index<=UMA_MAX_SUBSET_BUCKET_VALUE){browserService.recordHistogram("Hi
storyPage.RemoveEntryPositionSubset",index,UMA_MAX_SUBSET_BUCKET_VALUE)}}.bind(t
his));menu.closeMenu()},getSelectedList_:function(){return this.$$("#"+this.sele
ctedPage_)},canDeleteHistory_:function(){return loadTimeData.getBoolean("allowDe
letingHistory")}});(function(){"use strict";Polymer({is:"iron-location",properti
es:{path:{type:String,notify:true,value:function(){return window.decodeURICompon
ent(window.location.pathname)}},query:{type:String,notify:true,value:function(){
return window.decodeURIComponent(window.location.search.slice(1))}},hash:{type:S
tring,notify:true,value:function(){return window.decodeURIComponent(window.locat
ion.hash.slice(1))}},dwellTime:{type:Number,value:2e3},urlSpaceRegex:{type:Strin
g,value:""},_urlSpaceRegExp:{computed:"_makeRegExp(urlSpaceRegex)"},_lastChanged
At:{type:Number},_initialized:{type:Boolean,value:false}},hostAttributes:{hidden
:true},observers:["_updateUrl(path, query, hash)"],attached:function(){this.list
en(window,"hashchange","_hashChanged");this.listen(window,"location-changed","_u
rlChanged");this.listen(window,"popstate","_urlChanged");this.listen(document.bo
dy,"click","_globalOnClick");this._lastChangedAt=window.performance.now()-(this.
dwellTime-200);this._initialized=true;this._urlChanged()},detached:function(){th
is.unlisten(window,"hashchange","_hashChanged");this.unlisten(window,"location-c
hanged","_urlChanged");this.unlisten(window,"popstate","_urlChanged");this.unlis
ten(document.body,"click","_globalOnClick");this._initialized=false},_hashChange
d:function(){this.hash=window.decodeURIComponent(window.location.hash.substring(
1))},_urlChanged:function(){this._dontUpdateUrl=true;this._hashChanged();this.pa
th=window.decodeURIComponent(window.location.pathname);this.query=window.decodeU
RIComponent(window.location.search.substring(1));this._dontUpdateUrl=false;this.
_updateUrl()},_getUrl:function(){var partiallyEncodedPath=window.encodeURI(this.
path).replace(/\#/g,"%23").replace(/\?/g,"%3F");var partiallyEncodedQuery="";if(
this.query){partiallyEncodedQuery="?"+window.encodeURI(this.query).replace(/\#/g
,"%23")}var partiallyEncodedHash="";if(this.hash){partiallyEncodedHash="#"+windo
w.encodeURI(this.hash)}return partiallyEncodedPath+partiallyEncodedQuery+partial
lyEncodedHash},_updateUrl:function(){if(this._dontUpdateUrl||!this._initialized)
{return}if(this.path===window.decodeURIComponent(window.location.pathname)&&this
.query===window.decodeURIComponent(window.location.search.substring(1))&&this.ha
sh===window.decodeURIComponent(window.location.hash.substring(1))){return}var ne
wUrl=this._getUrl();var fullNewUrl=new URL(newUrl,window.location.protocol+"//"+
window.location.host).href;var now=window.performance.now();var shouldReplace=th
is._lastChangedAt+this.dwellTime>now;this._lastChangedAt=now;if(shouldReplace){w
indow.history.replaceState({},"",fullNewUrl)}else{window.history.pushState({},""
,fullNewUrl)}this.fire("location-changed",{},{node:window})},_globalOnClick:func
tion(event){if(event.defaultPrevented){return}var href=this._getSameOriginLinkHr
ef(event);if(!href){return}event.preventDefault();if(href===window.location.href
){return}window.history.pushState({},"",href);this.fire("location-changed",{},{n
ode:window})},_getSameOriginLinkHref:function(event){if(event.button!==0){return
null}if(event.metaKey||event.ctrlKey){return null}var eventPath=Polymer.dom(eve
nt).path;var anchor=null;for(var i=0;i<eventPath.length;i++){var element=eventPa
th[i];if(element.tagName==="A"&&element.href){anchor=element;break}}if(!anchor){
return null}if(anchor.target==="_blank"){return null}if((anchor.target==="_top"|
|anchor.target==="_parent")&&window.top!==window){return null}var href=anchor.hr
ef;var url;if(document.baseURI!=null){url=new URL(href,document.baseURI)}else{ur
l=new URL(href)}var origin;if(window.location.origin){origin=window.location.ori
gin}else{origin=window.location.protocol+"//"+window.location.hostname;if(window
.location.port){origin+=":"+window.location.port}}if(url.origin!==origin){return
null}var normalizedHref=url.pathname+url.search+url.hash;if(this._urlSpaceRegEx
p&&!this._urlSpaceRegExp.test(normalizedHref)){return null}var fullNormalizedHre
f=new URL(normalizedHref,window.location.href).href;return fullNormalizedHref},_
makeRegExp:function(urlSpaceRegex){return RegExp(urlSpaceRegex)}})})();"use stri
ct";Polymer({is:"iron-query-params",properties:{paramsString:{type:String,notify
:true,observer:"paramsStringChanged"},paramsObject:{type:Object,notify:true,valu
e:function(){return{}}},_dontReact:{type:Boolean,value:false}},hostAttributes:{h
idden:true},observers:["paramsObjectChanged(paramsObject.*)"],paramsStringChange
d:function(){this._dontReact=true;this.paramsObject=this._decodeParams(this.para
msString);this._dontReact=false},paramsObjectChanged:function(){if(this._dontRea
ct){return}this.paramsString=this._encodeParams(this.paramsObject)},_encodeParam
s:function(params){var encodedParams=[];for(var key in params){var value=params[
key];if(value===""){encodedParams.push(encodeURIComponent(key))}else if(value){e
ncodedParams.push(encodeURIComponent(key)+"="+encodeURIComponent(value.toString(
)))}}return encodedParams.join("&")},_decodeParams:function(paramString){var par
ams={};paramString=(paramString||"").replace(/\+/g,"%20");var paramList=paramStr
ing.split("&");for(var i=0;i<paramList.length;i++){var param=paramList[i].split(
"=");if(param[0]){params[decodeURIComponent(param[0])]=decodeURIComponent(param[
1]||"")}}return params}}); | 72 Polymer({is:"history-list-container",properties:{selectedPage_:String,grouped:Bo
olean,groupedRange:{type:Number,observer:"groupedRangeChanged_"},queryState:Obje
ct,queryResult:Object},observers:["searchTermChanged_(queryState.searchTerm)","g
roupedOffsetChanged_(queryState.groupedOffset)"],listeners:{"history-list-scroll
ed":"closeMenu_","load-more-history":"loadMoreHistory_","toggle-menu":"toggleMen
u_"},historyResult:function(info,results){this.initializeResults_(info,results);
this.closeMenu_();if(info.term&&!this.queryState.incremental){Polymer.IronA11yAn
nouncer.requestAvailability();this.fire("iron-announce",{text:md_history.History
Item.searchResultsTitle(results.length,info.term)})}var list=this.getSelectedLis
t_();list.addNewResults(results,this.queryState.incremental,info.finished)},quer
yHistory:function(incremental){var queryState=this.queryState;var noResults=!thi
s.queryResult||this.queryResult.results==null;if(queryState.queryingDisabled||!t
his.queryState.searchTerm&&noResults){return}var dialog=this.$.dialog.getIfExist
s();if(!incremental&&dialog&&dialog.open)dialog.close();this.set("queryState.que
rying",true);this.set("queryState.incremental",incremental);var lastVisitTime=0;
if(incremental){var lastVisit=this.queryResult.results.slice(-1)[0];lastVisitTim
e=lastVisit?Math.floor(lastVisit.time):0}var maxResults=this.groupedRange==Histo
ryRange.ALL_TIME?RESULTS_PER_PAGE:0;chrome.send("queryHistory",[queryState.searc
hTerm,queryState.groupedOffset,queryState.range,lastVisitTime,maxResults])},hist
oryDeleted:function(){if(this.getSelectedItemCount()>0)return;this.queryHistory(
false)},getContentScrollTarget:function(){return this.getSelectedList_()},getSel
ectedItemCount:function(){return this.getSelectedList_().selectedPaths.size},uns
electAllItems:function(count){var selectedList=this.getSelectedList_();if(select
edList)selectedList.unselectAllItems(count)},deleteSelectedWithPrompt:function()
{if(!loadTimeData.getBoolean("allowDeletingHistory"))return;var browserService=m
d_history.BrowserService.getInstance();browserService.recordAction("RemoveSelect
ed");if(this.queryState.searchTerm!="")browserService.recordAction("SearchResult
Remove");this.$.dialog.get().showModal();this.$$(".action-button").focus()},grou
pedRangeChanged_:function(range,oldRange){this.selectedPage_=range==HistoryRange
.ALL_TIME?"infinite-list":"grouped-list";if(oldRange==undefined)return;this.set(
"queryState.groupedOffset",0);if(this.queryResult.info){this.set("queryResult.re
sults",[]);this.historyResult(this.queryResult.info,[])}this.queryHistory(false)
;this.fire("history-view-changed")},searchTermChanged_:function(){this.queryHist
ory(false);if(this.queryState.searchTerm)md_history.BrowserService.getInstance()
.recordAction("Search")},groupedOffsetChanged_:function(){this.queryHistory(fals
e)},loadMoreHistory_:function(){this.queryHistory(true)},initializeResults_:func
tion(info,results){if(results.length==0)return;var currentDate=results[0].dateRe
lativeDay;for(var i=0;i<results.length;i++){results[i].selected=false;results[i]
.readableTimestamp=info.term==""?results[i].dateTimeOfDay:results[i].dateShort;i
f(results[i].dateRelativeDay!=currentDate){currentDate=results[i].dateRelativeDa
y}}},onDialogConfirmTap_:function(){md_history.BrowserService.getInstance().reco
rdAction("ConfirmRemoveSelected");this.getSelectedList_().deleteSelected();var d
ialog=assert(this.$.dialog.getIfExists());dialog.close()},onDialogCancelTap_:fun
ction(){md_history.BrowserService.getInstance().recordAction("CancelRemoveSelect
ed");var dialog=assert(this.$.dialog.getIfExists());dialog.close()},closeMenu_:f
unction(){var menu=this.$.sharedMenu.getIfExists();if(menu)menu.closeMenu()},tog
gleMenu_:function(e){var target=e.detail.target;var menu=this.$.sharedMenu.get()
;menu.toggleMenu(target,e.detail)},onMoreFromSiteTap_:function(){md_history.Brow
serService.getInstance().recordAction("EntryMenuShowMoreFromSite");var menu=asse
rt(this.$.sharedMenu.getIfExists());this.set("queryState.searchTerm",menu.itemDa
ta.item.domain);menu.closeMenu()},onRemoveFromHistoryTap_:function(){var browser
Service=md_history.BrowserService.getInstance();browserService.recordAction("Ent
ryMenuRemoveFromHistory");var menu=assert(this.$.sharedMenu.getIfExists());var i
temData=menu.itemData;browserService.deleteItems([itemData.item]).then(items=>{t
his.fire("unselect-all");this.getSelectedList_().removeItemsByPath([itemData.pat
h]);var index=itemData.index;if(index==undefined)return;var browserService=md_hi
story.BrowserService.getInstance();browserService.recordHistogram("HistoryPage.R
emoveEntryPosition",Math.min(index,UMA_MAX_BUCKET_VALUE),UMA_MAX_BUCKET_VALUE);i
f(index<=UMA_MAX_SUBSET_BUCKET_VALUE){browserService.recordHistogram("HistoryPag
e.RemoveEntryPositionSubset",index,UMA_MAX_SUBSET_BUCKET_VALUE)}});menu.closeMen
u()},getSelectedList_:function(){return this.$$("#"+this.selectedPage_)},canDele
teHistory_:function(){return loadTimeData.getBoolean("allowDeletingHistory")}});
(function(){"use strict";Polymer({is:"iron-location",properties:{path:{type:Stri
ng,notify:true,value:function(){return window.decodeURIComponent(window.location
.pathname)}},query:{type:String,notify:true,value:function(){return window.decod
eURIComponent(window.location.search.slice(1))}},hash:{type:String,notify:true,v
alue:function(){return window.decodeURIComponent(window.location.hash.slice(1))}
},dwellTime:{type:Number,value:2e3},urlSpaceRegex:{type:String,value:""},_urlSpa
ceRegExp:{computed:"_makeRegExp(urlSpaceRegex)"},_lastChangedAt:{type:Number},_i
nitialized:{type:Boolean,value:false}},hostAttributes:{hidden:true},observers:["
_updateUrl(path, query, hash)"],attached:function(){this.listen(window,"hashchan
ge","_hashChanged");this.listen(window,"location-changed","_urlChanged");this.li
sten(window,"popstate","_urlChanged");this.listen(document.body,"click","_global
OnClick");this._lastChangedAt=window.performance.now()-(this.dwellTime-200);this
._initialized=true;this._urlChanged()},detached:function(){this.unlisten(window,
"hashchange","_hashChanged");this.unlisten(window,"location-changed","_urlChange
d");this.unlisten(window,"popstate","_urlChanged");this.unlisten(document.body,"
click","_globalOnClick");this._initialized=false},_hashChanged:function(){this.h
ash=window.decodeURIComponent(window.location.hash.substring(1))},_urlChanged:fu
nction(){this._dontUpdateUrl=true;this._hashChanged();this.path=window.decodeURI
Component(window.location.pathname);this.query=window.decodeURIComponent(window.
location.search.substring(1));this._dontUpdateUrl=false;this._updateUrl()},_getU
rl:function(){var partiallyEncodedPath=window.encodeURI(this.path).replace(/\#/g
,"%23").replace(/\?/g,"%3F");var partiallyEncodedQuery="";if(this.query){partial
lyEncodedQuery="?"+window.encodeURI(this.query).replace(/\#/g,"%23")}var partial
lyEncodedHash="";if(this.hash){partiallyEncodedHash="#"+window.encodeURI(this.ha
sh)}return partiallyEncodedPath+partiallyEncodedQuery+partiallyEncodedHash},_upd
ateUrl:function(){if(this._dontUpdateUrl||!this._initialized){return}if(this.pat
h===window.decodeURIComponent(window.location.pathname)&&this.query===window.dec
odeURIComponent(window.location.search.substring(1))&&this.hash===window.decodeU
RIComponent(window.location.hash.substring(1))){return}var newUrl=this._getUrl()
;var fullNewUrl=new URL(newUrl,window.location.protocol+"//"+window.location.hos
t).href;var now=window.performance.now();var shouldReplace=this._lastChangedAt+t
his.dwellTime>now;this._lastChangedAt=now;if(shouldReplace){window.history.repla
ceState({},"",fullNewUrl)}else{window.history.pushState({},"",fullNewUrl)}this.f
ire("location-changed",{},{node:window})},_globalOnClick:function(event){if(even
t.defaultPrevented){return}var href=this._getSameOriginLinkHref(event);if(!href)
{return}event.preventDefault();if(href===window.location.href){return}window.his
tory.pushState({},"",href);this.fire("location-changed",{},{node:window})},_getS
ameOriginLinkHref:function(event){if(event.button!==0){return null}if(event.meta
Key||event.ctrlKey){return null}var eventPath=Polymer.dom(event).path;var anchor
=null;for(var i=0;i<eventPath.length;i++){var element=eventPath[i];if(element.ta
gName==="A"&&element.href){anchor=element;break}}if(!anchor){return null}if(anch
or.target==="_blank"){return null}if((anchor.target==="_top"||anchor.target==="_
parent")&&window.top!==window){return null}var href=anchor.href;var url;if(docum
ent.baseURI!=null){url=new URL(href,document.baseURI)}else{url=new URL(href)}var
origin;if(window.location.origin){origin=window.location.origin}else{origin=win
dow.location.protocol+"//"+window.location.hostname;if(window.location.port){ori
gin+=":"+window.location.port}}if(url.origin!==origin){return null}var normalize
dHref=url.pathname+url.search+url.hash;if(this._urlSpaceRegExp&&!this._urlSpaceR
egExp.test(normalizedHref)){return null}var fullNormalizedHref=new URL(normalize
dHref,window.location.href).href;return fullNormalizedHref},_makeRegExp:function
(urlSpaceRegex){return RegExp(urlSpaceRegex)}})})();"use strict";Polymer({is:"ir
on-query-params",properties:{paramsString:{type:String,notify:true,observer:"par
amsStringChanged"},paramsObject:{type:Object,notify:true,value:function(){return
{}}},_dontReact:{type:Boolean,value:false}},hostAttributes:{hidden:true},observe
rs:["paramsObjectChanged(paramsObject.*)"],paramsStringChanged:function(){this._
dontReact=true;this.paramsObject=this._decodeParams(this.paramsString);this._don
tReact=false},paramsObjectChanged:function(){if(this._dontReact){return}this.par
amsString=this._encodeParams(this.paramsObject)},_encodeParams:function(params){
var encodedParams=[];for(var key in params){var value=params[key];if(value==="")
{encodedParams.push(encodeURIComponent(key))}else if(value){encodedParams.push(e
ncodeURIComponent(key)+"="+encodeURIComponent(value.toString()))}}return encoded
Params.join("&")},_decodeParams:function(paramString){var params={};paramString=
(paramString||"").replace(/\+/g,"%20");var paramList=paramString.split("&");for(
var i=0;i<paramList.length;i++){var param=paramList[i].split("=");if(param[0]){p
arams[decodeURIComponent(param[0])]=decodeURIComponent(param[1]||"")}}return par
ams}}); |
73 // Copyright 2016 The Chromium Authors. All rights reserved. | 73 // Copyright 2016 The Chromium Authors. All rights reserved. |
74 // Use of this source code is governed by a BSD-style license that can be | 74 // Use of this source code is governed by a BSD-style license that can be |
75 // found in the LICENSE file. | 75 // found in the LICENSE file. |
76 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]}); | 76 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]}); |
77 // Copyright 2016 The Chromium Authors. All rights reserved. | 77 // Copyright 2016 The Chromium Authors. All rights reserved. |
78 // Use of this source code is governed by a BSD-style license that can be | 78 // Use of this source code is governed by a BSD-style license that can be |
79 // found in the LICENSE file. | 79 // found in the LICENSE file. |
80 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()}}); | 80 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()}}); |
81 // Copyright 2016 The Chromium Authors. All rights reserved. | 81 // Copyright 2016 The Chromium Authors. All rights reserved. |
82 // Use of this source code is governed by a BSD-style license that can be | 82 // Use of this source code is governed by a BSD-style license that can be |
83 // found in the LICENSE file. | 83 // found in the LICENSE file. |
84 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],properties:{showSide
barFooter:Boolean,hasSyncedResults:Boolean,selectedPage_:{type:String,observer:"
selectedPageChanged_"},grouped_:{type:Boolean,reflectToAttribute:true},queryStat
e_:{type:Object,value:function(){return{incremental:false,querying:true,querying
Disabled:false,_range:HistoryRange.ALL_TIME,searchTerm:"",groupedOffset:0,set ra
nge(val){this._range=Number(val)},get range(){return this._range}}}},queryResult
_:{type:Object,value:function(){return{info:null,results:null,sessionList:null}}
},hasDrawer_:Boolean,isUserSignedIn_:{type:Boolean,value:loadTimeData.getBoolean
("isUserSignedIn")},toolbarShadow_:{type:Boolean,reflectToAttribute:true,notify:
true},showMenuPromo_:{type:Boolean,value:function(){return loadTimeData.getBoole
an("showMenuPromo")}}},listeners:{"cr-toolbar-menu-promo-close":"onCrToolbarMenu
PromoClose_","cr-toolbar-menu-promo-shown":"onCrToolbarMenuPromoShown_","cr-tool
bar-menu-tap":"onCrToolbarMenuTap_","delete-selected":"deleteSelected","history-
checkbox-select":"checkboxSelected","history-close-drawer":"closeDrawer_","histo
ry-view-changed":"historyViewChanged_","opened-changed":"onOpenedChanged_","unse
lect-all":"unselectAll"},boundOnCanExecute_:null,boundOnCommand_:null,attached:f
unction(){this.grouped_=loadTimeData.getBoolean("groupByDomain");cr.ui.decorate(
"command",cr.ui.Command);this.boundOnCanExecute_=this.onCanExecute_.bind(this);t
his.boundOnCommand_=this.onCommand_.bind(this);document.addEventListener("canExe
cute",this.boundOnCanExecute_);document.addEventListener("command",this.boundOnC
ommand_)},detached:function(){document.removeEventListener("canExecute",this.bou
ndOnCanExecute_);document.removeEventListener("command",this.boundOnCommand_)},o
nFirstRender:function(){setTimeout(function(){chrome.send("metricsHandler:record
Time",["History.ResultsRenderedTime",window.performance.now()])});var searchFiel
d=this.$.toolbar.searchField;if(!searchField.narrow){searchField.getSearchInput(
).focus()}md_history.ensureLazyLoaded().then(function(){window.requestIdleCallba
ck(function(){document.fonts.load("bold 12px Roboto")})})},_scrollHandler:functi
on(){if(this.scrollTarget)this.toolbarShadow_=this.scrollTarget.scrollTop!=0},on
CrToolbarMenuPromoClose_:function(){this.showMenuPromo_=false},onCrToolbarMenuPr
omoShown_:function(){md_history.BrowserService.getInstance().menuPromoShown()},o
nCrToolbarMenuTap_:function(){var drawer=this.$$("#drawer");if(drawer)drawer.tog
gle()},onOpenedChanged_:function(e){if(e.detail.value)this.showMenuPromo_=false}
,checkboxSelected:function(e){var toolbar=this.$.toolbar;toolbar.count=this.$.hi
story.getSelectedItemCount()},unselectAll:function(){var listContainer=this.$.hi
story;var toolbar=this.$.toolbar;listContainer.unselectAllItems(toolbar.count);t
oolbar.count=0},deleteSelected:function(){this.$.history.deleteSelectedWithPromp
t()},historyResult:function(info,results){this.set("queryState_.querying",false)
;this.set("queryResult_.info",info);this.set("queryResult_.results",results);var
listContainer=this.$["history"];listContainer.historyResult(info,results)},focu
sToolbarSearchField:function(){this.$.toolbar.showSearchField()},onCanExecute_:f
unction(e){e=e;switch(e.command.id){case"find-command":case"toggle-grouped":e.ca
nExecute=true;break;case"slash-command":e.canExecute=!this.$.toolbar.searchField
.isSearchFocused();break;case"delete-command":e.canExecute=this.$.toolbar.count>
0;break}},onCommand_:function(e){if(e.command.id=="find-command"||e.command.id==
"slash-command")this.focusToolbarSearchField();if(e.command.id=="delete-command"
)this.deleteSelected();if(e.command.id=="toggle-grouped")this.grouped_=!this.gro
uped_},setForeignSessions:function(sessionList){this.set("queryResult_.sessionLi
st",sessionList)},historyDeleted:function(){this.$.history.historyDeleted()},upd
ateSignInState:function(isUserSignedIn){this.isUserSignedIn_=isUserSignedIn},syn
cedTabsSelected_:function(selectedPage){return selectedPage=="syncedTabs"},shoul
dShowSpinner_:function(querying,incremental,searchTerm){return querying&&!increm
ental&&searchTerm!=""},showSyncNotice_:function(hasSyncedResults,selectedPage){r
eturn hasSyncedResults&&selectedPage!="syncedTabs"},selectedPageChanged_:functio
n(){this.unselectAll();this.historyViewChanged_()},historyViewChanged_:function(
){requestAnimationFrame(function(){md_history.ensureLazyLoaded().then(function()
{if(!this.$.content.selectedItem)return;this.scrollTarget=this.$.content.selecte
dItem.getContentScrollTarget();this._scrollHandler()}.bind(this))}.bind(this));t
his.recordHistoryPageView_()},getSelectedPage_:function(selectedPage,items){retu
rn selectedPage},closeDrawer_:function(){var drawer=this.$$("#drawer");if(drawer
)drawer.close()},recordHistoryPageView_:function(){var histogramValue=HistoryPag
eViewHistogram.END;switch(this.selectedPage_){case"syncedTabs":histogramValue=th
is.isUserSignedIn_?HistoryPageViewHistogram.SYNCED_TABS:HistoryPageViewHistogram
.SIGNIN_PROMO;break;default:switch(this.queryState_.range){case HistoryRange.ALL
_TIME:histogramValue=HistoryPageViewHistogram.HISTORY;break;case HistoryRange.WE
EK:histogramValue=HistoryPageViewHistogram.GROUPED_WEEK;break;case HistoryRange.
MONTH:histogramValue=HistoryPageViewHistogram.GROUPED_MONTH;break}break}md_histo
ry.BrowserService.getInstance().recordHistogram("History.HistoryPageView",histog
ramValue,HistoryPageViewHistogram.END)}}); | 84 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],properties:{showSide
barFooter:Boolean,hasSyncedResults:Boolean,selectedPage_:{type:String,observer:"
selectedPageChanged_"},grouped_:{type:Boolean,reflectToAttribute:true},queryStat
e_:{type:Object,value:()=>({incremental:false,querying:true,queryingDisabled:fal
se,_range:HistoryRange.ALL_TIME,searchTerm:"",groupedOffset:0,set range(val){thi
s._range=Number(val)},get range(){return this._range}})},queryResult_:{type:Obje
ct,value:()=>({info:null,results:null,sessionList:null})},hasDrawer_:Boolean,isU
serSignedIn_:{type:Boolean,value:loadTimeData.getBoolean("isUserSignedIn")},tool
barShadow_:{type:Boolean,reflectToAttribute:true,notify:true},showMenuPromo_:{ty
pe:Boolean,value:()=>loadTimeData.getBoolean("showMenuPromo")}},listeners:{"cr-t
oolbar-menu-promo-close":"onCrToolbarMenuPromoClose_","cr-toolbar-menu-promo-sho
wn":"onCrToolbarMenuPromoShown_","cr-toolbar-menu-tap":"onCrToolbarMenuTap_","de
lete-selected":"deleteSelected","history-checkbox-select":"checkboxSelected","hi
story-close-drawer":"closeDrawer_","history-view-changed":"historyViewChanged_",
"opened-changed":"onOpenedChanged_","unselect-all":"unselectAll"},boundOnCanExec
ute_:null,boundOnCommand_:null,attached:function(){this.grouped_=loadTimeData.ge
tBoolean("groupByDomain");cr.ui.decorate("command",cr.ui.Command);this.boundOnCa
nExecute_=this.onCanExecute_.bind(this);this.boundOnCommand_=this.onCommand_.bin
d(this);document.addEventListener("canExecute",this.boundOnCanExecute_);document
.addEventListener("command",this.boundOnCommand_)},detached:function(){document.
removeEventListener("canExecute",this.boundOnCanExecute_);document.removeEventLi
stener("command",this.boundOnCommand_)},onFirstRender:function(){setTimeout(func
tion(){chrome.send("metricsHandler:recordTime",["History.ResultsRenderedTime",wi
ndow.performance.now()])});var searchField=this.$.toolbar.searchField;if(!search
Field.narrow){searchField.getSearchInput().focus()}md_history.ensureLazyLoaded()
.then(function(){window.requestIdleCallback(function(){document.fonts.load("bold
12px Roboto")})})},_scrollHandler:function(){if(this.scrollTarget)this.toolbarS
hadow_=this.scrollTarget.scrollTop!=0},onCrToolbarMenuPromoClose_:function(){thi
s.showMenuPromo_=false},onCrToolbarMenuPromoShown_:function(){md_history.Browser
Service.getInstance().menuPromoShown()},onCrToolbarMenuTap_:function(){var drawe
r=this.$$("#drawer");if(drawer)drawer.toggle()},onOpenedChanged_:function(e){if(
e.detail.value)this.showMenuPromo_=false},checkboxSelected:function(e){var toolb
ar=this.$.toolbar;toolbar.count=this.$.history.getSelectedItemCount()},unselectA
ll:function(){var listContainer=this.$.history;var toolbar=this.$.toolbar;listCo
ntainer.unselectAllItems(toolbar.count);toolbar.count=0},deleteSelected:function
(){this.$.history.deleteSelectedWithPrompt()},historyResult:function(info,result
s){this.set("queryState_.querying",false);this.set("queryResult_.info",info);thi
s.set("queryResult_.results",results);var listContainer=this.$["history"];listCo
ntainer.historyResult(info,results)},focusToolbarSearchField:function(){this.$.t
oolbar.showSearchField()},onCanExecute_:function(e){e=e;switch(e.command.id){cas
e"find-command":case"toggle-grouped":e.canExecute=true;break;case"slash-command"
:e.canExecute=!this.$.toolbar.searchField.isSearchFocused();break;case"delete-co
mmand":e.canExecute=this.$.toolbar.count>0;break}},onCommand_:function(e){if(e.c
ommand.id=="find-command"||e.command.id=="slash-command")this.focusToolbarSearch
Field();if(e.command.id=="delete-command")this.deleteSelected();if(e.command.id=
="toggle-grouped")this.grouped_=!this.grouped_},setForeignSessions:function(sess
ionList){this.set("queryResult_.sessionList",sessionList)},historyDeleted:functi
on(){this.$.history.historyDeleted()},updateSignInState:function(isUserSignedIn)
{this.isUserSignedIn_=isUserSignedIn},syncedTabsSelected_:function(selectedPage)
{return selectedPage=="syncedTabs"},shouldShowSpinner_:function(querying,increme
ntal,searchTerm){return querying&&!incremental&&searchTerm!=""},showSyncNotice_:
function(hasSyncedResults,selectedPage){return hasSyncedResults&&selectedPage!="
syncedTabs"},selectedPageChanged_:function(){this.unselectAll();this.historyView
Changed_()},historyViewChanged_:function(){requestAnimationFrame(()=>{md_history
.ensureLazyLoaded().then(()=>{if(!this.$.content.selectedItem)return;this.scroll
Target=this.$.content.selectedItem.getContentScrollTarget();this._scrollHandler(
)})});this.recordHistoryPageView_()},getSelectedPage_:function(selectedPage,item
s){return selectedPage},closeDrawer_:function(){var drawer=this.$$("#drawer");if
(drawer)drawer.close()},recordHistoryPageView_:function(){var histogramValue=His
toryPageViewHistogram.END;switch(this.selectedPage_){case"syncedTabs":histogramV
alue=this.isUserSignedIn_?HistoryPageViewHistogram.SYNCED_TABS:HistoryPageViewHi
stogram.SIGNIN_PROMO;break;default:switch(this.queryState_.range){case HistoryRa
nge.ALL_TIME:histogramValue=HistoryPageViewHistogram.HISTORY;break;case HistoryR
ange.WEEK:histogramValue=HistoryPageViewHistogram.GROUPED_WEEK;break;case Histor
yRange.MONTH:histogramValue=HistoryPageViewHistogram.GROUPED_MONTH;break}break}m
d_history.BrowserService.getInstance().recordHistogram("History.HistoryPageView"
,histogramValue,HistoryPageViewHistogram.END)}}); |
OLD | NEW |