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 OptionsPage = options.OptionsPage; | 9 /** @const */ var OptionsPage = options.OptionsPage; |
| 10 /** @const */ var LanguageList = options.LanguageList; | 10 /** @const */ var LanguageList = options.LanguageList; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 // Set up the button for editing custom spelling dictionary. | 118 // Set up the button for editing custom spelling dictionary. |
| 119 $('edit-dictionary-button').onclick = function(e) { | 119 $('edit-dictionary-button').onclick = function(e) { |
| 120 OptionsPage.navigateToPage('editDictionary'); | 120 OptionsPage.navigateToPage('editDictionary'); |
| 121 }; | 121 }; |
| 122 $('dictionary-download-retry-button').onclick = function(e) { | 122 $('dictionary-download-retry-button').onclick = function(e) { |
| 123 chrome.send('retryDictionaryDownload'); | 123 chrome.send('retryDictionaryDownload'); |
| 124 }; | 124 }; |
| 125 } | 125 } |
| 126 | 126 |
| 127 if (cr.isChromeOS) { | 127 if (cr.isChromeOS) { |
| 128 // Listen to user clicks on the add language list. | 128 // Listen to user click on the extension ime button. |
| 129 var addLanguageList = $('add-language-overlay-language-list'); | |
| 130 addLanguageList.addEventListener( | |
| 131 'click', | |
| 132 this.handleAddLanguageListClick_.bind(this)); | |
| 133 $('language-options-extension-ime-button').addEventListener( | 129 $('language-options-extension-ime-button').addEventListener( |
| 134 'click', | 130 'click', |
| 135 this.handleExtensionImeButtonClick_.bind(this)); | 131 this.handleExtensionImeButtonClick_.bind(this)); |
| 136 } else { | 132 } |
| 137 // Listen to add language dialog ok button. | |
| 138 var addLanguageOkButton = $('add-language-overlay-ok-button'); | |
| 139 addLanguageOkButton.addEventListener( | |
| 140 'click', | |
| 141 this.handleAddLanguageOkButtonClick_.bind(this)); | |
| 142 | 133 |
|
Dan Beam
2013/02/01 19:38:10
so this is available on CrOS now? seems like it wa
Seigo Nonaka
2013/02/04 06:10:45
Yes. Before UI didn't have OK button because all i
| |
| 134 // Listen to add language dialog ok button. | |
| 135 var addLanguageOkButton = $('add-language-overlay-ok-button'); | |
|
Dan Beam
2013/02/01 19:38:11
nit: inline `addLanguageOkButton` IMO
Seigo Nonaka
2013/02/04 06:10:45
Done.
| |
| 136 addLanguageOkButton.addEventListener( | |
| 137 'click', | |
| 138 this.handleAddLanguageOkButtonClick_.bind(this)); | |
|
Dan Beam
2013/02/01 19:38:11
nit: 'click', this.handleAddLanguageOkButtonClick_
Seigo Nonaka
2013/02/04 06:10:45
Done.
| |
| 139 | |
| 140 if (!cr.isChromeOS) { | |
| 143 // Show experimental features if enabled. | 141 // Show experimental features if enabled. |
| 144 if (loadTimeData.getBoolean('enableSpellingAutoCorrect')) | 142 if (loadTimeData.getBoolean('enableSpellingAutoCorrect')) |
| 145 $('auto-spell-correction-option').hidden = false; | 143 $('auto-spell-correction-option').hidden = false; |
| 146 | 144 |
| 147 // Handle spell check enable/disable. | 145 // Handle spell check enable/disable. |
| 148 if (!cr.isMac) { | 146 if (!cr.isMac) { |
| 149 Preferences.getInstance().addEventListener( | 147 Preferences.getInstance().addEventListener( |
| 150 this.enableSpellCheckPref, | 148 this.enableSpellCheckPref, |
| 151 this.updateEnableSpellCheck_.bind(this)); | 149 this.updateEnableSpellCheck_.bind(this)); |
| 152 } | 150 } |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 * @param {Event} e Click event. | 653 * @param {Event} e Click event. |
| 656 * @private | 654 * @private |
| 657 */ | 655 */ |
| 658 handleExtensionCheckboxClick_: function(e) { | 656 handleExtensionCheckboxClick_: function(e) { |
| 659 var checkbox = e.target; | 657 var checkbox = e.target; |
| 660 this.updateFilteredExtensionsFromCheckboxes_(); | 658 this.updateFilteredExtensionsFromCheckboxes_(); |
| 661 this.saveFilteredExtensionPref_(); | 659 this.saveFilteredExtensionPref_(); |
| 662 }, | 660 }, |
| 663 | 661 |
| 664 /** | 662 /** |
| 665 * Handles add language list's click event. | |
| 666 * @param {Event} e Click event. | |
| 667 */ | |
| 668 handleAddLanguageListClick_: function(e) { | |
| 669 var languageOptionsList = $('language-options-list'); | |
| 670 var languageCode = e.target.languageCode; | |
| 671 // languageCode can be undefined, if click was made on some random | |
| 672 // place in the overlay, rather than a button. Ignore it. | |
| 673 if (!languageCode) { | |
| 674 return; | |
| 675 } | |
| 676 languageOptionsList.addLanguage(languageCode); | |
| 677 var inputMethodIds = this.languageCodeToInputMethodIdsMap_[languageCode]; | |
| 678 // Enable the first input method for the language added. | |
| 679 if (inputMethodIds && inputMethodIds[0] && | |
| 680 // Don't add the input method it's already present. This can | |
| 681 // happen if the same input method is shared among multiple | |
| 682 // languages (ex. English US keyboard is used for English US and | |
| 683 // Filipino). | |
| 684 this.preloadEngines_.indexOf(inputMethodIds[0]) == -1) { | |
| 685 this.preloadEngines_.push(inputMethodIds[0]); | |
| 686 this.updateCheckboxesFromPreloadEngines_(); | |
| 687 this.savePreloadEnginesPref_(); | |
| 688 } | |
| 689 OptionsPage.closeOverlay(); | |
| 690 }, | |
| 691 | |
| 692 /** | |
| 693 * Handles extension IME button. | 663 * Handles extension IME button. |
| 694 */ | 664 */ |
| 695 handleExtensionImeButtonClick_: function() { | 665 handleExtensionImeButtonClick_: function() { |
| 696 $('language-options-list').clearSelection(); | 666 $('language-options-list').clearSelection(); |
| 697 | 667 |
| 698 var languageName = $('language-options-language-name'); | 668 var languageName = $('language-options-language-name'); |
| 699 languageName.textContent = loadTimeData.getString('extension_ime_label'); | 669 languageName.textContent = loadTimeData.getString('extension_ime_label'); |
| 700 | 670 |
| 701 var uiLanguageMessage = $('language-options-ui-language-message'); | 671 var uiLanguageMessage = $('language-options-ui-language-message'); |
| 702 uiLanguageMessage.textContent = | 672 uiLanguageMessage.textContent = |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 721 method.hidden = true; | 691 method.hidden = true; |
| 722 } | 692 } |
| 723 }, | 693 }, |
| 724 | 694 |
| 725 handleAddLanguageOkButtonClick_: function() { | 695 handleAddLanguageOkButtonClick_: function() { |
| 726 var languagesSelect = $('add-language-overlay-language-list'); | 696 var languagesSelect = $('add-language-overlay-language-list'); |
| 727 var selectedIndex = languagesSelect.selectedIndex; | 697 var selectedIndex = languagesSelect.selectedIndex; |
| 728 if (selectedIndex >= 0) { | 698 if (selectedIndex >= 0) { |
| 729 var selection = languagesSelect.options[selectedIndex]; | 699 var selection = languagesSelect.options[selectedIndex]; |
| 730 $('language-options-list').addLanguage(String(selection.value)); | 700 $('language-options-list').addLanguage(String(selection.value)); |
| 701 if (cr.isChromeOS) { | |
| 702 var inputMethodIds = | |
| 703 this.languageCodeToInputMethodIdsMap_[selection.value]; | |
| 704 // Enable the first input method for the language added. | |
| 705 if (inputMethodIds && inputMethodIds[0] && | |
| 706 // Don't add the input method it's already present. This can | |
| 707 // happen if the same input method is shared among multiple | |
| 708 // languages (ex. English US keyboard is used for English US and | |
| 709 // Filipino). | |
| 710 this.preloadEngines_.indexOf(inputMethodIds[0]) == -1) { | |
| 711 this.preloadEngines_.push(inputMethodIds[0]); | |
| 712 this.updateCheckboxesFromPreloadEngines_(); | |
| 713 this.savePreloadEnginesPref_(); | |
| 714 } | |
| 715 } | |
| 731 OptionsPage.closeOverlay(); | 716 OptionsPage.closeOverlay(); |
| 732 } | 717 } |
| 733 }, | 718 }, |
| 734 | 719 |
| 735 /** | 720 /** |
| 736 * Checks if languageCode is deletable or not. | 721 * Checks if languageCode is deletable or not. |
| 737 * @param {string} languageCode the languageCode to check for deletability. | 722 * @param {string} languageCode the languageCode to check for deletability. |
| 738 */ | 723 */ |
| 739 languageIsDeletable: function(languageCode) { | 724 languageIsDeletable: function(languageCode) { |
| 740 // Don't allow removing the language if it's a UI language. | 725 // Don't allow removing the language if it's a UI language. |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1091 | 1076 |
| 1092 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1077 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
| 1093 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1078 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
| 1094 }; | 1079 }; |
| 1095 | 1080 |
| 1096 // Export | 1081 // Export |
| 1097 return { | 1082 return { |
| 1098 LanguageOptions: LanguageOptions | 1083 LanguageOptions: LanguageOptions |
| 1099 }; | 1084 }; |
| 1100 }); | 1085 }); |
| OLD | NEW |