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

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

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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
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: {type: Object, observer: 'updateTooltips_'},
15 type: Object,
16 observer: 'updateTooltips_'
17 },
18 15
19 visible_: { 16 visible_: {type: Boolean, value: true}
20 type: Boolean, 17 },
21 value: true
22 }
23 },
24 18
25 isVisible: function() { 19 isVisible: function() {
26 return this.visible_; 20 return this.visible_;
27 }, 21 },
28 22
29 /** 23 /**
30 * @private 24 * @private
31 * Change button tooltips to match any changes to localized strings. 25 * Change button tooltips to match any changes to localized strings.
32 */ 26 */
33 updateTooltips_: function() { 27 updateTooltips_: function() {
34 this.$['fit-button'].tooltips = [ 28 this.$['fit-button'].tooltips =
35 this.strings.tooltipFitToPage, 29 [this.strings.tooltipFitToPage, this.strings.tooltipFitToWidth];
36 this.strings.tooltipFitToWidth 30 this.$['zoom-in-button'].tooltips = [this.strings.tooltipZoomIn];
37 ]; 31 this.$['zoom-out-button'].tooltips = [this.strings.tooltipZoomOut];
38 this.$['zoom-in-button'].tooltips = [this.strings.tooltipZoomIn]; 32 },
39 this.$['zoom-out-button'].tooltips = [this.strings.tooltipZoomOut];
40 },
41 33
42 /** 34 /**
43 * Handle clicks of the fit-button. 35 * Handle clicks of the fit-button.
44 */ 36 */
45 fitToggle: function() { 37 fitToggle: function() {
46 if (this.$['fit-button'].activeIndex == FIT_TO_WIDTH) 38 if (this.$['fit-button'].activeIndex == FIT_TO_WIDTH)
47 this.fire('fit-to-width'); 39 this.fire('fit-to-width');
48 else 40 else
49 this.fire('fit-to-page'); 41 this.fire('fit-to-page');
50 }, 42 },
51 43
52 /** 44 /**
53 * Handle the keyboard shortcut equivalent of fit-button clicks. 45 * Handle the keyboard shortcut equivalent of fit-button clicks.
54 */ 46 */
55 fitToggleFromHotKey: function() { 47 fitToggleFromHotKey: function() {
56 this.fitToggle(); 48 this.fitToggle();
57 49
58 // Toggle the button state since there was no mouse click. 50 // Toggle the button state since there was no mouse click.
59 var button = this.$['fit-button']; 51 var button = this.$['fit-button'];
60 if (button.activeIndex == FIT_TO_WIDTH) 52 if (button.activeIndex == FIT_TO_WIDTH)
61 button.activeIndex = FIT_TO_PAGE; 53 button.activeIndex = FIT_TO_PAGE;
62 else 54 else
63 button.activeIndex = FIT_TO_WIDTH; 55 button.activeIndex = FIT_TO_WIDTH;
64 }, 56 },
65 57
66 /** 58 /**
67 * Handle clicks of the zoom-in-button. 59 * Handle clicks of the zoom-in-button.
68 */ 60 */
69 zoomIn: function() { 61 zoomIn: function() {
70 this.fire('zoom-in'); 62 this.fire('zoom-in');
71 }, 63 },
72 64
73 /** 65 /**
74 * Handle clicks of the zoom-out-button. 66 * Handle clicks of the zoom-out-button.
75 */ 67 */
76 zoomOut: function() { 68 zoomOut: function() {
77 this.fire('zoom-out'); 69 this.fire('zoom-out');
78 }, 70 },
79 71
80 show: function() { 72 show: function() {
81 if (!this.visible_) { 73 if (!this.visible_) {
82 this.visible_ = true; 74 this.visible_ = true;
83 this.$['fit-button'].show(); 75 this.$['fit-button'].show();
84 this.$['zoom-in-button'].show(); 76 this.$['zoom-in-button'].show();
85 this.$['zoom-out-button'].show(); 77 this.$['zoom-out-button'].show();
86 } 78 }
87 }, 79 },
88 80
89 hide: function() { 81 hide: function() {
90 if (this.visible_) { 82 if (this.visible_) {
91 this.visible_ = false; 83 this.visible_ = false;
92 this.$['fit-button'].hide(); 84 this.$['fit-button'].hide();
93 this.$['zoom-in-button'].hide(); 85 this.$['zoom-in-button'].hide();
94 this.$['zoom-out-button'].hide(); 86 this.$['zoom-out-button'].hide();
95 } 87 }
96 }, 88 },
97 }); 89 });
98 90
99 })(); 91 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698