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

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 some clarity issues. 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
Dan Beam 2015/07/08 23:41:36 why did you add this \n?
Julius 2015/07/09 03:54:51 I shouldn't have, deleted.
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 canBeUsedForSpellchecking =
627 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { 637 languageCode in loadTimeData.getValue('spellCheckLanguageCodeSet');
638
639 if (!canBeUsedForSpellchecking) {
640 spellCheckLanguageMessage.textContent =
641 loadTimeData.getString('cannotBeUsedForSpellChecking');
642 spellCheckLanguageMessage.hidden = false;
643 return;
644 }
645
646 var isUsedForSpellchecking = languageCode in this.spellCheckLanguages_;
647 var isLanguageDownloaded =
648 !(languageCode in this.spellcheckDictionaryDownloadStatus_);
649
650 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) {
651 spellCheckLanguageCheckbox.languageCode = languageCode;
652 spellCheckLanguageCheckbox.checked = isUsedForSpellchecking;
653 spellCheckLanguageCheckboxDiv.hidden = false;
654 } else if (isUsedForSpellchecking) {
655 if (isLanguageDownloaded) {
628 spellCheckLanguageMessage.textContent = 656 spellCheckLanguageMessage.textContent =
629 loadTimeData.getString('isUsedForSpellChecking'); 657 loadTimeData.getString('isUsedForSpellChecking');
658 spellCheckLanguageMessage.hidden = false;
659 }
660 } else {
661 spellCheckLanguageButton.textContent =
662 loadTimeData.getString('useThisForSpellChecking');
663 spellCheckLanguageButton.hidden = false;
664 spellCheckLanguageButton.languageCode = languageCode;
665 }
666
667 switch (this.spellcheckDictionaryDownloadStatus_[languageCode]) {
668 case DOWNLOAD_STATUS.IN_PROGRESS:
669 dictionaryDownloadInProgress.hidden = false;
670 break;
671 case DOWNLOAD_STATUS.FAILED:
630 showMutuallyExclusiveNodes( 672 showMutuallyExclusiveNodes(
631 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); 673 [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) 674 if (this.spellcheckDictionaryDownloadFailures_ > 1)
640 dictionaryDownloadFailHelp.hidden = false; 675 dictionaryDownloadFailHelp.hidden = false;
641 } 676 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 } 677 }
658 }, 678 },
659 679
660 /** 680 /**
661 * Updates the checkbox for stopping translation. 681 * Updates the checkbox for stopping translation.
662 * @param {string} languageCode Language code (ex. "fr"). 682 * @param {string} languageCode Language code (ex. "fr").
663 * @private 683 * @private
664 */ 684 */
665 updateOfferToTranslateCheckbox_: function(languageCode) { 685 updateOfferToTranslateCheckbox_: function(languageCode) {
666 var div = $('language-options-offer-to-translate'); 686 var div = $('language-options-offer-to-translate');
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return (!cr.isChromeOS || 932 return (!cr.isChromeOS ||
913 this.canDeleteLanguage_(languageCode)); 933 this.canDeleteLanguage_(languageCode));
914 }, 934 },
915 935
916 /** 936 /**
917 * Handles browse.enable_spellchecking change. 937 * Handles browse.enable_spellchecking change.
918 * @param {Event} e Change event. 938 * @param {Event} e Change event.
919 * @private 939 * @private
920 */ 940 */
921 updateEnableSpellCheck_: function(e) { 941 updateEnableSpellCheck_: function(e) {
922 var value = !$('enable-spell-check').checked; 942 var value = !$('enable-spellcheck').checked;
923 $('language-options-spell-check-language-button').disabled = value; 943 $('spellcheck-language-button').disabled = value;
924 if (!cr.isMac) 944 if (!cr.isMac)
925 $('edit-dictionary-button').hidden = value; 945 $('edit-dictionary-button').hidden = value;
926 }, 946 },
927 947
928 /** 948 /**
929 * Handles translateBlockedLanguagesPref change. 949 * Handles translateBlockedLanguagesPref change.
930 * @param {Event} e Change event. 950 * @param {Event} e Change event.
931 * @private 951 * @private
932 */ 952 */
933 handleTranslateBlockedLanguagesPrefChange_: function(e) { 953 handleTranslateBlockedLanguagesPrefChange_: function(e) {
934 this.translateBlockedLanguages_ = e.value.value; 954 this.translateBlockedLanguages_ = e.value.value;
935 this.updateOfferToTranslateCheckbox_( 955 this.updateOfferToTranslateCheckbox_(
936 $('language-options-list').getSelectedLanguageCode()); 956 $('language-options-list').getSelectedLanguageCode());
937 }, 957 },
938 958
939 /** 959 /**
940 * Handles spellCheckDictionaryPref change. 960 * Updates spellcheck dictionary UI (checkboxes, buttons, and labels) when
941 * @param {Event} e Change event. 961 * preferences change.
962 * @param {Event} e Preference change event where e.value.value is the list
963 * of languages currently used for spellchecking.
942 * @private 964 * @private
943 */ 965 */
944 handleSpellCheckDictionaryPrefChange_: function(e) { 966 handleSpellCheckDictionariesPrefChange_: function(e) {
945 var languageCode = e.value.value; 967 if (cr.isMac)
946 this.spellCheckDictionary_ = languageCode; 968 return;
947 if (!cr.isMac) { 969
948 this.updateSpellCheckLanguageButton_( 970 var languages = e.value.value;
949 $('language-options-list').getSelectedLanguageCode()); 971 this.spellCheckLanguages_ = {};
972 for (var i = 0; i < languages.length; i++) {
973 this.spellCheckLanguages_[languages[i]] = true;
950 } 974 }
975 this.updateSpellCheckLanguageControls_(
976 $('language-options-list').getSelectedLanguageCode());
951 }, 977 },
952 978
953 /** 979 /**
954 * Handles translate.enabled change. 980 * Handles translate.enabled change.
955 * @param {Event} e Change event. 981 * @param {Event} e Change event.
956 * @private 982 * @private
957 */ 983 */
958 handleEnableTranslatePrefChange_: function(e) { 984 handleEnableTranslatePrefChange_: function(e) {
959 var enabled = e.value.value; 985 var enabled = e.value.value;
960 this.enableTranslate_ = enabled; 986 this.enableTranslate_ = enabled;
961 this.updateOfferToTranslateCheckbox_( 987 this.updateOfferToTranslateCheckbox_(
962 $('language-options-list').getSelectedLanguageCode()); 988 $('language-options-list').getSelectedLanguageCode());
963 }, 989 },
964 990
965 /** 991 /**
966 * Handles spellCheckLanguageButton click. 992 * Handles spellCheckLanguageButton click.
967 * @param {Event} e Click event. 993 * @param {Event} e Click event.
968 * @private 994 * @private
969 */ 995 */
970 handleSpellCheckLanguageButtonClick_: function(e) { 996 handleSpellCheckLanguageButtonClick_: function(e) {
971 var languageCodes = [e.target.languageCode]; 997 var languageCode = e.currentTarget.languageCode;
972 // Save the preference. 998 // Save the preference.
973 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF, 999 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF,
1000 [languageCode], true);
1001
1002 // The spellCheckLanguageChange argument is only used for logging.
1003 chrome.send('spellCheckLanguageChange', [languageCode]);
1004 chrome.send('coreOptionsUserMetricsAction',
1005 ['Options_Languages_SpellCheck']);
1006 },
1007
1008 /**
1009 * Updates the spellcheck.dictionaries preference with the currently
1010 * selected language codes.
1011 * @param {Event} e Click event. e.currentTarget represents the "Use this
1012 * language for spellchecking" checkbox.
1013 * @private
1014 */
1015 handleSpellCheckLanguageCheckboxClick_: function(e) {
1016 var languageCode = e.currentTarget.languageCode;
1017
1018 if (e.currentTarget.checked)
1019 this.spellCheckLanguages_[languageCode] = true;
1020 else
1021 delete this.spellCheckLanguages_[languageCode];
1022
1023 var languageCodes = Object.keys(this.spellCheckLanguages_);
1024 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF,
974 languageCodes, true); 1025 languageCodes, true);
1026
975 // The spellCheckLanguageChange argument is only used for logging. 1027 // The spellCheckLanguageChange argument is only used for logging.
976 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]); 1028 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]);
977 chrome.send('coreOptionsUserMetricsAction', 1029 chrome.send('coreOptionsUserMetricsAction',
978 ['Options_Languages_SpellCheck']); 1030 ['Options_Languages_SpellCheck']);
979 }, 1031 },
980 1032
981 /** 1033 /**
982 * Checks whether it's possible to remove the language specified by 1034 * Checks whether it's possible to remove the language specified by
983 * languageCode and returns true if possible. This function returns false 1035 * languageCode and returns true if possible. This function returns false
984 * if the removal causes the number of preload engines to be zero. 1036 * 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 1322 * @param {string} languageCode The language of the dictionary that just
1271 * began downloading. 1323 * began downloading.
1272 * @private 1324 * @private
1273 */ 1325 */
1274 onDictionaryDownloadBegin_: function(languageCode) { 1326 onDictionaryDownloadBegin_: function(languageCode) {
1275 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1327 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1276 DOWNLOAD_STATUS.IN_PROGRESS; 1328 DOWNLOAD_STATUS.IN_PROGRESS;
1277 if (!cr.isMac && 1329 if (!cr.isMac &&
1278 languageCode == 1330 languageCode ==
1279 $('language-options-list').getSelectedLanguageCode()) { 1331 $('language-options-list').getSelectedLanguageCode()) {
1280 this.updateSpellCheckLanguageButton_(languageCode); 1332 this.updateSpellCheckLanguageControls_(languageCode);
1281 } 1333 }
1282 }, 1334 },
1283 1335
1284 /** 1336 /**
1285 * A handler for when dictionary for |languageCode| successfully downloaded. 1337 * A handler for when dictionary for |languageCode| successfully downloaded.
1286 * @param {string} languageCode The language of the dictionary that 1338 * @param {string} languageCode The language of the dictionary that
1287 * succeeded downloading. 1339 * succeeded downloading.
1288 * @private 1340 * @private
1289 */ 1341 */
1290 onDictionaryDownloadSuccess_: function(languageCode) { 1342 onDictionaryDownloadSuccess_: function(languageCode) {
1291 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; 1343 delete this.spellcheckDictionaryDownloadStatus_[languageCode];
1292 this.spellcheckDictionaryDownloadFailures_ = 0; 1344 this.spellcheckDictionaryDownloadFailures_ = 0;
1293 if (!cr.isMac && 1345 if (!cr.isMac &&
1294 languageCode == 1346 languageCode ==
1295 $('language-options-list').getSelectedLanguageCode()) { 1347 $('language-options-list').getSelectedLanguageCode()) {
1296 this.updateSpellCheckLanguageButton_(languageCode); 1348 this.updateSpellCheckLanguageControls_(languageCode);
1297 } 1349 }
1298 }, 1350 },
1299 1351
1300 /** 1352 /**
1301 * A handler for when dictionary for |languageCode| fails to download. 1353 * A handler for when dictionary for |languageCode| fails to download.
1302 * @param {string} languageCode The language of the dictionary that failed 1354 * @param {string} languageCode The language of the dictionary that failed
1303 * to download. 1355 * to download.
1304 * @private 1356 * @private
1305 */ 1357 */
1306 onDictionaryDownloadFailure_: function(languageCode) { 1358 onDictionaryDownloadFailure_: function(languageCode) {
1307 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1359 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1308 DOWNLOAD_STATUS.FAILED; 1360 DOWNLOAD_STATUS.FAILED;
1309 this.spellcheckDictionaryDownloadFailures_++; 1361 this.spellcheckDictionaryDownloadFailures_++;
1310 if (!cr.isMac && 1362 if (!cr.isMac &&
1311 languageCode == 1363 languageCode ==
1312 $('language-options-list').getSelectedLanguageCode()) { 1364 $('language-options-list').getSelectedLanguageCode()) {
1313 this.updateSpellCheckLanguageButton_(languageCode); 1365 this.updateSpellCheckLanguageControls_(languageCode);
1314 } 1366 }
1315 }, 1367 },
1316 1368
1317 /** 1369 /**
1318 * Converts the language code for Translation. There are some differences 1370 * Converts the language code for Translation. There are some differences
1319 * between the language set for Translation and that for Accept-Language. 1371 * between the language set for Translation and that for Accept-Language.
1320 * @param {string} languageCode The language code like 'fr'. 1372 * @param {string} languageCode The language code like 'fr'.
1321 * @return {string} The converted language code. 1373 * @return {string} The converted language code.
1322 * @private 1374 * @private
1323 */ 1375 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 }; 1422 };
1371 1423
1372 LanguageOptions.onDictionaryDownloadSuccess = function(languageCode) { 1424 LanguageOptions.onDictionaryDownloadSuccess = function(languageCode) {
1373 LanguageOptions.getInstance().onDictionaryDownloadSuccess_(languageCode); 1425 LanguageOptions.getInstance().onDictionaryDownloadSuccess_(languageCode);
1374 }; 1426 };
1375 1427
1376 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { 1428 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) {
1377 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); 1429 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode);
1378 }; 1430 };
1379 1431
1432 LanguageOptions.updateSpellCheckLanguageControls = function(languageCode) {
1433 var instance = LanguageOptions.getInstance();
1434 instance.updateSpellCheckLanguageControls_(languageCode);
1435 };
1436
1380 // Export 1437 // Export
1381 return { 1438 return {
1382 LanguageOptions: LanguageOptions 1439 LanguageOptions: LanguageOptions
1383 }; 1440 };
1384 }); 1441 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698