OLD | NEW |
1 | 1 |
2 Polymer({ | 2 Polymer({ |
3 is: 'paper-toggle-button', | 3 is: 'paper-toggle-button', |
4 | 4 |
5 behaviors: [ | 5 behaviors: [ |
6 Polymer.PaperButtonBehavior | 6 Polymer.PaperRadioButtonBehavior |
7 ], | 7 ], |
8 | 8 |
9 // The custom properties shim is currently an opt-in feature. | 9 // The custom properties shim is currently an opt-in feature. |
10 enableCustomStyleProperties: true, | 10 enableCustomStyleProperties: true, |
11 | 11 |
12 hostAttributes: { | 12 hostAttributes: { |
13 role: 'button', | 13 role: 'button', |
14 'aria-pressed': 'false', | 14 'aria-pressed': 'false', |
15 tabindex: 0 | 15 tabindex: 0 |
16 }, | 16 }, |
(...skipping 13 matching lines...) Expand all Loading... |
30 * Gets or sets the state, `true` is checked and `false` is unchecked. | 30 * Gets or sets the state, `true` is checked and `false` is unchecked. |
31 * | 31 * |
32 * @attribute checked | 32 * @attribute checked |
33 * @type boolean | 33 * @type boolean |
34 * @default false | 34 * @default false |
35 */ | 35 */ |
36 checked: { | 36 checked: { |
37 type: Boolean, | 37 type: Boolean, |
38 value: false, | 38 value: false, |
39 reflectToAttribute: true, | 39 reflectToAttribute: true, |
| 40 notify: true, |
40 observer: '_checkedChanged' | 41 observer: '_checkedChanged' |
| 42 }, |
| 43 |
| 44 /** |
| 45 * If true, the button toggles the active state with each tap or press |
| 46 * of the spacebar. |
| 47 * |
| 48 * @attribute toggles |
| 49 * @type boolean |
| 50 * @default true |
| 51 */ |
| 52 toggles: { |
| 53 type: Boolean, |
| 54 value: true, |
| 55 reflectToAttribute: true |
41 } | 56 } |
42 }, | 57 }, |
43 | 58 |
44 listeners: { | 59 listeners: { |
45 // TODO(sjmiles): tracking feature disabled until we can control | 60 // TODO(sjmiles): tracking feature disabled until we can control |
46 // track/tap interaction with confidence | 61 // track/tap interaction with confidence |
47 //xtrack: '_ontrack' | 62 //xtrack: '_ontrack' |
48 }, | 63 }, |
49 | 64 |
50 ready: function() { | |
51 this.toggles = true; | |
52 }, | |
53 | |
54 // button-behavior hook | 65 // button-behavior hook |
55 _buttonStateChanged: function() { | 66 _buttonStateChanged: function() { |
56 this.checked = this.active; | 67 this.checked = this.active; |
57 }, | 68 }, |
58 | 69 |
59 _checkedChanged: function(checked) { | 70 _checkedChanged: function(checked) { |
60 this.active = this.checked; | 71 this.active = this.checked; |
61 this.fire('iron-change'); | 72 this.fire('iron-change'); |
62 }, | 73 }, |
63 | 74 |
(...skipping 23 matching lines...) Expand all Loading... |
87 }, | 98 }, |
88 | 99 |
89 _trackEnd: function(track) { | 100 _trackEnd: function(track) { |
90 this.$.toggleButton.classList.remove('dragging'); | 101 this.$.toggleButton.classList.remove('dragging'); |
91 this.transform(this, ''); | 102 this.transform(this, ''); |
92 this._userActivate(Math.abs(this._x) > this._width / 2); | 103 this._userActivate(Math.abs(this._x) > this._width / 2); |
93 } | 104 } |
94 | 105 |
95 }); | 106 }); |
96 | 107 |
OLD | NEW |