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

Side by Side Diff: chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js

Issue 2283803003: PDF: Add shortcut to toggle fit-to-{page,width}. (Closed)
Patch Set: Extend testZoomToolbarToggle Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 6
7 var FIT_TO_PAGE = 0; 7 var FIT_TO_PAGE = 0;
8 var FIT_TO_WIDTH = 1; 8 var FIT_TO_WIDTH = 1;
9 9
10 Polymer({ 10 Polymer({
11 is: 'viewer-zoom-toolbar', 11 is: 'viewer-zoom-toolbar',
12 12
13 properties: { 13 properties: {
14 strings: { 14 strings: {
15 type: Object, 15 type: Object,
16 observer: 'updateTooltips_' 16 observer: 'updateTooltips_'
17 }, 17 },
18 18
19 visible_: { 19 visible_: {
20 type: Boolean, 20 type: Boolean,
21 value: true 21 value: true
22 } 22 }
23 }, 23 },
24 24
25 isVisible: function() { 25 isVisible: function() {
26 return this.visible_; 26 return this.visible_;
27 }, 27 },
28 28
29 /** 29 /**
30 * @private
30 * Change button tooltips to match any changes to localized strings. 31 * Change button tooltips to match any changes to localized strings.
31 */ 32 */
32 updateTooltips_: function() { 33 updateTooltips_: function() {
33 this.$['fit-button'].tooltips = [ 34 this.$['fit-button'].tooltips = [
34 this.strings.tooltipFitToPage, 35 this.strings.tooltipFitToPage,
35 this.strings.tooltipFitToWidth 36 this.strings.tooltipFitToWidth
36 ]; 37 ];
37 this.$['zoom-in-button'].tooltips = [this.strings.tooltipZoomIn]; 38 this.$['zoom-in-button'].tooltips = [this.strings.tooltipZoomIn];
38 this.$['zoom-out-button'].tooltips = [this.strings.tooltipZoomOut]; 39 this.$['zoom-out-button'].tooltips = [this.strings.tooltipZoomOut];
39 }, 40 },
40 41
42 /**
43 * Handle clicks of the fit-button.
44 */
41 fitToggle: function() { 45 fitToggle: function() {
42 if (this.$['fit-button'].activeIndex == FIT_TO_WIDTH) 46 if (this.$['fit-button'].activeIndex == FIT_TO_WIDTH)
43 this.fire('fit-to-width'); 47 this.fire('fit-to-width');
44 else 48 else
45 this.fire('fit-to-page'); 49 this.fire('fit-to-page');
46 }, 50 },
47 51
52 /**
53 * Handle the keyboard shortcut equivalent of fit-button clicks.
54 */
55 fitToggleFromHotKey: function() {
56 this.fitToggle();
57
58 // Toggle the button state since there was no mouse click.
59 var button = this.$['fit-button'];
60 if (button.activeIndex == FIT_TO_WIDTH)
61 button.activeIndex = FIT_TO_PAGE;
62 else
63 button.activeIndex = FIT_TO_WIDTH;
64 },
65
66 /**
67 * Handle clicks of the zoom-in-button.
68 */
48 zoomIn: function() { 69 zoomIn: function() {
49 this.fire('zoom-in'); 70 this.fire('zoom-in');
50 }, 71 },
51 72
73 /**
74 * Handle clicks of the zoom-out-button.
75 */
52 zoomOut: function() { 76 zoomOut: function() {
53 this.fire('zoom-out'); 77 this.fire('zoom-out');
54 }, 78 },
55 79
56 show: function() { 80 show: function() {
57 if (!this.visible_) { 81 if (!this.visible_) {
58 this.visible_ = true; 82 this.visible_ = true;
59 this.$['fit-button'].show(); 83 this.$['fit-button'].show();
60 this.$['zoom-in-button'].show(); 84 this.$['zoom-in-button'].show();
61 this.$['zoom-out-button'].show(); 85 this.$['zoom-out-button'].show();
62 } 86 }
63 }, 87 },
64 88
65 hide: function() { 89 hide: function() {
66 if (this.visible_) { 90 if (this.visible_) {
67 this.visible_ = false; 91 this.visible_ = false;
68 this.$['fit-button'].hide(); 92 this.$['fit-button'].hide();
69 this.$['zoom-in-button'].hide(); 93 this.$['zoom-in-button'].hide();
70 this.$['zoom-out-button'].hide(); 94 this.$['zoom-out-button'].hide();
71 } 95 }
72 }, 96 },
73 }); 97 });
74 98
75 })(); 99 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698