OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('options', function() { | |
6 const OptionsPage = options.OptionsPage; | |
7 | |
8 /** | |
9 * Encapsulated handling of the Bluetooth options page. | |
10 * @constructor | |
11 */ | |
12 function BluetoothOptions() { | |
13 OptionsPage.call(this, | |
14 'bluetooth', | |
15 templateData.bluetoothOptionsPageTabTitle, | |
16 'bluetooth-options'); | |
17 } | |
18 | |
19 cr.addSingletonGetter(BluetoothOptions); | |
20 | |
21 BluetoothOptions.prototype = { | |
22 __proto__: OptionsPage.prototype, | |
23 | |
24 /** | |
25 * The list of available (unpaired) bluetooth devices. | |
26 * @type {DeletableItemList} | |
27 * @private | |
28 */ | |
29 deviceList_: null, | |
30 | |
31 /** @inheritDoc */ | |
32 initializePage: function() { | |
33 OptionsPage.prototype.initializePage.call(this); | |
34 this.createDeviceList_(); | |
35 | |
36 $('bluetooth-add-device-cancel-button').onclick = function(event) { | |
37 OptionsPage.closeOverlay(); | |
38 }; | |
39 | |
40 var self = this; | |
41 $('bluetooth-add-device-apply-button').onclick = function(event) { | |
42 var device = self.deviceList_.selectedItem; | |
43 var address = device.address; | |
44 chrome.send('updateBluetoothDevice', [address, 'connect']); | |
45 OptionsPage.closeOverlay(); | |
46 }; | |
47 | |
48 $('bluetooth-add-device-apply-button').onmousedown = function(event) { | |
49 // Prevent 'blur' event, which would reset the list selection, | |
50 // thereby disabling the apply button. | |
51 event.preventDefault(); | |
52 }; | |
53 | |
54 $('bluetooth-unpaired-devices-list').addEventListener('change', | |
55 function() { | |
56 var item = $('bluetooth-unpaired-devices-list').selectedItem; | |
57 var disabled = !item || item.paired || item.connected; | |
58 $('bluetooth-add-device-apply-button').disabled = disabled; | |
59 }); | |
60 }, | |
61 | |
62 /** | |
63 * Creates, decorates and initializes the bluetooth device list. | |
64 * @private | |
65 */ | |
66 createDeviceList_: function() { | |
67 this.deviceList_ = $('bluetooth-unpaired-devices-list'); | |
68 options.system.bluetooth.BluetoothDeviceList.decorate(this.deviceList_); | |
69 this.deviceList_.autoExpands = true; | |
70 } | |
71 }; | |
72 | |
73 // Export | |
74 return { | |
75 BluetoothOptions: BluetoothOptions | |
76 }; | |
77 }); | |
OLD | NEW |