| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(kochi): Generalize the notification as a component and put it | 5 // TODO(kochi): Generalize the notification as a component and put it |
| 6 // in js/cr/ui/notification.js . | 6 // in js/cr/ui/notification.js . |
| 7 | 7 |
| 8 cr.define('options', function() { | 8 cr.define('options', function() { |
| 9 /** @const */ var Page = cr.ui.pageManager.Page; | 9 /** @const */ var Page = cr.ui.pageManager.Page; |
| 10 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 10 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 Page.call(this, 'languages', | 77 Page.call(this, 'languages', |
| 78 loadTimeData.getString('languagePageTabTitle'), 'languagePage'); | 78 loadTimeData.getString('languagePageTabTitle'), 'languagePage'); |
| 79 } | 79 } |
| 80 | 80 |
| 81 cr.addSingletonGetter(LanguageOptions); | 81 cr.addSingletonGetter(LanguageOptions); |
| 82 | 82 |
| 83 // Inherit LanguageOptions from Page. | 83 // Inherit LanguageOptions from Page. |
| 84 LanguageOptions.prototype = { | 84 LanguageOptions.prototype = { |
| 85 __proto__: Page.prototype, | 85 __proto__: Page.prototype, |
| 86 | 86 |
| 87 /* For recording the prospective language (the next locale after relaunch). | 87 /** |
| 88 * For recording the prospective language (the next locale after relaunch). |
| 88 * @type {?string} | 89 * @type {?string} |
| 89 * @private | 90 * @private |
| 90 */ | 91 */ |
| 91 prospectiveUiLanguageCode_: null, | 92 prospectiveUiLanguageCode_: null, |
| 92 | 93 |
| 93 /* | 94 /** |
| 94 * Map from language code to spell check dictionary download status for that | 95 * Map from language code to spell check dictionary download status for that |
| 95 * language. | 96 * language. |
| 96 * @type {Array} | 97 * @type {Array} |
| 97 * @private | 98 * @private |
| 98 */ | 99 */ |
| 99 spellcheckDictionaryDownloadStatus_: [], | 100 spellcheckDictionaryDownloadStatus_: [], |
| 100 | 101 |
| 101 /** | 102 /** |
| 102 * Number of times a spell check dictionary download failed. | 103 * Number of times a spell check dictionary download failed. |
| 103 * @type {int} | 104 * @type {int} |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 return false; | 906 return false; |
| 906 return (!cr.isChromeOS || | 907 return (!cr.isChromeOS || |
| 907 this.canDeleteLanguage_(languageCode)); | 908 this.canDeleteLanguage_(languageCode)); |
| 908 }, | 909 }, |
| 909 | 910 |
| 910 /** | 911 /** |
| 911 * Handles browse.enable_spellchecking change. | 912 * Handles browse.enable_spellchecking change. |
| 912 * @param {Event} e Change event. | 913 * @param {Event} e Change event. |
| 913 * @private | 914 * @private |
| 914 */ | 915 */ |
| 915 updateEnableSpellCheck_: function() { | 916 updateEnableSpellCheck_: function(e) { |
| 916 var value = !$('enable-spell-check').checked; | 917 var value = !$('enable-spell-check').checked; |
| 917 $('language-options-spell-check-language-button').disabled = value; | 918 $('language-options-spell-check-language-button').disabled = value; |
| 918 if (!cr.IsMac) | 919 if (!cr.IsMac) |
| 919 $('edit-dictionary-button').hidden = value; | 920 $('edit-dictionary-button').hidden = value; |
| 920 }, | 921 }, |
| 921 | 922 |
| 922 /** | 923 /** |
| 923 * Handles translateBlockedLanguagesPref change. | 924 * Handles translateBlockedLanguagesPref change. |
| 924 * @param {Event} e Change event. | 925 * @param {Event} e Change event. |
| 925 * @private | 926 * @private |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 this.spellcheckDictionaryDownloadStatus_[languageCode] = | 1292 this.spellcheckDictionaryDownloadStatus_[languageCode] = |
| 1292 DOWNLOAD_STATUS.FAILED; | 1293 DOWNLOAD_STATUS.FAILED; |
| 1293 this.spellcheckDictionaryDownloadFailures_++; | 1294 this.spellcheckDictionaryDownloadFailures_++; |
| 1294 if (!cr.isMac && | 1295 if (!cr.isMac && |
| 1295 languageCode == | 1296 languageCode == |
| 1296 $('language-options-list').getSelectedLanguageCode()) { | 1297 $('language-options-list').getSelectedLanguageCode()) { |
| 1297 this.updateSpellCheckLanguageButton_(languageCode); | 1298 this.updateSpellCheckLanguageButton_(languageCode); |
| 1298 } | 1299 } |
| 1299 }, | 1300 }, |
| 1300 | 1301 |
| 1301 /* | 1302 /** |
| 1302 * Converts the language code for Translation. There are some differences | 1303 * Converts the language code for Translation. There are some differences |
| 1303 * between the language set for Translation and that for Accept-Language. | 1304 * between the language set for Translation and that for Accept-Language. |
| 1304 * @param {string} languageCode The language code like 'fr'. | 1305 * @param {string} languageCode The language code like 'fr'. |
| 1305 * @return {string} The converted language code. | 1306 * @return {string} The converted language code. |
| 1306 * @private | 1307 * @private |
| 1307 */ | 1308 */ |
| 1308 convertLangCodeForTranslation_: function(languageCode) { | 1309 convertLangCodeForTranslation_: function(languageCode) { |
| 1309 var tokens = languageCode.split('-'); | 1310 var tokens = languageCode.split('-'); |
| 1310 var main = tokens[0]; | 1311 var main = tokens[0]; |
| 1311 | 1312 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 | 1357 |
| 1357 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1358 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
| 1358 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1359 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
| 1359 }; | 1360 }; |
| 1360 | 1361 |
| 1361 // Export | 1362 // Export |
| 1362 return { | 1363 return { |
| 1363 LanguageOptions: LanguageOptions | 1364 LanguageOptions: LanguageOptions |
| 1364 }; | 1365 }; |
| 1365 }); | 1366 }); |
| OLD | NEW |