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

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_welcome.js

Issue 2886843005: [i18n] use Polymer data binding to change locale strings (Closed)
Patch Set: use str_() to update i18n Created 3 years, 7 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
« no previous file with comments | « chrome/browser/resources/chromeos/login/oobe_welcome.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Polymer element for displaying material design OOBE. 6 * @fileoverview Polymer element for displaying material design OOBE.
7 */ 7 */
8 8
9 Polymer({ 9 Polymer({
10 is: 'oobe-welcome-md', 10 is: 'oobe-welcome-md',
(...skipping 14 matching lines...) Expand all
25 type: String, 25 type: String,
26 value: '', 26 value: '',
27 }, 27 },
28 28
29 /** 29 /**
30 * List of languages for language selector dropdown. 30 * List of languages for language selector dropdown.
31 * @type {!Array<OobeTypes.LanguageDsc>} 31 * @type {!Array<OobeTypes.LanguageDsc>}
32 */ 32 */
33 languages: { 33 languages: {
34 type: Array, 34 type: Array,
35 observer: "onLanguagesChanged_", 35 observer: 'onLanguagesChanged_',
36 }, 36 },
37 37
38 /** 38 /**
39 * List of keyboards for keyboard selector dropdown. 39 * List of keyboards for keyboard selector dropdown.
40 * @type {!Array<OobeTypes.IMEDsc>} 40 * @type {!Array<OobeTypes.IMEDsc>}
41 */ 41 */
42 keyboards: { 42 keyboards: {
43 type: Array, 43 type: Array,
44 observer: "onKeyboardsChanged_", 44 observer: 'onKeyboardsChanged_',
45 }, 45 },
46 46
47 /** 47 /**
48 * Flag that enables MD-OOBE. 48 * Flag that enables MD-OOBE.
49 */ 49 */
50 enabled: { 50 enabled: {
51 type: Boolean, 51 type: Boolean,
52 value: false, 52 value: false,
53 }, 53 },
54 54
(...skipping 15 matching lines...) Expand all
70 }, 70 },
71 71
72 /** 72 /**
73 * If UI uses forced keyboard navigation. 73 * If UI uses forced keyboard navigation.
74 */ 74 */
75 highlightStrength: { 75 highlightStrength: {
76 type: String, 76 type: String,
77 value: '', 77 value: '',
78 }, 78 },
79 79
80 /*
81 * Signal dynamic language change.
82 * Note: the type and value are arbitrary, but the value does need to change
83 * to cause a str('...', i18n_) update.
84 * @private
85 */
86 i18n_: {
87 type: Number,
88 value: 0,
89 },
90
80 /** 91 /**
81 * True when connected to a network. 92 * True when connected to a network.
82 * @private 93 * @private
83 */ 94 */
84 isConnected_: { 95 isConnected_: {
85 type: Boolean, 96 type: Boolean,
86 value: false, 97 value: false,
87 }, 98 },
88 99
89 /** 100 /**
90 * Controls displaying of "Enable debugging features" link. 101 * Controls displaying of "Enable debugging features" link.
91 */ 102 */
92 debuggingLinkVisible: Boolean, 103 debuggingLinkVisible: Boolean,
93 }, 104 },
94 105
95 /** 106 /**
96 * GUID of the user-selected network. It is remembered after user taps on 107 * GUID of the user-selected network. It is remembered after user taps on
97 * network entry. After we receive event "connected" on this network, 108 * network entry. After we receive event "connected" on this network,
98 * OOBE will proceed. 109 * OOBE will proceed.
99 */ 110 */
100 networkLastSelectedGuid_: '', 111 networkLastSelectedGuid_: '',
101 112
102 /** @override */ 113 /** @override */
(...skipping 20 matching lines...) Expand all
123 networkListItemNotConnected: 134 networkListItemNotConnected:
124 loadTimeData.getString('networkListItemNotConnected'), 135 loadTimeData.getString('networkListItemNotConnected'),
125 vpnNameTemplate: loadTimeData.getString('vpnNameTemplate'), 136 vpnNameTemplate: loadTimeData.getString('vpnNameTemplate'),
126 137
127 // Additional strings for custom items. 138 // Additional strings for custom items.
128 addMobileNetworkMenuName: 139 addMobileNetworkMenuName:
129 loadTimeData.getString('addMobileNetworkMenuName'), 140 loadTimeData.getString('addMobileNetworkMenuName'),
130 addWiFiNetworkMenuName: loadTimeData.getString('addWiFiNetworkMenuName'), 141 addWiFiNetworkMenuName: loadTimeData.getString('addWiFiNetworkMenuName'),
131 proxySettingsMenuName: loadTimeData.getString('proxySettingsMenuName'), 142 proxySettingsMenuName: loadTimeData.getString('proxySettingsMenuName'),
132 }; 143 };
144
145 this.set('i18n_', this.i18n_ + 1);
Alexander Alekseev 2017/05/20 01:21:12 I don't like the idea of per-screen JS depencence.
dschuyler 2017/05/20 01:44:48 I agree that it is not pretty, but it's a special
Alexander Alekseev 2017/05/20 01:50:57 I believe that OOBE/Login is likely a half of Chro
Dan Beam 2017/05/20 02:03:29 i don't know how a behavior would help that the bi
Dan Beam 2017/05/20 02:03:29 fwiw: this could also just be this.i18n_++;
Alexander Alekseev 2017/05/20 02:25:21 updateLocalizedContent should go into the behavior
dschuyler 2017/05/23 00:03:18 Acknowledged.
dschuyler 2017/05/23 00:03:18 Acknowledged.
dschuyler 2017/05/23 00:03:18 I'd like that (moving the existing code) to be a s
dschuyler 2017/05/23 00:03:18 Done.
133 }, 146 },
134 147
135 /** 148 /**
136 * Hides all screens to help switching from one screen to another. 149 * Hides all screens to help switching from one screen to another.
137 * @private 150 * @private
138 */ 151 */
139 hideAllScreens_: function() { 152 hideAllScreens_: function() {
140 this.$.welcomeScreen.hidden = true; 153 this.$.welcomeScreen.hidden = true;
141 154
142 var screens = Polymer.dom(this.root).querySelectorAll('oobe-dialog') 155 var screens = Polymer.dom(this.root).querySelectorAll('oobe-dialog');
143 for (var i = 0; i < screens.length; ++i) { 156 for (var i = 0; i < screens.length; ++i) {
144 screens[i].hidden = true; 157 screens[i].hidden = true;
145 } 158 }
146 }, 159 },
147 160
148 /** 161 /**
149 * Shows given screen. 162 * Shows given screen.
150 * @param id String Screen ID. 163 * @param id String Screen ID.
151 * @private 164 * @private
152 */ 165 */
153 showScreen_: function(id) { 166 showScreen_: function(id) {
154 this.hideAllScreens_(); 167 this.hideAllScreens_();
155 168
156 var screen = this.$[id]; 169 var screen = this.$[id];
157 assert(screen); 170 assert(screen);
158 screen.hidden = false; 171 screen.hidden = false;
159 screen.show(); 172 screen.show();
160 }, 173 },
161 174
162 /** 175 /**
176 * Get the i18n string for the given tag.
177 * @return {string}
178 * @private
179 */
180 str_: function(tag) {
181 return loadTimeData.getString(tag);
182 },
183
184 /**
163 * Returns active screen object. 185 * Returns active screen object.
164 * @private 186 * @private
165 */ 187 */
166 getActiveScreen_: function() { 188 getActiveScreen_: function() {
167 var screens = Polymer.dom(this.root).querySelectorAll('oobe-dialog') 189 var screens = Polymer.dom(this.root).querySelectorAll('oobe-dialog');
168 for (var i = 0; i < screens.length; ++i) { 190 for (var i = 0; i < screens.length; ++i) {
169 if (!screens[i].hidden) 191 if (!screens[i].hidden)
170 return screens[i]; 192 return screens[i];
171 } 193 }
172 return this.$.welcomeScreen; 194 return this.$.welcomeScreen;
173 }, 195 },
174 196
175 focus: function() { 197 focus: function() {
176 this.getActiveScreen_().focus(); 198 this.getActiveScreen_().focus();
177 }, 199 },
(...skipping 22 matching lines...) Expand all
200 * when connected to a network. 222 * when connected to a network.
201 * @private 223 * @private
202 */ 224 */
203 getNetworkCustomItems_: function(isConnected_) { 225 getNetworkCustomItems_: function(isConnected_) {
204 var self = this; 226 var self = this;
205 var items = [ 227 var items = [
206 { 228 {
207 customItemName: 'proxySettingsMenuName', 229 customItemName: 'proxySettingsMenuName',
208 polymerIcon: 'oobe-welcome-20:add-proxy', 230 polymerIcon: 'oobe-welcome-20:add-proxy',
209 customData: { 231 customData: {
210 onTap: function() { self.OpenProxySettingsDialog_(); }, 232 onTap: function() {
233 self.OpenProxySettingsDialog_();
234 },
211 }, 235 },
212 }, 236 },
213 { 237 {
214 customItemName: 'addWiFiNetworkMenuName', 238 customItemName: 'addWiFiNetworkMenuName',
215 polymerIcon: 'oobe-welcome-20:add-wifi', 239 polymerIcon: 'oobe-welcome-20:add-wifi',
216 customData: { 240 customData: {
217 onTap: function() { self.OpenAddWiFiNetworkDialog_(); }, 241 onTap: function() {
242 self.OpenAddWiFiNetworkDialog_();
243 },
218 }, 244 },
219 }, 245 },
220 { 246 {
221 customItemName: 'addMobileNetworkMenuName', 247 customItemName: 'addMobileNetworkMenuName',
222 polymerIcon: 'oobe-welcome-20:add-cellular', 248 polymerIcon: 'oobe-welcome-20:add-cellular',
223 customData: { 249 customData: {
224 onTap: function() { self.OpenAddWiFiNetworkDialog_(); }, 250 onTap: function() {
251 self.OpenAddWiFiNetworkDialog_();
252 },
225 }, 253 },
226 }, 254 },
227 ]; 255 ];
228 if (isConnected_) 256 if (isConnected_)
229 return items; 257 return items;
230 return items.slice(1); 258 return items.slice(1);
231 }, 259 },
232 260
233 /** 261 /**
234 * Returns true if timezone button should be visible. 262 * Returns true if timezone button should be visible.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 /** 296 /**
269 * Handle "Timezone" button for "Welcome" screen. 297 * Handle "Timezone" button for "Welcome" screen.
270 * 298 *
271 * @private 299 * @private
272 */ 300 */
273 onWelcomeTimezoneButtonClicked_: function() { 301 onWelcomeTimezoneButtonClicked_: function() {
274 this.showScreen_('timezoneScreen'); 302 this.showScreen_('timezoneScreen');
275 }, 303 },
276 304
277 /** 305 /**
278 * Handle Networwork Setup screen "Proxy settings" button. 306 * Handle Network Setup screen "Proxy settings" button.
279 * 307 *
280 * @private 308 * @private
281 */ 309 */
282 OpenProxySettingsDialog_: function(item) { 310 OpenProxySettingsDialog_: function(item) {
283 chrome.send('launchProxySettingsDialog'); 311 chrome.send('launchProxySettingsDialog');
284 }, 312 },
285 313
286 /** 314 /**
287 * Handle Networwork Setup screen "Add WiFi network" button. 315 * Handle Network Setup screen "Add WiFi network" button.
288 * 316 *
289 * @private 317 * @private
290 */ 318 */
291 OpenAddWiFiNetworkDialog_: function(item) { 319 OpenAddWiFiNetworkDialog_: function(item) {
292 chrome.send('launchAddWiFiNetworkDialog'); 320 chrome.send('launchAddWiFiNetworkDialog');
293 }, 321 },
294 322
295 /** 323 /**
296 * Handle Networwork Setup screen "Add cellular network" button. 324 * Handle Network Setup screen "Add cellular network" button.
297 * 325 *
298 * @private 326 * @private
299 */ 327 */
300 OpenAddMobileNetworkDialog_: function(item) { 328 OpenAddMobileNetworkDialog_: function(item) {
301 chrome.send('launchAddMobileNetworkDialog'); 329 chrome.send('launchAddMobileNetworkDialog');
302 }, 330 },
303 331
304 /** 332 /**
305 * This is called when network setup is done. 333 * This is called when network setup is done.
306 * 334 *
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 * @private 515 * @private
488 */ 516 */
489 onTimezoneSelected_: function(event) { 517 onTimezoneSelected_: function(event) {
490 var item = event.detail; 518 var item = event.detail;
491 if (!item) 519 if (!item)
492 return; 520 return;
493 521
494 this.screen.onTimezoneSelected_(item.value); 522 this.screen.onTimezoneSelected_(item.value);
495 }, 523 },
496 }); 524 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/login/oobe_welcome.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698