Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Side by Side Diff: ui/webui/resources/cr_elements/network/cr_network_icon.js

Issue 2648843002: cr-network-icon: Animate connecting using .svg (Closed)
Patch Set: Use <include> for .svg files and type=BINDATA Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 rendering network icons based on ONC 6 * @fileoverview Polymer element for rendering network icons based on ONC
7 * state properties. 7 * state properties.
8 */ 8 */
9 9
10 Polymer({ 10 Polymer({
(...skipping 16 matching lines...) Expand all
27 isListItem: { 27 isListItem: {
28 type: Boolean, 28 type: Boolean,
29 value: false, 29 value: false,
30 }, 30 },
31 }, 31 },
32 32
33 /** 33 /**
34 * @return {string} The name of the svg icon image to show. 34 * @return {string} The name of the svg icon image to show.
35 * @private 35 * @private
36 */ 36 */
37 getIcon_: function() { 37 getIconClass_: function() {
38 if (!this.networkState) 38 if (!this.networkState)
39 return ''; 39 return '';
40 let showDisconnected = 40 var type = this.networkState.Type;
41 !this.isListItem && (!this.networkState.ConnectionState || 41 if (type == CrOnc.Type.ETHERNET)
42 this.networkState.ConnectionState == 42 return 'ethernet';
43 CrOnc.ConnectionState.NOT_CONNECTED); 43 if (type == CrOnc.Type.VPN)
44 return 'vpn';
44 45
45 switch (this.networkState.Type) { 46 var prefix = type == CrOnc.Type.CELLULAR ? 'cellular-' : 'wifi-';
46 case CrOnc.Type.ETHERNET: { 47 var connectionState = this.networkState.ConnectionState;
47 return 'network:settings-ethernet'; 48 if (connectionState == CrOnc.ConnectionState.CONNECTING)
48 } 49 return prefix + 'connecting';
49 case CrOnc.Type.VPN: { 50 var strength;
50 return 'network:vpn-key'; 51 if (!this.isListItem &&
51 } 52 (!connectionState ||
52 case CrOnc.Type.CELLULAR: { 53 connectionState == CrOnc.ConnectionState.NOT_CONNECTED)) {
53 let strength = 54 if (type != CrOnc.Type.CELLULAR)
54 showDisconnected ? 0 : CrOnc.getSignalStrength(this.networkState); 55 return prefix + 'off';
55 let index = this.strengthToIndex_(strength); 56 strength = 0;
56 return 'network:signal-cellular-' + index.toString(10) + '-bar'; 57 } else {
57 } 58 strength = CrOnc.getSignalStrength(this.networkState);
58 case CrOnc.Type.WI_FI:
59 case CrOnc.Type.WI_MAX: {
60 if (showDisconnected)
61 return 'network:signal-wifi-off';
62 let strength = CrOnc.getSignalStrength(this.networkState);
63 let index = this.strengthToIndex_(strength);
64 return 'network:signal-wifi-' + index.toString(10) + '-bar';
65 }
66 default:
67 assertNotReached();
68 } 59 }
69 return ''; 60 return prefix + this.strengthToIndex_(strength).toString(10);
70 }, 61 },
71 62
72 /** 63 /**
73 * @param {number} strength The signal strength from [0 - 100]. 64 * @param {number} strength The signal strength from [0 - 100].
74 * @return {number} An index from 0-4 corresponding to |strength|. 65 * @return {number} An index from 0-4 corresponding to |strength|.
75 * @private 66 * @private
76 */ 67 */
77 strengthToIndex_: function(strength) { 68 strengthToIndex_: function(strength) {
78 if (strength == 0) 69 if (strength == 0)
79 return 0; 70 return 0;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 let networkState = this.networkState; 137 let networkState = this.networkState;
147 if (!this.networkState) 138 if (!this.networkState)
148 return false; 139 return false;
149 if (networkState.Type == CrOnc.Type.WI_FI && networkState.WiFi) { 140 if (networkState.Type == CrOnc.Type.WI_FI && networkState.WiFi) {
150 let security = networkState.WiFi.Security; 141 let security = networkState.WiFi.Security;
151 return !!security && security != 'None'; 142 return !!security && security != 'None';
152 } 143 }
153 return false; 144 return false;
154 }, 145 },
155 }); 146 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/network/cr_network_icon.html ('k') | ui/webui/resources/cr_elements/network/ethernet.svg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698