OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 Polymer('device-list', { |
| 6 publish: { |
| 7 /** |
| 8 * The label of the list to be displayed. |
| 9 * @type {string} |
| 10 */ |
| 11 label: 'Device List', |
| 12 |
| 13 /** |
| 14 * Info of the devices contained in the list. |
| 15 * @type {Array.<DeviceInfo>} |
| 16 */ |
| 17 devices: null |
| 18 }, |
| 19 |
| 20 /** |
| 21 * Called when an instance is created. |
| 22 */ |
| 23 created: function() { |
| 24 this.devices = []; |
| 25 }, |
| 26 |
| 27 /** |
| 28 * @param {string} reason The device ineligibility reason. |
| 29 * @return {string} The prettified ineligibility reason. |
| 30 * @private |
| 31 */ |
| 32 prettifyReason_: function(reason) { |
| 33 if (reason == null) |
| 34 return ''; |
| 35 var reasonWithSpaces = reason.replace(/([A-Z])/g, ' $1'); |
| 36 return reasonWithSpaces[0].toUpperCase() + reasonWithSpaces.slice(1); |
| 37 }, |
| 38 |
| 39 /** |
| 40 * @param {string} connectionStatus The Bluetooth connection status. |
| 41 * @return {string} The icon id to be shown for the connection state. |
| 42 * @private |
| 43 */ |
| 44 getIconForConnection_: function(connectionStatus) { |
| 45 switch (connectionStatus) { |
| 46 case 'connected': |
| 47 return 'device:bluetooth-connected'; |
| 48 case 'disconnected': |
| 49 return 'device:bluetooth'; |
| 50 case 'connecting': |
| 51 return 'device:bluetooth-searching'; |
| 52 default: |
| 53 return 'device:bluetooth-disabled'; |
| 54 } |
| 55 }, |
| 56 |
| 57 /** |
| 58 * @param {string} reason The device ineligibility reason. |
| 59 * @return {string} The icon id to be shown for the ineligibility reason. |
| 60 * @private |
| 61 */ |
| 62 getIconForIneligibilityReason_: function(reason) { |
| 63 switch (reason) { |
| 64 case 'badOsVersion': |
| 65 return 'notification:system-update'; |
| 66 case 'bluetoothNotSupported': |
| 67 return 'device:bluetooth-disabled'; |
| 68 case 'deviceOffline': |
| 69 return 'device:signal-cellular-off'; |
| 70 case 'invalidCredentials': |
| 71 return 'notification:sync-problem'; |
| 72 default: |
| 73 return 'error'; |
| 74 }; |
| 75 } |
| 76 }); |
OLD | NEW |