| 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 var RepeatingButton = cr.ui.RepeatingButton; | 8 var RepeatingButton = cr.ui.RepeatingButton; |
| 9 | 9 |
| 10 ///////////////////////////////////////////////////////////////////////////// | 10 ///////////////////////////////////////////////////////////////////////////// |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 options.system.bluetooth.BluetoothListElement.decorate( | 46 options.system.bluetooth.BluetoothListElement.decorate( |
| 47 $('bluetooth-device-list')); | 47 $('bluetooth-device-list')); |
| 48 | 48 |
| 49 // TODO(kevers): Populate list of connected bluetooth devices. | 49 // TODO(kevers): Populate list of connected bluetooth devices. |
| 50 // Set state of 'Enable bluetooth' checkbox. | 50 // Set state of 'Enable bluetooth' checkbox. |
| 51 $('bluetooth-find-devices').onclick = function(event) { | 51 $('bluetooth-find-devices').onclick = function(event) { |
| 52 findBluetoothDevices_(); | 52 findBluetoothDevices_(); |
| 53 }; | 53 }; |
| 54 $('enable-bluetooth-check').onchange = function(event) { | 54 $('enable-bluetooth').onclick = function(event) { |
| 55 chrome.send('bluetoothEnableChange', | 55 chrome.send('bluetoothEnableChange', [Boolean(true)]); |
| 56 [Boolean($('enable-bluetooth-check').checked)]); | |
| 57 }; | 56 }; |
| 58 | 57 $('disable-bluetooth').onclick = function(event) { |
| 58 chrome.send('bluetoothEnableChange', [Boolean(false)]); |
| 59 }; |
| 59 $('language-button').onclick = function(event) { | 60 $('language-button').onclick = function(event) { |
| 60 OptionsPage.navigateToPage('language'); | 61 OptionsPage.navigateToPage('language'); |
| 61 }; | 62 }; |
| 62 $('modifier-keys-button').onclick = function(event) { | 63 $('modifier-keys-button').onclick = function(event) { |
| 63 OptionsPage.navigateToPage('languageCustomizeModifierKeysOverlay'); | 64 OptionsPage.navigateToPage('languageCustomizeModifierKeysOverlay'); |
| 64 }; | 65 }; |
| 65 $('accesibility-check').onchange = function(event) { | 66 $('accesibility-check').onchange = function(event) { |
| 66 chrome.send('accessibilityChange', | 67 chrome.send('accessibilityChange', |
| 67 [String($('accesibility-check').checked)]); | 68 [String($('accesibility-check').checked)]); |
| 68 }; | 69 }; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 SystemOptions.showBluetoothSettings = function() { | 137 SystemOptions.showBluetoothSettings = function() { |
| 137 $('bluetooth-devices').hidden = false; | 138 $('bluetooth-devices').hidden = false; |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 /** | 141 /** |
| 141 * Sets the state of the checkbox indicating if bluetooth is turned on. The | 142 * Sets the state of the checkbox indicating if bluetooth is turned on. The |
| 142 * state of the "Find devices" button and the list of discovered devices may | 143 * state of the "Find devices" button and the list of discovered devices may |
| 143 * also be affected by a change to the state. | 144 * also be affected by a change to the state. |
| 144 * @param {boolean} checked Flag Indicating if Bluetooth is turned on. | 145 * @param {boolean} checked Flag Indicating if Bluetooth is turned on. |
| 145 */ | 146 */ |
| 146 SystemOptions.setBluetoothCheckboxState = function(checked) { | 147 SystemOptions.setBluetoothState = function(checked) { |
| 147 $('enable-bluetooth-check').checked = checked; | 148 $('disable-bluetooth').hidden = !checked; |
| 148 $('bluetooth-find-devices').disabled = !checked; | 149 $('enable-bluetooth').hidden = checked; |
| 150 $('bluetooth-finder-container').hidden = !checked; |
| 151 $('no-bluetooth-devices-label').hidden = !checked; |
| 152 if (!checked) { |
| 153 setVisibility_('bluetooth-scanning-label', false); |
| 154 setVisibility_('bluetooth-scanning-icon', false); |
| 155 } |
| 149 // Flush list of previously discovered devices if bluetooth is turned off. | 156 // Flush list of previously discovered devices if bluetooth is turned off. |
| 150 if (!checked) { | 157 if (!checked) { |
| 151 var devices = $('bluetooth-device-list').childNodes; | 158 var devices = $('bluetooth-device-list').childNodes; |
| 152 for (var i = devices.length - 1; i >= 0; i--) { | 159 for (var i = devices.length - 1; i >= 0; i--) { |
| 153 var device = devices.item(i); | 160 var device = devices.item(i); |
| 154 $('bluetooth-device-list').removeChild(device); | 161 $('bluetooth-device-list').removeChild(device); |
| 155 } | 162 } |
| 156 } | 163 } |
| 157 } | 164 } |
| 158 | 165 |
| 159 /** | 166 /** |
| 160 * Adds an element to the list of available bluetooth devices. If an element | 167 * Adds an element to the list of available bluetooth devices. If an element |
| 161 * with a matching address is found, the existing element is updated. | 168 * with a matching address is found, the existing element is updated. |
| 162 * @param {{name: string, | 169 * @param {{name: string, |
| 163 * address: string, | 170 * address: string, |
| 164 * icon: string, | 171 * icon: string, |
| 165 * paired: boolean, | 172 * paired: boolean, |
| 166 * connected: boolean}} device | 173 * connected: boolean}} device |
| 167 * Decription of the bluetooth device. | 174 * Decription of the bluetooth device. |
| 168 */ | 175 */ |
| 169 SystemOptions.addBluetoothDevice = function(device) { | 176 SystemOptions.addBluetoothDevice = function(device) { |
| 170 $('bluetooth-device-list').appendDevice(device); | 177 if ($('bluetooth-device-list').appendDevice(device)) |
| 178 $('no-bluetooth-devices-label').hidden = true; |
| 171 }; | 179 }; |
| 172 | 180 |
| 173 /** | 181 /** |
| 174 * Hides the scanning label and icon that are used to indicate that a device | 182 * Hides the scanning label and icon that are used to indicate that a device |
| 175 * search is in progress. | 183 * search is in progress. |
| 176 */ | 184 */ |
| 177 SystemOptions.notifyBluetoothSearchComplete = function() { | 185 SystemOptions.notifyBluetoothSearchComplete = function() { |
| 178 setVisibility_('bluetooth-scanning-label', false); | 186 setVisibility_('bluetooth-scanning-label', false); |
| 179 setVisibility_('bluetooth-scanning-icon', false); | 187 setVisibility_('bluetooth-scanning-icon', false); |
| 180 }; | 188 }; |
| 181 | 189 |
| 182 /** | 190 /** |
| 183 * Displays the Touchpad Controls section when we detect a touchpad. | 191 * Displays the Touchpad Controls section when we detect a touchpad. |
| 184 */ | 192 */ |
| 185 SystemOptions.showTouchpadControls = function() { | 193 SystemOptions.showTouchpadControls = function() { |
| 186 $('touchpad-controls').hidden = false; | 194 $('touchpad-controls').hidden = false; |
| 187 }; | 195 }; |
| 188 | 196 |
| 189 // Export | 197 // Export |
| 190 return { | 198 return { |
| 191 SystemOptions: SystemOptions | 199 SystemOptions: SystemOptions |
| 192 }; | 200 }; |
| 193 | 201 |
| 194 }); | 202 }); |
| OLD | NEW |