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

Side by Side Diff: chrome/browser/resources/settings/languages_page/languages_page.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-page' is the settings page 6 * @fileoverview 'settings-languages-page' is the settings page
7 * for language and input method settings. 7 * for language and input method settings.
8 */ 8 */
9 (function() { 9 (function() {
10 'use strict'; 10 'use strict';
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 * @return {boolean} True if |language| is first in the list of enabled 101 * @return {boolean} True if |language| is first in the list of enabled
102 * languages. Used to hide the "Move up" option. 102 * languages. Used to hide the "Move up" option.
103 * @private 103 * @private
104 */ 104 */
105 isFirstLanguage_: function(language) { 105 isFirstLanguage_: function(language) {
106 return language == this.languages.enabled[0]; 106 return language == this.languages.enabled[0];
107 }, 107 },
108 108
109 /** 109 /**
110 * @param {!LanguageState} language 110 * @param {!LanguageState} language
111 * @return {boolean} True if |language| is first or second in the list of
112 * enabled languages. Used to hide the "Move to top" option.
113 * @private
114 */
115 isFirstOrSecondLanguage_: function(language) {
116 return this.languages.enabled.slice(0, 2).includes(language);
117 },
118
119 /**
120 * @param {!LanguageState} language
111 * @return {boolean} True if |language| is last in the list of enabled 121 * @return {boolean} True if |language| is last in the list of enabled
112 * languages. Used to hide the "Move down" option. 122 * languages. Used to hide the "Move down" option.
113 * @private 123 * @private
114 */ 124 */
115 isLastLanguage_: function(language) { 125 isLastLanguage_: function(language) {
116 return language == this.languages.enabled.slice(-1)[0]; 126 return language == this.languages.enabled.slice(-1)[0];
117 }, 127 },
118 128
119 /** 129 /**
120 * @param {!Object} change Polymer change object for languages.enabled.*. 130 * @param {!Object} change Polymer change object for languages.enabled.*.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 * @private 178 * @private
169 */ 179 */
170 onUILanguageChange_: function(e) { 180 onUILanguageChange_: function(e) {
171 if (e.target.checked) { 181 if (e.target.checked) {
172 this.languageHelper.setUILanguage(this.detailLanguage_.language.code); 182 this.languageHelper.setUILanguage(this.detailLanguage_.language.code);
173 } else if (this.detailLanguage_.language.code == 183 } else if (this.detailLanguage_.language.code ==
174 this.languageHelper.getProspectiveUILanguage()) { 184 this.languageHelper.getProspectiveUILanguage()) {
175 // Reset the chosen UI language to the actual UI language. 185 // Reset the chosen UI language to the actual UI language.
176 this.languageHelper.resetUILanguage(); 186 this.languageHelper.resetUILanguage();
177 } 187 }
188 /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu();
178 }, 189 },
179 190
180 /** 191 /**
181 * @param {!chrome.languageSettingsPrivate.Language} language 192 * @param {!chrome.languageSettingsPrivate.Language} language
182 * @param {string} targetLanguageCode The default translate target language. 193 * @param {string} targetLanguageCode The default translate target language.
183 * @return {boolean} True if the translate checkbox should be disabled. 194 * @return {boolean} True if the translate checkbox should be disabled.
184 * @private 195 * @private
185 */ 196 */
186 disableTranslateCheckbox_: function(language, targetLanguageCode) { 197 disableTranslateCheckbox_: function(language, targetLanguageCode) {
187 if (!language.supportsTranslate) 198 if (!language.supportsTranslate)
188 return true; 199 return true;
189 200
190 return this.languageHelper.convertLanguageCodeForTranslate(language.code) == 201 return this.languageHelper.convertLanguageCodeForTranslate(language.code) ==
191 targetLanguageCode; 202 targetLanguageCode;
192 }, 203 },
193 204
194 /** 205 /**
195 * Handler for changes to the translate checkbox. 206 * Handler for changes to the translate checkbox.
196 * @param {!{target: !PaperCheckboxElement}} e 207 * @param {!{target: !PaperCheckboxElement}} e
197 * @private 208 * @private
198 */ 209 */
199 onTranslateCheckboxChange_: function(e) { 210 onTranslateCheckboxChange_: function(e) {
200 if (e.target.checked) { 211 if (e.target.checked) {
201 this.languageHelper.enableTranslateLanguage( 212 this.languageHelper.enableTranslateLanguage(
202 this.detailLanguage_.language.code); 213 this.detailLanguage_.language.code);
203 } else { 214 } else {
204 this.languageHelper.disableTranslateLanguage( 215 this.languageHelper.disableTranslateLanguage(
205 this.detailLanguage_.language.code); 216 this.detailLanguage_.language.code);
206 } 217 }
218 /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu();
207 }, 219 },
208 220
209 /** 221 /**
222 * Returns "complex" if the menu includes checkboxes, which should change the
223 * spacing of items and show a separator in the menu.
224 * @param {boolean} translateEnabled
225 * @return {string}
226 */
227 getMenuClass_: function(translateEnabled) {
228 if (translateEnabled || cr.isChromeOS || cr.isWindows)
229 return 'complex';
230 return '';
231 },
232
233 /**
234 * Moves the language to the top of the list.
235 * @private
236 */
237 onMoveToTopTap_: function() {
238 /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu();
239 this.languageHelper.moveLanguageToFront(this.detailLanguage_.language.code);
240 },
241
242 /**
210 * Moves the language up in the list. 243 * Moves the language up in the list.
211 * @private 244 * @private
212 */ 245 */
213 onMoveUpTap_: function() { 246 onMoveUpTap_: function() {
214 /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu(); 247 /** @type {!CrSharedMenuElement} */(this.$.menu.get()).closeMenu();
215 this.languageHelper.moveLanguage(this.detailLanguage_.language.code, -1); 248 this.languageHelper.moveLanguage(this.detailLanguage_.language.code, -1);
216 }, 249 },
217 250
218 /** 251 /**
219 * Moves the language down in the list. 252 * Moves the language down in the list.
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 onRestartTap_: function() { 496 onRestartTap_: function() {
464 <if expr="chromeos"> 497 <if expr="chromeos">
465 settings.LifetimeBrowserProxyImpl.getInstance().signOutAndRestart(); 498 settings.LifetimeBrowserProxyImpl.getInstance().signOutAndRestart();
466 </if> 499 </if>
467 <if expr="not chromeos"> 500 <if expr="not chromeos">
468 settings.LifetimeBrowserProxyImpl.getInstance().restart(); 501 settings.LifetimeBrowserProxyImpl.getInstance().restart();
469 </if> 502 </if>
470 }, 503 },
471 }); 504 });
472 })(); 505 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698