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

Side by Side Diff: chrome/browser/resources/settings/device_page/device_page.js

Issue 2675383003: MD Settings: CrOS: Elim device page icons (Closed)
Patch Set: Rebase Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 'settings-device-page' is the settings page for device and 6 * @fileoverview 'settings-device-page' is the settings page for device and
7 * peripheral settings. 7 * peripheral settings.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-device-page', 10 is: 'settings-device-page',
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 /** @private {boolean} Whether a low-power (USB) charger is being used. */ 64 /** @private {boolean} Whether a low-power (USB) charger is being used. */
65 lowPowerCharger_: Boolean, 65 lowPowerCharger_: Boolean,
66 66
67 /** 67 /**
68 * List of available dual-role power sources, if enablePowerSettings_ is on. 68 * List of available dual-role power sources, if enablePowerSettings_ is on.
69 * @private {!Array<!settings.PowerSource>|undefined} 69 * @private {!Array<!settings.PowerSource>|undefined}
70 */ 70 */
71 powerSources_: Array, 71 powerSources_: Array,
72 72
73 /** @private */ 73 /** @private */
74 batteryIcon_: {
75 type: String,
76 computed: 'computeBatteryIcon_(batteryStatus_, lowPowerCharger_)',
77 value: 'settings:battery-unknown',
78 },
79
80 /** @private */
81 powerLabel_: { 74 powerLabel_: {
82 type: String, 75 type: String,
83 computed: 'computePowerLabel_(powerSources_, batteryStatus_.calculating)', 76 computed: 'computePowerLabel_(powerSources_, batteryStatus_.calculating)',
84 }, 77 },
85 78
86 /** @private */ 79 /** @private */
87 showPowerDropdown_: { 80 showPowerDropdown_: {
88 type: Boolean, 81 type: Boolean,
89 computed: 'computeShowPowerDropdown_(powerSources_)', 82 computed: 'computeShowPowerDropdown_(powerSources_)',
90 value: false, 83 value: false,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (this.hasMouse_ && this.hasTouchpad_) 126 if (this.hasMouse_ && this.hasTouchpad_)
134 return this.i18n('mouseAndTouchpadTitle'); 127 return this.i18n('mouseAndTouchpadTitle');
135 if (this.hasMouse_) 128 if (this.hasMouse_)
136 return this.i18n('mouseTitle'); 129 return this.i18n('mouseTitle');
137 if (this.hasTouchpad_) 130 if (this.hasTouchpad_)
138 return this.i18n('touchpadTitle'); 131 return this.i18n('touchpadTitle');
139 return ''; 132 return '';
140 }, 133 },
141 134
142 /** 135 /**
143 * @return {string}
144 * @private
145 */
146 getPointersIcon_: function() {
147 if (this.hasMouse_)
148 return 'settings:mouse';
149 if (this.hasTouchpad_)
150 return 'settings:touch-app';
151 return '';
152 },
153
154 /**
155 * @param {*} lhs 136 * @param {*} lhs
156 * @param {*} rhs 137 * @param {*} rhs
157 * @return {boolean} 138 * @return {boolean}
158 */ 139 */
159 isEqual_: function(lhs, rhs) { 140 isEqual_: function(lhs, rhs) {
160 return lhs === rhs; 141 return lhs === rhs;
161 }, 142 },
162 143
163 /** 144 /**
164 * @param {!settings.BatteryStatus} batteryStatus
165 * @param {boolean} lowPowerCharger
166 * @return {string}
167 */
168 computeBatteryIcon_: function(batteryStatus, lowPowerCharger) {
169 var iconPrefix = 'settings:battery-';
170
171 if (batteryStatus.calculating)
172 return iconPrefix + 'unknown';
173
174 if (lowPowerCharger)
175 return iconPrefix + 'unreliable';
176
177 if (!batteryStatus.charging && batteryStatus.percent < 5)
178 return iconPrefix + 'alert';
179
180 // Compute the rest of the icon: iconPrefix + '[charging-]<percent>'.
181 if (batteryStatus.charging)
182 iconPrefix += 'charging-';
183
184 // Show the highest level icon that doesn't go over the actual percentage.
185 if (batteryStatus.percent < 30)
186 return iconPrefix + '20';
187 if (batteryStatus.percent < 50)
188 return iconPrefix + '30';
189 if (batteryStatus.percent < 60)
190 return iconPrefix + '50';
191 if (batteryStatus.percent < 80)
192 return iconPrefix + '60';
193 if (batteryStatus.percent < 90)
194 return iconPrefix + '80';
195 if (batteryStatus.percent < 100)
196 return iconPrefix + '90';
197 return iconPrefix + 'full';
198 },
199
200 /**
201 * @param {!Array<!settings.PowerSource>|undefined} powerSources 145 * @param {!Array<!settings.PowerSource>|undefined} powerSources
202 * @param {boolean} calculating 146 * @param {boolean} calculating
203 * @return {string} The primary label for the power row. 147 * @return {string} The primary label for the power row.
204 * @private 148 * @private
205 */ 149 */
206 computePowerLabel_: function(powerSources, calculating) { 150 computePowerLabel_: function(powerSources, calculating) {
207 return this.i18n(calculating ? 'calculatingPower' : 151 return this.i18n(calculating ? 'calculatingPower' :
208 powerSources.length ? 'powerSourceLabel' : 'powerSourceBattery'); 152 powerSources.length ? 'powerSourceLabel' : 'powerSourceBattery');
209 }, 153 },
210 154
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 * @private 256 * @private
313 */ 257 */
314 checkPointerSubpage_: function() { 258 checkPointerSubpage_: function() {
315 // Check that the properties have explicitly been set to false. 259 // Check that the properties have explicitly been set to false.
316 if (this.hasMouse_ === false && this.hasTouchpad_ === false && 260 if (this.hasMouse_ === false && this.hasTouchpad_ === false &&
317 settings.getCurrentRoute() == settings.Route.POINTERS) { 261 settings.getCurrentRoute() == settings.Route.POINTERS) {
318 settings.navigateTo(settings.Route.DEVICE); 262 settings.navigateTo(settings.Route.DEVICE);
319 } 263 }
320 }, 264 },
321 }); 265 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/device_page/device_page.html ('k') | chrome/browser/resources/settings/icons.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698