summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.js
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-23 17:21:03 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-23 16:25:15 +0000
commitc551f43206405019121bd2b2c93714319a0a3300 (patch)
tree1f48c30631c421fd4bbb3c36da20183c8a2ed7d7 /chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.js
parent7961cea6d1041e3e454dae6a1da660b453efd238 (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-pdf-toolbar/viewer-pdf-toolbar.js')
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.js264
1 files changed, 0 insertions, 264 deletions
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.js b/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.js
deleted file mode 100644
index afb87dfe6b7..00000000000
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.js
+++ /dev/null
@@ -1,264 +0,0 @@
-// 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.
-(function() {
-Polymer({
- is: 'viewer-pdf-toolbar',
-
- properties: {
- /**
- * Whether annotation mode can be entered. This would be false if for
- * example the PDF is encrypted or password protected. Note, this is
- * true regardless of whether the feature flag is enabled.
- */
- annotationAvailable: {
- type: Boolean,
- value: true,
- },
-
- /** Whether the viewer is currently in annotation mode. */
- annotationMode: {
- type: Boolean,
- notify: true,
- value: false,
- reflectToAttribute: true,
- },
-
- /** @type {?Object} */
- annotationTool: {
- type: Object,
- value: null,
- notify: true,
- },
-
- /**
- * Tree of PDF bookmarks (empty if the document has no bookmarks).
- * @type {!Array<!Bookmark>}
- */
- bookmarks: {
- type: Array,
- value: () => [],
- },
-
- canRedoAnnotation: {
- type: Boolean,
- value: false,
- },
-
- canUndoAnnotation: {
- type: Boolean,
- value: false,
- },
-
- /** The number of pages in the PDF document. */
- docLength: Number,
-
- /** The title of the PDF document. */
- docTitle: String,
-
- /** The current loading progress of the PDF document (0 - 100). */
- loadProgress: {
- type: Number,
- observer: 'loadProgressChanged_',
- },
-
- /** Whether the toolbar is opened and visible. */
- opened: {
- type: Boolean,
- value: true,
- },
-
- /** The number of the page being viewed (1-based). */
- pageNo: Number,
-
- /** Whether the PDF Annotations feature is enabled. */
- pdfAnnotationsEnabled: {
- type: Boolean,
- value: false,
- },
-
- /** Whether the Printing feature is enabled. */
- printingEnabled: {
- type: Boolean,
- value: false,
- },
-
- strings: Object,
- },
-
- /** @type {?Object} */
- animation_: null,
-
- /**
- * @param {number} newProgress
- * @param {number} oldProgress
- * @private
- */
- loadProgressChanged_: function(newProgress, oldProgress) {
- const loaded = newProgress >= 100;
- const progressReset = newProgress < oldProgress;
- if (progressReset || loaded) {
- this.$.pageselector.classList.toggle('invisible', !loaded);
- this.$.buttons.classList.toggle('invisible', !loaded);
- this.$.progress.style.opacity = loaded ? 0 : 1;
- this.$['annotations-bar'].hidden = !loaded || !this.annotationMode;
- }
- },
-
- hide: function() {
- if (this.opened && !this.shouldKeepOpen()) {
- this.toggleVisibility();
- }
- },
-
- show: function() {
- if (!this.opened) {
- this.toggleVisibility();
- }
- },
-
- toggleVisibility: function() {
- this.opened = !this.opened;
-
- // We keep a handle on the animation in order to cancel the filling
- // behavior of previous animations.
- if (this.animation_) {
- this.animation_.cancel();
- }
-
- if (this.opened) {
- this.animation_ = this.animate(
- [{transform: 'translateY(-100%)'}, {transform: 'translateY(0%)'}], {
- duration: 250,
- easing: 'cubic-bezier(0, 0, 0.2, 1)',
- fill: 'forwards',
- });
- } else {
- this.animation_ = this.animate(
- [{transform: 'translateY(0%)'}, {transform: 'translateY(-100%)'}], {
- duration: 250,
- easing: 'cubic-bezier(0.4, 0, 1, 1)',
- fill: 'forwards',
- });
- }
- },
-
- selectPageNumber: function() {
- this.$.pageselector.select();
- },
-
- /** @return {boolean} Whether the toolbar should be kept open. */
- shouldKeepOpen: function() {
- return this.$.bookmarks.dropdownOpen || this.loadProgress < 100 ||
- this.$.pageselector.isActive() || this.annotationMode;
- },
-
- /** @return {boolean} Whether a dropdown was open and was hidden. */
- hideDropdowns: function() {
- let result = false;
- if (this.$.bookmarks.dropdownOpen) {
- this.$.bookmarks.toggleDropdown();
- result = true;
- }
- if (this.$.pen.dropdownOpen) {
- this.$.pen.toggleDropdown();
- result = true;
- }
- if (this.$.highlighter.dropdownOpen) {
- this.$.highlighter.toggleDropdown();
- result = true;
- }
- return result;
- },
-
- /** @param {number} lowerBound */
- setDropdownLowerBound: function(lowerBound) {
- this.$.bookmarks.lowerBound = lowerBound;
- },
-
- rotateRight: function() {
- this.fire('rotate-right');
- },
-
- download: function() {
- this.fire('save');
- },
-
- print: function() {
- this.fire('print');
- },
-
- undo: function() {
- this.fire('undo');
- },
-
- redo: function() {
- this.fire('redo');
- },
-
- toggleAnnotation: function() {
- this.annotationMode = !this.annotationMode;
- if (this.annotationMode) {
- // Select pen tool when entering annotation mode.
- this.updateAnnotationTool_(this.$.pen);
- }
- this.dispatchEvent(new CustomEvent('annotation-mode-toggled', {
- detail: {
- value: this.annotationMode,
- },
- }));
- },
-
- /**
- * @param {!Event} e
- * @private
- */
- annotationToolClicked_: function(e) {
- this.updateAnnotationTool_(/** @type {!HTMLElement} */ (e.currentTarget));
- },
-
- /**
- * @param {!Event} e
- * @private
- */
- annotationToolOptionChanged_: function(e) {
- const element = e.currentTarget.parentElement;
- if (!this.annotationTool || element.id != this.annotationTool.tool) {
- return;
- }
- this.updateAnnotationTool_(e.currentTarget.parentElement);
- },
-
- /**
- * @param {!HTMLElement} element
- * @private
- */
- updateAnnotationTool_: function(element) {
- const tool = element.id;
- const options = element.querySelector('viewer-pen-options') || {
- selectedSize: 1,
- selectedColor: null,
- };
- const attributeStyleMap = element.attributeStyleMap;
- attributeStyleMap.set('--pen-tip-fill', options.selectedColor);
- attributeStyleMap.set(
- '--pen-tip-border',
- options.selectedColor == '#000000' ? 'currentcolor' :
- options.selectedColor);
- this.annotationTool = {
- tool: tool,
- size: options.selectedSize,
- color: options.selectedColor,
- };
- },
-
- /**
- * @param {string} toolName
- * @return {boolean} Whether the annotation tool is using tool |toolName|.
- * @private
- */
- isAnnotationTool_: function(toolName) {
- return !!this.annotationTool && this.annotationTool.tool === toolName;
- },
-});
-})();