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 |
11 /** | 11 /** |
12 * Bluetooth settings constants. | 12 * Bluetooth settings constants. |
13 */ | 13 */ |
14 function Constants() {} | 14 function Constants() {} |
15 | 15 |
16 /** | 16 /** |
17 * Creates a new bluetooth list item. | 17 * Creates a new bluetooth list item. |
18 * @param {{name: string, | 18 * @param {{name: string, |
19 * address: string, | 19 * address: string, |
20 * paired: boolean, | 20 * paired: boolean, |
21 * connected: boolean, | 21 * connected: boolean, |
22 * connecting: boolean, | 22 * connecting: boolean, |
23 * connectable: boolean, | 23 * connectable: boolean, |
24 * pairing: string|undefined, | 24 * pairing: (string|undefined), |
25 * passkey: number|undefined, | 25 * passkey: (number|undefined), |
26 * pincode: string|undefined, | 26 * pincode: (string|undefined), |
27 * entered: number|undefined}} device | 27 * entered: (number|undefined)}} device |
28 * Description of the Bluetooth device. | 28 * Description of the Bluetooth device. |
29 * @constructor | 29 * @constructor |
30 * @extends {options.DeletableItem} | 30 * @extends {options.DeletableItem} |
31 */ | 31 */ |
32 function BluetoothListItem(device) { | 32 function BluetoothListItem(device) { |
33 var el = cr.doc.createElement('div'); | 33 var el = cr.doc.createElement('div'); |
34 el.__proto__ = BluetoothListItem.prototype; | 34 el.__proto__ = BluetoothListItem.prototype; |
35 el.data = {}; | 35 el.data = {}; |
36 for (var key in device) | 36 for (var key in device) |
37 el.data[key] = device[key]; | 37 el.data[key] = device[key]; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 /** | 105 /** |
106 * Height of a list entry in px. | 106 * Height of a list entry in px. |
107 * @type {number} | 107 * @type {number} |
108 * @private | 108 * @private |
109 */ | 109 */ |
110 itemHeight_: 32, | 110 itemHeight_: 32, |
111 | 111 |
112 /** | 112 /** |
113 * Width of a list entry in px. | 113 * Width of a list entry in px. |
114 * @type {number} | 114 * @type {number} |
115 * @private. | 115 * @private |
116 */ | 116 */ |
117 itemWidth_: 400, | 117 itemWidth_: 400, |
118 | 118 |
119 /** @override */ | 119 /** @override */ |
120 decorate: function() { | 120 decorate: function() { |
121 DeletableItemList.prototype.decorate.call(this); | 121 DeletableItemList.prototype.decorate.call(this); |
122 // Force layout of all items even if not in the viewport to address | 122 // Force layout of all items even if not in the viewport to address |
123 // errors in scroll positioning when the list is hidden during initial | 123 // errors in scroll positioning when the list is hidden during initial |
124 // layout. The impact on performance should be minimal given that the | 124 // layout. The impact on performance should be minimal given that the |
125 // list is not expected to grow very large. Fixed height items are also | 125 // list is not expected to grow very large. Fixed height items are also |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 marginBotton: 0, | 253 marginBotton: 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 |
264 * the list of bluetooth device. | 264 * the list of bluetooth device. |
265 * @private. | 265 * @private |
266 */ | 266 */ |
267 getDefaultItemSize_: function() { | 267 getDefaultItemSize_: function() { |
268 return { | 268 return { |
269 height: this.itemHeight_, | 269 height: this.itemHeight_, |
270 width: this.itemWidth_ | 270 width: this.itemWidth_ |
271 }; | 271 }; |
272 }, | 272 }, |
273 | 273 |
274 /** | 274 /** |
275 * Override base implementation of handleClick_, which unconditionally | 275 * Override base implementation of handleClick_, which unconditionally |
(...skipping 62 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 |