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: 'gaia-button', | 6 is: 'gaia-button', |
7 | 7 |
8 properties: { | 8 properties: { |
9 disabled: { | 9 disabled: {type: Boolean, value: false, reflectToAttribute: true}, |
10 type: Boolean, | |
11 value: false, | |
12 reflectToAttribute: true | |
13 }, | |
14 | 10 |
15 type: { | 11 type: { |
16 type: String, | 12 type: String, |
17 value: '', | 13 value: '', |
18 reflectToAttribute: true, | 14 reflectToAttribute: true, |
19 observer: 'typeChanged_' | 15 observer: 'typeChanged_' |
20 } | 16 } |
21 }, | 17 }, |
22 | 18 |
23 focus: function() { | 19 focus: function() { |
24 this.$.button.focus(); | 20 this.$.button.focus(); |
25 }, | 21 }, |
26 | 22 |
27 focusedChanged_: function() { | 23 focusedChanged_: function() { |
28 if (this.type == 'link' || this.type == 'dialog') | 24 if (this.type == 'link' || this.type == 'dialog') |
29 return; | 25 return; |
30 this.$.button.raised = this.$.button.focused; | 26 this.$.button.raised = this.$.button.focused; |
31 }, | 27 }, |
32 | 28 |
33 typeChanged_: function() { | 29 typeChanged_: function() { |
34 if (this.type == 'link') | 30 if (this.type == 'link') |
35 this.$.button.setAttribute('noink', ''); | 31 this.$.button.setAttribute('noink', ''); |
36 else | 32 else |
37 this.$.button.removeAttribute('noink'); | 33 this.$.button.removeAttribute('noink'); |
38 }, | 34 }, |
39 | 35 |
40 onClick_: function(e) { | 36 onClick_: function(e) { |
41 if (this.disabled) | 37 if (this.disabled) |
42 e.stopPropagation(); | 38 e.stopPropagation(); |
43 } | 39 } |
44 }); | 40 }); |
45 | 41 |
46 Polymer({ | 42 Polymer({ |
47 is: 'gaia-icon-button', | 43 is: 'gaia-icon-button', |
48 | 44 |
49 properties: { | 45 properties: { |
50 disabled: { | 46 disabled: {type: Boolean, value: false, reflectToAttribute: true}, |
51 type: Boolean, | |
52 value: false, | |
53 reflectToAttribute: true | |
54 }, | |
55 | 47 |
56 icon: String, | 48 icon: String, |
57 | 49 |
58 ariaLabel: String | 50 ariaLabel: String |
59 }, | 51 }, |
60 | 52 |
61 focus: function() { | 53 focus: function() { |
62 this.$.iconButton.focus(); | 54 this.$.iconButton.focus(); |
63 }, | 55 }, |
64 | 56 |
65 onClick_: function(e) { | 57 onClick_: function(e) { |
66 if (this.disabled) | 58 if (this.disabled) |
67 e.stopPropagation(); | 59 e.stopPropagation(); |
68 } | 60 } |
69 }); | 61 }); |
OLD | NEW |