diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-23 17:21:03 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-23 16:25:15 +0000 |
commit | c551f43206405019121bd2b2c93714319a0a3300 (patch) | |
tree | 1f48c30631c421fd4bbb3c36da20183c8a2ed7d7 /chromium/chrome/browser/resources/pdf/elements/viewer-zoom-button.js | |
parent | 7961cea6d1041e3e454dae6a1da660b453efd238 (diff) |
BASELINE: Update Chromium to 79.0.3945.139
Change-Id: I336b7182fab9bca80b709682489c07db112eaca5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/resources/pdf/elements/viewer-zoom-button.js')
-rw-r--r-- | chromium/chrome/browser/resources/pdf/elements/viewer-zoom-button.js | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-button.js b/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-button.js new file mode 100644 index 00000000000..2359900d83c --- /dev/null +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-button.js @@ -0,0 +1,134 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +Polymer({ + is: 'viewer-zoom-button', + + properties: { + /** Index of the icon currently being displayed. */ + activeIndex: { + type: Number, + value: 0, + }, + + delay: { + type: Number, + observer: 'delayChanged_', + }, + + /** + * Icons to be displayed on the FAB. Multiple icons should be separated with + * spaces, and will be cycled through every time the FAB is clicked. + */ + icons: String, + + /** + * Used to show the appropriate drop shadow when buttons are focused with + * the keyboard. + */ + keyboardNavigationActive: { + type: Boolean, + reflectToAttribute: true, + }, + + newPrintPreview: { + type: Boolean, + reflectToAttribute: true, + }, + + showOnLeft: { + type: Boolean, + reflectToAttribute: true, + }, + + /** @type {?Array<string>} */ + tooltips: Array, + + /** @private */ + closed_: { + type: Boolean, + reflectToAttribute: true, + value: false, + }, + + /** + * Array version of the list of icons. Polymer does not allow array + * properties to be set from HTML, so we must use a string property and + * perform the conversion manually. + * @private {!Array<string>} + */ + icons_: { + type: Array, + value: [''], + computed: 'computeIconsArray_(icons)', + }, + + /** + * Icon currently being displayed on the FAB. + * @private + */ + visibleIcon_: { + type: String, + computed: 'computeVisibleIcon_(icons_, activeIndex)', + }, + + /** @private */ + visibleTooltip_: { + type: String, + computed: 'computeVisibleTooltip_(tooltips, activeIndex)', + } + }, + + /** + * @param {string} icons Icon names in a string, delimited by spaces + * @return {!Array<string>} Array of icon name strings + * @private + */ + computeIconsArray_: function(icons) { + return icons.split(' '); + }, + + /** + * @param {!Array<string>} icons Array of icon name strings. + * @param {number} activeIndex Index of the currently active icon. + * @return {string} Icon name for the currently visible icon. + * @private + */ + computeVisibleIcon_: function(icons, activeIndex) { + return icons[activeIndex]; + }, + + /** + * @param {?Array<string>} tooltips Array of tooltip strings. + * @param {number} activeIndex Index of the currently active icon. + * @return {string} Tooltip for the currently visible icon. + * @private + */ + computeVisibleTooltip_: function(tooltips, activeIndex) { + return tooltips === undefined ? '' : tooltips[activeIndex]; + }, + + /** @private */ + delayChanged_: function() { + this.$.wrapper.style.transitionDelay = this.delay + 'ms'; + }, + + show: function() { + this.closed_ = false; + }, + + hide: function() { + this.closed_ = true; + }, + + /** @private */ + fireClick_: function() { + // We cannot attach an on-click to the entire viewer-zoom-button, as this + // will include clicks on the margins. Instead, proxy clicks on the FAB + // through. + this.fire('fabclick'); + + this.activeIndex = (this.activeIndex + 1) % this.icons_.length; + } +}); |