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 /** | 5 /** |
6 * @fileoverview Polymer element for displaying the network state for a specific | 6 * @fileoverview Polymer element for displaying the network state for a specific |
7 * type and a list of networks for that type. | 7 * type and a list of networks for that type. |
8 */ | 8 */ |
9 | 9 |
10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ | 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ |
11 var DeviceStateProperties; | 11 var DeviceStateProperties; |
12 | 12 |
13 Polymer({ | 13 Polymer({ |
14 is: 'network-summary-item', | 14 is: 'network-summary-item', |
15 | 15 |
16 properties: { | 16 properties: { |
17 /** | 17 /** The expanded state of the list of networks. */ |
18 * True if the list is expanded. | |
19 */ | |
20 expanded: { | 18 expanded: { |
21 type: Boolean, | 19 type: Boolean, |
22 value: false, | 20 value: false, |
23 observer: 'expandedChanged_', | 21 observer: 'expandedChanged_', |
24 }, | 22 }, |
25 | 23 |
26 /** | 24 /** |
25 * Whether the list has been expanded. This is used to ensure the | |
26 * iron-collapse section animates correctly. | |
27 */ | |
28 wasExpanded: { | |
29 type: Boolean, | |
30 value: false, | |
31 }, | |
32 | |
33 /** | |
27 * The maximum height in pixels for the list of networks. | 34 * The maximum height in pixels for the list of networks. |
28 */ | 35 */ |
29 maxHeight: { | 36 maxHeight: { |
30 type: Number, | 37 type: Number, |
31 value: 200, | 38 value: 200, |
32 }, | 39 }, |
33 | 40 |
34 /** | 41 /** |
35 * Device state for the network type. | 42 * Device state for the network type. |
36 * @type {DeviceStateProperties|undefined} | 43 * @type {DeviceStateProperties|undefined} |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 | 100 |
94 /** | 101 /** |
95 * @param {DeviceStateProperties|undefined} deviceState | 102 * @param {DeviceStateProperties|undefined} deviceState |
96 * @return {boolean} Whether or not the device state is enabled. | 103 * @return {boolean} Whether or not the device state is enabled. |
97 * @private | 104 * @private |
98 */ | 105 */ |
99 deviceIsEnabled_: function(deviceState) { | 106 deviceIsEnabled_: function(deviceState) { |
100 return !!deviceState && deviceState.State == 'Enabled'; | 107 return !!deviceState && deviceState.State == 'Enabled'; |
101 }, | 108 }, |
102 | 109 |
103 /** | 110 /** |
dschuyler
2016/08/18 23:30:18
I think this needs a comment. Is this what this
fu
stevenjb
2016/08/19 00:20:43
Added a hopefully helpful comment.
| |
111 * @return {boolean} | |
112 * @private | |
113 */ | |
114 domIfIsVisible_() { | |
115 if (this.expanded == this.wasExpanded) | |
116 return this.expanded; | |
117 if (this.expanded) { | |
118 Polymer.RenderStatus.afterNextRender(this, function() { | |
119 this.wasExpanded = true; | |
120 }.bind(this)); | |
121 return true; | |
122 } | |
123 return this.wasExpanded; | |
124 }, | |
125 | |
126 /** | |
dschuyler
2016/08/18 23:30:18
Please add a comment. Maybe:
* Always false until
stevenjb
2016/08/19 00:20:43
Acknowledged.
| |
127 * @return {boolean} | |
128 * @private | |
129 */ | |
130 ironCollapseIsOpened_() { | |
131 return this.expanded && this.wasExpanded; | |
132 }, | |
133 | |
134 /** | |
104 * @param {DeviceStateProperties} deviceState | 135 * @param {DeviceStateProperties} deviceState |
105 * @return {boolean} | 136 * @return {boolean} |
106 * @private | 137 * @private |
107 */ | 138 */ |
108 enableIsVisible_: function(deviceState) { | 139 enableIsVisible_: function(deviceState) { |
109 return !!deviceState && deviceState.Type != CrOnc.Type.ETHERNET && | 140 return !!deviceState && deviceState.Type != CrOnc.Type.ETHERNET && |
110 deviceState.Type != CrOnc.Type.VPN; | 141 deviceState.Type != CrOnc.Type.VPN; |
111 }, | 142 }, |
112 | 143 |
113 /** | 144 /** |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 | 207 |
177 /** | 208 /** |
178 * Called whenever the 'selectable' state might change. | 209 * Called whenever the 'selectable' state might change. |
179 * @private | 210 * @private |
180 */ | 211 */ |
181 updateSelectable_: function() { | 212 updateSelectable_: function() { |
182 var selectable = this.deviceIsEnabled_(this.deviceState); | 213 var selectable = this.deviceIsEnabled_(this.deviceState); |
183 this.$.details.classList.toggle('selectable', selectable); | 214 this.$.details.classList.toggle('selectable', selectable); |
184 }, | 215 }, |
185 }); | 216 }); |
OLD | NEW |