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

Side by Side Diff: chrome/browser/resources/settings/languages_page/languages.js

Issue 2359353002: MD Settings: Polish for Languages main page (Closed)
Patch Set: dbeam feedback Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 'settings-languages' handles Chrome's language and input 6 * @fileoverview 'settings-languages' handles Chrome's language and input
7 * method settings. The 'languages' property, which reflects the current 7 * method settings. The 'languages' property, which reflects the current
8 * language settings, must not be changed directly. Instead, changes to 8 * language settings, must not be changed directly. Instead, changes to
9 * language settings should be made using the LanguageHelper APIs provided by 9 * language settings should be made using the LanguageHelper APIs provided by
10 * this class via languageHelper. 10 * this class via languageHelper.
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (this.enabledLanguageSet_.has(languageCodes[newIndex])) 569 if (this.enabledLanguageSet_.has(languageCodes[newIndex]))
570 distance--; 570 distance--;
571 } 571 }
572 572
573 languageCodes[originalIndex] = languageCodes[newIndex]; 573 languageCodes[originalIndex] = languageCodes[newIndex];
574 languageCodes[newIndex] = languageCode; 574 languageCodes[newIndex] = languageCode;
575 this.setPrefValue(preferredLanguagesPrefName, languageCodes.join(',')); 575 this.setPrefValue(preferredLanguagesPrefName, languageCodes.join(','));
576 }, 576 },
577 577
578 /** 578 /**
579 * Moves the language directly to the front of the list of enabled languages.
580 * @param {string} languageCode
581 */
582 moveLanguageToFront: function(languageCode) {
583 if (!CrSettingsPrefs.isInitialized)
584 return;
585
586 var languageCodes =
587 this.getPref(preferredLanguagesPrefName).value.split(',');
588 var originalIndex = languageCodes.indexOf(languageCode);
589 assert(originalIndex != -1);
590
591 languageCodes.splice(originalIndex, 1);
592 languageCodes.unshift(languageCode);
593
594 this.setPrefValue(preferredLanguagesPrefName, languageCodes.join(','));
595 },
596
597 /**
579 * Enables translate for the given language by removing the translate 598 * Enables translate for the given language by removing the translate
580 * language from the blocked languages preference. 599 * language from the blocked languages preference.
581 * @param {string} languageCode 600 * @param {string} languageCode
582 */ 601 */
583 enableTranslateLanguage: function(languageCode) { 602 enableTranslateLanguage: function(languageCode) {
584 languageCode = this.convertLanguageCodeForTranslate(languageCode); 603 languageCode = this.convertLanguageCodeForTranslate(languageCode);
585 this.deletePrefListItem('translate_blocked_languages', languageCode); 604 this.deletePrefListItem('translate_blocked_languages', languageCode);
586 }, 605 },
587 606
588 /** 607 /**
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 this.updateEnabledInputMethods_(); 745 this.updateEnabledInputMethods_();
727 }, 746 },
728 747
729 /** @param {string} id Removed input method ID. */ 748 /** @param {string} id Removed input method ID. */
730 onInputMethodRemoved_: function(id) { 749 onInputMethodRemoved_: function(id) {
731 assert(cr.isChromeOS); 750 assert(cr.isChromeOS);
732 this.updateEnabledInputMethods_(); 751 this.updateEnabledInputMethods_();
733 }, 752 },
734 }); 753 });
735 })(); 754 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698