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

Side by Side Diff: chrome/browser/resources/settings/languages_page/languages_page.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-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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 /** 64 /**
65 * Handler for clicking a language on the main page, which selects the 65 * Handler for clicking a language on the main page, which selects the
66 * language as the prospective UI language on Chrome OS and Windows. 66 * language as the prospective UI language on Chrome OS and Windows.
67 * @param {!{model: !{item: !LanguageState}}} e 67 * @param {!{model: !{item: !LanguageState}}} e
68 */ 68 */
69 onLanguageTap_: function(e) { 69 onLanguageTap_: function(e) {
70 // Only change the UI language on platforms that allow it. 70 // Only change the UI language on platforms that allow it.
71 if (!cr.isChromeOS && !cr.isWindows) 71 if (!cr.isChromeOS && !cr.isWindows)
72 return; 72 return;
73 73
74 // Taps on the paper-icon-button are handled in onShowLanguageDetailTap_.
75 if (e.target.tagName == 'PAPER-ICON-BUTTON')
76 return;
77
78 // Set the prospective UI language. This won't take effect until a restart. 74 // Set the prospective UI language. This won't take effect until a restart.
79 if (e.model.item.language.supportsUI) 75 if (e.model.item.language.supportsUI)
80 this.languageHelper_.setUILanguage(e.model.item.language.code); 76 this.languageHelper_.setUILanguage(e.model.item.language.code);
81 }, 77 },
82 78
83 /** 79 /**
84 * Handler for enabling or disabling spell check. 80 * Handler for enabling or disabling spell check.
85 * @param {!{target: Element, model: !{item: !LanguageState}}} e 81 * @param {!{target: Element, model: !{item: !LanguageState}}} e
86 */ 82 */
87 onSpellCheckChange_: function(e) { 83 onSpellCheckChange_: function(e) {
88 this.languageHelper_.toggleSpellCheck(e.model.item.language.code, 84 this.languageHelper_.toggleSpellCheck(e.model.item.language.code,
89 e.target.checked); 85 e.target.checked);
90 }, 86 },
91 87
92 /** @private */ 88 /** @private */
93 onBackTap_: function() { 89 onBackTap_: function() {
94 this.$.pages.back(); 90 this.$.pages.back();
95 }, 91 },
96 92
97 /** 93 /**
98 * Opens the Manage Languages page. 94 * Opens the Manage Languages page.
99 * @private 95 * @private
100 */ 96 */
101 onManageLanguagesTap_: function() { 97 onManageLanguagesTap_: function() {
102 this.$.pages.setSubpageChain(['manage-languages']); 98 this.$.pages.setSubpageChain(['manage-languages']);
103 this.forceRenderList_('settings-manage-languages-page'); 99 this.forceRenderList_('settings-manage-languages-page');
104 }, 100 },
105 101
106 /** 102 /**
103 * @param {number} index Index of the language in the list of languages.
104 * @param {!Object} change Polymer change object (provided in the HTML so this
105 * gets called whenever languages.enabled.* changes).
michaelpg 2016/06/21 00:34:42 doesn't |index| change when the list changes?
Moe 2016/06/21 20:10:19 Not really. It may be a Polymer bug. It seems like
michaelpg 2016/06/22 01:06:27 TIL, thanks.
106 * @return {boolean} True if the given language is the first one in the list
107 * of languages.
108 * @private
109 */
110 isFirstLanguage_: function(index, change) {
111 return index == 0;
112 },
113
114 /**
115 * Moves the language up in the list.
116 * @param {!{model: !{item: !LanguageState}}} e
117 * @private
118 */
119 onMoveUpTap_: function(e) {
michaelpg 2016/06/21 00:34:42 nit: put this above onMoveDownTap_
Moe 2016/06/21 20:10:19 Done.
120 this.languageHelper_.moveLanguage(e.model.item.language.code, -1);
121 },
122
123 /**
124 * @param {number} index Index of the language in the list of languages.
125 * @param {!Object} change Polymer change object (provided in the HTML so this
126 * gets called whenever languages.enabled.* changes).
127 * @return {boolean} True if the given language is the last one in the list of
128 * languages.
129 * @private
130 */
131 isLastLanguage_: function(index, change) {
132 return index == this.languages.enabled.length - 1;
133 },
134
135 /**
136 * @param {!Object} change Polymer change object (provided in the HTML so this
michaelpg 2016/06/21 00:34:42 meh, feel free to omit this param altogether, if n
Moe 2016/06/21 20:10:19 Done.
137 * gets called whenever languages.enabled.* changes).
138 * @return {boolean} True if there are less than 2 languages.
139 */
140 isHelpTextHidden_: function(change) {
141 return this.languages.enabled.length <= 1;
142 },
143
144 /**
145 * Moves the language down in the list.
146 * @param {!{model: !{item: !LanguageState}}} e
147 * @private
148 */
149 onMoveDownTap_: function(e) {
150 this.languageHelper_.moveLanguage(e.model.item.language.code, 1);
151 },
152
153 /**
107 * Opens the Language Detail page for the language. 154 * Opens the Language Detail page for the language.
108 * @param {!{model: !{item: !LanguageState}}} e 155 * @param {!{model: !{item: !LanguageState}}} e
109 * @private 156 * @private
110 */ 157 */
111 onShowLanguageDetailTap_: function(e) { 158 onShowLanguageDetailTap_: function(e) {
112 this.detailLanguage_ = e.model.item; 159 this.detailLanguage_ = e.model.item;
113 this.$.pages.setSubpageChain(['language-detail']); 160 this.$.pages.setSubpageChain(['language-detail']);
114 }, 161 },
115 162
116 /** 163 /**
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 * HACK(michaelpg): This is necessary to show the list when navigating to 333 * HACK(michaelpg): This is necessary to show the list when navigating to
287 * the sub-page. Remove this function when PolymerElements/neon-animation#60 334 * the sub-page. Remove this function when PolymerElements/neon-animation#60
288 * is fixed. 335 * is fixed.
289 * @param {string} tagName Name of the element containing the <iron-list>. 336 * @param {string} tagName Name of the element containing the <iron-list>.
290 */ 337 */
291 forceRenderList_: function(tagName) { 338 forceRenderList_: function(tagName) {
292 this.$$(tagName).$$('iron-list').fire('iron-resize'); 339 this.$$(tagName).$$('iron-list').fire('iron-resize');
293 }, 340 },
294 }); 341 });
295 })(); 342 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698