Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / login / oobe_screen_network.js
blob6101874cde42808566955d7ad14d02f1a27fb858
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.
5 /**
6  * @fileoverview Oobe network screen implementation.
7  */
9 login.createScreen('NetworkScreen', 'connect', function() {
10   return {
11     EXTERNAL_API: [
12       'enableContinueButton',
13       'setTimezone',
14       'showError'
15     ],
17     /**
18      * Dropdown element for networks selection.
19      */
20     dropdown_: null,
22     /** @override */
23     decorate: function() {
24       Oobe.setupSelect($('language-select'),
25                        loadTimeData.getValue('languageList'),
26                        'networkOnLanguageChanged');
28       Oobe.setupSelect($('keyboard-select'),
29                        loadTimeData.getValue('inputMethodsList'),
30                        'networkOnInputMethodChanged');
32       Oobe.setupSelect($('timezone-select'),
33                        loadTimeData.getValue('timezoneList'),
34                        'networkOnTimezoneChanged');
36       this.dropdown_ = $('networks-list');
37       cr.ui.DropDown.decorate(this.dropdown_);
38     },
40     onBeforeShow: function(data) {
41       cr.ui.DropDown.show('networks-list', true, -1);
42     },
44     onBeforeHide: function() {
45       cr.ui.DropDown.hide('networks-list');
46       this.enableContinueButton(false);
47     },
49     /**
50      * Header text of the screen.
51      * @type {string}
52      */
53     get header() {
54       return loadTimeData.getString('networkScreenTitle');
55     },
57     /**
58      * Buttons in oobe wizard's button strip.
59      * @type {array} Array of Buttons.
60      */
61     get buttons() {
62       var buttons = [];
64       var continueButton = this.ownerDocument.createElement('button');
65       continueButton.disabled = true;
66       continueButton.id = 'continue-button';
67       continueButton.textContent = loadTimeData.getString('continueButton');
68       continueButton.classList.add('preserve-disabled-state');
69       continueButton.addEventListener('click', function(e) {
70         chrome.send('networkOnExit');
71         e.stopPropagation();
72       });
73       buttons.push(continueButton);
75       return buttons;
76     },
78     /**
79      * Returns a control which should receive an initial focus.
80      */
81     get defaultControl() {
82       return $('language-select');
83     },
85     /**
86      * Enables/disables continue button.
87      * @param {boolean} enable Should the button be enabled?
88      */
89     enableContinueButton: function(enable) {
90       $('continue-button').disabled = !enable;
91     },
93     /**
94      * Sets the current timezone.
95      * @param {string} timezoneId The timezone ID to select.
96      */
97     setTimezone: function(timezoneId) {
98       $('timezone-select').value = timezoneId;
99     },
101     /**
102      * Shows the network error message.
103      * @param {string} message Message to be shown.
104      */
105     showError: function(message) {
106       var error = document.createElement('div');
107       var messageDiv = document.createElement('div');
108       messageDiv.className = 'error-message-bubble';
109       messageDiv.textContent = message;
110       error.appendChild(messageDiv);
112       $('bubble').showContentForElement($('networks-list'),
113                                         cr.ui.Bubble.Attachment.BOTTOM,
114                                         error);
115     }
116   };