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

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

Issue 2077063002: MD Settings: Allow the user to order the list of languages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed broken tests Created 4 years, 6 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' provides convenient access to 6 * @fileoverview 'settings-languages' provides convenient access to
7 * Chrome's language and input method settings. 7 * Chrome's language and input method settings.
8 * 8 *
9 * Instances of this element have a 'languages' property, which reflects the 9 * Instances of this element have a 'languages' property, which reflects the
10 * current language settings. The 'languages' property is read-only, meaning 10 * current language settings. The 'languages' property is read-only, meaning
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 var inputMethods = this.languageInputMethods_.get(otherLanguageCode); 539 var inputMethods = this.languageInputMethods_.get(otherLanguageCode);
540 return inputMethods && inputMethods.some(function(inputMethod) { 540 return inputMethods && inputMethods.some(function(inputMethod) {
541 return this.isComponentIme(inputMethod) && 541 return this.isComponentIme(inputMethod) &&
542 this.supportedInputMethodMap_.get(inputMethod.id).enabled; 542 this.supportedInputMethodMap_.get(inputMethod.id).enabled;
543 }, this); 543 }, this);
544 }, this); 544 }, this);
545 return otherInputMethodsEnabled; 545 return otherInputMethodsEnabled;
546 }, 546 },
547 547
548 /** 548 /**
549 * Moves the language in the list of enabled languages by the given offset.
550 * @param {string} languageCode
551 * @param {number} offset Negative offset moves the language toward the front
552 * of the list. A Positive one moves the language toward the back.
553 */
554 moveLanguage: function(languageCode, offset) {
555 if (!CrSettingsPrefs.isInitialized)
556 return;
557
558 var languageCodes =
559 this.getPref(preferredLanguagesPrefName).value.split(',');
560
561 var originalIndex = languageCodes.indexOf(languageCode);
562 var newIndex = originalIndex + offset;
563 if (originalIndex == -1 || newIndex < 0 || newIndex >= languageCodes.length)
564 return;
565
566 languageCodes.splice(originalIndex, 1);
567 languageCodes.splice(newIndex, 0, languageCode);
568 this.languageSettingsPrivate.setLanguageList(languageCodes);
michaelpg 2016/06/21 00:34:42 there's a bug(?) here: https://cs.chromium.org/chr
Moe 2016/06/21 20:10:19 I confirm this behavior. We may need to keep expan
569 },
570
571 /**
549 * Enables translate for the given language by removing the translate 572 * Enables translate for the given language by removing the translate
550 * language from the blocked languages preference. 573 * language from the blocked languages preference.
551 * @param {string} languageCode 574 * @param {string} languageCode
552 */ 575 */
553 enableTranslateLanguage: function(languageCode) { 576 enableTranslateLanguage: function(languageCode) {
554 languageCode = this.convertLanguageCodeForTranslate(languageCode); 577 languageCode = this.convertLanguageCodeForTranslate(languageCode);
555 this.deletePrefListItem('translate_blocked_languages', languageCode); 578 this.deletePrefListItem('translate_blocked_languages', languageCode);
556 }, 579 },
557 580
558 /** 581 /**
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 * manually sending a change notification for our 'languages' property (since 772 * manually sending a change notification for our 'languages' property (since
750 * it's the same object as the singleton's property, but isn't bound by 773 * it's the same object as the singleton's property, but isn't bound by
751 * Polymer). 774 * Polymer).
752 * @private 775 * @private
753 */ 776 */
754 singletonLanguagesChanged_: function(e) { 777 singletonLanguagesChanged_: function(e) {
755 // Forward the change notification to the host. 778 // Forward the change notification to the host.
756 this.fire(e.type, e.detail, {bubbles: false}); 779 this.fire(e.type, e.detail, {bubbles: false});
757 }, 780 },
758 }); 781 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698