OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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', function() { | 5 cr.define('options', function() { |
6 | 6 |
7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
8 ///////////////////////////////////////////////////////////////////////////// | 8 ///////////////////////////////////////////////////////////////////////////// |
9 // SystemOptions class: | 9 // SystemOptions class: |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 // Disable time-related settings if we're not logged in as a real user. | 34 // Disable time-related settings if we're not logged in as a real user. |
35 if (AccountsOptions.loggedInAsGuest()) { | 35 if (AccountsOptions.loggedInAsGuest()) { |
36 var timezone = $('timezone-select'); | 36 var timezone = $('timezone-select'); |
37 if (timezone) | 37 if (timezone) |
38 timezone.disabled = true; | 38 timezone.disabled = true; |
39 var use_24hour_clock = $('use-24hour-clock'); | 39 var use_24hour_clock = $('use-24hour-clock'); |
40 if (use_24hour_clock) | 40 if (use_24hour_clock) |
41 use_24hour_clock.disabled = true; | 41 use_24hour_clock.disabled = true; |
42 } | 42 } |
43 | 43 |
| 44 options.system.bluetooth.BluetoothListElement.decorate( |
| 45 $('bluetooth-device-list')); |
| 46 |
44 // TODO (kevers) - Populate list of connected bluetooth devices. | 47 // TODO (kevers) - Populate list of connected bluetooth devices. |
45 // Set state of 'Enable bluetooth' checkbox. | 48 // Set state of 'Enable bluetooth' checkbox. |
46 // Set state of 'Find devices' button. | 49 |
| 50 $('bluetooth-find-devices').disabled = |
| 51 $('enable-bluetooth-label') ? false : true; |
| 52 $('bluetooth-find-devices').onclick = function(event) { |
| 53 findBluetoothDevices_(); |
| 54 }; |
47 | 55 |
48 $('language-button').onclick = function(event) { | 56 $('language-button').onclick = function(event) { |
49 OptionsPage.navigateToPage('language'); | 57 OptionsPage.navigateToPage('language'); |
50 }; | 58 }; |
51 $('modifier-keys-button').onclick = function(event) { | 59 $('modifier-keys-button').onclick = function(event) { |
52 OptionsPage.navigateToPage('languageCustomizeModifierKeysOverlay'); | 60 OptionsPage.navigateToPage('languageCustomizeModifierKeysOverlay'); |
53 }; | 61 }; |
54 $('accesibility-check').onchange = function(event) { | 62 $('accesibility-check').onchange = function(event) { |
55 chrome.send('accessibilityChange', | 63 chrome.send('accessibilityChange', |
56 [String($('accesibility-check').checked)]); | 64 [String($('accesibility-check').checked)]); |
57 }; | 65 }; |
58 } | 66 } |
59 }; | 67 }; |
60 | 68 |
| 69 /** |
| 70 * Scan for bluetooth devices. |
| 71 * @private |
| 72 */ |
| 73 function findBluetoothDevices_() { |
| 74 setVisibility_('bluetooth-scanning-label', true); |
| 75 setVisibility_('bluetooth-scanning-icon', true); |
| 76 |
| 77 // Remove devices that are not currently connected. |
| 78 var devices = $('bluetooth-device-list').childNodes; |
| 79 for (var i = devices.length - 1; i >= 0; i--) { |
| 80 var device = devices.item(i); |
| 81 var data = device.data; |
| 82 if (!data || data.status !== 'connected') |
| 83 $('bluetooth-device-list').removeChild(device); |
| 84 } |
| 85 // TODO (kevers) - Set arguments to a list of the currently connected |
| 86 // devices. |
| 87 chrome.send('findBluetoothDevices'); |
| 88 } |
| 89 |
| 90 /** |
| 91 * Sets the visibility of an element. |
| 92 * @param {string} id The id of the element. |
| 93 * @param {boolean} visible True if the element should be made visible. |
| 94 * @private |
| 95 */ |
| 96 function setVisibility_(id, visible) { |
| 97 if (visible) |
| 98 $(id).classList.remove("transparent"); |
| 99 else |
| 100 $(id).classList.add("transparent"); |
| 101 } |
| 102 |
61 // | 103 // |
62 // Chrome callbacks | 104 // Chrome callbacks |
63 // | 105 // |
64 | 106 |
65 /** | 107 /** |
66 * Set the initial state of the accessibility checkbox. | 108 * Set the initial state of the accessibility checkbox. |
67 */ | 109 */ |
68 SystemOptions.SetAccessibilityCheckboxState = function(checked) { | 110 SystemOptions.SetAccessibilityCheckboxState = function(checked) { |
69 $('accesibility-check').checked = checked; | 111 $('accesibility-check').checked = checked; |
70 }; | 112 }; |
71 | 113 |
72 /** | 114 /** |
73 * Activate the bluetooth settings section on the System settings page. | 115 * Activate the bluetooth settings section on the System settings page. |
74 */ | 116 */ |
75 SystemOptions.ShowBluetoothSettings = function() { | 117 SystemOptions.showBluetoothSettings = function() { |
76 $('bluetooth-devices').hidden = false; | 118 $('bluetooth-devices').hidden = false; |
77 } | 119 } |
78 | 120 |
| 121 /** |
| 122 * Adds an element to the list of available bluetooth devices. |
| 123 * @param{{'deviceName': string, |
| 124 * 'deviceId': string, |
| 125 * 'deviceType': Constants.DEVICE_TYPE, |
| 126 * 'deviceStatus': Constants.DEVICE_STATUS} device |
| 127 * Decription of the bluetooth device. |
| 128 */ |
| 129 SystemOptions.addBluetoothDevice = function(device) { |
| 130 $('bluetooth-device-list').appendDevice(device); |
| 131 } |
| 132 |
| 133 /** |
| 134 * Hides the scanning label and icon that are used to indicate that a device |
| 135 * search is in progress. |
| 136 */ |
| 137 SystemOptions.notifyBluetoothSearchComplete = function() { |
| 138 // TDOO (kevers) - Reset state immediately once results are received |
| 139 // asynchronously. |
| 140 setTimeout(function() { |
| 141 setVisibility_('bluetooth-scanning-label', false); |
| 142 setVisibility_('bluetooth-scanning-icon', false); |
| 143 }, 2000); |
| 144 } |
| 145 |
79 // Export | 146 // Export |
80 return { | 147 return { |
81 SystemOptions: SystemOptions | 148 SystemOptions: SystemOptions |
82 }; | 149 }; |
83 | 150 |
84 }); | 151 }); |
OLD | NEW |