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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 } else { | 88 } else { |
| 89 OptionsPage.navigateToPage('addLanguage'); | 89 OptionsPage.navigateToPage('addLanguage'); |
| 90 } | 90 } |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 if (cr.isChromeOS) { | 93 if (cr.isChromeOS) { |
| 94 // Listen to user clicks on the add language list. | 94 // Listen to user clicks on the add language list. |
| 95 var addLanguageList = $('add-language-overlay-language-list'); | 95 var addLanguageList = $('add-language-overlay-language-list'); |
| 96 addLanguageList.addEventListener('click', | 96 addLanguageList.addEventListener('click', |
| 97 this.handleAddLanguageListClick_.bind(this)); | 97 this.handleAddLanguageListClick_.bind(this)); |
| 98 $('language-options-extension-ime-button').addEventListener('click', | |
|
James Hawkins
2012/09/12 16:11:58
nit: The start of parameter rows must align on the
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 99 this.handleExtensionImeButtonClick_.bind(this)); | |
| 98 } else { | 100 } else { |
| 99 // Listen to add language dialog ok button. | 101 // Listen to add language dialog ok button. |
| 100 var addLanguageOkButton = $('add-language-overlay-ok-button'); | 102 var addLanguageOkButton = $('add-language-overlay-ok-button'); |
| 101 addLanguageOkButton.addEventListener('click', | 103 addLanguageOkButton.addEventListener('click', |
| 102 this.handleAddLanguageOkButtonClick_.bind(this)); | 104 this.handleAddLanguageOkButtonClick_.bind(this)); |
| 103 | 105 |
| 104 // Show experimental features if enabled. | 106 // Show experimental features if enabled. |
| 105 if (loadTimeData.getBoolean('experimentalSpellCheckFeatures')) | 107 if (loadTimeData.getBoolean('experimentalSpellCheckFeatures')) |
| 106 $('auto-spell-correction-option').hidden = false; | 108 $('auto-spell-correction-option').hidden = false; |
| 107 | 109 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 129 OptionsPage.closeOverlay.bind(OptionsPage); | 131 OptionsPage.closeOverlay.bind(OptionsPage); |
| 130 }, | 132 }, |
| 131 | 133 |
| 132 // The preference is a boolean that enables/disables spell checking. | 134 // The preference is a boolean that enables/disables spell checking. |
| 133 enableSpellCheckPref: 'browser.enable_spellchecking', | 135 enableSpellCheckPref: 'browser.enable_spellchecking', |
| 134 // The preference is a CSV string that describes preload engines | 136 // The preference is a CSV string that describes preload engines |
| 135 // (i.e. active input methods). | 137 // (i.e. active input methods). |
| 136 preloadEnginesPref: 'settings.language.preload_engines', | 138 preloadEnginesPref: 'settings.language.preload_engines', |
| 137 // The list of preload engines, like ['mozc', 'pinyin']. | 139 // The list of preload engines, like ['mozc', 'pinyin']. |
| 138 preloadEngines_: [], | 140 preloadEngines_: [], |
| 141 // The preference that lists the extension IMEs that are filtered out of | |
| 142 // the language menu. | |
| 143 filteredExtensionImesPref: 'settings.language.filtered_extension_imes', | |
| 144 // The list of extension IMEs that are filtered out of the language menu. | |
| 145 filteredExtensionImes_: [], | |
| 139 // The preference is a string that describes the spell check | 146 // The preference is a string that describes the spell check |
| 140 // dictionary language, like "en-US". | 147 // dictionary language, like "en-US". |
| 141 spellCheckDictionaryPref: 'spellcheck.dictionary', | 148 spellCheckDictionaryPref: 'spellcheck.dictionary', |
| 142 spellCheckDictionary_: '', | 149 spellCheckDictionary_: '', |
| 143 // The map of language code to input method IDs, like: | 150 // The map of language code to input method IDs, like: |
| 144 // {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} | 151 // {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} |
| 145 languageCodeToInputMethodIdsMap_: {}, | 152 languageCodeToInputMethodIdsMap_: {}, |
| 146 | 153 |
| 147 /** | 154 /** |
| 148 * Initializes the input method list. | 155 * Initializes the input method list. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 173 // Add the configure button if the config page is present for this | 180 // Add the configure button if the config page is present for this |
| 174 // input method. | 181 // input method. |
| 175 if (inputMethod.id in INPUT_METHOD_ID_TO_CONFIG_PAGE_NAME) { | 182 if (inputMethod.id in INPUT_METHOD_ID_TO_CONFIG_PAGE_NAME) { |
| 176 var pageName = INPUT_METHOD_ID_TO_CONFIG_PAGE_NAME[inputMethod.id]; | 183 var pageName = INPUT_METHOD_ID_TO_CONFIG_PAGE_NAME[inputMethod.id]; |
| 177 var button = this.createConfigureInputMethodButton_(inputMethod.id, | 184 var button = this.createConfigureInputMethodButton_(inputMethod.id, |
| 178 pageName); | 185 pageName); |
| 179 element.appendChild(button); | 186 element.appendChild(button); |
| 180 } | 187 } |
| 181 inputMethodList.appendChild(element); | 188 inputMethodList.appendChild(element); |
| 182 } | 189 } |
| 190 | |
| 191 var extensionImeList = loadTimeData.getValue('extensionImeList'); | |
| 192 for (var i = 0; i < extensionImeList.length; i++) { | |
| 193 var inputMethod = extensionImeList[i]; | |
| 194 var element = inputMethodPrototype.cloneNode(true); | |
| 195 element.id = ''; | |
| 196 //element.languageCodeSet = {kExtensionImePage: true}; | |
|
James Hawkins
2012/09/12 16:11:58
Dead code?
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 197 element.languageCodeSet = {}; | |
| 198 var input = element.querySelectorAll('input')[0]; | |
| 199 input.inputMethodId = inputMethod.id; | |
| 200 var span = element.querySelectorAll('span')[0]; | |
| 201 span.textContent = inputMethod.displayName; | |
| 202 | |
| 203 // Listen to user clicks. | |
|
James Hawkins
2012/09/12 16:11:58
nit: This comment is superfluous.
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 204 input.addEventListener('click', | |
| 205 this.handleExtensionCheckboxClick_.bind(this)); | |
| 206 | |
| 207 inputMethodList.appendChild(element); | |
| 208 } | |
| 209 | |
| 183 // Listen to pref change once the input method list is initialized. | 210 // Listen to pref change once the input method list is initialized. |
| 184 Preferences.getInstance().addEventListener(this.preloadEnginesPref, | 211 Preferences.getInstance().addEventListener(this.preloadEnginesPref, |
| 185 this.handlePreloadEnginesPrefChange_.bind(this)); | 212 this.handlePreloadEnginesPrefChange_.bind(this)); |
| 213 Preferences.getInstance().addEventListener(this.filteredExtensionImesPref, | |
|
James Hawkins
2012/09/12 16:11:58
nit: The start of parameter rows must align on the
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 214 this.handleFilteredExtensionsPrefChange_.bind(this)); | |
| 186 }, | 215 }, |
| 187 | 216 |
| 188 /** | 217 /** |
| 189 * Creates a configure button for the given input method ID. | 218 * Creates a configure button for the given input method ID. |
| 190 * @param {string} inputMethodId Input method ID (ex. "pinyin"). | 219 * @param {string} inputMethodId Input method ID (ex. "pinyin"). |
| 191 * @param {string} pageName Name of the config page (ex. "languagePinyin"). | 220 * @param {string} pageName Name of the config page (ex. "languagePinyin"). |
| 192 * @private | 221 * @private |
| 193 */ | 222 */ |
| 194 createConfigureInputMethodButton_: function(inputMethodId, pageName) { | 223 createConfigureInputMethodButton_: function(inputMethodId, pageName) { |
| 195 var button = document.createElement('button'); | 224 var button = document.createElement('button'); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 219 | 248 |
| 220 /** | 249 /** |
| 221 * Handles languageOptionsList's change event. | 250 * Handles languageOptionsList's change event. |
| 222 * @param {Event} e Change event. | 251 * @param {Event} e Change event. |
| 223 * @private | 252 * @private |
| 224 */ | 253 */ |
| 225 handleLanguageOptionsListChange_: function(e) { | 254 handleLanguageOptionsListChange_: function(e) { |
| 226 var languageOptionsList = $('language-options-list'); | 255 var languageOptionsList = $('language-options-list'); |
| 227 var languageCode = languageOptionsList.getSelectedLanguageCode(); | 256 var languageCode = languageOptionsList.getSelectedLanguageCode(); |
| 228 | 257 |
| 258 // If there's no selection, just return. | |
| 259 if (!languageCode) | |
| 260 return; | |
| 261 | |
| 229 // Select the language if it's specified in the URL hash (ex. lang=ja). | 262 // Select the language if it's specified in the URL hash (ex. lang=ja). |
| 230 // Used for automated testing. | 263 // Used for automated testing. |
| 231 var match = document.location.hash.match(/\blang=([\w-]+)/); | 264 var match = document.location.hash.match(/\blang=([\w-]+)/); |
| 232 if (match) { | 265 if (match) { |
| 233 var specifiedLanguageCode = match[1]; | 266 var specifiedLanguageCode = match[1]; |
| 234 if (languageOptionsList.selectLanguageByCode(specifiedLanguageCode)) { | 267 if (languageOptionsList.selectLanguageByCode(specifiedLanguageCode)) { |
| 235 languageCode = specifiedLanguageCode; | 268 languageCode = specifiedLanguageCode; |
| 236 } | 269 } |
| 237 } | 270 } |
| 238 | 271 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 * @private | 544 * @private |
| 512 */ | 545 */ |
| 513 handlePreloadEnginesPrefChange_: function(e) { | 546 handlePreloadEnginesPrefChange_: function(e) { |
| 514 var value = e.value.value; | 547 var value = e.value.value; |
| 515 this.preloadEngines_ = this.filterBadPreloadEngines_(value.split(',')); | 548 this.preloadEngines_ = this.filterBadPreloadEngines_(value.split(',')); |
| 516 this.updateCheckboxesFromPreloadEngines_(); | 549 this.updateCheckboxesFromPreloadEngines_(); |
| 517 $('language-options-list').updateDeletable(); | 550 $('language-options-list').updateDeletable(); |
| 518 }, | 551 }, |
| 519 | 552 |
| 520 /** | 553 /** |
| 554 * Handles filteredExtensionImesPref change. | |
| 555 * @param {Event} e Change event. | |
| 556 * @private | |
| 557 */ | |
| 558 handleFilteredExtensionsPrefChange_: function(e) { | |
| 559 var value = e.value.value; | |
| 560 this.filteredExtensionImes_ = value.split(','); | |
| 561 this.updateCheckboxesFromFilteredExtensions_(); | |
| 562 }, | |
| 563 | |
| 564 /** | |
| 521 * Handles input method checkbox's click event. | 565 * Handles input method checkbox's click event. |
| 522 * @param {Event} e Click event. | 566 * @param {Event} e Click event. |
| 523 * @private | 567 * @private |
| 524 */ | 568 */ |
| 525 handleCheckboxClick_: function(e) { | 569 handleCheckboxClick_: function(e) { |
| 526 var checkbox = e.target; | 570 var checkbox = e.target; |
| 527 if (this.preloadEngines_.length == 1 && !checkbox.checked) { | 571 if (this.preloadEngines_.length == 1 && !checkbox.checked) { |
| 528 // Don't allow disabling the last input method. | 572 // Don't allow disabling the last input method. |
| 529 this.showNotification_( | 573 this.showNotification_( |
| 530 loadTimeData.getString('please_add_another_input_method'), | 574 loadTimeData.getString('please_add_another_input_method'), |
| 531 loadTimeData.getString('ok_button')); | 575 loadTimeData.getString('ok_button')); |
| 532 checkbox.checked = true; | 576 checkbox.checked = true; |
| 533 return; | 577 return; |
| 534 } | 578 } |
| 535 if (checkbox.checked) { | 579 if (checkbox.checked) { |
| 536 chrome.send('inputMethodEnable', [checkbox.inputMethodId]); | 580 chrome.send('inputMethodEnable', [checkbox.inputMethodId]); |
| 537 } else { | 581 } else { |
| 538 chrome.send('inputMethodDisable', [checkbox.inputMethodId]); | 582 chrome.send('inputMethodDisable', [checkbox.inputMethodId]); |
| 539 } | 583 } |
| 540 this.updatePreloadEnginesFromCheckboxes_(); | 584 this.updatePreloadEnginesFromCheckboxes_(); |
| 541 this.preloadEngines_ = this.sortPreloadEngines_(this.preloadEngines_); | 585 this.preloadEngines_ = this.sortPreloadEngines_(this.preloadEngines_); |
| 542 this.savePreloadEnginesPref_(); | 586 this.savePreloadEnginesPref_(); |
| 543 }, | 587 }, |
| 544 | 588 |
| 545 /** | 589 /** |
| 590 * Handles extension input method checkbox's click event. | |
| 591 * @param {Event} e Click event. | |
| 592 * @private | |
| 593 */ | |
| 594 handleExtensionCheckboxClick_: function(e) { | |
| 595 var checkbox = e.target; | |
| 596 /* | |
| 597 if (checkbox.checked) { | |
| 598 chrome.send('inputMethodEnable', [checkbox.inputMethodId]); | |
|
James Hawkins
2012/09/12 16:11:58
Dead code?
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 599 } else { | |
| 600 chrome.send('inputMethodDisable', [checkbox.inputMethodId]); | |
| 601 }*/ | |
| 602 this.updateFilteredExtensionsFromCheckboxes_(); | |
| 603 this.saveFilteredExtensionPref_(); | |
| 604 }, | |
| 605 | |
| 606 /** | |
| 546 * Handles add language list's click event. | 607 * Handles add language list's click event. |
| 547 * @param {Event} e Click event. | 608 * @param {Event} e Click event. |
| 548 */ | 609 */ |
| 549 handleAddLanguageListClick_: function(e) { | 610 handleAddLanguageListClick_: function(e) { |
| 550 var languageOptionsList = $('language-options-list'); | 611 var languageOptionsList = $('language-options-list'); |
| 551 var languageCode = e.target.languageCode; | 612 var languageCode = e.target.languageCode; |
| 552 // languageCode can be undefined, if click was made on some random | 613 // languageCode can be undefined, if click was made on some random |
| 553 // place in the overlay, rather than a button. Ignore it. | 614 // place in the overlay, rather than a button. Ignore it. |
| 554 if (!languageCode) { | 615 if (!languageCode) { |
| 555 return; | 616 return; |
| 556 } | 617 } |
| 557 languageOptionsList.addLanguage(languageCode); | 618 languageOptionsList.addLanguage(languageCode); |
| 558 var inputMethodIds = this.languageCodeToInputMethodIdsMap_[languageCode]; | 619 var inputMethodIds = this.languageCodeToInputMethodIdsMap_[languageCode]; |
| 559 // Enable the first input method for the language added. | 620 // Enable the first input method for the language added. |
| 560 if (inputMethodIds && inputMethodIds[0] && | 621 if (inputMethodIds && inputMethodIds[0] && |
| 561 // Don't add the input method it's already present. This can | 622 // Don't add the input method it's already present. This can |
| 562 // happen if the same input method is shared among multiple | 623 // happen if the same input method is shared among multiple |
| 563 // languages (ex. English US keyboard is used for English US and | 624 // languages (ex. English US keyboard is used for English US and |
| 564 // Filipino). | 625 // Filipino). |
| 565 this.preloadEngines_.indexOf(inputMethodIds[0]) == -1) { | 626 this.preloadEngines_.indexOf(inputMethodIds[0]) == -1) { |
| 566 this.preloadEngines_.push(inputMethodIds[0]); | 627 this.preloadEngines_.push(inputMethodIds[0]); |
| 567 this.updateCheckboxesFromPreloadEngines_(); | 628 this.updateCheckboxesFromPreloadEngines_(); |
| 568 this.savePreloadEnginesPref_(); | 629 this.savePreloadEnginesPref_(); |
| 569 } | 630 } |
| 570 OptionsPage.closeOverlay(); | 631 OptionsPage.closeOverlay(); |
| 571 }, | 632 }, |
| 572 | 633 |
| 573 /** | 634 /** |
| 574 * Handles add language dialog ok button. | 635 * Handles extension IME button. |
| 575 */ | 636 */ |
| 637 handleExtensionImeButtonClick_: function() { | |
| 638 $('language-options-list').clearSelection(); | |
| 639 | |
| 640 var languageName = $('language-options-language-name'); | |
| 641 languageName.textContent = loadTimeData.getString('extension_ime_label'); | |
| 642 | |
| 643 var uiLanguageMessage = $('language-options-ui-language-message'); | |
| 644 uiLanguageMessage.textContent = | |
| 645 loadTimeData.getString('extension_ime_description'); | |
| 646 | |
| 647 var uiLanguageButton = $('language-options-ui-language-button'); | |
| 648 uiLanguageButton.onclick = null; | |
| 649 uiLanguageButton.hidden = true; | |
| 650 | |
| 651 this.updateSpellCheckLanguageButton_(); | |
| 652 | |
| 653 // Hide all input method checkboxes that aren't extension IMEs. | |
| 654 var inputMethodList = $('language-options-input-method-list'); | |
| 655 var methods = inputMethodList.querySelectorAll('.input-method'); | |
| 656 for (var i = 0; i < methods.length; i++) { | |
| 657 var method = methods[i]; | |
| 658 var input = method.querySelectorAll('input')[0]; | |
| 659 // Give it focus if the ID matches. | |
| 660 if (input.inputMethodId.match(/^_ext_ime_/)) { | |
|
James Hawkins
2012/09/12 16:11:58
nit: No braces for single-line blocks.
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 661 method.hidden = false; | |
| 662 } else { | |
| 663 method.hidden = true; | |
| 664 } | |
| 665 } | |
| 666 }, | |
| 667 | |
| 668 | |
| 576 handleAddLanguageOkButtonClick_: function() { | 669 handleAddLanguageOkButtonClick_: function() { |
| 577 var languagesSelect = $('add-language-overlay-language-list'); | 670 var languagesSelect = $('add-language-overlay-language-list'); |
| 578 var selectedIndex = languagesSelect.selectedIndex; | 671 var selectedIndex = languagesSelect.selectedIndex; |
| 579 if (selectedIndex >= 0) { | 672 if (selectedIndex >= 0) { |
| 580 var selection = languagesSelect.options[selectedIndex]; | 673 var selection = languagesSelect.options[selectedIndex]; |
| 581 $('language-options-list').addLanguage(String(selection.value)); | 674 $('language-options-list').addLanguage(String(selection.value)); |
| 582 OptionsPage.closeOverlay(); | 675 OptionsPage.closeOverlay(); |
| 583 } | 676 } |
| 584 }, | 677 }, |
| 585 | 678 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 if (!(this.preloadEngines_[i] in enginesToBeRemovedSet)) { | 771 if (!(this.preloadEngines_[i] in enginesToBeRemovedSet)) { |
| 679 newPreloadEngines.push(this.preloadEngines_[i]); | 772 newPreloadEngines.push(this.preloadEngines_[i]); |
| 680 } | 773 } |
| 681 } | 774 } |
| 682 // Don't allow this operation if it causes the number of preload | 775 // Don't allow this operation if it causes the number of preload |
| 683 // engines to be zero. | 776 // engines to be zero. |
| 684 return (newPreloadEngines.length > 0); | 777 return (newPreloadEngines.length > 0); |
| 685 }, | 778 }, |
| 686 | 779 |
| 687 /** | 780 /** |
| 781 * Saves the filtered extension preference. | |
| 782 * @private | |
| 783 */ | |
| 784 saveFilteredExtensionPref_: function() { | |
| 785 Preferences.setStringPref(this.filteredExtensionImesPref, | |
| 786 this.filteredExtensionImes_.join(','), true); | |
| 787 }, | |
| 788 | |
| 789 /** | |
| 790 * Updates the checkboxes in the input method list from the filtered | |
| 791 * extensions preference. | |
| 792 * @private | |
| 793 */ | |
| 794 updateCheckboxesFromFilteredExtensions_: function() { | |
| 795 // Convert the list into a dictonary for simpler lookup. | |
| 796 var dictionary = {}; | |
| 797 for (var i = 0; i < this.filteredExtensionImes_.length; i++) { | |
|
James Hawkins
2012/09/12 16:11:58
nit: No braces for single-line blocks.
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 798 dictionary[this.filteredExtensionImes_[i]] = true; | |
| 799 } | |
| 800 | |
| 801 var inputMethodList = $('language-options-input-method-list'); | |
| 802 var checkboxes = inputMethodList.querySelectorAll('input'); | |
| 803 for (var i = 0; i < checkboxes.length; i++) { | |
| 804 if (checkboxes[i].inputMethodId.match(/^_ext_ime_/)) { | |
|
James Hawkins
2012/09/12 16:11:58
nit: No braces for single-line blocks.
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 805 checkboxes[i].checked = !(checkboxes[i].inputMethodId in dictionary); | |
| 806 } | |
| 807 } | |
| 808 }, | |
| 809 | |
| 810 /** | |
| 811 * Updates the filtered extensions preference from the checkboxes in the | |
| 812 * input method list. | |
| 813 * @private | |
| 814 */ | |
| 815 updateFilteredExtensionsFromCheckboxes_: function() { | |
| 816 this.filteredExtensionImes_ = []; | |
| 817 var inputMethodList = $('language-options-input-method-list'); | |
| 818 var checkboxes = inputMethodList.querySelectorAll('input'); | |
| 819 for (var i = 0; i < checkboxes.length; i++) { | |
| 820 if (checkboxes[i].inputMethodId.match(/^_ext_ime_/)) { | |
| 821 if (!checkboxes[i].checked) { | |
|
James Hawkins
2012/09/12 16:11:58
nit: No braces for single-line blocks.
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 822 this.filteredExtensionImes_.push(checkboxes[i].inputMethodId); | |
| 823 } | |
| 824 } | |
| 825 } | |
| 826 }, | |
| 827 | |
| 828 /** | |
| 688 * Saves the preload engines preference. | 829 * Saves the preload engines preference. |
| 689 * @private | 830 * @private |
| 690 */ | 831 */ |
| 691 savePreloadEnginesPref_: function() { | 832 savePreloadEnginesPref_: function() { |
| 692 Preferences.setStringPref(this.preloadEnginesPref, | 833 Preferences.setStringPref(this.preloadEnginesPref, |
| 693 this.preloadEngines_.join(','), true); | 834 this.preloadEngines_.join(','), true); |
| 694 }, | 835 }, |
| 695 | 836 |
| 696 /** | 837 /** |
| 697 * Updates the checkboxes in the input method list from the preload | 838 * Updates the checkboxes in the input method list from the preload |
| 698 * engines preference. | 839 * engines preference. |
| 699 * @private | 840 * @private |
| 700 */ | 841 */ |
| 701 updateCheckboxesFromPreloadEngines_: function() { | 842 updateCheckboxesFromPreloadEngines_: function() { |
| 702 // Convert the list into a dictonary for simpler lookup. | 843 // Convert the list into a dictonary for simpler lookup. |
| 703 var dictionary = {}; | 844 var dictionary = {}; |
| 704 for (var i = 0; i < this.preloadEngines_.length; i++) { | 845 for (var i = 0; i < this.preloadEngines_.length; i++) { |
| 705 dictionary[this.preloadEngines_[i]] = true; | 846 dictionary[this.preloadEngines_[i]] = true; |
| 706 } | 847 } |
| 707 | 848 |
| 708 var inputMethodList = $('language-options-input-method-list'); | 849 var inputMethodList = $('language-options-input-method-list'); |
| 709 var checkboxes = inputMethodList.querySelectorAll('input'); | 850 var checkboxes = inputMethodList.querySelectorAll('input'); |
| 710 for (var i = 0; i < checkboxes.length; i++) { | 851 for (var i = 0; i < checkboxes.length; i++) { |
| 711 checkboxes[i].checked = (checkboxes[i].inputMethodId in dictionary); | 852 if (!checkboxes[i].inputMethodId.match(/^_ext_ime_/)) { |
| 853 checkboxes[i].checked = (checkboxes[i].inputMethodId in dictionary); | |
|
James Hawkins
2012/09/12 16:11:58
nit: No braces for single-line blocks.
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 854 } | |
| 712 } | 855 } |
| 713 }, | 856 }, |
| 714 | 857 |
| 715 /** | 858 /** |
| 716 * Updates the preload engines preference from the checkboxes in the | 859 * Updates the preload engines preference from the checkboxes in the |
| 717 * input method list. | 860 * input method list. |
| 718 * @private | 861 * @private |
| 719 */ | 862 */ |
| 720 updatePreloadEnginesFromCheckboxes_: function() { | 863 updatePreloadEnginesFromCheckboxes_: function() { |
| 721 this.preloadEngines_ = []; | 864 this.preloadEngines_ = []; |
| 722 var inputMethodList = $('language-options-input-method-list'); | 865 var inputMethodList = $('language-options-input-method-list'); |
| 723 var checkboxes = inputMethodList.querySelectorAll('input'); | 866 var checkboxes = inputMethodList.querySelectorAll('input'); |
| 724 for (var i = 0; i < checkboxes.length; i++) { | 867 for (var i = 0; i < checkboxes.length; i++) { |
| 725 if (checkboxes[i].checked) { | 868 if (!checkboxes[i].inputMethodId.match(/^_ext_ime_/)) { |
| 726 this.preloadEngines_.push(checkboxes[i].inputMethodId); | 869 if (checkboxes[i].checked) { |
|
James Hawkins
2012/09/12 16:11:58
nit: No braces for single-line blocks.
Zachary Kuznia
2012/09/13 09:28:32
Done.
| |
| 870 this.preloadEngines_.push(checkboxes[i].inputMethodId); | |
| 871 } | |
| 727 } | 872 } |
| 728 } | 873 } |
| 729 var languageOptionsList = $('language-options-list'); | 874 var languageOptionsList = $('language-options-list'); |
| 730 languageOptionsList.updateDeletable(); | 875 languageOptionsList.updateDeletable(); |
| 731 }, | 876 }, |
| 732 | 877 |
| 733 /** | 878 /** |
| 734 * Filters bad preload engines in case bad preload engines are | 879 * Filters bad preload engines in case bad preload engines are |
| 735 * stored in the preference. Removes duplicates as well. | 880 * stored in the preference. Removes duplicates as well. |
| 736 * @param {Array} preloadEngines List of preload engines. | 881 * @param {Array} preloadEngines List of preload engines. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 // only take effect after restart. | 996 // only take effect after restart. |
| 852 showMutuallyExclusiveNodes([$('language-options-ui-language-button'), | 997 showMutuallyExclusiveNodes([$('language-options-ui-language-button'), |
| 853 $('language-options-ui-notification-bar')], 1); | 998 $('language-options-ui-notification-bar')], 1); |
| 854 }; | 999 }; |
| 855 | 1000 |
| 856 // Export | 1001 // Export |
| 857 return { | 1002 return { |
| 858 LanguageOptions: LanguageOptions | 1003 LanguageOptions: LanguageOptions |
| 859 }; | 1004 }; |
| 860 }); | 1005 }); |
| OLD | NEW |