blob: 9fa856d2a310d5583aa546382f82724019cd2dbe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
///////////////////////////////////////////////////////////////////////////////
// AddLanguageOverlay class:
cr.define('options', function() {
const OptionsPage = options.OptionsPage;
/**
* Encapsulated handling of ChromeOS add language overlay page.
* @constructor
*/
function AddLanguageOverlay() {
OptionsPage.call(this, 'addLanguage',
localStrings.getString('add_button'),
'add-language-overlay-page');
}
cr.addSingletonGetter(AddLanguageOverlay);
AddLanguageOverlay.prototype = {
// Inherit AddLanguageOverlay from OptionsPage.
__proto__: OptionsPage.prototype,
/**
* Initializes AddLanguageOverlay page.
* Calls base class implementation to starts preference initialization.
*/
initializePage: function() {
// Call base class implementation to starts preference initialization.
OptionsPage.prototype.initializePage.call(this);
// Set up the cancel button.
$('add-language-overlay-cancel-button').onclick = function(e) {
OptionsPage.closeOverlay();
};
// Create the language list with which users can add a language.
var addLanguageList = $('add-language-overlay-language-list');
var languageListData = templateData.languageList;
for (var i = 0; i < languageListData.length; i++) {
var language = languageListData[i];
var displayText = language.displayName;
// If the native name is different, add it.
if (language.displayName != language.nativeDisplayName) {
displayText += ' - ' + language.nativeDisplayName;
}
if (cr.isChromeOS) {
var button = document.createElement('button');
button.className = 'link-button';
button.textContent = displayText;
button.languageCode = language.code;
var li = document.createElement('li');
li.languageCode = language.code;
li.appendChild(button);
addLanguageList.appendChild(li);
} else {
var option = document.createElement('option');
option.value = language.code;
option.textContent = displayText;
addLanguageList.appendChild(option);
}
}
},
};
return {
AddLanguageOverlay: AddLanguageOverlay
};
});
|