| Index: chrome/browser/resources/md_downloads/crisper.js
|
| diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js
|
| index de974974530524d8a14aaa09fec6b7fe235a62f6..d124ab677bae9947773901be50ed13ad4d0aec87 100644
|
| --- a/chrome/browser/resources/md_downloads/crisper.js
|
| +++ b/chrome/browser/resources/md_downloads/crisper.js
|
| @@ -10853,41 +10853,6 @@ Polymer({
|
| }
|
|
|
| });
|
| -Polymer({
|
| - is: 'paper-material',
|
| -
|
| - properties: {
|
| -
|
| - /**
|
| - * The z-depth of this element, from 0-5. Setting to 0 will remove the
|
| - * shadow, and each increasing number greater than 0 will be "deeper"
|
| - * than the last.
|
| - *
|
| - * @attribute elevation
|
| - * @type number
|
| - * @default 1
|
| - */
|
| - elevation: {
|
| - type: Number,
|
| - reflectToAttribute: true,
|
| - value: 1
|
| - },
|
| -
|
| - /**
|
| - * Set this to true to animate the shadow when setting a new
|
| - * `elevation` value.
|
| - *
|
| - * @attribute animated
|
| - * @type boolean
|
| - * @default false
|
| - */
|
| - animated: {
|
| - type: Boolean,
|
| - reflectToAttribute: true,
|
| - value: false
|
| - }
|
| - }
|
| - });
|
| (function() {
|
| 'use strict';
|
|
|
| @@ -11295,118 +11260,398 @@ Polymer({
|
| }
|
| };
|
| })();
|
| -(function() {
|
| - var Utility = {
|
| - distance: function(x1, y1, x2, y2) {
|
| - var xDelta = (x1 - x2);
|
| - var yDelta = (y1 - y2);
|
| -
|
| - return Math.sqrt(xDelta * xDelta + yDelta * yDelta);
|
| - },
|
| -
|
| - now: window.performance && window.performance.now ?
|
| - window.performance.now.bind(window.performance) : Date.now
|
| - };
|
| +/**
|
| + * @demo demo/index.html
|
| + * @polymerBehavior
|
| + */
|
| + Polymer.IronControlState = {
|
|
|
| - /**
|
| - * @param {HTMLElement} element
|
| - * @constructor
|
| - */
|
| - function ElementMetrics(element) {
|
| - this.element = element;
|
| - this.width = this.boundingRect.width;
|
| - this.height = this.boundingRect.height;
|
| + properties: {
|
|
|
| - this.size = Math.max(this.width, this.height);
|
| - }
|
| + /**
|
| + * If true, the element currently has focus.
|
| + */
|
| + focused: {
|
| + type: Boolean,
|
| + value: false,
|
| + notify: true,
|
| + readOnly: true,
|
| + reflectToAttribute: true
|
| + },
|
|
|
| - ElementMetrics.prototype = {
|
| - get boundingRect () {
|
| - return this.element.getBoundingClientRect();
|
| + /**
|
| + * If true, the user cannot interact with this element.
|
| + */
|
| + disabled: {
|
| + type: Boolean,
|
| + value: false,
|
| + notify: true,
|
| + observer: '_disabledChanged',
|
| + reflectToAttribute: true
|
| },
|
|
|
| - furthestCornerDistanceFrom: 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);
|
| - var bottomRight = Utility.distance(x, y, this.width, this.height);
|
| + _oldTabIndex: {
|
| + type: Number
|
| + },
|
|
|
| - return Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
| + _boundFocusBlurHandler: {
|
| + type: Function,
|
| + value: function() {
|
| + return this._focusBlurHandler.bind(this);
|
| + }
|
| }
|
| - };
|
| -
|
| - /**
|
| - * @param {HTMLElement} element
|
| - * @constructor
|
| - */
|
| - function Ripple(element) {
|
| - this.element = element;
|
| - this.color = window.getComputedStyle(element).color;
|
|
|
| - this.wave = document.createElement('div');
|
| - this.waveContainer = document.createElement('div');
|
| - this.wave.style.backgroundColor = this.color;
|
| - this.wave.classList.add('wave');
|
| - this.waveContainer.classList.add('wave-container');
|
| - Polymer.dom(this.waveContainer).appendChild(this.wave);
|
| + },
|
|
|
| - this.resetInteractionState();
|
| - }
|
| + observers: [
|
| + '_changedControlState(focused, disabled)'
|
| + ],
|
|
|
| - Ripple.MAX_RADIUS = 300;
|
| + ready: function() {
|
| + this.addEventListener('focus', this._boundFocusBlurHandler, true);
|
| + this.addEventListener('blur', this._boundFocusBlurHandler, true);
|
| + },
|
|
|
| - Ripple.prototype = {
|
| - get recenters() {
|
| - return this.element.recenters;
|
| - },
|
| + _focusBlurHandler: function(event) {
|
| + // NOTE(cdata): if we are in ShadowDOM land, `event.target` will
|
| + // eventually become `this` due to retargeting; if we are not in
|
| + // ShadowDOM land, `event.target` will eventually become `this` due
|
| + // to the second conditional which fires a synthetic event (that is also
|
| + // handled). In either case, we can disregard `event.path`.
|
|
|
| - get center() {
|
| - return this.element.center;
|
| - },
|
| + if (event.target === this) {
|
| + var focused = event.type === 'focus';
|
| + this._setFocused(focused);
|
| + } else if (!this.shadowRoot) {
|
| + this.fire(event.type, {sourceEvent: event}, {
|
| + node: this,
|
| + bubbles: event.bubbles,
|
| + cancelable: event.cancelable
|
| + });
|
| + }
|
| + },
|
|
|
| - get mouseDownElapsed() {
|
| - var elapsed;
|
| + _disabledChanged: function(disabled, old) {
|
| + this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
|
| + this.style.pointerEvents = disabled ? 'none' : '';
|
| + if (disabled) {
|
| + this._oldTabIndex = this.tabIndex;
|
| + this.focused = false;
|
| + this.tabIndex = -1;
|
| + } else if (this._oldTabIndex !== undefined) {
|
| + this.tabIndex = this._oldTabIndex;
|
| + }
|
| + },
|
|
|
| - if (!this.mouseDownStart) {
|
| - return 0;
|
| - }
|
| + _changedControlState: function() {
|
| + // _controlStateChanged is abstract, follow-on behaviors may implement it
|
| + if (this._controlStateChanged) {
|
| + this._controlStateChanged();
|
| + }
|
| + }
|
|
|
| - elapsed = Utility.now() - this.mouseDownStart;
|
| + };
|
| +/**
|
| + * @demo demo/index.html
|
| + * @polymerBehavior Polymer.IronButtonState
|
| + */
|
| + Polymer.IronButtonStateImpl = {
|
|
|
| - if (this.mouseUpStart) {
|
| - elapsed -= this.mouseUpElapsed;
|
| - }
|
| + properties: {
|
|
|
| - return elapsed;
|
| + /**
|
| + * If true, the user is currently holding down the button.
|
| + */
|
| + pressed: {
|
| + type: Boolean,
|
| + readOnly: true,
|
| + value: false,
|
| + reflectToAttribute: true,
|
| + observer: '_pressedChanged'
|
| },
|
|
|
| - get mouseUpElapsed() {
|
| - return this.mouseUpStart ?
|
| - Utility.now () - this.mouseUpStart : 0;
|
| + /**
|
| + * If true, the button toggles the active state with each tap or press
|
| + * of the spacebar.
|
| + */
|
| + toggles: {
|
| + type: Boolean,
|
| + value: false,
|
| + reflectToAttribute: true
|
| },
|
|
|
| - get mouseDownElapsedSeconds() {
|
| - return this.mouseDownElapsed / 1000;
|
| + /**
|
| + * If true, the button is a toggle and is currently in the active state.
|
| + */
|
| + active: {
|
| + type: Boolean,
|
| + value: false,
|
| + notify: true,
|
| + reflectToAttribute: true
|
| },
|
|
|
| - get mouseUpElapsedSeconds() {
|
| - return this.mouseUpElapsed / 1000;
|
| + /**
|
| + * True if the element is currently being pressed by a "pointer," which
|
| + * is loosely defined as mouse or touch input (but specifically excluding
|
| + * keyboard input).
|
| + */
|
| + pointerDown: {
|
| + type: Boolean,
|
| + readOnly: true,
|
| + value: false
|
| },
|
|
|
| - get mouseInteractionSeconds() {
|
| - return this.mouseDownElapsedSeconds + this.mouseUpElapsedSeconds;
|
| + /**
|
| + * True if the input device that caused the element to receive focus
|
| + * was a keyboard.
|
| + */
|
| + receivedFocusFromKeyboard: {
|
| + type: Boolean,
|
| + readOnly: true
|
| },
|
|
|
| - get initialOpacity() {
|
| - return this.element.initialOpacity;
|
| - },
|
| + /**
|
| + * The aria attribute to be set if the button is a toggle and in the
|
| + * active state.
|
| + */
|
| + ariaActiveAttribute: {
|
| + type: String,
|
| + value: 'aria-pressed',
|
| + observer: '_ariaActiveAttributeChanged'
|
| + }
|
| + },
|
|
|
| - get opacityDecayVelocity() {
|
| - return this.element.opacityDecayVelocity;
|
| - },
|
| + listeners: {
|
| + down: '_downHandler',
|
| + up: '_upHandler',
|
| + tap: '_tapHandler'
|
| + },
|
|
|
| - get radius() {
|
| - var width2 = this.containerMetrics.width * this.containerMetrics.width;
|
| + observers: [
|
| + '_detectKeyboardFocus(focused)',
|
| + '_activeChanged(active, ariaActiveAttribute)'
|
| + ],
|
| +
|
| + keyBindings: {
|
| + 'enter:keydown': '_asyncClick',
|
| + 'space:keydown': '_spaceKeyDownHandler',
|
| + 'space:keyup': '_spaceKeyUpHandler',
|
| + },
|
| +
|
| + _mouseEventRe: /^mouse/,
|
| +
|
| + _tapHandler: function() {
|
| + if (this.toggles) {
|
| + // a tap is needed to toggle the active state
|
| + this._userActivate(!this.active);
|
| + } else {
|
| + this.active = false;
|
| + }
|
| + },
|
| +
|
| + _detectKeyboardFocus: function(focused) {
|
| + this._setReceivedFocusFromKeyboard(!this.pointerDown && focused);
|
| + },
|
| +
|
| + // to emulate native checkbox, (de-)activations from a user interaction fire
|
| + // 'change' events
|
| + _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: function(event) {
|
| + var keyboardEvent = event.detail.keyboardEvent;
|
| + keyboardEvent.preventDefault();
|
| + keyboardEvent.stopImmediatePropagation();
|
| + this._setPressed(true);
|
| + },
|
| +
|
| + _spaceKeyUpHandler: function() {
|
| + if (this.pressed) {
|
| + this._asyncClick();
|
| + }
|
| + this._setPressed(false);
|
| + },
|
| +
|
| + // trigger click asynchronously, the asynchrony is useful to allow one
|
| + // event handler to unwind before triggering another event
|
| + _asyncClick: function() {
|
| + this.async(function() {
|
| + this.click();
|
| + }, 1);
|
| + },
|
| +
|
| + // any of these changes are considered a change to button state
|
| +
|
| + _pressedChanged: function(pressed) {
|
| + this._changedButtonState();
|
| + },
|
| +
|
| + _ariaActiveAttributeChanged: function(value, oldValue) {
|
| + if (oldValue && oldValue != value && this.hasAttribute(oldValue)) {
|
| + this.removeAttribute(oldValue);
|
| + }
|
| + },
|
| +
|
| + _activeChanged: function(active, ariaActiveAttribute) {
|
| + if (this.toggles) {
|
| + this.setAttribute(this.ariaActiveAttribute,
|
| + active ? 'true' : 'false');
|
| + } else {
|
| + this.removeAttribute(this.ariaActiveAttribute);
|
| + }
|
| + this._changedButtonState();
|
| + },
|
| +
|
| + _controlStateChanged: function() {
|
| + if (this.disabled) {
|
| + this._setPressed(false);
|
| + } else {
|
| + this._changedButtonState();
|
| + }
|
| + },
|
| +
|
| + // provide hook for follow-on behaviors to react to button-state
|
| +
|
| + _changedButtonState: function() {
|
| + if (this._buttonStateChanged) {
|
| + this._buttonStateChanged(); // abstract
|
| + }
|
| + }
|
| +
|
| + };
|
| +
|
| + /** @polymerBehavior */
|
| + Polymer.IronButtonState = [
|
| + Polymer.IronA11yKeysBehavior,
|
| + Polymer.IronButtonStateImpl
|
| + ];
|
| +(function() {
|
| + var Utility = {
|
| + distance: function(x1, y1, x2, y2) {
|
| + var xDelta = (x1 - x2);
|
| + var yDelta = (y1 - y2);
|
| +
|
| + return Math.sqrt(xDelta * xDelta + yDelta * yDelta);
|
| + },
|
| +
|
| + now: window.performance && window.performance.now ?
|
| + window.performance.now.bind(window.performance) : Date.now
|
| + };
|
| +
|
| + /**
|
| + * @param {HTMLElement} element
|
| + * @constructor
|
| + */
|
| + function ElementMetrics(element) {
|
| + this.element = element;
|
| + this.width = this.boundingRect.width;
|
| + this.height = this.boundingRect.height;
|
| +
|
| + this.size = Math.max(this.width, this.height);
|
| + }
|
| +
|
| + ElementMetrics.prototype = {
|
| + get boundingRect () {
|
| + return this.element.getBoundingClientRect();
|
| + },
|
| +
|
| + furthestCornerDistanceFrom: function(x, y) {
|
| + var 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);
|
| + var bottomRight = Utility.distance(x, y, this.width, this.height);
|
| +
|
| + return Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
| + }
|
| + };
|
| +
|
| + /**
|
| + * @param {HTMLElement} element
|
| + * @constructor
|
| + */
|
| + function Ripple(element) {
|
| + this.element = element;
|
| + this.color = window.getComputedStyle(element).color;
|
| +
|
| + this.wave = document.createElement('div');
|
| + this.waveContainer = document.createElement('div');
|
| + this.wave.style.backgroundColor = this.color;
|
| + this.wave.classList.add('wave');
|
| + this.waveContainer.classList.add('wave-container');
|
| + Polymer.dom(this.waveContainer).appendChild(this.wave);
|
| +
|
| + this.resetInteractionState();
|
| + }
|
| +
|
| + Ripple.MAX_RADIUS = 300;
|
| +
|
| + Ripple.prototype = {
|
| + get recenters() {
|
| + return this.element.recenters;
|
| + },
|
| +
|
| + get center() {
|
| + return this.element.center;
|
| + },
|
| +
|
| + get mouseDownElapsed() {
|
| + var elapsed;
|
| +
|
| + if (!this.mouseDownStart) {
|
| + return 0;
|
| + }
|
| +
|
| + elapsed = Utility.now() - this.mouseDownStart;
|
| +
|
| + if (this.mouseUpStart) {
|
| + elapsed -= this.mouseUpElapsed;
|
| + }
|
| +
|
| + return elapsed;
|
| + },
|
| +
|
| + get mouseUpElapsed() {
|
| + return this.mouseUpStart ?
|
| + Utility.now () - this.mouseUpStart : 0;
|
| + },
|
| +
|
| + get mouseDownElapsedSeconds() {
|
| + return this.mouseDownElapsed / 1000;
|
| + },
|
| +
|
| + get mouseUpElapsedSeconds() {
|
| + return this.mouseUpElapsed / 1000;
|
| + },
|
| +
|
| + get mouseInteractionSeconds() {
|
| + return this.mouseDownElapsedSeconds + this.mouseUpElapsedSeconds;
|
| + },
|
| +
|
| + get initialOpacity() {
|
| + return this.element.initialOpacity;
|
| + },
|
| +
|
| + get opacityDecayVelocity() {
|
| + return this.element.opacityDecayVelocity;
|
| + },
|
| +
|
| + get radius() {
|
| + var width2 = this.containerMetrics.width * this.containerMetrics.width;
|
| var height2 = this.containerMetrics.height * this.containerMetrics.height;
|
| var waveRadius = Math.min(
|
| Math.sqrt(width2 + height2),
|
| @@ -11822,362 +12067,82 @@ Polymer({
|
| this._setAnimating(true);
|
|
|
| return ripple;
|
| - },
|
| -
|
| - removeRipple: function(ripple) {
|
| - var rippleIndex = this.ripples.indexOf(ripple);
|
| -
|
| - if (rippleIndex < 0) {
|
| - return;
|
| - }
|
| -
|
| - this.ripples.splice(rippleIndex, 1);
|
| -
|
| - ripple.remove();
|
| -
|
| - if (!this.ripples.length) {
|
| - this._setAnimating(false);
|
| - }
|
| - },
|
| -
|
| - animate: function() {
|
| - var index;
|
| - var ripple;
|
| -
|
| - this._animating = true;
|
| -
|
| - for (index = 0; index < this.ripples.length; ++index) {
|
| - ripple = this.ripples[index];
|
| -
|
| - ripple.draw();
|
| -
|
| - this.$.background.style.opacity = ripple.outerOpacity;
|
| -
|
| - if (ripple.isOpacityFullyDecayed && !ripple.isRestingAtMaxRadius) {
|
| - this.removeRipple(ripple);
|
| - }
|
| - }
|
| -
|
| - if (!this.shouldKeepAnimating && this.ripples.length === 0) {
|
| - this.onAnimationComplete();
|
| - } else {
|
| - window.requestAnimationFrame(this._boundAnimate);
|
| - }
|
| - },
|
| -
|
| - _onEnterKeydown: function() {
|
| - this.uiDownAction();
|
| - this.async(this.uiUpAction, 1);
|
| - },
|
| -
|
| - _onSpaceKeydown: function() {
|
| - this.uiDownAction();
|
| - },
|
| -
|
| - _onSpaceKeyup: function() {
|
| - this.uiUpAction();
|
| - },
|
| -
|
| - // note: holdDown does not respect noink since it can be a focus based
|
| - // effect.
|
| - _holdDownChanged: function(newVal, oldVal) {
|
| - if (oldVal === undefined) {
|
| - return;
|
| - }
|
| - if (newVal) {
|
| - this.downAction();
|
| - } else {
|
| - this.upAction();
|
| - }
|
| - },
|
| -
|
| - _noinkChanged: function(noink, attached) {
|
| - if (attached) {
|
| - this.keyEventTarget = noink ? this : this.target;
|
| - }
|
| - }
|
| - });
|
| - })();
|
| -/**
|
| - * @demo demo/index.html
|
| - * @polymerBehavior
|
| - */
|
| - Polymer.IronControlState = {
|
| -
|
| - properties: {
|
| -
|
| - /**
|
| - * If true, the element currently has focus.
|
| - */
|
| - focused: {
|
| - type: Boolean,
|
| - value: false,
|
| - notify: true,
|
| - readOnly: true,
|
| - reflectToAttribute: true
|
| - },
|
| -
|
| - /**
|
| - * If true, the user cannot interact with this element.
|
| - */
|
| - disabled: {
|
| - type: Boolean,
|
| - value: false,
|
| - notify: true,
|
| - observer: '_disabledChanged',
|
| - reflectToAttribute: true
|
| - },
|
| -
|
| - _oldTabIndex: {
|
| - type: Number
|
| - },
|
| -
|
| - _boundFocusBlurHandler: {
|
| - type: Function,
|
| - value: function() {
|
| - return this._focusBlurHandler.bind(this);
|
| - }
|
| - }
|
| -
|
| - },
|
| -
|
| - observers: [
|
| - '_changedControlState(focused, disabled)'
|
| - ],
|
| -
|
| - ready: function() {
|
| - this.addEventListener('focus', this._boundFocusBlurHandler, true);
|
| - this.addEventListener('blur', this._boundFocusBlurHandler, true);
|
| - },
|
| -
|
| - _focusBlurHandler: function(event) {
|
| - // NOTE(cdata): if we are in ShadowDOM land, `event.target` will
|
| - // eventually become `this` due to retargeting; if we are not in
|
| - // ShadowDOM land, `event.target` will eventually become `this` due
|
| - // to the second conditional which fires a synthetic event (that is also
|
| - // handled). In either case, we can disregard `event.path`.
|
| -
|
| - if (event.target === this) {
|
| - var focused = event.type === 'focus';
|
| - this._setFocused(focused);
|
| - } else if (!this.shadowRoot) {
|
| - this.fire(event.type, {sourceEvent: event}, {
|
| - node: this,
|
| - bubbles: event.bubbles,
|
| - cancelable: event.cancelable
|
| - });
|
| - }
|
| - },
|
| -
|
| - _disabledChanged: function(disabled, old) {
|
| - this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
|
| - this.style.pointerEvents = disabled ? 'none' : '';
|
| - if (disabled) {
|
| - this._oldTabIndex = this.tabIndex;
|
| - this.focused = false;
|
| - this.tabIndex = -1;
|
| - } else if (this._oldTabIndex !== undefined) {
|
| - this.tabIndex = this._oldTabIndex;
|
| - }
|
| - },
|
| -
|
| - _changedControlState: function() {
|
| - // _controlStateChanged is abstract, follow-on behaviors may implement it
|
| - if (this._controlStateChanged) {
|
| - this._controlStateChanged();
|
| - }
|
| - }
|
| -
|
| - };
|
| -/**
|
| - * @demo demo/index.html
|
| - * @polymerBehavior Polymer.IronButtonState
|
| - */
|
| - Polymer.IronButtonStateImpl = {
|
| -
|
| - properties: {
|
| -
|
| - /**
|
| - * If true, the user is currently holding down the button.
|
| - */
|
| - pressed: {
|
| - type: Boolean,
|
| - readOnly: true,
|
| - value: false,
|
| - reflectToAttribute: true,
|
| - observer: '_pressedChanged'
|
| - },
|
| -
|
| - /**
|
| - * If true, the button toggles the active state with each tap or press
|
| - * of the spacebar.
|
| - */
|
| - toggles: {
|
| - type: Boolean,
|
| - value: false,
|
| - reflectToAttribute: true
|
| - },
|
| -
|
| - /**
|
| - * If true, the button is a toggle and is currently in the active state.
|
| - */
|
| - active: {
|
| - type: Boolean,
|
| - value: false,
|
| - notify: true,
|
| - reflectToAttribute: true
|
| - },
|
| -
|
| - /**
|
| - * True if the element is currently being pressed by a "pointer," which
|
| - * is loosely defined as mouse or touch input (but specifically excluding
|
| - * keyboard input).
|
| - */
|
| - pointerDown: {
|
| - type: Boolean,
|
| - readOnly: true,
|
| - value: false
|
| - },
|
| -
|
| - /**
|
| - * True if the input device that caused the element to receive focus
|
| - * was a keyboard.
|
| - */
|
| - receivedFocusFromKeyboard: {
|
| - type: Boolean,
|
| - readOnly: true
|
| - },
|
| -
|
| - /**
|
| - * The aria attribute to be set if the button is a toggle and in the
|
| - * active state.
|
| - */
|
| - ariaActiveAttribute: {
|
| - type: String,
|
| - value: 'aria-pressed',
|
| - observer: '_ariaActiveAttributeChanged'
|
| - }
|
| - },
|
| -
|
| - listeners: {
|
| - down: '_downHandler',
|
| - up: '_upHandler',
|
| - tap: '_tapHandler'
|
| - },
|
| -
|
| - observers: [
|
| - '_detectKeyboardFocus(focused)',
|
| - '_activeChanged(active, ariaActiveAttribute)'
|
| - ],
|
| -
|
| - keyBindings: {
|
| - 'enter:keydown': '_asyncClick',
|
| - 'space:keydown': '_spaceKeyDownHandler',
|
| - 'space:keyup': '_spaceKeyUpHandler',
|
| - },
|
| -
|
| - _mouseEventRe: /^mouse/,
|
| -
|
| - _tapHandler: function() {
|
| - if (this.toggles) {
|
| - // a tap is needed to toggle the active state
|
| - this._userActivate(!this.active);
|
| - } else {
|
| - this.active = false;
|
| - }
|
| - },
|
| + },
|
|
|
| - _detectKeyboardFocus: function(focused) {
|
| - this._setReceivedFocusFromKeyboard(!this.pointerDown && focused);
|
| - },
|
| + removeRipple: function(ripple) {
|
| + var rippleIndex = this.ripples.indexOf(ripple);
|
|
|
| - // to emulate native checkbox, (de-)activations from a user interaction fire
|
| - // 'change' events
|
| - _userActivate: function(active) {
|
| - if (this.active !== active) {
|
| - this.active = active;
|
| - this.fire('change');
|
| - }
|
| - },
|
| + if (rippleIndex < 0) {
|
| + return;
|
| + }
|
|
|
| - _downHandler: function(event) {
|
| - this._setPointerDown(true);
|
| - this._setPressed(true);
|
| - this._setReceivedFocusFromKeyboard(false);
|
| - },
|
| + this.ripples.splice(rippleIndex, 1);
|
|
|
| - _upHandler: function() {
|
| - this._setPointerDown(false);
|
| - this._setPressed(false);
|
| - },
|
| + ripple.remove();
|
|
|
| - _spaceKeyDownHandler: function(event) {
|
| - var keyboardEvent = event.detail.keyboardEvent;
|
| - keyboardEvent.preventDefault();
|
| - keyboardEvent.stopImmediatePropagation();
|
| - this._setPressed(true);
|
| - },
|
| + if (!this.ripples.length) {
|
| + this._setAnimating(false);
|
| + }
|
| + },
|
|
|
| - _spaceKeyUpHandler: function() {
|
| - if (this.pressed) {
|
| - this._asyncClick();
|
| - }
|
| - this._setPressed(false);
|
| - },
|
| + animate: function() {
|
| + var index;
|
| + var ripple;
|
|
|
| - // trigger click asynchronously, the asynchrony is useful to allow one
|
| - // event handler to unwind before triggering another event
|
| - _asyncClick: function() {
|
| - this.async(function() {
|
| - this.click();
|
| - }, 1);
|
| - },
|
| + this._animating = true;
|
|
|
| - // any of these changes are considered a change to button state
|
| + for (index = 0; index < this.ripples.length; ++index) {
|
| + ripple = this.ripples[index];
|
|
|
| - _pressedChanged: function(pressed) {
|
| - this._changedButtonState();
|
| - },
|
| + ripple.draw();
|
|
|
| - _ariaActiveAttributeChanged: function(value, oldValue) {
|
| - if (oldValue && oldValue != value && this.hasAttribute(oldValue)) {
|
| - this.removeAttribute(oldValue);
|
| - }
|
| - },
|
| + this.$.background.style.opacity = ripple.outerOpacity;
|
|
|
| - _activeChanged: function(active, ariaActiveAttribute) {
|
| - if (this.toggles) {
|
| - this.setAttribute(this.ariaActiveAttribute,
|
| - active ? 'true' : 'false');
|
| - } else {
|
| - this.removeAttribute(this.ariaActiveAttribute);
|
| - }
|
| - this._changedButtonState();
|
| - },
|
| + if (ripple.isOpacityFullyDecayed && !ripple.isRestingAtMaxRadius) {
|
| + this.removeRipple(ripple);
|
| + }
|
| + }
|
|
|
| - _controlStateChanged: function() {
|
| - if (this.disabled) {
|
| - this._setPressed(false);
|
| - } else {
|
| - this._changedButtonState();
|
| - }
|
| - },
|
| + if (!this.shouldKeepAnimating && this.ripples.length === 0) {
|
| + this.onAnimationComplete();
|
| + } else {
|
| + window.requestAnimationFrame(this._boundAnimate);
|
| + }
|
| + },
|
|
|
| - // provide hook for follow-on behaviors to react to button-state
|
| + _onEnterKeydown: function() {
|
| + this.uiDownAction();
|
| + this.async(this.uiUpAction, 1);
|
| + },
|
|
|
| - _changedButtonState: function() {
|
| - if (this._buttonStateChanged) {
|
| - this._buttonStateChanged(); // abstract
|
| - }
|
| - }
|
| + _onSpaceKeydown: function() {
|
| + this.uiDownAction();
|
| + },
|
|
|
| - };
|
| + _onSpaceKeyup: function() {
|
| + this.uiUpAction();
|
| + },
|
|
|
| - /** @polymerBehavior */
|
| - Polymer.IronButtonState = [
|
| - Polymer.IronA11yKeysBehavior,
|
| - Polymer.IronButtonStateImpl
|
| - ];
|
| + // note: holdDown does not respect noink since it can be a focus based
|
| + // effect.
|
| + _holdDownChanged: function(newVal, oldVal) {
|
| + if (oldVal === undefined) {
|
| + return;
|
| + }
|
| + if (newVal) {
|
| + this.downAction();
|
| + } else {
|
| + this.upAction();
|
| + }
|
| + },
|
| +
|
| + _noinkChanged: function(noink, attached) {
|
| + if (attached) {
|
| + this.keyEventTarget = noink ? this : this.target;
|
| + }
|
| + }
|
| + });
|
| + })();
|
| /**
|
| * `Polymer.PaperRippleBehavior` dynamically implements a ripple
|
| * when the element has focus via pointer or keyboard.
|
| @@ -12279,6 +12244,78 @@ Polymer({
|
| }
|
|
|
| };
|
| +/**
|
| + * `Polymer.PaperInkyFocusBehavior` implements a ripple when the element has keyboard focus.
|
| + *
|
| + * @polymerBehavior Polymer.PaperInkyFocusBehaviorImpl
|
| + */
|
| + Polymer.PaperInkyFocusBehaviorImpl = {
|
| +
|
| + observers: [
|
| + '_focusedChanged(receivedFocusFromKeyboard)'
|
| + ],
|
| +
|
| + _focusedChanged: function(receivedFocusFromKeyboard) {
|
| + if (receivedFocusFromKeyboard) {
|
| + this.ensureRipple();
|
| + }
|
| + if (this.hasRipple()) {
|
| + this._ripple.holdDown = receivedFocusFromKeyboard;
|
| + }
|
| + },
|
| +
|
| + _createRipple: function() {
|
| + var ripple = Polymer.PaperRippleBehavior._createRipple();
|
| + ripple.id = 'ink';
|
| + ripple.setAttribute('center', '');
|
| + ripple.classList.add('circle');
|
| + return ripple;
|
| + }
|
| +
|
| + };
|
| +
|
| + /** @polymerBehavior Polymer.PaperInkyFocusBehavior */
|
| + Polymer.PaperInkyFocusBehavior = [
|
| + Polymer.IronButtonState,
|
| + Polymer.IronControlState,
|
| + Polymer.PaperRippleBehavior,
|
| + Polymer.PaperInkyFocusBehaviorImpl
|
| + ];
|
| +Polymer({
|
| + is: 'paper-material',
|
| +
|
| + properties: {
|
| +
|
| + /**
|
| + * The z-depth of this element, from 0-5. Setting to 0 will remove the
|
| + * shadow, and each increasing number greater than 0 will be "deeper"
|
| + * than the last.
|
| + *
|
| + * @attribute elevation
|
| + * @type number
|
| + * @default 1
|
| + */
|
| + elevation: {
|
| + type: Number,
|
| + reflectToAttribute: true,
|
| + value: 1
|
| + },
|
| +
|
| + /**
|
| + * Set this to true to animate the shadow when setting a new
|
| + * `elevation` value.
|
| + *
|
| + * @attribute animated
|
| + * @type boolean
|
| + * @default false
|
| + */
|
| + animated: {
|
| + type: Boolean,
|
| + reflectToAttribute: true,
|
| + value: false
|
| + }
|
| + }
|
| + });
|
| /** @polymerBehavior Polymer.PaperButtonBehavior */
|
| Polymer.PaperButtonBehaviorImpl = {
|
|
|
| @@ -12584,6 +12621,19 @@ Polymer({
|
| // found in the LICENSE file.
|
|
|
| cr.define('downloads', function() {
|
| + var InkyTextButton = Polymer({
|
| + is: 'inky-text-button',
|
| +
|
| + behaviors: [
|
| + Polymer.PaperInkyFocusBehavior
|
| + ],
|
| +
|
| + hostAttributes: {
|
| + role: 'button',
|
| + tabindex: 0,
|
| + },
|
| + });
|
| +
|
| var Item = Polymer({
|
| is: 'downloads-item',
|
|
|
| @@ -12900,7 +12950,10 @@ cr.define('downloads', function() {
|
| },
|
| });
|
|
|
| - return {Item: Item};
|
| + return {
|
| + InkyTextButton: InkyTextButton,
|
| + Item: Item,
|
| + };
|
| });
|
| Polymer({
|
| is: 'paper-item',
|
| @@ -15882,43 +15935,6 @@ Polymer({
|
|
|
| Polymer.PaperMenuButton = PaperMenuButton;
|
| })();
|
| -/**
|
| - * `Polymer.PaperInkyFocusBehavior` implements a ripple when the element has keyboard focus.
|
| - *
|
| - * @polymerBehavior Polymer.PaperInkyFocusBehaviorImpl
|
| - */
|
| - Polymer.PaperInkyFocusBehaviorImpl = {
|
| -
|
| - observers: [
|
| - '_focusedChanged(receivedFocusFromKeyboard)'
|
| - ],
|
| -
|
| - _focusedChanged: function(receivedFocusFromKeyboard) {
|
| - if (receivedFocusFromKeyboard) {
|
| - this.ensureRipple();
|
| - }
|
| - if (this.hasRipple()) {
|
| - this._ripple.holdDown = receivedFocusFromKeyboard;
|
| - }
|
| - },
|
| -
|
| - _createRipple: function() {
|
| - var ripple = Polymer.PaperRippleBehavior._createRipple();
|
| - ripple.id = 'ink';
|
| - ripple.setAttribute('center', '');
|
| - ripple.classList.add('circle');
|
| - return ripple;
|
| - }
|
| -
|
| - };
|
| -
|
| - /** @polymerBehavior Polymer.PaperInkyFocusBehavior */
|
| - Polymer.PaperInkyFocusBehavior = [
|
| - Polymer.IronButtonState,
|
| - Polymer.IronControlState,
|
| - Polymer.PaperRippleBehavior,
|
| - Polymer.PaperInkyFocusBehaviorImpl
|
| - ];
|
| Polymer({
|
| is: 'paper-icon-button',
|
|
|
|
|