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 Page
= cr
.ui
.pageManager
.Page
;
10 /** @const */ var PageManager
= cr
.ui
.pageManager
.PageManager
;
13 * Encapsulated handling of ChromeOS add language overlay page.
15 * @extends {cr.ui.pageManager.Page}
17 function AddLanguageOverlay() {
18 Page
.call(this, 'addLanguage',
19 loadTimeData
.getString('addButton'),
20 'add-language-overlay-page');
23 cr
.addSingletonGetter(AddLanguageOverlay
);
25 AddLanguageOverlay
.prototype = {
26 // Inherit AddLanguageOverlay from Page.
27 __proto__
: Page
.prototype,
30 initializePage: function() {
31 Page
.prototype.initializePage
.call(this);
33 // Set up the cancel button.
34 $('add-language-overlay-cancel-button').onclick = function(e
) {
35 PageManager
.closeOverlay();
38 // Create the language list with which users can add a language.
39 var addLanguageList
= $('add-language-overlay-language-list');
41 * @type {Array<{code: string, displayName: string,
42 * textDirection: string, nativeDisplayName: string}>}
43 * @see chrome/browser/ui/webui/options/language_options_handler.cc
45 var languageListData
= loadTimeData
.getValue('languageList');
46 for (var i
= 0; i
< languageListData
.length
; i
++) {
47 var language
= languageListData
[i
];
48 var displayText
= language
.displayName
;
49 // If the native name is different, add it.
50 if (language
.displayName
!= language
.nativeDisplayName
)
51 displayText
+= ' - ' + language
.nativeDisplayName
;
53 var option
= cr
.doc
.createElement('option');
54 option
.value
= language
.code
;
55 option
.textContent
= displayText
;
56 addLanguageList
.appendChild(option
);
62 AddLanguageOverlay
: AddLanguageOverlay