| Index: third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js
|
| diff --git a/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js
|
| index 405afe187bf9067914bca48413ce5df35133334a..2d39dfeb8bd3a16ffe12dcd37b8184de4c3493fe 100644
|
| --- a/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js
|
| +++ b/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js
|
| @@ -80,6 +80,14 @@
|
| },
|
|
|
| /**
|
| + * If provided, this will be the element that will be focused when
|
| + * the dropdown opens.
|
| + */
|
| + focusTarget: {
|
| + type: Object
|
| + },
|
| +
|
| + /**
|
| * Set to true to disable animations when opening and closing the
|
| * dropdown.
|
| */
|
| @@ -119,6 +127,17 @@
|
| return Polymer.dom(this.$.content).getDistributedNodes()[0];
|
| },
|
|
|
| + /**
|
| + * The element that should be focused when the dropdown opens.
|
| + */
|
| + get _focusTarget() {
|
| + return this.focusTarget || this.containedElement;
|
| + },
|
| +
|
| + /**
|
| + * The element that should be used to position the dropdown when
|
| + * it opens, if no position target is configured.
|
| + */
|
| get _defaultPositionTarget() {
|
| var parent = Polymer.dom(this).parentNode;
|
|
|
| @@ -129,6 +148,9 @@
|
| return parent;
|
| },
|
|
|
| + /**
|
| + * The bounding rect of the position target.
|
| + */
|
| get _positionRect() {
|
| if (!this._positionRectMemo && this.positionTarget) {
|
| this._positionRectMemo = this.positionTarget.getBoundingClientRect();
|
| @@ -137,6 +159,9 @@
|
| return this._positionRectMemo;
|
| },
|
|
|
| + /**
|
| + * The horizontal offset value used to position the dropdown.
|
| + */
|
| get _horizontalAlignTargetValue() {
|
| var target;
|
|
|
| @@ -151,6 +176,9 @@
|
| return Math.max(target, 0);
|
| },
|
|
|
| + /**
|
| + * The vertical offset value used to position the dropdown.
|
| + */
|
| get _verticalAlignTargetValue() {
|
| var target;
|
|
|
| @@ -165,27 +193,41 @@
|
| return Math.max(target, 0);
|
| },
|
|
|
| + /**
|
| + * Called when the value of `opened` changes.
|
| + *
|
| + * @param {boolean} opened True if the dropdown is opened.
|
| + */
|
| _openedChanged: function(opened) {
|
| if (opened && this.disabled) {
|
| this.cancel();
|
| } else {
|
| - this._cancelAnimations();
|
| + this.cancelAnimation();
|
| this._prepareDropdown();
|
| Polymer.IronOverlayBehaviorImpl._openedChanged.apply(this, arguments);
|
| }
|
| +
|
| + if (this.opened) {
|
| + this._focusContent();
|
| + }
|
| },
|
|
|
| + /**
|
| + * Overridden from `IronOverlayBehavior`.
|
| + */
|
| _renderOpened: function() {
|
| Polymer.IronDropdownScrollManager.pushScrollLock(this);
|
| if (!this.noAnimations && this.animationConfig && this.animationConfig.open) {
|
| this.$.contentWrapper.classList.add('animating');
|
| this.playAnimation('open');
|
| } else {
|
| - this._focusContent();
|
| Polymer.IronOverlayBehaviorImpl._renderOpened.apply(this, arguments);
|
| }
|
| },
|
|
|
| + /**
|
| + * Overridden from `IronOverlayBehavior`.
|
| + */
|
| _renderClosed: function() {
|
| Polymer.IronDropdownScrollManager.removeScrollLock(this);
|
| if (!this.noAnimations && this.animationConfig && this.animationConfig.close) {
|
| @@ -196,6 +238,12 @@
|
| }
|
| },
|
|
|
| + /**
|
| + * Called when animation finishes on the dropdown (when opening or
|
| + * closing). Responsible for "completing" the process of opening or
|
| + * closing the dropdown by positioning it or setting its display to
|
| + * none.
|
| + */
|
| _onNeonAnimationFinish: function() {
|
| this.$.contentWrapper.classList.remove('animating');
|
| if (this.opened) {
|
| @@ -205,6 +253,9 @@
|
| }
|
| },
|
|
|
| + /**
|
| + * Called when an `iron-resize` event fires.
|
| + */
|
| _onIronResize: function() {
|
| var containedElement = this.containedElement;
|
| var scrollTop;
|
| @@ -227,14 +278,17 @@
|
| }
|
| },
|
|
|
| + /**
|
| + * Called when the `positionTarget` property changes.
|
| + */
|
| _positionTargetChanged: function() {
|
| this._updateOverlayPosition();
|
| },
|
|
|
| - _cancelAnimations: function() {
|
| - this.cancelAnimation();
|
| - },
|
| -
|
| + /**
|
| + * Constructs the final animation config from different properties used
|
| + * to configure specific parts of the opening and closing animations.
|
| + */
|
| _updateAnimationConfig: function() {
|
| var animationConfig = {};
|
| var animations = [];
|
| @@ -262,12 +316,21 @@
|
| this.animationConfig = animationConfig;
|
| },
|
|
|
| + /**
|
| + * Prepares the dropdown for opening by updating measured layout
|
| + * values.
|
| + */
|
| _prepareDropdown: function() {
|
| this.sizingTarget = this.containedElement || this.sizingTarget;
|
| this._updateAnimationConfig();
|
| this._updateOverlayPosition();
|
| },
|
|
|
| + /**
|
| + * Updates the overlay position based on configured horizontal
|
| + * and vertical alignment, and re-memoizes these values for the sake
|
| + * of behavior in `IronFitBehavior`.
|
| + */
|
| _updateOverlayPosition: function() {
|
| this._positionRectMemo = null;
|
|
|
| @@ -293,10 +356,17 @@
|
| }
|
| },
|
|
|
| + /**
|
| + * Focuses the configured focus target.
|
| + */
|
| _focusContent: function() {
|
| - if (this.containedElement) {
|
| - this.containedElement.focus();
|
| - }
|
| + // NOTE(cdata): This is async so that it can attempt the focus after
|
| + // `display: none` is removed from the element.
|
| + this.async(function() {
|
| + if (this._focusTarget) {
|
| + this._focusTarget.focus();
|
| + }
|
| + });
|
| }
|
| });
|
| })();
|
|
|