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 /** | 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 const steps = ['connect', 'eula', 'update']; | 10 const steps = ['connect', 'eula', 'update']; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 this.currentStep_ = nextStepIndex; | 72 this.currentStep_ = nextStepIndex; |
73 $('oobe').className = nextStepId; | 73 $('oobe').className = nextStepId; |
74 }, | 74 }, |
75 }; | 75 }; |
76 | 76 |
77 /** | 77 /** |
78 * Setups given "select" element using the list and adds callback. | 78 * Setups given "select" element using the list and adds callback. |
79 * @param {!Element} select Select object to be updated. | 79 * @param {!Element} select Select object to be updated. |
80 * @param {!Object} list List of the options to be added. | 80 * @param {!Object} list List of the options to be added. |
81 * @param {string} callback Callback name which should be send to Chrome. | 81 * @param {string} callback Callback name which should be send to Chrome or |
| 82 * an empty string if the event listener shouldn't be added. |
82 */ | 83 */ |
83 Oobe.setupSelect = function(select, list, callback) { | 84 Oobe.setupSelect = function(select, list, callback) { |
84 select.options.length = 0; | 85 select.options.length = 0; |
85 for (var i = 0; i < list.length; ++i) { | 86 for (var i = 0; i < list.length; ++i) { |
86 var item = list[i]; | 87 var item = list[i]; |
87 var option = | 88 var option = |
88 new Option(item.title, item.value, item.selected, item.selected); | 89 new Option(item.title, item.value, item.selected, item.selected); |
89 select.appendChild(option); | 90 select.appendChild(option); |
90 } | 91 } |
91 select.addEventListener('change', function(event) { | 92 if (callback) { |
92 chrome.send(callback, [select.options[select.selectedIndex].value]); | 93 select.addEventListener('change', function(event) { |
93 }); | 94 chrome.send(callback, [select.options[select.selectedIndex].value]); |
| 95 }); |
| 96 } |
94 } | 97 } |
95 | 98 |
96 /** | 99 /** |
97 * Returns offset (top, left) of the element. | 100 * Returns offset (top, left) of the element. |
98 * @param {!Element} element HTML element | 101 * @param {!Element} element HTML element |
99 * @return {!Object} The offset (top, left). | 102 * @return {!Object} The offset (top, left). |
100 */ | 103 */ |
101 Oobe.getOffset = function(element) { | 104 Oobe.getOffset = function(element) { |
102 var x = 0; | 105 var x = 0; |
103 var y = 0; | 106 var y = 0; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 $('tpm-password').hidden = false; | 229 $('tpm-password').hidden = false; |
227 } | 230 } |
228 | 231 |
229 /** | 232 /** |
230 * Reloads content of the page (localized strings, options of the select | 233 * Reloads content of the page (localized strings, options of the select |
231 * controls). | 234 * controls). |
232 * @param {!Object} data New dictionary with i18n values. | 235 * @param {!Object} data New dictionary with i18n values. |
233 */ | 236 */ |
234 Oobe.reloadContent = function(data) { | 237 Oobe.reloadContent = function(data) { |
235 i18nTemplate.process(document, data); | 238 i18nTemplate.process(document, data); |
236 // Also update language and input methods lists. | 239 // Update language and input method menu lists. |
237 Oobe.setupSelect($('language-select'), | 240 Oobe.setupSelect($('language-select'), data.languageList, ''); |
238 data.languageList, | 241 Oobe.setupSelect($('keyboard-select'), data.inputMethodsList, ''); |
239 'networkOnLanguageChanged'); | 242 // Update the network control position. |
240 Oobe.setupSelect($('keyboard-select'), | 243 Oobe.refreshNetworkControl(); |
241 data.inputMethodsList, | |
242 'networkOnInputMethodChanged'); | |
243 } | 244 } |
244 | 245 |
245 // Export | 246 // Export |
246 return { | 247 return { |
247 Oobe: Oobe | 248 Oobe: Oobe |
248 }; | 249 }; |
249 }); | 250 }); |
250 | 251 |
251 var Oobe = cr.ui.Oobe; | 252 var Oobe = cr.ui.Oobe; |
252 | 253 |
253 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); | 254 document.addEventListener('DOMContentLoaded', cr.ui.Oobe.initialize); |
OLD | NEW |