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)]); |
(...skipping 12 matching lines...) Expand all Loading... | |
69 $('accesibility-check').checked = checked; | 77 $('accesibility-check').checked = checked; |
70 }; | 78 }; |
71 | 79 |
72 /** | 80 /** |
73 * Activate the bluetooth settings section on the System settings page. | 81 * Activate the bluetooth settings section on the System settings page. |
74 */ | 82 */ |
75 SystemOptions.ShowBluetoothSettings = function() { | 83 SystemOptions.ShowBluetoothSettings = function() { |
76 $('bluetooth-devices').hidden = false; | 84 $('bluetooth-devices').hidden = false; |
77 } | 85 } |
78 | 86 |
87 /** | |
88 * Adds an element to the list of available bluetooth devices. | |
89 * @param{{'deviceName': string, | |
90 * 'deviceId': string, | |
91 * 'deviceType': Constants.DEVICE_TYPE, | |
92 * 'deviceStatus': Constants.DEVICE_STATUS} device | |
93 * Decription of the bluetooth device. | |
94 */ | |
95 SystemOptions.AddBluetoothDevice = function(device) { | |
James Hawkins
2011/10/06 17:20:45
Public methods should be at the bottom.
James Hawkins
2011/10/06 17:20:45
s/Add/add/
kevers
2011/10/06 20:24:41
Done.
kevers
2011/10/06 20:24:41
Done.
| |
96 $('bluetooth-device-list').appendDevice(device); | |
97 } | |
98 | |
99 /** | |
100 * Hides the scanning label and icon that are used to indicate that a device | |
101 * search is in progress. | |
102 */ | |
103 SystemOptions.NotifyBluetoothSearchComplete = function() { | |
James Hawkins
2011/10/06 17:20:45
s/Notify/notify/
kevers
2011/10/06 20:24:41
Done.
| |
104 // TDOO (kevers) - Reset state immediately once results are received | |
105 // asynchronously. | |
106 setTimeout(function() { | |
107 setVisibility_('bluetooth-scanning-label', false); | |
108 setVisibility_('bluetooth-scanning-icon', false); | |
109 }, 2000); | |
110 } | |
111 | |
112 /** | |
113 * Scan for bluetooth devices. | |
114 * @private | |
115 */ | |
116 function findBluetoothDevices_() { | |
117 setVisibility_('bluetooth-scanning-label', true); | |
118 setVisibility_('bluetooth-scanning-icon', true); | |
119 | |
120 // Remove devices that are not currently connected. | |
121 var devices = $('bluetooth-device-list').childNodes; | |
122 for (var i = devices.length - 1; i >= 0; i--) { | |
123 var device = devices.item(i); | |
124 var data = device.data; | |
125 if (!data || data.status !== 'connected') | |
126 $('bluetooth-device-list').removeChild(device); | |
127 } | |
128 // TODO (kevers) - Set arguments to a list of the currently connected | |
129 // devices. | |
130 chrome.send('findBluetoothDevices'); | |
131 } | |
132 | |
133 /** | |
134 * Sets the visibility of an element. | |
135 * @param {string} id The id of the element. | |
136 * @param {boolean} visible True if the element should be made visible. | |
137 * @private | |
138 */ | |
139 function setVisibility_(id, visible) { | |
140 var el = $(id); | |
141 if (el.hidden != visible) { | |
142 if (visible) | |
143 el.classList.remove("transparent"); | |
144 return; | |
145 } | |
146 if (visible) { | |
147 el.hidden = false; | |
148 setTimeout(function() { | |
149 el.classList.remove('transparent'); | |
150 }); | |
151 } else { | |
152 el.addEventListener('webkitTransitionEnd', function f(e) { | |
153 if (e.propertyName != 'opacity') | |
154 return; | |
155 el.removeEventListener('webkitTransitionEnd', f); | |
James Hawkins
2011/10/06 17:20:45
Can't this all be done in CSS?
kevers
2011/10/06 20:24:41
Can animate opacity but not the 'hidden' attribute
| |
156 fadeCompleted_(el); | |
157 }); | |
158 el.classList.add('transparent'); | |
159 } | |
160 } | |
161 | |
162 /** | |
163 * Called when the opacity animation finishes on an element. | |
164 * @param {!Element} el The target element. | |
165 * @private | |
166 */ | |
167 function fadeCompleted_(el) { | |
168 if (el.classList.contains('transparent')) | |
169 el.hidden = true; | |
170 } | |
171 | |
79 // Export | 172 // Export |
80 return { | 173 return { |
81 SystemOptions: SystemOptions | 174 SystemOptions: SystemOptions |
82 }; | 175 }; |
83 | 176 |
84 }); | 177 }); |
OLD | NEW |