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

Unified Diff: chrome/browser/resources/settings/languages_page/languages_page.js

Issue 2359353002: MD Settings: Polish for Languages main page (Closed)
Patch Set: fix unintentional cr-shared-menu revert from rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/languages_page/languages_page.js
diff --git a/chrome/browser/resources/settings/languages_page/languages_page.js b/chrome/browser/resources/settings/languages_page/languages_page.js
index 93817afa845402a4d99e420c36cf5120e50660ec..19a0538498b65492fd431a00e2df807e2879f28f 100644
--- a/chrome/browser/resources/settings/languages_page/languages_page.js
+++ b/chrome/browser/resources/settings/languages_page/languages_page.js
@@ -108,6 +108,16 @@ Polymer({
/**
* @param {!LanguageState} language
+ * @return {boolean} True if |language| is first or second in the list of
+ * enabled languages. Used to hide the "Move to top" option.
+ * @private
+ */
+ isFirstOrSecondLanguage_: function(language) {
+ return this.languages.enabled.slice(0, 2).includes(language);
+ },
+
+ /**
+ * @param {!LanguageState} language
* @return {boolean} True if |language| is last in the list of enabled
* languages. Used to hide the "Move down" option.
* @private
@@ -175,6 +185,7 @@ Polymer({
// Reset the chosen UI language to the actual UI language.
this.languageHelper.resetUILanguage();
}
+ /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu();
},
/**
@@ -204,6 +215,28 @@ Polymer({
this.languageHelper.disableTranslateLanguage(
this.detailLanguage_.language.code);
}
+ /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu();
+ },
+
+ /**
+ * Returns "complex" if the menu includes checkboxes, which should change the
+ * spacing of items and show a separator in the menu.
+ * @param {boolean} translateEnabled
+ * @return {string}
+ */
+ getMenuClass_: function(translateEnabled) {
+ if (translateEnabled || cr.isChromeOS || cr.isWindows)
+ return 'complex';
+ return '';
+ },
+
+ /**
+ * Moves the language to the top of the list.
+ * @private
+ */
+ onMoveToTopTap_: function() {
+ /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu();
+ this.languageHelper.moveLanguageToFront(this.detailLanguage_.language.code);
},
/**

Powered by Google App Engine
This is Rietveld 408576698