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 // AddLanguageOverlay class:
8 cr.define('options', function() {
9 /** @const */ var OptionsPage = options.OptionsPage;
12 * Encapsulated handling of ChromeOS add language overlay page.
15 function AddLanguageOverlay() {
16 OptionsPage.call(this, 'addLanguage',
17 loadTimeData.getString('addButton'),
18 'add-language-overlay-page');
21 cr.addSingletonGetter(AddLanguageOverlay);
23 AddLanguageOverlay.prototype = {
24 // Inherit AddLanguageOverlay from OptionsPage.
25 __proto__: OptionsPage.prototype,
28 * Initializes AddLanguageOverlay page.
29 * Calls base class implementation to starts preference initialization.
31 initializePage: function() {
32 // Call base class implementation to starts preference initialization.
33 OptionsPage.prototype.initializePage.call(this);
35 // Set up the cancel button.
36 $('add-language-overlay-cancel-button').onclick = function(e) {
37 OptionsPage.closeOverlay();
40 // Create the language list with which users can add a language.
41 var addLanguageList = $('add-language-overlay-language-list');
42 var languageListData = loadTimeData.getValue('languageList');
43 for (var i = 0; i < languageListData.length; i++) {
44 var language = languageListData[i];
45 var displayText = language.displayName;
46 // If the native name is different, add it.
47 if (language.displayName != language.nativeDisplayName)
48 displayText += ' - ' + language.nativeDisplayName;
50 var option = cr.doc.createElement('option');
51 option.value = language.code;
52 option.textContent = displayText;
53 addLanguageList.appendChild(option);
59 AddLanguageOverlay: AddLanguageOverlay