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

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

Issue 2523403003: Language settings: fix focus issues (Closed)
Patch Set: rebase Created 4 years 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 * @type {!LanguageState|undefined} 45 * @type {!LanguageState|undefined}
46 * @private 46 * @private
47 */ 47 */
48 detailLanguage_: Object, 48 detailLanguage_: Object,
49 49
50 /** @private */ 50 /** @private */
51 showAddLanguagesDialog_: Boolean, 51 showAddLanguagesDialog_: Boolean,
52 }, 52 },
53 53
54 /** 54 /**
55 * Handler for clicking a language on the main page, which selects the
56 * language as the prospective UI language on Chrome OS and Windows.
57 * @param {!Event} e The tap event.
58 */
59 onLanguageTap_: function(e) {
60 // Only change the UI language on platforms that allow it.
61 if ((!cr.isChromeOS && !cr.isWindows) || loadTimeData.getBoolean('isGuest'))
62 return;
63
64 // Set the prospective UI language. This won't take effect until a restart.
65 var tapEvent = /** @type {!{model: !{item: !LanguageState}}} */(e);
66 if (tapEvent.model.item.language.supportsUI)
67 this.languageHelper.setUILanguage(tapEvent.model.item.language.code);
68 },
69
70 /**
71 * Handler for enabling or disabling spell check. 55 * Handler for enabling or disabling spell check.
72 * @param {!{target: Element, model: !{item: !LanguageState}}} e 56 * @param {!{target: Element, model: !{item: !LanguageState}}} e
73 */ 57 */
74 onSpellCheckChange_: function(e) { 58 onSpellCheckChange_: function(e) {
75 this.languageHelper.toggleSpellCheck(e.model.item.language.code, 59 this.languageHelper.toggleSpellCheck(e.model.item.language.code,
76 e.target.checked); 60 e.target.checked);
77 }, 61 },
78 62
79 /** @private */ 63 /** @private */
80 onBackTap_: function() { 64 onBackTap_: function() {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 /** 253 /**
270 * Opens the Manage Input Methods page. 254 * Opens the Manage Input Methods page.
271 * @private 255 * @private
272 */ 256 */
273 onManageInputMethodsTap_: function() { 257 onManageInputMethodsTap_: function() {
274 assert(cr.isChromeOS); 258 assert(cr.isChromeOS);
275 settings.navigateTo(settings.Route.INPUT_METHODS); 259 settings.navigateTo(settings.Route.INPUT_METHODS);
276 }, 260 },
277 261
278 /** 262 /**
279 * Handler for clicking an input method on the main page, which sets it as 263 * Handler for tap and <Enter> events on an input method on the main page,
280 * the current input method. 264 * which sets it as the current input method.
281 * @param {!{model: !{item: !chrome.languageSettingsPrivate.InputMethod}, 265 * @param {!{model: !{item: !chrome.languageSettingsPrivate.InputMethod},
282 * target: !{tagName: string}}} e 266 * target: !{tagName: string},
267 * type: string,
268 * key: (string|undefined)}} e
283 */ 269 */
284 onInputMethodTap_: function(e) { 270 onInputMethodTap_: function(e) {
285 assert(cr.isChromeOS); 271 assert(cr.isChromeOS);
286 272
287 // Taps on the paper-icon-button are handled in onInputMethodOptionsTap_. 273 // Taps on the paper-icon-button are handled in onInputMethodOptionsTap_.
288 if (e.target.tagName == 'PAPER-ICON-BUTTON') 274 if (e.target.tagName == 'PAPER-ICON-BUTTON')
289 return; 275 return;
290 276
277 // Ignore key presses other than <Enter>.
278 if (e.type == 'keypress' && e.key != 'Enter')
279 return;
280
291 // Set the input method. 281 // Set the input method.
292 this.languageHelper.setCurrentInputMethod(e.model.item.id); 282 this.languageHelper.setCurrentInputMethod(e.model.item.id);
293 }, 283 },
294 284
295 /** 285 /**
296 * Opens the input method extension's options page in a new tab (or focuses 286 * Opens the input method extension's options page in a new tab (or focuses
297 * an existing instance of the IME's options). 287 * an existing instance of the IME's options).
298 * @param {!{model: !{item: chrome.languageSettingsPrivate.InputMethod}}} e 288 * @param {!{model: !{item: chrome.languageSettingsPrivate.InputMethod}}} e
299 * @private 289 * @private
300 */ 290 */
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 * @private 492 * @private
503 */ 493 */
504 onRestartTap_: function() { 494 onRestartTap_: function() {
505 <if expr="chromeos"> 495 <if expr="chromeos">
506 settings.LifetimeBrowserProxyImpl.getInstance().signOutAndRestart(); 496 settings.LifetimeBrowserProxyImpl.getInstance().signOutAndRestart();
507 </if> 497 </if>
508 <if expr="not chromeos"> 498 <if expr="not chromeos">
509 settings.LifetimeBrowserProxyImpl.getInstance().restart(); 499 settings.LifetimeBrowserProxyImpl.getInstance().restart();
510 </if> 500 </if>
511 }, 501 },
502
503 /**
504 * Toggles the expand button within the element being listened to.
505 * @param {!Event} e
506 * @private
507 */
508 toggleExpandButton_: function(e) {
509 // The expand button handles toggling itself.
510 var expandButtonTag = 'CR-EXPAND-BUTTON';
511 if (e.target.tagName == expandButtonTag)
512 return;
513
514 /** @type {!CrExpandButtonElement} */
515 var expandButton = e.currentTarget.querySelector(expandButtonTag);
516 assert(expandButton);
517 expandButton.expanded = !expandButton.expanded;
518 },
512 }); 519 });
513 })(); 520 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698