| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 /////////////////////////////////////////////////////////////////////////////// | |
| 6 // AddLanguageOverlay class: | |
| 7 | |
| 8 cr.define('options.language', function() { | |
| 9 | |
| 10 const OptionsPage = options.OptionsPage; | |
| 11 | |
| 12 /** | |
| 13 * Encapsulated handling of ChromeOS add language overlay page. | |
| 14 * @constructor | |
| 15 */ | |
| 16 function AddLanguageOverlay() { | |
| 17 OptionsPage.call(this, 'addLanguageOverlay', | |
| 18 localStrings.getString('add_button'), | |
| 19 'add-language-overlay-page'); | |
| 20 } | |
| 21 | |
| 22 cr.addSingletonGetter(AddLanguageOverlay); | |
| 23 | |
| 24 AddLanguageOverlay.prototype = { | |
| 25 // Inherit AddLanguageOverlay from OptionsPage. | |
| 26 __proto__: OptionsPage.prototype, | |
| 27 | |
| 28 /** | |
| 29 * Initializes AddLanguageOverlay page. | |
| 30 * Calls base class implementation to starts preference initialization. | |
| 31 */ | |
| 32 initializePage: function() { | |
| 33 // Call base class implementation to starts preference initialization. | |
| 34 OptionsPage.prototype.initializePage.call(this); | |
| 35 | |
| 36 // Set up the cancel button. | |
| 37 $('add-language-overlay-cancel-button').onclick = function(e) { | |
| 38 OptionsPage.clearOverlays(); | |
| 39 }; | |
| 40 | |
| 41 // Create the language list with which users can add a language. | |
| 42 // Note that we have about 40 languages. | |
| 43 var addLanguageList = $('add-language-overlay-language-list'); | |
| 44 var languageListData = templateData.languageList; | |
| 45 for (var i = 0; i < languageListData.length; i++) { | |
| 46 var language = languageListData[i]; | |
| 47 var button = document.createElement('button'); | |
| 48 button.className = 'link-button'; | |
| 49 button.textContent = language.displayName; | |
| 50 // If the native name is different, add it. | |
| 51 if (language.displayName != language.nativeDisplayName) { | |
| 52 button.textContent += ' - ' + language.nativeDisplayName; | |
| 53 } | |
| 54 button.languageCode = language.code; | |
| 55 var li = document.createElement('li'); | |
| 56 li.languageCode = language.code; | |
| 57 li.appendChild(button); | |
| 58 addLanguageList.appendChild(li); | |
| 59 } | |
| 60 }, | |
| 61 }; | |
| 62 | |
| 63 return { | |
| 64 AddLanguageOverlay: AddLanguageOverlay | |
| 65 }; | |
| 66 }); | |
| OLD | NEW |