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

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

Issue 1856873002: MD Settings: Polish languages pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@LanguageStyleToHtml
Patch Set: rebase Created 4 years, 8 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 26 matching lines...) Expand all
37 * Read-only reference to the languages model provided by the 37 * Read-only reference to the languages model provided by the
38 * 'settings-languages' instance. 38 * 'settings-languages' instance.
39 * @type {LanguagesModel|undefined} 39 * @type {LanguagesModel|undefined}
40 */ 40 */
41 languages: { 41 languages: {
42 type: Object, 42 type: Object,
43 notify: true, 43 notify: true,
44 }, 44 },
45 45
46 /** @private */ 46 /** @private */
47 languagesSecondary_: {
48 type: String,
49 value: 'Placeholder, e.g. English (United States)',
50 },
51
52 /** @private */
53 inputMethodsSecondary_: { 47 inputMethodsSecondary_: {
54 type: String, 48 type: String,
55 value: 'Placeholder, e.g. US keyboard', 49 value: 'Placeholder, e.g. US keyboard',
56 }, 50 },
57 51
58 /** @private */ 52 /** @private */
59 spellCheckSecondary_: { 53 spellCheckSecondary_: {
60 type: String, 54 type: String,
61 value: 'Placeholder, e.g. English (United States)', 55 value: 'Placeholder, e.g. English (United States)',
62 }, 56 },
57
58 /**
59 * The language to display the details for.
60 * @type {!LanguageInfo|undefined}
61 * @private
62 */
63 detailLanguage_: Object,
63 }, 64 },
64 65
65 /** @private {!LanguageHelper} */ 66 /** @private {!LanguageHelper} */
66 languageHelper_: LanguageHelperImpl.getInstance(), 67 languageHelper_: LanguageHelperImpl.getInstance(),
67 68
68 /** 69 /**
69 * Handler for clicking a language on the main page, which selects the 70 * Handler for clicking a language on the main page, which selects the
70 * language as the prospective UI language on Chrome OS and Windows. 71 * language as the prospective UI language on Chrome OS and Windows.
71 * @param {!{model: !{item: !LanguageInfo}}} e 72 * @param {!{model: !{item: !LanguageInfo}}} e
72 */ 73 */
(...skipping 29 matching lines...) Expand all
102 * Opens the Manage Languages page. 103 * Opens the Manage Languages page.
103 * @private 104 * @private
104 */ 105 */
105 onManageLanguagesTap_: function() { 106 onManageLanguagesTap_: function() {
106 this.$.pages.setSubpageChain(['manage-languages']); 107 this.$.pages.setSubpageChain(['manage-languages']);
107 this.forceRenderList_('settings-manage-languages-page'); 108 this.forceRenderList_('settings-manage-languages-page');
108 }, 109 },
109 110
110 /** 111 /**
111 * Opens the Language Detail page for the language. 112 * Opens the Language Detail page for the language.
112 * @param {!{model: !{item}}} e 113 * @param {!{model: !{item: !LanguageInfo}}} e
113 * @private 114 * @private
114 */ 115 */
115 onShowLanguageDetailTap_: function(e) { 116 onShowLanguageDetailTap_: function(e) {
116 this.$.languageSelector.select(e.model.item); 117 this.detailLanguage_ = e.model.item;
117 this.$.pages.setSubpageChain(['language-detail']); 118 this.$.pages.setSubpageChain(['language-detail']);
118 }, 119 },
119 120
120 <if expr="not is_macosx"> 121 <if expr="not is_macosx">
121 /** 122 /**
123 * Returns the enabled languages which support spell check.
124 * @private
125 */
126 spellCheckLanguages_: function() {
127 return this.languages.enabledLanguages.filter(function(languageInfo) {
128 return languageInfo.language.supportsSpellcheck;
129 });
130 },
131
132 /**
122 * Opens the Custom Dictionary page. 133 * Opens the Custom Dictionary page.
123 * @private 134 * @private
124 */ 135 */
125 onEditDictionaryTap_: function() { 136 onEditDictionaryTap_: function() {
126 this.$.pages.setSubpageChain(['edit-dictionary']); 137 this.$.pages.setSubpageChain(['edit-dictionary']);
127 this.forceRenderList_('settings-edit-dictionary-page'); 138 this.forceRenderList_('settings-edit-dictionary-page');
128 }, 139 },
129 </if> 140 </if>
130 141
131 <if expr="chromeos or is_win"> 142 <if expr="chromeos or is_win">
132 /** 143 /**
133 * Checks whether the prospective UI language (the pref that indicates what 144 * Checks whether the prospective UI language (the pref that indicates what
134 * language to use in Chrome) matches the current language. This pref is only 145 * language to use in Chrome) matches the current language. This pref is only
135 * on Chrome OS and Windows; we don't control the UI language elsewhere. 146 * on Chrome OS and Windows; we don't control the UI language elsewhere.
136 * @param {string} languageCode The language code identifying a language. 147 * @param {string} languageCode The language code identifying a language.
137 * @param {string} prospectiveUILanguage The prospective UI language. 148 * @param {string} prospectiveUILanguage The prospective UI language.
138 * @return {boolean} True if the given language matches the prospective UI 149 * @return {boolean} True if the given language matches the prospective UI
139 * pref (which may be different from the actual UI language). 150 * pref (which may be different from the actual UI language).
140 * @private 151 * @private
141 */ 152 */
142 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { 153 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) {
143 return languageCode == this.languageHelper_.getProspectiveUILanguage(); 154 return languageCode == this.languageHelper_.getProspectiveUILanguage();
144 }, 155 },
145 </if> 156 </if>
146 157
158 /**
159 * @return {string}
160 * @private
161 */
162 getProspectiveUILanguageName_: function() {
163 return this.languageHelper_.getLanguage(
164 this.languageHelper_.getProspectiveUILanguage()).displayName;
165 },
166
167 /**
168 * Returns either the "selected" class, if the language matches the
169 * prospective UI language, or an empty string. Languages can only be
170 * selected on Chrome OS and Windows.
171 * @param {string} languageCode The language code identifying a language.
172 * @param {string} prospectiveUILanguage The prospective UI language.
173 * @return {string} The class name for the language item.
174 * @private
175 */
176 getLanguageItemClass_: function(languageCode, prospectiveUILanguage) {
177 <if expr="chromeos or is_win">
178 if (this.isProspectiveUILanguage_(languageCode, prospectiveUILanguage))
179 return 'selected';
180 </if>
181 return '';
182 },
183
184 <if expr="chromeos">
147 /** 185 /**
148 * @param {string} id The input method ID. 186 * @param {string} id The input method ID.
149 * @param {string} currentId The ID of the currently enabled input method. 187 * @param {string} currentId The ID of the currently enabled input method.
150 * @return {boolean} True if the IDs match. 188 * @return {boolean} True if the IDs match.
151 * @private 189 * @private
152 */ 190 */
153 isCurrentInputMethod_: function(id, currentId) { 191 isCurrentInputMethod_: function(id, currentId) {
154 assert(cr.isChromeOS); 192 assert(cr.isChromeOS);
155 return id == currentId; 193 return id == currentId;
156 }, 194 },
157 195
158 /** 196 /**
197 * @param {string} id The input method ID.
198 * @param {string} currentId The ID of the currently enabled input method.
199 * @return {string} The class for the input method item.
200 * @private
201 */
202 getInputMethodItemClass_: function(id, currentId) {
203 return this.isCurrentInputMethod_(id, currentId) ? 'selected' : '';
204 },
205 </if>
206
207 /**
159 * HACK(michaelpg): This is necessary to show the list when navigating to 208 * HACK(michaelpg): This is necessary to show the list when navigating to
160 * the sub-page. Remove this function when PolymerElements/neon-animation#60 209 * the sub-page. Remove this function when PolymerElements/neon-animation#60
161 * is fixed. 210 * is fixed.
162 * @param {string} tagName Name of the element containing the <iron-list>. 211 * @param {string} tagName Name of the element containing the <iron-list>.
163 */ 212 */
164 forceRenderList_: function(tagName) { 213 forceRenderList_: function(tagName) {
165 this.$$(tagName).$$('iron-list').fire('iron-resize'); 214 this.$$(tagName).$$('iron-list').fire('iron-resize');
166 }, 215 },
167 }); 216 });
168 })(); 217 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698