OLD | NEW |
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({ |
(...skipping 20 matching lines...) Expand all Loading... |
31 */ | 31 */ |
32 updateTooltips_: function() { | 32 updateTooltips_: function() { |
33 this.$['fit-button'].tooltips = [ | 33 this.$['fit-button'].tooltips = [ |
34 this.strings.tooltipFitToPage, | 34 this.strings.tooltipFitToPage, |
35 this.strings.tooltipFitToWidth | 35 this.strings.tooltipFitToWidth |
36 ]; | 36 ]; |
37 this.$['zoom-in-button'].tooltips = [this.strings.tooltipZoomIn]; | 37 this.$['zoom-in-button'].tooltips = [this.strings.tooltipZoomIn]; |
38 this.$['zoom-out-button'].tooltips = [this.strings.tooltipZoomOut]; | 38 this.$['zoom-out-button'].tooltips = [this.strings.tooltipZoomOut]; |
39 }, | 39 }, |
40 | 40 |
| 41 /** |
| 42 * Toggle the state of the fit-button when something external, e.g. the |
| 43 * fit-button equivalent shortcut key, toggles the zoom state. |
| 44 */ |
| 45 toggleFitButtonUIState: function() { |
| 46 var button = this.$['fit-button']; |
| 47 if (button.activeIndex == FIT_TO_WIDTH) |
| 48 button.activeIndex = FIT_TO_PAGE; |
| 49 else |
| 50 button.activeIndex = FIT_TO_WIDTH; |
| 51 }, |
| 52 |
| 53 /** |
| 54 * Handle clicks of the fit-button. |
| 55 */ |
41 fitToggle: function() { | 56 fitToggle: function() { |
42 if (this.$['fit-button'].activeIndex == FIT_TO_WIDTH) | 57 if (this.$['fit-button'].activeIndex == FIT_TO_WIDTH) |
43 this.fire('fit-to-width'); | 58 this.fire('fit-to-width'); |
44 else | 59 else |
45 this.fire('fit-to-page'); | 60 this.fire('fit-to-page'); |
46 }, | 61 }, |
47 | 62 |
| 63 /** |
| 64 * Handle clicks of the zoom-in-button. |
| 65 */ |
48 zoomIn: function() { | 66 zoomIn: function() { |
49 this.fire('zoom-in'); | 67 this.fire('zoom-in'); |
50 }, | 68 }, |
51 | 69 |
| 70 /** |
| 71 * Handle clicks of the zoom-out-button. |
| 72 */ |
52 zoomOut: function() { | 73 zoomOut: function() { |
53 this.fire('zoom-out'); | 74 this.fire('zoom-out'); |
54 }, | 75 }, |
55 | 76 |
56 show: function() { | 77 show: function() { |
57 if (!this.visible_) { | 78 if (!this.visible_) { |
58 this.visible_ = true; | 79 this.visible_ = true; |
59 this.$['fit-button'].show(); | 80 this.$['fit-button'].show(); |
60 this.$['zoom-in-button'].show(); | 81 this.$['zoom-in-button'].show(); |
61 this.$['zoom-out-button'].show(); | 82 this.$['zoom-out-button'].show(); |
62 } | 83 } |
63 }, | 84 }, |
64 | 85 |
65 hide: function() { | 86 hide: function() { |
66 if (this.visible_) { | 87 if (this.visible_) { |
67 this.visible_ = false; | 88 this.visible_ = false; |
68 this.$['fit-button'].hide(); | 89 this.$['fit-button'].hide(); |
69 this.$['zoom-in-button'].hide(); | 90 this.$['zoom-in-button'].hide(); |
70 this.$['zoom-out-button'].hide(); | 91 this.$['zoom-out-button'].hide(); |
71 } | 92 } |
72 }, | 93 }, |
73 }); | 94 }); |
74 | 95 |
75 })(); | 96 })(); |
OLD | NEW |