OLD | NEW |
---|---|
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 Loading... | |
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} | |
dschuyler
2016/04/07 19:24:01
@private
michaelpg
2016/04/07 23:10:48
Done.
| |
61 */ | |
62 detailLanguage_: Object, | |
63 }, | 63 }, |
64 | 64 |
65 /** @private {!LanguageHelper} */ | 65 /** @private {!LanguageHelper} */ |
66 languageHelper_: LanguageHelperImpl.getInstance(), | 66 languageHelper_: LanguageHelperImpl.getInstance(), |
67 | 67 |
68 /** | 68 /** |
69 * Handler for clicking a language on the main page, which selects the | 69 * Handler for clicking a language on the main page, which selects the |
70 * language as the prospective UI language on Chrome OS and Windows. | 70 * language as the prospective UI language on Chrome OS and Windows. |
71 * @param {!{model: !{item: !LanguageInfo}}} e | 71 * @param {!{model: !{item: !LanguageInfo}}} e |
72 */ | 72 */ |
(...skipping 29 matching lines...) Expand all Loading... | |
102 * Opens the Manage Languages page. | 102 * Opens the Manage Languages page. |
103 * @private | 103 * @private |
104 */ | 104 */ |
105 onManageLanguagesTap_: function() { | 105 onManageLanguagesTap_: function() { |
106 this.$.pages.setSubpageChain(['manage-languages']); | 106 this.$.pages.setSubpageChain(['manage-languages']); |
107 this.forceRenderList_('settings-manage-languages-page'); | 107 this.forceRenderList_('settings-manage-languages-page'); |
108 }, | 108 }, |
109 | 109 |
110 /** | 110 /** |
111 * Opens the Language Detail page for the language. | 111 * Opens the Language Detail page for the language. |
112 * @param {!{model: !{item}}} e | 112 * @param {!{model: !{item: !LanguageInfo}}} e |
113 * @private | 113 * @private |
114 */ | 114 */ |
115 onShowLanguageDetailTap_: function(e) { | 115 onShowLanguageDetailTap_: function(e) { |
116 this.$.languageSelector.select(e.model.item); | 116 this.detailLanguage_ = e.model.item; |
117 this.$.pages.setSubpageChain(['language-detail']); | 117 this.$.pages.setSubpageChain(['language-detail']); |
118 }, | 118 }, |
119 | 119 |
120 <if expr="not is_macosx"> | 120 <if expr="not is_macosx"> |
121 /** | 121 /** |
122 * Returns the enabled languages which support spell check. | |
123 * @private | |
124 */ | |
125 spellCheckLanguages_: function() { | |
126 return this.languages.enabledLanguages.filter(function(languageInfo) { | |
127 return languageInfo.language.supportsSpellcheck; | |
128 }); | |
129 }, | |
130 | |
131 /** | |
122 * Opens the Custom Dictionary page. | 132 * Opens the Custom Dictionary page. |
123 * @private | 133 * @private |
124 */ | 134 */ |
125 onEditDictionaryTap_: function() { | 135 onEditDictionaryTap_: function() { |
126 this.$.pages.setSubpageChain(['edit-dictionary']); | 136 this.$.pages.setSubpageChain(['edit-dictionary']); |
127 this.forceRenderList_('settings-edit-dictionary-page'); | 137 this.forceRenderList_('settings-edit-dictionary-page'); |
128 }, | 138 }, |
129 </if> | 139 </if> |
130 | 140 |
131 <if expr="chromeos or is_win"> | 141 <if expr="chromeos or is_win"> |
132 /** | 142 /** |
133 * Checks whether the prospective UI language (the pref that indicates what | 143 * 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 | 144 * 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. | 145 * on Chrome OS and Windows; we don't control the UI language elsewhere. |
136 * @param {string} languageCode The language code identifying a language. | 146 * @param {string} languageCode The language code identifying a language. |
137 * @param {string} prospectiveUILanguage The prospective UI language. | 147 * @param {string} prospectiveUILanguage The prospective UI language. |
138 * @return {boolean} True if the given language matches the prospective UI | 148 * @return {boolean} True if the given language matches the prospective UI |
139 * pref (which may be different from the actual UI language). | 149 * pref (which may be different from the actual UI language). |
140 * @private | 150 * @private |
141 */ | 151 */ |
142 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { | 152 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { |
143 return languageCode == this.languageHelper_.getProspectiveUILanguage(); | 153 return languageCode == this.languageHelper_.getProspectiveUILanguage(); |
144 }, | 154 }, |
145 </if> | 155 </if> |
146 | 156 |
157 /** | |
158 * @return {string} | |
159 * @private | |
160 */ | |
161 getProspectiveUILanguageName_: function() { | |
162 return this.languageHelper_.getLanguage( | |
163 this.languageHelper_.getProspectiveUILanguage()).displayName; | |
164 }, | |
165 | |
166 /** | |
167 * Returns either the "selected" class, if the language matches the | |
168 * prospective UI language, or an empty string. Languages can only be | |
169 * selected on Chrome OS and Windows. | |
170 * @param {string} languageCode The language code identifying a language. | |
171 * @param {string} prospectiveUILanguage The prospective UI language. | |
172 * @return {string} The class name for the language item. | |
173 * @private | |
174 */ | |
175 getLanguageItemClass_: function(languageCode, prospectiveUILanguage) { | |
176 <if expr="chromeos or is_win"> | |
177 if (this.isProspectiveUILanguage_(languageCode, prospectiveUILanguage)) | |
178 return 'selected'; | |
179 </if> | |
180 return ''; | |
181 }, | |
182 | |
183 <if expr="chromeos"> | |
147 /** | 184 /** |
148 * @param {string} id The input method ID. | 185 * @param {string} id The input method ID. |
149 * @param {string} currentId The ID of the currently enabled input method. | 186 * @param {string} currentId The ID of the currently enabled input method. |
150 * @return {boolean} True if the IDs match. | 187 * @return {boolean} True if the IDs match. |
151 * @private | 188 * @private |
152 */ | 189 */ |
153 isCurrentInputMethod_: function(id, currentId) { | 190 isCurrentInputMethod_: function(id, currentId) { |
154 assert(cr.isChromeOS); | 191 assert(cr.isChromeOS); |
155 return id == currentId; | 192 return id == currentId; |
156 }, | 193 }, |
157 | 194 |
158 /** | 195 /** |
196 * @param {string} id The input method ID. | |
197 * @param {string} currentId The ID of the currently enabled input method. | |
198 * @return {string} The class for the input method item. | |
199 * @private | |
200 */ | |
201 getInputMethodItemClass_: function(id, currentId) { | |
202 return this.isCurrentInputMethod_(id, currentId) ? 'selected' : ''; | |
203 }, | |
204 </if> | |
205 | |
206 /** | |
159 * HACK(michaelpg): This is necessary to show the list when navigating to | 207 * HACK(michaelpg): This is necessary to show the list when navigating to |
160 * the sub-page. Remove this function when PolymerElements/neon-animation#60 | 208 * the sub-page. Remove this function when PolymerElements/neon-animation#60 |
161 * is fixed. | 209 * is fixed. |
162 * @param {string} tagName Name of the element containing the <iron-list>. | 210 * @param {string} tagName Name of the element containing the <iron-list>. |
163 */ | 211 */ |
164 forceRenderList_: function(tagName) { | 212 forceRenderList_: function(tagName) { |
165 this.$$(tagName).$$('iron-list').fire('iron-resize'); | 213 this.$$(tagName).$$('iron-list').fire('iron-resize'); |
166 }, | 214 }, |
167 }); | 215 }); |
168 })(); | 216 })(); |
OLD | NEW |