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 information about a network | 6 * @fileoverview Polymer element for displaying information about a network |
7 * in a list or summary based on ONC state properties. | 7 * in a list or summary based on ONC state properties. |
8 */ | 8 */ |
9 | 9 |
10 Polymer({ | 10 Polymer({ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 getItemName_: function() { | 84 getItemName_: function() { |
85 if (this.item.hasOwnProperty('customItemName')) { | 85 if (this.item.hasOwnProperty('customItemName')) { |
86 let item = /** @type {!CrNetworkList.CustomItemState} */ (this.item); | 86 let item = /** @type {!CrNetworkList.CustomItemState} */ (this.item); |
87 let name = item.customItemName || ''; | 87 let name = item.customItemName || ''; |
88 if (this.i18nExists(item.customItemName)) | 88 if (this.i18nExists(item.customItemName)) |
89 name = this.i18n(item.customItemName); | 89 name = this.i18n(item.customItemName); |
90 return name; | 90 return name; |
91 } | 91 } |
92 let network = /** @type {!CrOnc.NetworkStateProperties} */ (this.item); | 92 let network = /** @type {!CrOnc.NetworkStateProperties} */ (this.item); |
93 if (this.isListItem) | 93 if (this.isListItem) |
94 return CrOnc.getNetworkName(network, this.i18n); | 94 return CrOnc.getNetworkName(network, this, this.i18n); |
95 return this.i18n('OncType' + network.Type); | 95 return this.i18n('OncType' + network.Type); |
96 }, | 96 }, |
97 | 97 |
98 /** @private */ | 98 /** @private */ |
99 isStateTextVisible_() { | 99 isStateTextVisible_() { |
100 return !!this.networkState && (!this.isListItem || this.isConnected_()); | 100 return !!this.networkState && (!this.isListItem || this.isConnected_()); |
101 }, | 101 }, |
102 | 102 |
103 /** @private */ | 103 /** @private */ |
104 isStateTextConnected_() { | 104 isStateTextConnected_() { |
105 return this.isListItem && this.isConnected_(); | 105 return this.isListItem && this.isConnected_(); |
106 }, | 106 }, |
107 | 107 |
108 /** | 108 /** |
109 * This only gets called for network items once networkState is set. | 109 * This only gets called for network items once networkState is set. |
110 * @private | 110 * @private |
111 */ | 111 */ |
112 getNetworkStateText_: function() { | 112 getNetworkStateText_: function() { |
113 if (!this.isStateTextVisible_()) | 113 if (!this.isStateTextVisible_()) |
114 return ''; | 114 return ''; |
115 let network = this.networkState; | 115 let network = this.networkState; |
116 if (this.isListItem) | 116 if (this.isListItem) |
117 return this.i18n('networkListItemConnected'); | 117 return this.i18n('networkListItemConnected'); |
118 if (network.Name && network.ConnectionState) { | 118 if (network.Name && network.ConnectionState) { |
119 return this.getConnectionStateText_( | 119 return this.getConnectionStateText_( |
120 network.ConnectionState, CrOnc.getNetworkName(network, this.i18n)); | 120 network.ConnectionState, |
| 121 CrOnc.getNetworkName(network, this, this.i18n)); |
121 } | 122 } |
122 return this.i18n('networkDisabled'); | 123 return this.i18n('networkDisabled'); |
123 }, | 124 }, |
124 | 125 |
125 /** | 126 /** |
126 * Returns the appropriate connection state text. | 127 * Returns the appropriate connection state text. |
127 * @param {string} state The connection state. | 128 * @param {string} state The connection state. |
128 * @param {string} name The name of the network. | 129 * @param {string} name The name of the network. |
129 * @return {string} | 130 * @return {string} |
130 */ | 131 */ |
(...skipping 26 matching lines...) Expand all Loading... |
157 * Fires a 'show-details' event with |this.networkState| as the details. | 158 * Fires a 'show-details' event with |this.networkState| as the details. |
158 * @param {Event} event | 159 * @param {Event} event |
159 * @private | 160 * @private |
160 */ | 161 */ |
161 fireShowDetails_: function(event) { | 162 fireShowDetails_: function(event) { |
162 assert(this.networkState); | 163 assert(this.networkState); |
163 this.fire('show-detail', this.networkState); | 164 this.fire('show-detail', this.networkState); |
164 event.stopPropagation(); | 165 event.stopPropagation(); |
165 }, | 166 }, |
166 }); | 167 }); |
OLD | NEW |