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
3 // found in the LICENSE file.
6 * @fileoverview Oobe network screen implementation.
9 login.createScreen('NetworkScreen', 'connect', function() {
12 'enableContinueButton',
19 * Dropdown element for networks selection.
24 decorate: function() {
25 Oobe.setupSelect($('language-select'),
26 loadTimeData.getValue('languageList'),
27 'networkOnLanguageChanged');
29 Oobe.setupSelect($('keyboard-select'),
30 loadTimeData.getValue('inputMethodsList'),
31 'networkOnInputMethodChanged');
33 Oobe.setupSelect($('timezone-select'),
34 loadTimeData.getValue('timezoneList'),
35 'networkOnTimezoneChanged');
37 this.dropdown_ = $('networks-list');
38 cr.ui.DropDown.decorate(this.dropdown_);
41 onBeforeShow: function(data) {
42 cr.ui.DropDown.show('networks-list', true, -1);
45 onBeforeHide: function() {
46 cr.ui.DropDown.hide('networks-list');
47 this.enableContinueButton(false);
51 * Header text of the screen.
55 return loadTimeData.getString('networkScreenTitle');
59 * Buttons in oobe wizard's button strip.
60 * @type {array} Array of Buttons.
65 var continueButton = this.ownerDocument.createElement('button');
66 continueButton.disabled = true;
67 continueButton.id = 'continue-button';
68 continueButton.textContent = loadTimeData.getString('continueButton');
69 continueButton.classList.add('preserve-disabled-state');
70 continueButton.addEventListener('click', function(e) {
71 chrome.send('networkOnExit');
74 buttons.push(continueButton);
80 * Returns a control which should receive an initial focus.
82 get defaultControl() {
83 return $('language-select');
87 * Enables/disables continue button.
88 * @param {boolean} enable Should the button be enabled?
90 enableContinueButton: function(enable) {
91 $('continue-button').disabled = !enable;
95 * Sets the current input method.
96 * @param {string} inputMethodId The ID of the input method to select.
98 setInputMethod: function(inputMethodId) {
99 option = $('keyboard-select').querySelector(
100 'option[value="' + inputMethodId + '"]');
102 option.selected = true;
106 * Sets the current timezone.
107 * @param {string} timezoneId The timezone ID to select.
109 setTimezone: function(timezoneId) {
110 $('timezone-select').value = timezoneId;
114 * Shows the network error message.
115 * @param {string} message Message to be shown.
117 showError: function(message) {
118 var error = document.createElement('div');
119 var messageDiv = document.createElement('div');
120 messageDiv.className = 'error-message-bubble';
121 messageDiv.textContent = message;
122 error.appendChild(messageDiv);
123 error.setAttribute('role', 'alert');
125 $('bubble').showContentForElement($('networks-list'),
126 cr.ui.Bubble.Attachment.BOTTOM,