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 Polymer({ | 5 Polymer({ |
6 is: 'viewer-zoom-button', | 6 is: 'viewer-zoom-button', |
7 | 7 |
8 properties: { | 8 properties: { |
9 /** | 9 /** |
10 * Icons to be displayed on the FAB. Multiple icons should be separated with | 10 * Icons to be displayed on the FAB. Multiple icons should be separated with |
11 * spaces, and will be cycled through every time the FAB is clicked. | 11 * spaces, and will be cycled through every time the FAB is clicked. |
12 */ | 12 */ |
13 icons: String, | 13 icons: String, |
14 | 14 |
15 /** | 15 /** |
16 * Array version of the list of icons. Polymer does not allow array | 16 * Array version of the list of icons. Polymer does not allow array |
17 * properties to be set from HTML, so we must use a string property and | 17 * properties to be set from HTML, so we must use a string property and |
18 * perform the conversion manually. | 18 * perform the conversion manually. |
19 * @private | 19 * @private |
20 */ | 20 */ |
21 icons_: { | 21 icons_: {type: Array, value: [''], computed: 'computeIconsArray_(icons)'}, |
22 type: Array, | |
23 value: [''], | |
24 computed: 'computeIconsArray_(icons)' | |
25 }, | |
26 | 22 |
27 tooltips: Array, | 23 tooltips: Array, |
28 | 24 |
29 closed: { | 25 closed: {type: Boolean, reflectToAttribute: true, value: false}, |
30 type: Boolean, | |
31 reflectToAttribute: true, | |
32 value: false | |
33 }, | |
34 | 26 |
35 delay: { | 27 delay: {type: Number, observer: 'delayChanged_'}, |
36 type: Number, | |
37 observer: 'delayChanged_' | |
38 }, | |
39 | 28 |
40 /** | 29 /** |
41 * Index of the icon currently being displayed. | 30 * Index of the icon currently being displayed. |
42 */ | 31 */ |
43 activeIndex: { | 32 activeIndex: {type: Number, value: 0}, |
44 type: Number, | |
45 value: 0 | |
46 }, | |
47 | 33 |
48 /** | 34 /** |
49 * Icon currently being displayed on the FAB. | 35 * Icon currently being displayed on the FAB. |
50 * @private | 36 * @private |
51 */ | 37 */ |
52 visibleIcon_: { | 38 visibleIcon_: |
53 type: String, | 39 {type: String, computed: 'computeVisibleIcon_(icons_, activeIndex)'}, |
54 computed: 'computeVisibleIcon_(icons_, activeIndex)' | |
55 }, | |
56 | 40 |
57 visibleTooltip_: { | 41 visibleTooltip_: { |
58 type: String, | 42 type: String, |
59 computed: 'computeVisibleTooltip_(tooltips, activeIndex)' | 43 computed: 'computeVisibleTooltip_(tooltips, activeIndex)' |
60 } | 44 } |
61 }, | 45 }, |
62 | 46 |
63 computeIconsArray_: function(icons) { | 47 computeIconsArray_: function(icons) { |
64 return icons.split(' '); | 48 return icons.split(' '); |
65 }, | 49 }, |
(...skipping 20 matching lines...) Expand all Loading... |
86 | 70 |
87 fireClick: function() { | 71 fireClick: function() { |
88 // We cannot attach an on-click to the entire viewer-zoom-button, as this | 72 // We cannot attach an on-click to the entire viewer-zoom-button, as this |
89 // will include clicks on the margins. Instead, proxy clicks on the FAB | 73 // will include clicks on the margins. Instead, proxy clicks on the FAB |
90 // through. | 74 // through. |
91 this.fire('fabclick'); | 75 this.fire('fabclick'); |
92 | 76 |
93 this.activeIndex = (this.activeIndex + 1) % this.icons_.length; | 77 this.activeIndex = (this.activeIndex + 1) % this.icons_.length; |
94 } | 78 } |
95 }); | 79 }); |
OLD | NEW |