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

Unified Diff: third_party/polymer/v1_0/components-chromium/paper-tabs/paper-tabs-extracted.js

Issue 1862213002: Roll third_party/polymer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete appearance_browsertest.js, result of a previous bad merge. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/paper-tabs/paper-tabs-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/paper-tabs/paper-tabs-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-tabs/paper-tabs-extracted.js
index 9711b0ef6dac2e31512c6f507664682f3eb412d4..c62ca49ae69f3470d65a0b1629abba7aee349068 100644
--- a/third_party/polymer/v1_0/components-chromium/paper-tabs/paper-tabs-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/paper-tabs/paper-tabs-extracted.js
@@ -71,6 +71,25 @@ Polymer({
value: 'paper-tab'
},
+ /**
+ * If true, tabs are automatically selected when focused using the
+ * keyboard.
+ */
+ autoselect: {
+ type: Boolean,
+ value: false
+ },
+
+ /**
+ * The delay (in milliseconds) between when the user stops interacting
+ * with the tabs through the keyboard and when the focused item is
+ * automatically selected (if `autoselect` is true).
+ */
+ autoselectDelay: {
+ type: Number,
+ value: 0
+ },
+
_step: {
type: Number,
value: 10
@@ -107,14 +126,26 @@ Polymer({
'iron-deselect': '_onIronDeselect'
},
+ keyBindings: {
+ 'left:keyup right:keyup': '_onArrowKeyup'
+ },
+
created: function() {
this._holdJob = null;
+ this._pendingActivationItem = undefined;
+ this._pendingActivationTimeout = undefined;
+ this._bindDelayedActivationHandler = this._delayedActivationHandler.bind(this);
+ this.addEventListener('blur', this._onBlurCapture.bind(this), true);
},
ready: function() {
this.setScrollDirection('y', this.$.tabsContainer);
},
+ detached: function() {
+ this._cancelPendingActivation();
+ },
+
_noinkChanged: function(noink) {
var childTabs = Polymer.dom(this).querySelectorAll('paper-tab');
childTabs.forEach(noink ? this._setNoinkAttribute : this._removeNoinkAttribute);
@@ -176,6 +207,62 @@ Polymer({
}, 1);
},
+ _activateHandler: function() {
+ // Cancel item activations scheduled by keyboard events when any other
+ // action causes an item to be activated (e.g. clicks).
+ this._cancelPendingActivation();
+
+ Polymer.IronMenuBehaviorImpl._activateHandler.apply(this, arguments);
+ },
+
+ /**
+ * Activates an item after a delay (in milliseconds).
+ */
+ _scheduleActivation: function(item, delay) {
+ this._pendingActivationItem = item;
+ this._pendingActivationTimeout = this.async(
+ this._bindDelayedActivationHandler, delay);
+ },
+
+ /**
+ * Activates the last item given to `_scheduleActivation`.
+ */
+ _delayedActivationHandler: function() {
+ var item = this._pendingActivationItem;
+ this._pendingActivationItem = undefined;
+ this._pendingActivationTimeout = undefined;
+ item.fire(this.activateEvent, null, {
+ bubbles: true,
+ cancelable: true
+ });
+ },
+
+ /**
+ * Cancels a previously scheduled item activation made with
+ * `_scheduleActivation`.
+ */
+ _cancelPendingActivation: function() {
+ if (this._pendingActivationTimeout !== undefined) {
+ this.cancelAsync(this._pendingActivationTimeout);
+ this._pendingActivationItem = undefined;
+ this._pendingActivationTimeout = undefined;
+ }
+ },
+
+ _onArrowKeyup: function(event) {
+ if (this.autoselect) {
+ this._scheduleActivation(this.focusedItem, this.autoselectDelay);
+ }
+ },
+
+ _onBlurCapture: function(event) {
+ // Cancel a scheduled item activation (if any) when that item is
+ // blurred.
+ if (event.target === this._pendingActivationItem) {
+ this._cancelPendingActivation();
+ }
+ },
+
get _tabContainerScrollSize () {
return Math.max(
0,
@@ -184,7 +271,6 @@ Polymer({
);
},
-
_scroll: function(e, detail) {
if (!this.scrollable) {
return;

Powered by Google App Engine
This is Rietveld 408576698