Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/browser/resources/options/language_options.js

Issue 1156473007: Enables the user to select multiple languages for spellchecking (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 var ENABLED_EXTENSION_IME_PREF = 'settings.language.enabled_extension_imes'; 45 var ENABLED_EXTENSION_IME_PREF = 'settings.language.enabled_extension_imes';
46 46
47 /** 47 /**
48 * The preference that lists the languages which are not translated. 48 * The preference that lists the languages which are not translated.
49 * @type {string} 49 * @type {string}
50 * @const 50 * @const
51 */ 51 */
52 var TRANSLATE_BLOCKED_LANGUAGES_PREF = 'translate_blocked_languages'; 52 var TRANSLATE_BLOCKED_LANGUAGES_PREF = 'translate_blocked_languages';
53 53
54 /** 54 /**
55 * The preference key that is a string that describes the spell check 55 * The preference key that is a list of strings that describes the spellcheck
56 * dictionary language, like "en-US". 56 * dictionary language, like ["en-US", "fr"].
57 * @type {string} 57 * @type {string}
58 * @const 58 * @const
59 */ 59 */
60 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries'; 60 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries';
61 61
62 /** 62 /**
63 * The preference that indicates if the Translate feature is enabled. 63 * The preference that indicates if the Translate feature is enabled.
64 * @type {string} 64 * @type {string}
65 * @const 65 * @const
66 */ 66 */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 translateBlockedLanguages_: [], 129 translateBlockedLanguages_: [],
130 130
131 /** 131 /**
132 * The list of the languages supported by Translate server 132 * The list of the languages supported by Translate server
133 * @type {Array} 133 * @type {Array}
134 * @private 134 * @private
135 */ 135 */
136 translateSupportedLanguages_: [], 136 translateSupportedLanguages_: [],
137 137
138 /** 138 /**
139 * The preference is a string that describes the spell check dictionary 139 * The dictionary of currently selected spell check dictionary languages,
140 * language, like "en-US". 140 * like {"en-US": true, "sl-SI": true}.
141 * @type {string} 141 * @type {Object}
142 * @private 142 * @private
143 */ 143 */
144 spellCheckDictionary_: '', 144 spellCheckLanguages_: {},
145 145
146 /** 146 /**
147 * The map of language code to input method IDs, like: 147 * The map of language code to input method IDs, like:
148 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} 148 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...}
149 * @type {Object} 149 * @type {Object}
150 * @private 150 * @private
151 */ 151 */
152 languageCodeToInputMethodIdsMap_: {}, 152 languageCodeToInputMethodIdsMap_: {},
153 153
154 /** 154 /**
(...skipping 26 matching lines...) Expand all
181 } 181 }
182 182
183 var checkbox = $('offer-to-translate-in-this-language'); 183 var checkbox = $('offer-to-translate-in-this-language');
184 checkbox.addEventListener('click', 184 checkbox.addEventListener('click',
185 this.handleOfferToTranslateCheckboxClick_.bind(this)); 185 this.handleOfferToTranslateCheckboxClick_.bind(this));
186 186
187 Preferences.getInstance().addEventListener( 187 Preferences.getInstance().addEventListener(
188 TRANSLATE_BLOCKED_LANGUAGES_PREF, 188 TRANSLATE_BLOCKED_LANGUAGES_PREF,
189 this.handleTranslateBlockedLanguagesPrefChange_.bind(this)); 189 this.handleTranslateBlockedLanguagesPrefChange_.bind(this));
190 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARIES_PREF, 190 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARIES_PREF,
191 this.handleSpellCheckDictionaryPrefChange_.bind(this)); 191 this.handleSpellCheckDictionariesPrefChange_.bind(this));
192
192 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, 193 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE,
193 this.handleEnableTranslatePrefChange_.bind(this)); 194 this.handleEnableTranslatePrefChange_.bind(this));
194 this.translateSupportedLanguages_ = 195 this.translateSupportedLanguages_ =
195 loadTimeData.getValue('translateSupportedLanguages'); 196 loadTimeData.getValue('translateSupportedLanguages');
196 197
197 // Set up add button. 198 // Set up add button.
198 var onclick = function(e) { 199 var onclick = function(e) {
199 // Add the language without showing the overlay if it's specified in 200 // Add the language without showing the overlay if it's specified in
200 // the URL hash (ex. lang_add=ja). Used for automated testing. 201 // the URL hash (ex. lang_add=ja). Used for automated testing.
201 var match = document.location.hash.match(/\blang_add=([\w-]+)/); 202 var match = document.location.hash.match(/\blang_add=([\w-]+)/);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Handle spell check enable/disable. 234 // Handle spell check enable/disable.
234 if (!cr.isMac) { 235 if (!cr.isMac) {
235 Preferences.getInstance().addEventListener( 236 Preferences.getInstance().addEventListener(
236 ENABLE_SPELL_CHECK_PREF, 237 ENABLE_SPELL_CHECK_PREF,
237 this.updateEnableSpellCheck_.bind(this)); 238 this.updateEnableSpellCheck_.bind(this));
238 } 239 }
239 } 240 }
240 241
241 // Handle clicks on "Use this language for spell checking" button. 242 // Handle clicks on "Use this language for spell checking" button.
242 if (!cr.isMac) { 243 if (!cr.isMac) {
243 var spellCheckLanguageButton = getRequiredElement( 244 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) {
244 'language-options-spell-check-language-button'); 245 $('spellcheck-language-checkbox').addEventListener(
245 spellCheckLanguageButton.addEventListener( 246 'change',
246 'click', 247 this.handleSpellCheckLanguageCheckboxClick_.bind(this));
247 this.handleSpellCheckLanguageButtonClick_.bind(this)); 248 } else {
249 $('spellcheck-language-button').addEventListener(
250 'click',
251 this.handleSpellCheckLanguageButtonClick_.bind(this));
252 }
248 } 253 }
249 254
250 if (cr.isChromeOS) { 255 if (cr.isChromeOS) {
251 $('language-options-ui-restart-button').onclick = function() { 256 $('language-options-ui-restart-button').onclick = function() {
252 chrome.send('uiLanguageRestart'); 257 chrome.send('uiLanguageRestart');
253 }; 258 };
254 } 259 }
255 260
256 $('language-confirm').onclick = 261 $('language-confirm').onclick =
257 PageManager.closeOverlay.bind(PageManager); 262 PageManager.closeOverlay.bind(PageManager);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 425 }
421 426
422 this.updateOfferToTranslateCheckbox_(languageCode); 427 this.updateOfferToTranslateCheckbox_(languageCode);
423 428
424 if (cr.isWindows || cr.isChromeOS) 429 if (cr.isWindows || cr.isChromeOS)
425 this.updateUiLanguageButton_(languageCode); 430 this.updateUiLanguageButton_(languageCode);
426 431
427 this.updateSelectedLanguageName_(languageCode); 432 this.updateSelectedLanguageName_(languageCode);
428 433
429 if (!cr.isMac) 434 if (!cr.isMac)
430 this.updateSpellCheckLanguageButton_(languageCode); 435 this.updateSpellCheckLanguageControls_(languageCode);
431 436
432 if (cr.isChromeOS) 437 if (cr.isChromeOS)
433 this.updateInputMethodList_(languageCode); 438 this.updateInputMethodList_(languageCode);
434 439
435 this.updateLanguageListInAddLanguageOverlay_(); 440 this.updateLanguageListInAddLanguageOverlay_();
436 }, 441 },
437 442
438 /** 443 /**
439 * Handles languageOptionsList's save event. 444 * Handles languageOptionsList's save event.
440 * @param {Event} e Save event. 445 * @param {Event} e Save event.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 showMutuallyExclusiveNodes( 602 showMutuallyExclusiveNodes(
598 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); 603 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1);
599 } 604 }
600 }, 605 },
601 606
602 /** 607 /**
603 * Updates the spell check language button. 608 * Updates the spell check language button.
604 * @param {string} languageCode Language code (ex. "fr"). 609 * @param {string} languageCode Language code (ex. "fr").
605 * @private 610 * @private
606 */ 611 */
607 updateSpellCheckLanguageButton_: function(languageCode) { 612 updateSpellCheckLanguageControls_: function(languageCode) {
613 assert(languageCode);
608 var spellCheckLanguageSection = $('language-options-spellcheck'); 614 var spellCheckLanguageSection = $('language-options-spellcheck');
609 var spellCheckLanguageButton = 615 var spellCheckLanguageButton = $('spellcheck-language-button');
610 $('language-options-spell-check-language-button'); 616 var spellCheckLanguageCheckboxDiv =
611 var spellCheckLanguageMessage = 617 $('spellcheck-language-checkbox-container');
612 $('language-options-spell-check-language-message'); 618 var spellCheckLanguageCheckbox = $('spellcheck-language-checkbox');
619 var spellCheckLanguageMessage = $('spellcheck-language-message');
613 var dictionaryDownloadInProgress = 620 var dictionaryDownloadInProgress =
614 $('language-options-dictionary-downloading-message'); 621 $('language-options-dictionary-downloading-message');
615 var dictionaryDownloadFailed = 622 var dictionaryDownloadFailed =
616 $('language-options-dictionary-download-failed-message'); 623 $('language-options-dictionary-download-failed-message');
617 var dictionaryDownloadFailHelp = 624 var dictionaryDownloadFailHelp =
618 $('language-options-dictionary-download-fail-help-message'); 625 $('language-options-dictionary-download-fail-help-message');
626
619 spellCheckLanguageSection.hidden = false; 627 spellCheckLanguageSection.hidden = false;
620 spellCheckLanguageMessage.hidden = true; 628 spellCheckLanguageMessage.hidden = true;
621 spellCheckLanguageButton.hidden = true; 629 spellCheckLanguageButton.hidden = true;
630 spellCheckLanguageCheckboxDiv.hidden = true;
622 dictionaryDownloadInProgress.hidden = true; 631 dictionaryDownloadInProgress.hidden = true;
623 dictionaryDownloadFailed.hidden = true; 632 dictionaryDownloadFailed.hidden = true;
624 dictionaryDownloadFailHelp.hidden = true; 633 dictionaryDownloadFailHelp.hidden = true;
634 spellCheckLanguageCheckbox.checked = false;
625 635
626 if (languageCode == this.spellCheckDictionary_) { 636 var isLanguageCodeInCodeSet =
627 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { 637 languageCode in loadTimeData.getValue('spellCheckLanguageCodeSet');
638 var isLanguageCodeInLanguages = languageCode in this.spellCheckLanguages_;
Dan Beam 2015/07/08 18:56:27 better name (still have no idea what this means)
Julius 2015/07/08 20:38:48 isLanguageCodeInLanguages -> isUsedForSpellcheckin
639 var isLanguageUsedForSpellchecking =
640 !(languageCode in this.spellcheckDictionaryDownloadStatus_);
Dan Beam 2015/07/08 18:56:27 isLanguageDownloaded?
Dan Beam 2015/07/08 18:56:27 move these below if (!) { return } block
Julius 2015/07/08 20:38:48 Done.
Julius 2015/07/08 20:38:48 Done.
641
642 if (!isLanguageCodeInCodeSet) {
643 spellCheckLanguageMessage.textContent =
644 loadTimeData.getString('cannotBeUsedForSpellChecking');
645 spellCheckLanguageMessage.hidden = false;
646 return;
647 }
648
649 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) {
650 spellCheckLanguageCheckbox.languageCode = languageCode;
651 spellCheckLanguageCheckbox.checked = isLanguageCodeInLanguages;
652 spellCheckLanguageCheckboxDiv.hidden = false;
653 } else if (isLanguageCodeInLanguages) {
654 if (isLanguageUsedForSpellchecking) {
628 spellCheckLanguageMessage.textContent = 655 spellCheckLanguageMessage.textContent =
629 loadTimeData.getString('isUsedForSpellChecking'); 656 loadTimeData.getString('isUsedForSpellChecking');
657 spellCheckLanguageMessage.hidden = false;
658 }
659 } else {
660 spellCheckLanguageButton.textContent =
661 loadTimeData.getString('useThisForSpellChecking');
662 spellCheckLanguageButton.hidden = false;
663 spellCheckLanguageButton.languageCode = languageCode;
664 }
665
666 switch (this.spellcheckDictionaryDownloadStatus_[languageCode]) {
667 case DOWNLOAD_STATUS.IN_PROGRESS:
668 dictionaryDownloadInProgress.hidden = false;
669 break;
670 case DOWNLOAD_STATUS.FAILED:
630 showMutuallyExclusiveNodes( 671 showMutuallyExclusiveNodes(
631 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); 672 [spellCheckLanguageSection, dictionaryDownloadFailed], 1);
632 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] ==
633 DOWNLOAD_STATUS.IN_PROGRESS) {
634 dictionaryDownloadInProgress.hidden = false;
635 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] ==
636 DOWNLOAD_STATUS.FAILED) {
637 spellCheckLanguageSection.hidden = true;
638 dictionaryDownloadFailed.hidden = false;
639 if (this.spellcheckDictionaryDownloadFailures_ > 1) 673 if (this.spellcheckDictionaryDownloadFailures_ > 1)
640 dictionaryDownloadFailHelp.hidden = false; 674 dictionaryDownloadFailHelp.hidden = false;
641 } 675 break;
642 } else if (languageCode in
643 loadTimeData.getValue('spellCheckLanguageCodeSet')) {
644 spellCheckLanguageButton.textContent =
645 loadTimeData.getString('useThisForSpellChecking');
646 showMutuallyExclusiveNodes(
647 [spellCheckLanguageButton, spellCheckLanguageMessage], 0);
648 spellCheckLanguageButton.languageCode = languageCode;
649 } else if (!languageCode) {
650 spellCheckLanguageButton.hidden = true;
651 spellCheckLanguageMessage.hidden = true;
652 } else {
653 spellCheckLanguageMessage.textContent =
654 loadTimeData.getString('cannotBeUsedForSpellChecking');
655 showMutuallyExclusiveNodes(
656 [spellCheckLanguageButton, spellCheckLanguageMessage], 1);
657 } 676 }
658 }, 677 },
659 678
660 /** 679 /**
661 * Updates the checkbox for stopping translation. 680 * Updates the checkbox for stopping translation.
662 * @param {string} languageCode Language code (ex. "fr"). 681 * @param {string} languageCode Language code (ex. "fr").
663 * @private 682 * @private
664 */ 683 */
665 updateOfferToTranslateCheckbox_: function(languageCode) { 684 updateOfferToTranslateCheckbox_: function(languageCode) {
666 var div = $('language-options-offer-to-translate'); 685 var div = $('language-options-offer-to-translate');
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return (!cr.isChromeOS || 931 return (!cr.isChromeOS ||
913 this.canDeleteLanguage_(languageCode)); 932 this.canDeleteLanguage_(languageCode));
914 }, 933 },
915 934
916 /** 935 /**
917 * Handles browse.enable_spellchecking change. 936 * Handles browse.enable_spellchecking change.
918 * @param {Event} e Change event. 937 * @param {Event} e Change event.
919 * @private 938 * @private
920 */ 939 */
921 updateEnableSpellCheck_: function(e) { 940 updateEnableSpellCheck_: function(e) {
922 var value = !$('enable-spell-check').checked; 941 var value = !$('enable-spellcheck').checked;
923 $('language-options-spell-check-language-button').disabled = value; 942 $('spellcheck-language-button').disabled = value;
924 if (!cr.isMac) 943 if (!cr.isMac)
925 $('edit-dictionary-button').hidden = value; 944 $('edit-dictionary-button').hidden = value;
926 }, 945 },
927 946
928 /** 947 /**
929 * Handles translateBlockedLanguagesPref change. 948 * Handles translateBlockedLanguagesPref change.
930 * @param {Event} e Change event. 949 * @param {Event} e Change event.
931 * @private 950 * @private
932 */ 951 */
933 handleTranslateBlockedLanguagesPrefChange_: function(e) { 952 handleTranslateBlockedLanguagesPrefChange_: function(e) {
934 this.translateBlockedLanguages_ = e.value.value; 953 this.translateBlockedLanguages_ = e.value.value;
935 this.updateOfferToTranslateCheckbox_( 954 this.updateOfferToTranslateCheckbox_(
936 $('language-options-list').getSelectedLanguageCode()); 955 $('language-options-list').getSelectedLanguageCode());
937 }, 956 },
938 957
939 /** 958 /**
940 * Handles spellCheckDictionaryPref change. 959 * Updates spellcheck dictionary UI (checkboxes, buttons, and labels) when
941 * @param {Event} e Change event. 960 * preferences change.
961 * @param {Event} e Preference change event where e.value.value is the list
962 * of languages currently used for spellchecking.
942 * @private 963 * @private
943 */ 964 */
944 handleSpellCheckDictionaryPrefChange_: function(e) { 965 handleSpellCheckDictionariesPrefChange_: function(e) {
945 var languageCode = e.value.value; 966 if (cr.isMac)
946 this.spellCheckDictionary_ = languageCode; 967 return;
947 if (!cr.isMac) { 968
948 this.updateSpellCheckLanguageButton_( 969 var languages = e.value.value;
949 $('language-options-list').getSelectedLanguageCode()); 970 this.spellCheckLanguages_ = {};
971 for (var i = 0; i < languages.length; i++) {
972 this.spellCheckLanguages_[languages[i]] = true;
950 } 973 }
974 this.updateSpellCheckLanguageControls_(
975 $('language-options-list').getSelectedLanguageCode());
951 }, 976 },
952 977
953 /** 978 /**
954 * Handles translate.enabled change. 979 * Handles translate.enabled change.
955 * @param {Event} e Change event. 980 * @param {Event} e Change event.
956 * @private 981 * @private
957 */ 982 */
958 handleEnableTranslatePrefChange_: function(e) { 983 handleEnableTranslatePrefChange_: function(e) {
959 var enabled = e.value.value; 984 var enabled = e.value.value;
960 this.enableTranslate_ = enabled; 985 this.enableTranslate_ = enabled;
961 this.updateOfferToTranslateCheckbox_( 986 this.updateOfferToTranslateCheckbox_(
962 $('language-options-list').getSelectedLanguageCode()); 987 $('language-options-list').getSelectedLanguageCode());
963 }, 988 },
964 989
965 /** 990 /**
966 * Handles spellCheckLanguageButton click. 991 * Handles spellCheckLanguageButton click.
967 * @param {Event} e Click event. 992 * @param {Event} e Click event.
968 * @private 993 * @private
969 */ 994 */
970 handleSpellCheckLanguageButtonClick_: function(e) { 995 handleSpellCheckLanguageButtonClick_: function(e) {
971 var languageCodes = [e.target.languageCode]; 996 var languageCode = e.currentTarget.languageCode;
972 // Save the preference. 997 // Save the preference.
973 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF, 998 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF,
999 [languageCode], true);
1000
1001 // The spellCheckLanguageChange argument is only used for logging.
1002 chrome.send('spellCheckLanguageChange', [languageCode]);
1003 chrome.send('coreOptionsUserMetricsAction',
1004 ['Options_Languages_SpellCheck']);
1005 },
1006
1007 /**
1008 * Updates the spellcheck.dictionaries preference with the currently
1009 * selected language codes.
1010 * @param {Event} e Click event. e.currentTarget represents the "Use this
1011 * language for spellchecking" checkbox.
1012 * @private
1013 */
1014 handleSpellCheckLanguageCheckboxClick_: function(e) {
1015 var languageCode = e.currentTarget.languageCode;
1016
1017 if (e.currentTarget.checked)
1018 this.spellCheckLanguages_[languageCode] = true;
1019 else
1020 delete this.spellCheckLanguages_[languageCode];
1021
1022 var languageCodes = Object.keys(this.spellCheckLanguages_);
1023 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF,
974 languageCodes, true); 1024 languageCodes, true);
1025
975 // The spellCheckLanguageChange argument is only used for logging. 1026 // The spellCheckLanguageChange argument is only used for logging.
976 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]); 1027 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]);
977 chrome.send('coreOptionsUserMetricsAction', 1028 chrome.send('coreOptionsUserMetricsAction',
978 ['Options_Languages_SpellCheck']); 1029 ['Options_Languages_SpellCheck']);
979 }, 1030 },
980 1031
981 /** 1032 /**
982 * Checks whether it's possible to remove the language specified by 1033 * Checks whether it's possible to remove the language specified by
983 * languageCode and returns true if possible. This function returns false 1034 * languageCode and returns true if possible. This function returns false
984 * if the removal causes the number of preload engines to be zero. 1035 * if the removal causes the number of preload engines to be zero.
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 * @param {string} languageCode The language of the dictionary that just 1321 * @param {string} languageCode The language of the dictionary that just
1271 * began downloading. 1322 * began downloading.
1272 * @private 1323 * @private
1273 */ 1324 */
1274 onDictionaryDownloadBegin_: function(languageCode) { 1325 onDictionaryDownloadBegin_: function(languageCode) {
1275 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1326 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1276 DOWNLOAD_STATUS.IN_PROGRESS; 1327 DOWNLOAD_STATUS.IN_PROGRESS;
1277 if (!cr.isMac && 1328 if (!cr.isMac &&
1278 languageCode == 1329 languageCode ==
1279 $('language-options-list').getSelectedLanguageCode()) { 1330 $('language-options-list').getSelectedLanguageCode()) {
1280 this.updateSpellCheckLanguageButton_(languageCode); 1331 this.updateSpellCheckLanguageControls_(languageCode);
1281 } 1332 }
1282 }, 1333 },
1283 1334
1284 /** 1335 /**
1285 * A handler for when dictionary for |languageCode| successfully downloaded. 1336 * A handler for when dictionary for |languageCode| successfully downloaded.
1286 * @param {string} languageCode The language of the dictionary that 1337 * @param {string} languageCode The language of the dictionary that
1287 * succeeded downloading. 1338 * succeeded downloading.
1288 * @private 1339 * @private
1289 */ 1340 */
1290 onDictionaryDownloadSuccess_: function(languageCode) { 1341 onDictionaryDownloadSuccess_: function(languageCode) {
1291 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; 1342 delete this.spellcheckDictionaryDownloadStatus_[languageCode];
1292 this.spellcheckDictionaryDownloadFailures_ = 0; 1343 this.spellcheckDictionaryDownloadFailures_ = 0;
1293 if (!cr.isMac && 1344 if (!cr.isMac &&
1294 languageCode == 1345 languageCode ==
1295 $('language-options-list').getSelectedLanguageCode()) { 1346 $('language-options-list').getSelectedLanguageCode()) {
1296 this.updateSpellCheckLanguageButton_(languageCode); 1347 this.updateSpellCheckLanguageControls_(languageCode);
1297 } 1348 }
1298 }, 1349 },
1299 1350
1300 /** 1351 /**
1301 * A handler for when dictionary for |languageCode| fails to download. 1352 * A handler for when dictionary for |languageCode| fails to download.
1302 * @param {string} languageCode The language of the dictionary that failed 1353 * @param {string} languageCode The language of the dictionary that failed
1303 * to download. 1354 * to download.
1304 * @private 1355 * @private
1305 */ 1356 */
1306 onDictionaryDownloadFailure_: function(languageCode) { 1357 onDictionaryDownloadFailure_: function(languageCode) {
1307 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1358 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1308 DOWNLOAD_STATUS.FAILED; 1359 DOWNLOAD_STATUS.FAILED;
1309 this.spellcheckDictionaryDownloadFailures_++; 1360 this.spellcheckDictionaryDownloadFailures_++;
1310 if (!cr.isMac && 1361 if (!cr.isMac &&
1311 languageCode == 1362 languageCode ==
1312 $('language-options-list').getSelectedLanguageCode()) { 1363 $('language-options-list').getSelectedLanguageCode()) {
1313 this.updateSpellCheckLanguageButton_(languageCode); 1364 this.updateSpellCheckLanguageControls_(languageCode);
1314 } 1365 }
1315 }, 1366 },
1316 1367
1317 /** 1368 /**
1318 * Converts the language code for Translation. There are some differences 1369 * Converts the language code for Translation. There are some differences
1319 * between the language set for Translation and that for Accept-Language. 1370 * between the language set for Translation and that for Accept-Language.
1320 * @param {string} languageCode The language code like 'fr'. 1371 * @param {string} languageCode The language code like 'fr'.
1321 * @return {string} The converted language code. 1372 * @return {string} The converted language code.
1322 * @private 1373 * @private
1323 */ 1374 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 }; 1421 };
1371 1422
1372 LanguageOptions.onDictionaryDownloadSuccess = function(languageCode) { 1423 LanguageOptions.onDictionaryDownloadSuccess = function(languageCode) {
1373 LanguageOptions.getInstance().onDictionaryDownloadSuccess_(languageCode); 1424 LanguageOptions.getInstance().onDictionaryDownloadSuccess_(languageCode);
1374 }; 1425 };
1375 1426
1376 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { 1427 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) {
1377 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); 1428 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode);
1378 }; 1429 };
1379 1430
1431 LanguageOptions.updateSpellCheckLanguageControls = function(languageCode) {
1432 var instance = LanguageOptions.getInstance();
1433 instance.updateSpellCheckLanguageControls_(languageCode);
1434 };
1435
1380 // Export 1436 // Export
1381 return { 1437 return {
1382 LanguageOptions: LanguageOptions 1438 LanguageOptions: LanguageOptions
1383 }; 1439 };
1384 }); 1440 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698