Chromium Code Reviews| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * The preference key that is a string that describes the spell check | 55 * The preference key that is a string that describes the spell check |
| 56 * dictionary language, like "en-US". | 56 * dictionary language, like "en-US". |
| 57 * @type {string} | 57 * @type {string} |
| 58 * @const | 58 * @const |
| 59 */ | 59 */ |
| 60 var SPELL_CHECK_DICTIONARY_PREF = 'spellcheck.dictionary'; | 60 var SPELL_CHECK_DICTIONARY_PREF = 'spellcheck.dictionary'; |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * The preference key that describes the spell check dictionary languages | |
| 64 * currently selected (as a comma separated string, like "en-US,sl-SI"). | |
| 65 * @type {string} | |
| 66 * @const | |
| 67 */ | |
| 68 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries'; | |
| 69 | |
| 70 /** | |
| 63 * The preference that indicates if the Translate feature is enabled. | 71 * The preference that indicates if the Translate feature is enabled. |
| 64 * @type {string} | 72 * @type {string} |
| 65 * @const | 73 * @const |
| 66 */ | 74 */ |
| 67 var ENABLE_TRANSLATE = 'translate.enabled'; | 75 var ENABLE_TRANSLATE = 'translate.enabled'; |
| 68 | 76 |
| 69 ///////////////////////////////////////////////////////////////////////////// | 77 ///////////////////////////////////////////////////////////////////////////// |
| 70 // LanguageOptions class: | 78 // LanguageOptions class: |
| 71 | 79 |
| 72 /** | 80 /** |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 145 |
| 138 /** | 146 /** |
| 139 * The preference is a string that describes the spell check dictionary | 147 * The preference is a string that describes the spell check dictionary |
| 140 * language, like "en-US". | 148 * language, like "en-US". |
| 141 * @type {string} | 149 * @type {string} |
| 142 * @private | 150 * @private |
| 143 */ | 151 */ |
| 144 spellCheckDictionary_: '', | 152 spellCheckDictionary_: '', |
| 145 | 153 |
| 146 /** | 154 /** |
| 155 * The list of currently selected spell check dictionary languages, like | |
| 156 * "en-US, sl-SI". | |
| 157 * @type {array} | |
| 158 * @private | |
| 159 */ | |
| 160 spellCheckDictionaries_: {}, | |
| 161 | |
| 162 /** | |
| 147 * The map of language code to input method IDs, like: | 163 * The map of language code to input method IDs, like: |
| 148 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} | 164 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} |
| 149 * @type {Object} | 165 * @type {Object} |
| 150 * @private | 166 * @private |
| 151 */ | 167 */ |
| 152 languageCodeToInputMethodIdsMap_: {}, | 168 languageCodeToInputMethodIdsMap_: {}, |
| 153 | 169 |
| 154 /** | 170 /** |
| 155 * The value that indicates if Translate feature is enabled or not. | 171 * The value that indicates if Translate feature is enabled or not. |
| 156 * @type {boolean} | 172 * @type {boolean} |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 180 this.initializeLanguageCodeToInputMethodIdsMap_(); | 196 this.initializeLanguageCodeToInputMethodIdsMap_(); |
| 181 } | 197 } |
| 182 | 198 |
| 183 var checkbox = $('offer-to-translate-in-this-language'); | 199 var checkbox = $('offer-to-translate-in-this-language'); |
| 184 checkbox.addEventListener('click', | 200 checkbox.addEventListener('click', |
| 185 this.handleOfferToTranslateCheckboxClick_.bind(this)); | 201 this.handleOfferToTranslateCheckboxClick_.bind(this)); |
| 186 | 202 |
| 187 Preferences.getInstance().addEventListener( | 203 Preferences.getInstance().addEventListener( |
| 188 TRANSLATE_BLOCKED_LANGUAGES_PREF, | 204 TRANSLATE_BLOCKED_LANGUAGES_PREF, |
| 189 this.handleTranslateBlockedLanguagesPrefChange_.bind(this)); | 205 this.handleTranslateBlockedLanguagesPrefChange_.bind(this)); |
| 190 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARY_PREF, | 206 |
| 207 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { | |
| 208 Preferences.getInstance().addEventListener( | |
| 209 SPELL_CHECK_DICTIONARIES_PREF, | |
| 210 this.handleSpellCheckDictionariesPrefChange_.bind(this)); | |
| 211 } else { | |
| 212 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARY_PREF, | |
| 191 this.handleSpellCheckDictionaryPrefChange_.bind(this)); | 213 this.handleSpellCheckDictionaryPrefChange_.bind(this)); |
| 214 } | |
| 215 | |
| 192 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, | 216 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, |
| 193 this.handleEnableTranslatePrefChange_.bind(this)); | 217 this.handleEnableTranslatePrefChange_.bind(this)); |
| 194 this.translateSupportedLanguages_ = | 218 this.translateSupportedLanguages_ = |
| 195 loadTimeData.getValue('translateSupportedLanguages'); | 219 loadTimeData.getValue('translateSupportedLanguages'); |
| 196 | 220 |
| 197 // Set up add button. | 221 // Set up add button. |
| 198 var onclick = function(e) { | 222 var onclick = function(e) { |
| 199 // Add the language without showing the overlay if it's specified in | 223 // Add the language without showing the overlay if it's specified in |
| 200 // the URL hash (ex. lang_add=ja). Used for automated testing. | 224 // the URL hash (ex. lang_add=ja). Used for automated testing. |
| 201 var match = document.location.hash.match(/\blang_add=([\w-]+)/); | 225 var match = document.location.hash.match(/\blang_add=([\w-]+)/); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 // Handle spell check enable/disable. | 257 // Handle spell check enable/disable. |
| 234 if (!cr.isMac) { | 258 if (!cr.isMac) { |
| 235 Preferences.getInstance().addEventListener( | 259 Preferences.getInstance().addEventListener( |
| 236 ENABLE_SPELL_CHECK_PREF, | 260 ENABLE_SPELL_CHECK_PREF, |
| 237 this.updateEnableSpellCheck_.bind(this)); | 261 this.updateEnableSpellCheck_.bind(this)); |
| 238 } | 262 } |
| 239 } | 263 } |
| 240 | 264 |
| 241 // Handle clicks on "Use this language for spell checking" button. | 265 // Handle clicks on "Use this language for spell checking" button. |
| 242 if (!cr.isMac) { | 266 if (!cr.isMac) { |
| 243 var spellCheckLanguageButton = getRequiredElement( | 267 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { |
| 244 'language-options-spell-check-language-button'); | 268 var spellCheckLanguageCheckbox = getRequiredElement( |
| 245 spellCheckLanguageButton.addEventListener( | 269 'language-options-spell-check-language-checkbox'); |
| 246 'click', | 270 spellCheckLanguageCheckbox.addEventListener( |
| 247 this.handleSpellCheckLanguageButtonClick_.bind(this)); | 271 'click', |
| 272 this.handleSpellCheckLanguageCheckboxClick_.bind(this)); | |
| 273 } else { | |
| 274 var spellCheckLanguageButton = getRequiredElement( | |
| 275 'language-options-spell-check-language-button'); | |
| 276 spellCheckLanguageButton.addEventListener( | |
| 277 'click', | |
| 278 this.handleSpellCheckLanguageButtonClick_.bind(this)); | |
| 279 } | |
| 248 } | 280 } |
| 249 | 281 |
| 250 if (cr.isChromeOS) { | 282 if (cr.isChromeOS) { |
| 251 $('language-options-ui-restart-button').onclick = function() { | 283 $('language-options-ui-restart-button').onclick = function() { |
| 252 chrome.send('uiLanguageRestart'); | 284 chrome.send('uiLanguageRestart'); |
| 253 }; | 285 }; |
| 254 } | 286 } |
| 255 | 287 |
| 256 $('language-confirm').onclick = | 288 $('language-confirm').onclick = |
| 257 PageManager.closeOverlay.bind(PageManager); | 289 PageManager.closeOverlay.bind(PageManager); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 } | 452 } |
| 421 | 453 |
| 422 this.updateOfferToTranslateCheckbox_(languageCode); | 454 this.updateOfferToTranslateCheckbox_(languageCode); |
| 423 | 455 |
| 424 if (cr.isWindows || cr.isChromeOS) | 456 if (cr.isWindows || cr.isChromeOS) |
| 425 this.updateUiLanguageButton_(languageCode); | 457 this.updateUiLanguageButton_(languageCode); |
| 426 | 458 |
| 427 this.updateSelectedLanguageName_(languageCode); | 459 this.updateSelectedLanguageName_(languageCode); |
| 428 | 460 |
| 429 if (!cr.isMac) | 461 if (!cr.isMac) |
| 430 this.updateSpellCheckLanguageButton_(languageCode); | 462 this.updateSpellCheckLanguageControls_(languageCode); |
| 431 | 463 |
| 432 if (cr.isChromeOS) | 464 if (cr.isChromeOS) |
| 433 this.updateInputMethodList_(languageCode); | 465 this.updateInputMethodList_(languageCode); |
| 434 | 466 |
| 435 this.updateLanguageListInAddLanguageOverlay_(); | 467 this.updateLanguageListInAddLanguageOverlay_(); |
| 436 }, | 468 }, |
| 437 | 469 |
| 438 /** | 470 /** |
| 439 * Handles languageOptionsList's save event. | 471 * Handles languageOptionsList's save event. |
| 440 * @param {Event} e Save event. | 472 * @param {Event} e Save event. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 showMutuallyExclusiveNodes( | 629 showMutuallyExclusiveNodes( |
| 598 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); | 630 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); |
| 599 } | 631 } |
| 600 }, | 632 }, |
| 601 | 633 |
| 602 /** | 634 /** |
| 603 * Updates the spell check language button. | 635 * Updates the spell check language button. |
| 604 * @param {string} languageCode Language code (ex. "fr"). | 636 * @param {string} languageCode Language code (ex. "fr"). |
| 605 * @private | 637 * @private |
| 606 */ | 638 */ |
| 607 updateSpellCheckLanguageButton_: function(languageCode) { | 639 updateSpellCheckLanguageControls_: function(languageCode) { |
| 608 var spellCheckLanguageSection = $('language-options-spellcheck'); | 640 var spellCheckLanguageSection = $('language-options-spellcheck'); |
| 609 var spellCheckLanguageButton = | 641 var spellCheckLanguageButton = |
| 610 $('language-options-spell-check-language-button'); | 642 $('language-options-spell-check-language-button'); |
| 643 var spellCheckLanguageCheckboxDiv = | |
| 644 $('language-options-spell-check-language-checkbox-div'); | |
| 645 var spellCheckLanguageCheckbox = | |
| 646 $('language-options-spell-check-language-checkbox'); | |
| 611 var spellCheckLanguageMessage = | 647 var spellCheckLanguageMessage = |
| 612 $('language-options-spell-check-language-message'); | 648 $('language-options-spell-check-language-message'); |
| 613 var dictionaryDownloadInProgress = | 649 var dictionaryDownloadInProgress = |
| 614 $('language-options-dictionary-downloading-message'); | 650 $('language-options-dictionary-downloading-message'); |
| 615 var dictionaryDownloadFailed = | 651 var dictionaryDownloadFailed = |
| 616 $('language-options-dictionary-download-failed-message'); | 652 $('language-options-dictionary-download-failed-message'); |
| 617 var dictionaryDownloadFailHelp = | 653 var dictionaryDownloadFailHelp = |
| 618 $('language-options-dictionary-download-fail-help-message'); | 654 $('language-options-dictionary-download-fail-help-message'); |
| 655 | |
|
please use gerrit instead
2015/02/23 18:51:47
No need to introduce extra newline.
Klemen Forstnerič
2015/02/24 21:57:45
Done.
| |
| 619 spellCheckLanguageSection.hidden = false; | 656 spellCheckLanguageSection.hidden = false; |
| 620 spellCheckLanguageMessage.hidden = true; | 657 spellCheckLanguageMessage.hidden = true; |
| 621 spellCheckLanguageButton.hidden = true; | 658 spellCheckLanguageButton.hidden = true; |
| 659 spellCheckLanguageCheckboxDiv.hidden = true; | |
| 622 dictionaryDownloadInProgress.hidden = true; | 660 dictionaryDownloadInProgress.hidden = true; |
| 623 dictionaryDownloadFailed.hidden = true; | 661 dictionaryDownloadFailed.hidden = true; |
| 624 dictionaryDownloadFailHelp.hidden = true; | 662 dictionaryDownloadFailHelp.hidden = true; |
| 625 | 663 |
| 626 if (languageCode == this.spellCheckDictionary_) { | 664 spellCheckLanguageCheckbox.checked = false; |
| 627 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { | 665 |
| 666 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { | |
| 667 if (languageCode in | |
| 668 loadTimeData.getValue('spellCheckLanguageCodeSet')) { | |
| 669 spellCheckLanguageCheckbox.languageCode = languageCode; | |
| 670 if (languageCode in this.spellCheckDictionaries_) | |
| 671 spellCheckLanguageCheckbox.checked = true; | |
| 672 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { | |
| 673 spellCheckLanguageMessage.hidden = true; | |
| 674 spellCheckLanguageCheckboxDiv.hidden = false; | |
| 675 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | |
| 676 DOWNLOAD_STATUS_IN_PROGRESS) { | |
|
please use gerrit instead
2015/02/23 18:51:47
Please unify the dictionary download progress code
Klemen Forstnerič
2015/02/24 21:57:45
Done.
| |
| 677 dictionaryDownloadInProgress.hidden = false; | |
| 678 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | |
| 679 DOWNLOAD_STATUS.FAILED) { | |
| 680 spellCheckLanguageSection.hidden = true; | |
| 681 dictionaryDownloadFailed.hidden = false; | |
| 682 if (this.spellcheckDictionaryDownloadFailures_ > 1) | |
| 683 dictionaryDownloadFailHelp.hidden = false; | |
| 684 } | |
| 685 } else if (!languageCode) { | |
| 686 spellCheckLanguageCheckboxDiv.hidden = true; | |
| 687 spellCheckLanguageMessage.hidden = true; | |
| 688 } else { | |
| 628 spellCheckLanguageMessage.textContent = | 689 spellCheckLanguageMessage.textContent = |
| 629 loadTimeData.getString('isUsedForSpellChecking'); | 690 loadTimeData.getString('cannotBeUsedForSpellChecking'); |
| 691 spellCheckLanguageMessage.hidden = false; | |
| 692 spellCheckLanguageCheckboxDiv.hidden = true; | |
| 693 } | |
| 694 } else { | |
| 695 if (languageCode == this.spellCheckDictionary_) { | |
| 696 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { | |
| 697 spellCheckLanguageMessage.textContent = | |
| 698 loadTimeData.getString('isUsedForSpellChecking'); | |
| 699 showMutuallyExclusiveNodes( | |
| 700 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | |
| 701 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | |
| 702 DOWNLOAD_STATUS.IN_PROGRESS) { | |
| 703 dictionaryDownloadInProgress.hidden = false; | |
| 704 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | |
| 705 DOWNLOAD_STATUS.FAILED) { | |
| 706 spellCheckLanguageSection.hidden = true; | |
| 707 dictionaryDownloadFailed.hidden = false; | |
| 708 if (this.spellcheckDictionaryDownloadFailures_ > 1) | |
| 709 dictionaryDownloadFailHelp.hidden = false; | |
| 710 } | |
| 711 } else if (languageCode in | |
| 712 loadTimeData.getValue('spellCheckLanguageCodeSet')) { | |
| 713 spellCheckLanguageButton.textContent = | |
| 714 loadTimeData.getString('useThisForSpellChecking'); | |
| 715 showMutuallyExclusiveNodes( | |
| 716 [spellCheckLanguageButton, spellCheckLanguageMessage], 0); | |
| 717 spellCheckLanguageButton.languageCode = languageCode; | |
| 718 } else if (!languageCode) { | |
| 719 spellCheckLanguageButton.hidden = true; | |
| 720 spellCheckLanguageMessage.hidden = true; | |
| 721 } else { | |
| 722 spellCheckLanguageMessage.textContent = | |
| 723 loadTimeData.getString('cannotBeUsedForSpellChecking'); | |
| 630 showMutuallyExclusiveNodes( | 724 showMutuallyExclusiveNodes( |
| 631 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | 725 [spellCheckLanguageButton, spellCheckLanguageMessage], 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) | |
| 640 dictionaryDownloadFailHelp.hidden = false; | |
| 641 } | 726 } |
| 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 } | 727 } |
| 658 }, | 728 }, |
| 659 | 729 |
| 660 /** | 730 /** |
| 661 * Updates the checkbox for stopping translation. | 731 * Updates the checkbox for stopping translation. |
| 662 * @param {string} languageCode Language code (ex. "fr"). | 732 * @param {string} languageCode Language code (ex. "fr"). |
| 663 * @private | 733 * @private |
| 664 */ | 734 */ |
| 665 updateOfferToTranslateCheckbox_: function(languageCode) { | 735 updateOfferToTranslateCheckbox_: function(languageCode) { |
| 666 var div = $('language-options-offer-to-translate'); | 736 var div = $('language-options-offer-to-translate'); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 | 1008 |
| 939 /** | 1009 /** |
| 940 * Handles spellCheckDictionaryPref change. | 1010 * Handles spellCheckDictionaryPref change. |
| 941 * @param {Event} e Change event. | 1011 * @param {Event} e Change event. |
| 942 * @private | 1012 * @private |
| 943 */ | 1013 */ |
| 944 handleSpellCheckDictionaryPrefChange_: function(e) { | 1014 handleSpellCheckDictionaryPrefChange_: function(e) { |
| 945 var languageCode = e.value.value; | 1015 var languageCode = e.value.value; |
| 946 this.spellCheckDictionary_ = languageCode; | 1016 this.spellCheckDictionary_ = languageCode; |
| 947 if (!cr.isMac) { | 1017 if (!cr.isMac) { |
| 948 this.updateSpellCheckLanguageButton_( | 1018 this.updateSpellCheckLanguageControls_( |
| 949 $('language-options-list').getSelectedLanguageCode()); | 1019 $('language-options-list').getSelectedLanguageCode()); |
| 950 } | 1020 } |
| 951 }, | 1021 }, |
| 952 | 1022 |
| 1023 handleSpellCheckDictionariesPrefChange_: function(e) { | |
| 1024 if (cr.isMac) | |
| 1025 return; | |
| 1026 | |
| 1027 var commaSeparatedLanguageCodes = e.value.value; | |
| 1028 var languageCodesSplit = commaSeparatedLanguageCodes.split(','); | |
| 1029 | |
| 1030 this.spellCheckDictionaries_ = {}; | |
| 1031 for (var i = 0; i < languageCodesSplit.length; i++) | |
| 1032 this.spellCheckDictionaries_[languageCodesSplit[i]] = true; | |
| 1033 | |
| 1034 this.updateSpellCheckLanguageControls_( | |
| 1035 $('language-options-list').getSelectedLanguageCode()); | |
| 1036 }, | |
| 1037 | |
| 953 /** | 1038 /** |
| 954 * Handles translate.enabled change. | 1039 * Handles translate.enabled change. |
| 955 * @param {Event} e Change event. | 1040 * @param {Event} e Change event. |
| 956 * @private | 1041 * @private |
| 957 */ | 1042 */ |
| 958 handleEnableTranslatePrefChange_: function(e) { | 1043 handleEnableTranslatePrefChange_: function(e) { |
| 959 var enabled = e.value.value; | 1044 var enabled = e.value.value; |
| 960 this.enableTranslate_ = enabled; | 1045 this.enableTranslate_ = enabled; |
| 961 this.updateOfferToTranslateCheckbox_( | 1046 this.updateOfferToTranslateCheckbox_( |
| 962 $('language-options-list').getSelectedLanguageCode()); | 1047 $('language-options-list').getSelectedLanguageCode()); |
| 963 }, | 1048 }, |
| 964 | 1049 |
| 965 /** | 1050 /** |
| 966 * Handles spellCheckLanguageButton click. | 1051 * Handles spellCheckLanguageButton click. |
| 967 * @param {Event} e Click event. | 1052 * @param {Event} e Click event. |
| 968 * @private | 1053 * @private |
| 969 */ | 1054 */ |
| 970 handleSpellCheckLanguageButtonClick_: function(e) { | 1055 handleSpellCheckLanguageButtonClick_: function(e) { |
| 971 var languageCode = e.target.languageCode; | 1056 var languageCode = e.target.languageCode; |
| 972 // Save the preference. | 1057 // Save the preference. |
| 973 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF, | 1058 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF, |
| 974 languageCode, true); | 1059 languageCode, true); |
| 975 chrome.send('spellCheckLanguageChange', [languageCode]); | 1060 chrome.send('spellCheckLanguageChange', [languageCode]); |
| 976 chrome.send('coreOptionsUserMetricsAction', | 1061 chrome.send('coreOptionsUserMetricsAction', |
| 977 ['Options_Languages_SpellCheck']); | 1062 ['Options_Languages_SpellCheck']); |
| 978 }, | 1063 }, |
| 979 | 1064 |
| 980 /** | 1065 /** |
| 1066 * Handles spellCheckLanguageCheckbox click. | |
| 1067 * @param {Event} e Click event. | |
| 1068 * @private | |
| 1069 */ | |
| 1070 handleSpellCheckLanguageCheckboxClick_: function(e) { | |
| 1071 var languageCode = e.target.languageCode; | |
| 1072 var isChecked = e.target.checked; | |
| 1073 | |
| 1074 if (isChecked) | |
|
please use gerrit instead
2015/02/23 18:51:47
Inline "e.target.checked"
Klemen Forstnerič
2015/02/24 21:57:45
Done.
| |
| 1075 this.spellCheckDictionaries_[languageCode] = true; | |
| 1076 else | |
| 1077 delete this.spellCheckDictionaries_[languageCode]; | |
| 1078 | |
| 1079 var languageCodes = []; | |
| 1080 for (var languageCode in this.spellCheckDictionaries_) { | |
|
please use gerrit instead
2015/02/23 18:51:47
Don't redefine "languageCode" variable inside of t
Klemen Forstnerič
2015/02/24 21:57:45
Whoops, I missed this one. Done.
| |
| 1081 if (this.spellCheckDictionaries_.hasOwnProperty(languageCode)) | |
| 1082 languageCodes.push(languageCode); | |
| 1083 } | |
| 1084 | |
| 1085 Preferences.setStringPref(SPELL_CHECK_DICTIONARIES_PREF, | |
| 1086 languageCodes.join(','), true); | |
| 1087 }, | |
| 1088 | |
| 1089 /** | |
| 981 * Checks whether it's possible to remove the language specified by | 1090 * Checks whether it's possible to remove the language specified by |
| 982 * languageCode and returns true if possible. This function returns false | 1091 * languageCode and returns true if possible. This function returns false |
| 983 * if the removal causes the number of preload engines to be zero. | 1092 * if the removal causes the number of preload engines to be zero. |
| 984 * | 1093 * |
| 985 * @param {string} languageCode Language code (ex. "fr"). | 1094 * @param {string} languageCode Language code (ex. "fr"). |
| 986 * @return {boolean} Returns true on success. | 1095 * @return {boolean} Returns true on success. |
| 987 * @private | 1096 * @private |
| 988 */ | 1097 */ |
| 989 canDeleteLanguage_: function(languageCode) { | 1098 canDeleteLanguage_: function(languageCode) { |
| 990 // First create the set of engines to be removed from input methods | 1099 // First create the set of engines to be removed from input methods |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1269 * @param {string} languageCode The language of the dictionary that just | 1378 * @param {string} languageCode The language of the dictionary that just |
| 1270 * began downloading. | 1379 * began downloading. |
| 1271 * @private | 1380 * @private |
| 1272 */ | 1381 */ |
| 1273 onDictionaryDownloadBegin_: function(languageCode) { | 1382 onDictionaryDownloadBegin_: function(languageCode) { |
| 1274 this.spellcheckDictionaryDownloadStatus_[languageCode] = | 1383 this.spellcheckDictionaryDownloadStatus_[languageCode] = |
| 1275 DOWNLOAD_STATUS.IN_PROGRESS; | 1384 DOWNLOAD_STATUS.IN_PROGRESS; |
| 1276 if (!cr.isMac && | 1385 if (!cr.isMac && |
| 1277 languageCode == | 1386 languageCode == |
| 1278 $('language-options-list').getSelectedLanguageCode()) { | 1387 $('language-options-list').getSelectedLanguageCode()) { |
| 1279 this.updateSpellCheckLanguageButton_(languageCode); | 1388 this.updateSpellCheckLanguageControls_(languageCode); |
| 1280 } | 1389 } |
| 1281 }, | 1390 }, |
| 1282 | 1391 |
| 1283 /** | 1392 /** |
| 1284 * A handler for when dictionary for |languageCode| successfully downloaded. | 1393 * A handler for when dictionary for |languageCode| successfully downloaded. |
| 1285 * @param {string} languageCode The language of the dictionary that | 1394 * @param {string} languageCode The language of the dictionary that |
| 1286 * succeeded downloading. | 1395 * succeeded downloading. |
| 1287 * @private | 1396 * @private |
| 1288 */ | 1397 */ |
| 1289 onDictionaryDownloadSuccess_: function(languageCode) { | 1398 onDictionaryDownloadSuccess_: function(languageCode) { |
| 1290 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; | 1399 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; |
| 1291 this.spellcheckDictionaryDownloadFailures_ = 0; | 1400 this.spellcheckDictionaryDownloadFailures_ = 0; |
| 1292 if (!cr.isMac && | 1401 if (!cr.isMac && |
| 1293 languageCode == | 1402 languageCode == |
| 1294 $('language-options-list').getSelectedLanguageCode()) { | 1403 $('language-options-list').getSelectedLanguageCode()) { |
| 1295 this.updateSpellCheckLanguageButton_(languageCode); | 1404 this.updateSpellCheckLanguageControls_(languageCode); |
| 1296 } | 1405 } |
| 1297 }, | 1406 }, |
| 1298 | 1407 |
| 1299 /** | 1408 /** |
| 1300 * A handler for when dictionary for |languageCode| fails to download. | 1409 * A handler for when dictionary for |languageCode| fails to download. |
| 1301 * @param {string} languageCode The language of the dictionary that failed | 1410 * @param {string} languageCode The language of the dictionary that failed |
| 1302 * to download. | 1411 * to download. |
| 1303 * @private | 1412 * @private |
| 1304 */ | 1413 */ |
| 1305 onDictionaryDownloadFailure_: function(languageCode) { | 1414 onDictionaryDownloadFailure_: function(languageCode) { |
| 1306 this.spellcheckDictionaryDownloadStatus_[languageCode] = | 1415 this.spellcheckDictionaryDownloadStatus_[languageCode] = |
| 1307 DOWNLOAD_STATUS.FAILED; | 1416 DOWNLOAD_STATUS.FAILED; |
| 1308 this.spellcheckDictionaryDownloadFailures_++; | 1417 this.spellcheckDictionaryDownloadFailures_++; |
| 1309 if (!cr.isMac && | 1418 if (!cr.isMac && |
| 1310 languageCode == | 1419 languageCode == |
| 1311 $('language-options-list').getSelectedLanguageCode()) { | 1420 $('language-options-list').getSelectedLanguageCode()) { |
| 1312 this.updateSpellCheckLanguageButton_(languageCode); | 1421 this.updateSpellCheckLanguageControls_(languageCode); |
| 1313 } | 1422 } |
| 1314 }, | 1423 }, |
| 1315 | 1424 |
| 1316 /** | 1425 /** |
| 1317 * Converts the language code for Translation. There are some differences | 1426 * Converts the language code for Translation. There are some differences |
| 1318 * between the language set for Translation and that for Accept-Language. | 1427 * between the language set for Translation and that for Accept-Language. |
| 1319 * @param {string} languageCode The language code like 'fr'. | 1428 * @param {string} languageCode The language code like 'fr'. |
| 1320 * @return {string} The converted language code. | 1429 * @return {string} The converted language code. |
| 1321 * @private | 1430 * @private |
| 1322 */ | 1431 */ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1374 | 1483 |
| 1375 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1484 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
| 1376 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1485 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
| 1377 }; | 1486 }; |
| 1378 | 1487 |
| 1379 // Export | 1488 // Export |
| 1380 return { | 1489 return { |
| 1381 LanguageOptions: LanguageOptions | 1490 LanguageOptions: LanguageOptions |
| 1382 }; | 1491 }; |
| 1383 }); | 1492 }); |
| OLD | NEW |