| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options.system.bluetooth', function() { | 5 cr.define('options.system.bluetooth', function() { |
| 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 7 /** @const */ var DeletableItem = options.DeletableItem; | 7 /** @const */ var DeletableItem = options.DeletableItem; |
| 8 /** @const */ var DeletableItemList = options.DeletableItemList; | 8 /** @const */ var DeletableItemList = options.DeletableItemList; |
| 9 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 9 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 __proto__: DeletableItem.prototype, | 46 __proto__: DeletableItem.prototype, |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Description of the Bluetooth device. | 49 * Description of the Bluetooth device. |
| 50 * @type {{name: string, | 50 * @type {{name: string, |
| 51 * address: string, | 51 * address: string, |
| 52 * paired: boolean, | 52 * paired: boolean, |
| 53 * connected: boolean, | 53 * connected: boolean, |
| 54 * connecting: boolean, | 54 * connecting: boolean, |
| 55 * connectable: boolean, | 55 * connectable: boolean, |
| 56 * pairing: string|undefined, | 56 * pairing: (string|undefined), |
| 57 * passkey: number|undefined, | 57 * passkey: (number|undefined), |
| 58 * pincode: string|undefined, | 58 * pincode: (string|undefined), |
| 59 * entered: number|undefined}} | 59 * entered: (number|undefined)}} |
| 60 */ | 60 */ |
| 61 data: null, | 61 data: null, |
| 62 | 62 |
| 63 /** @override */ | 63 /** @override */ |
| 64 decorate: function() { | 64 decorate: function() { |
| 65 DeletableItem.prototype.decorate.call(this); | 65 DeletableItem.prototype.decorate.call(this); |
| 66 var label = this.ownerDocument.createElement('div'); | 66 var label = this.ownerDocument.createElement('div'); |
| 67 label.className = 'bluetooth-device-label'; | 67 label.className = 'bluetooth-device-label'; |
| 68 this.classList.add('bluetooth-device'); | 68 this.classList.add('bluetooth-device'); |
| 69 // There are four kinds of devices we want to distinguish: | 69 // There are four kinds of devices we want to distinguish: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 /** | 134 /** |
| 135 * Adds a bluetooth device to the list of available devices. A check is | 135 * Adds a bluetooth device to the list of available devices. A check is |
| 136 * made to see if the device is already in the list, in which case the | 136 * made to see if the device is already in the list, in which case the |
| 137 * existing device is updated. | 137 * existing device is updated. |
| 138 * @param {{name: string, | 138 * @param {{name: string, |
| 139 * address: string, | 139 * address: string, |
| 140 * paired: boolean, | 140 * paired: boolean, |
| 141 * connected: boolean, | 141 * connected: boolean, |
| 142 * connecting: boolean, | 142 * connecting: boolean, |
| 143 * connectable: boolean, | 143 * connectable: boolean, |
| 144 * pairing: string|undefined, | 144 * pairing: (string|undefined), |
| 145 * passkey: number|undefined, | 145 * passkey: (number|undefined), |
| 146 * pincode: string|undefined, | 146 * pincode: (string|undefined), |
| 147 * entered: number|undefined}} device | 147 * entered: (number|undefined)}} device |
| 148 * Description of the bluetooth device. | 148 * Description of the bluetooth device. |
| 149 * @return {boolean} True if the devies was successfully added or updated. | 149 * @return {boolean} True if the devies was successfully added or updated. |
| 150 */ | 150 */ |
| 151 appendDevice: function(device) { | 151 appendDevice: function(device) { |
| 152 var selectedDevice = this.getSelectedDevice_(); | 152 var selectedDevice = this.getSelectedDevice_(); |
| 153 var index = this.find(device.address); | 153 var index = this.find(device.address); |
| 154 if (index == undefined) { | 154 if (index == undefined) { |
| 155 this.dataModel.push(device); | 155 this.dataModel.push(device); |
| 156 this.redraw(); | 156 this.redraw(); |
| 157 } else { | 157 } else { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 177 this.getSelectedDevice_(); | 177 this.getSelectedDevice_(); |
| 178 this.invalidate(); | 178 this.invalidate(); |
| 179 this.redraw(); | 179 this.redraw(); |
| 180 if (selectedDevice) | 180 if (selectedDevice) |
| 181 this.setSelectedDevice_(selectedDevice); | 181 this.setSelectedDevice_(selectedDevice); |
| 182 }, | 182 }, |
| 183 | 183 |
| 184 /** | 184 /** |
| 185 * Retrieves the address of the selected device, or null if no device is | 185 * Retrieves the address of the selected device, or null if no device is |
| 186 * selected. | 186 * selected. |
| 187 * @return {?string} Address of selected device or null. | 187 * @return {(string|undefined)} Address of selected device or null. |
| 188 * @private | 188 * @private |
| 189 */ | 189 */ |
| 190 getSelectedDevice_: function() { | 190 getSelectedDevice_: function() { |
| 191 var selection = this.selectedItem; | 191 var selection = this.selectedItem; |
| 192 if (selection) | 192 if (selection) |
| 193 return selection.address; | 193 return selection.address; |
| 194 return null; | 194 return undefined; |
| 195 }, | 195 }, |
| 196 | 196 |
| 197 /** | 197 /** |
| 198 * Selects the device with the matching address. | 198 * Selects the device with the matching address. |
| 199 * @param {string} address The unique address of the device. | 199 * @param {string} address The unique address of the device. |
| 200 * @private | 200 * @private |
| 201 */ | 201 */ |
| 202 setSelectedDevice_: function(address) { | 202 setSelectedDevice_: function(address) { |
| 203 var index = this.find(address); | 203 var index = this.find(address); |
| 204 if (index != undefined) | 204 if (index != undefined) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 * case. | 243 * case. |
| 244 * @return {{height: number, marginTop: number, marginBottom: number, | 244 * @return {{height: number, marginTop: number, marginBottom: number, |
| 245 * width: number, marginLeft: number, marginRight: number}} | 245 * width: number, marginLeft: number, marginRight: number}} |
| 246 * The height and width of the item, taking margins into account, | 246 * The height and width of the item, taking margins into account, |
| 247 * and the margins themselves. | 247 * and the margins themselves. |
| 248 */ | 248 */ |
| 249 measureItem: function() { | 249 measureItem: function() { |
| 250 return { | 250 return { |
| 251 height: this.itemHeight_, | 251 height: this.itemHeight_, |
| 252 marginTop: 0, | 252 marginTop: 0, |
| 253 marginBotton: 0, | 253 marginBottom: 0, |
| 254 width: this.itemWidth_, | 254 width: this.itemWidth_, |
| 255 marginLeft: 0, | 255 marginLeft: 0, |
| 256 marginRight: 0 | 256 marginRight: 0 |
| 257 }; | 257 }; |
| 258 }, | 258 }, |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * Override the default implementation to return a predetermined size, | 261 * Override the default implementation to return a predetermined size, |
| 262 * which in turns allows proper layout of items even if the list is hidden. | 262 * which in turns allows proper layout of items even if the list is hidden. |
| 263 * @return {{height: number, width: number}} Dimensions of a single item in | 263 * @return {{height: number, width: number}} Dimensions of a single item in |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 cr.defineProperty(BluetoothListItem, 'notconnectable', | 339 cr.defineProperty(BluetoothListItem, 'notconnectable', |
| 340 cr.PropertyKind.BOOL_ATTR); | 340 cr.PropertyKind.BOOL_ATTR); |
| 341 | 341 |
| 342 return { | 342 return { |
| 343 BluetoothListItem: BluetoothListItem, | 343 BluetoothListItem: BluetoothListItem, |
| 344 BluetoothDeviceList: BluetoothDeviceList, | 344 BluetoothDeviceList: BluetoothDeviceList, |
| 345 Constants: Constants | 345 Constants: Constants |
| 346 }; | 346 }; |
| 347 }); | 347 }); |
| OLD | NEW |