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 /** | 5 /** |
6 * @fileoverview Out of the box experience flow (OOBE). | 6 * @fileoverview Out of the box experience flow (OOBE). |
7 * This is the main code for the OOBE WebUI implementation. | 7 * This is the main code for the OOBE WebUI implementation. |
8 */ | 8 */ |
9 | 9 |
10 <include src="login_common.js"></include> | 10 <include src="login_common.js"></include> |
11 <include src="oobe_screen_eula.js"></include> | 11 <include src="oobe_screen_eula.js"></include> |
12 <include src="oobe_screen_network.js"></include> | 12 <include src="oobe_screen_network.js"></include> |
13 <include src="oobe_screen_update.js"></include> | 13 <include src="oobe_screen_update.js"></include> |
14 | 14 |
15 cr.define('cr.ui.Oobe', function() { | 15 cr.define('cr.ui.Oobe', function() { |
16 return { | 16 return { |
17 /** | 17 /** |
18 * Setups given "select" element using the list and adds callback. | 18 * Setups given "select" element using the list and adds callback. |
| 19 * Creates option groups if needed. |
19 * @param {!Element} select Select object to be updated. | 20 * @param {!Element} select Select object to be updated. |
20 * @param {!Object} list List of the options to be added. | 21 * @param {!Object} list List of the options to be added. |
| 22 * Elements with optionGroupName are considered option group. |
21 * @param {string} callback Callback name which should be send to Chrome or | 23 * @param {string} callback Callback name which should be send to Chrome or |
22 * an empty string if the event listener shouldn't be added. | 24 * an empty string if the event listener shouldn't be added. |
23 */ | 25 */ |
24 setupSelect: function(select, list, callback) { | 26 setupSelect: function(select, list, callback) { |
25 select.options.length = 0; | 27 select.innerHTML = ''; |
| 28 var optgroup = select; |
26 for (var i = 0; i < list.length; ++i) { | 29 for (var i = 0; i < list.length; ++i) { |
27 var item = list[i]; | 30 var item = list[i]; |
28 var option = | 31 if (item.optionGroupName) { |
29 new Option(item.title, item.value, item.selected, item.selected); | 32 optgroup = document.createElement('optgroup'); |
30 select.appendChild(option); | 33 optgroup.label = item.optionGroupName; |
| 34 select.appendChild(optgroup); |
| 35 } else { |
| 36 var option = |
| 37 new Option(item.title, item.value, item.selected, item.selected); |
| 38 optgroup.appendChild(option); |
| 39 } |
31 } | 40 } |
32 if (callback) { | 41 if (callback) { |
33 var sendCallback = function() { | 42 var sendCallback = function() { |
34 chrome.send(callback, [select.options[select.selectedIndex].value]); | 43 chrome.send(callback, [select.options[select.selectedIndex].value]); |
35 }; | 44 }; |
36 select.addEventListener('blur', sendCallback); | 45 select.addEventListener('blur', sendCallback); |
37 select.addEventListener('click', sendCallback); | 46 select.addEventListener('click', sendCallback); |
38 select.addEventListener('keyup', function(event) { | 47 select.addEventListener('keyup', function(event) { |
39 var keycodeInterested = [ | 48 var keycodeInterested = [ |
40 9, // Tab | 49 9, // Tab |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 /** | 241 /** |
233 * Updates localized content of the screens. | 242 * Updates localized content of the screens. |
234 * Should be executed on language change. | 243 * Should be executed on language change. |
235 */ | 244 */ |
236 updateLocalizedContent: function() { | 245 updateLocalizedContent: function() { |
237 // Buttons, headers and links. | 246 // Buttons, headers and links. |
238 Oobe.getInstance().updateLocalizedContent_(); | 247 Oobe.getInstance().updateLocalizedContent_(); |
239 } | 248 } |
240 }; | 249 }; |
241 }); | 250 }); |
OLD | NEW |