Chromium Code Reviews| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 /** | 269 /** |
| 270 * Opens the Manage Input Methods page. | 270 * Opens the Manage Input Methods page. |
| 271 * @private | 271 * @private |
| 272 */ | 272 */ |
| 273 onManageInputMethodsTap_: function() { | 273 onManageInputMethodsTap_: function() { |
| 274 assert(cr.isChromeOS); | 274 assert(cr.isChromeOS); |
| 275 settings.navigateTo(settings.Route.INPUT_METHODS); | 275 settings.navigateTo(settings.Route.INPUT_METHODS); |
| 276 }, | 276 }, |
| 277 | 277 |
| 278 /** | 278 /** |
| 279 * Handler for clicking an input method on the main page, which sets it as | 279 * Handler for tap and <Enter> events on an input method on the main page, |
| 280 * the current input method. | 280 * which sets it as the current input method. |
| 281 * @param {!{model: !{item: !chrome.languageSettingsPrivate.InputMethod}, | 281 * @param {!{model: !{item: !chrome.languageSettingsPrivate.InputMethod}, |
| 282 * target: !{tagName: string}}} e | 282 * target: !{tagName: string}, |
| 283 * type: string, | |
| 284 * key: (string|undefined)}} e | |
| 283 */ | 285 */ |
| 284 onInputMethodTap_: function(e) { | 286 onInputMethodTap_: function(e) { |
| 285 assert(cr.isChromeOS); | 287 assert(cr.isChromeOS); |
| 286 | 288 |
| 287 // Taps on the paper-icon-button are handled in onInputMethodOptionsTap_. | 289 // Taps on the paper-icon-button are handled in onInputMethodOptionsTap_. |
| 288 if (e.target.tagName == 'PAPER-ICON-BUTTON') | 290 if (e.target.tagName == 'PAPER-ICON-BUTTON') |
| 289 return; | 291 return; |
| 290 | 292 |
| 293 // Ignore key presses other than <Enter>. | |
| 294 if (e.type == 'keypress' && e.key != 'Enter') | |
| 295 return; | |
| 296 | |
| 291 // Set the input method. | 297 // Set the input method. |
| 292 this.languageHelper.setCurrentInputMethod(e.model.item.id); | 298 this.languageHelper.setCurrentInputMethod(e.model.item.id); |
| 293 }, | 299 }, |
| 294 | 300 |
| 295 /** | 301 /** |
| 296 * Opens the input method extension's options page in a new tab (or focuses | 302 * Opens the input method extension's options page in a new tab (or focuses |
| 297 * an existing instance of the IME's options). | 303 * an existing instance of the IME's options). |
| 298 * @param {!{model: !{item: chrome.languageSettingsPrivate.InputMethod}}} e | 304 * @param {!{model: !{item: chrome.languageSettingsPrivate.InputMethod}}} e |
| 299 * @private | 305 * @private |
| 300 */ | 306 */ |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 | 385 |
| 380 /** | 386 /** |
| 381 * @return {string} | 387 * @return {string} |
| 382 * @private | 388 * @private |
| 383 */ | 389 */ |
| 384 getLanguageListTwoLine_: function() { | 390 getLanguageListTwoLine_: function() { |
| 385 return cr.isChromeOS || cr.isWindows ? 'two-line' : ''; | 391 return cr.isChromeOS || cr.isWindows ? 'two-line' : ''; |
| 386 }, | 392 }, |
| 387 | 393 |
| 388 /** | 394 /** |
| 395 * @return {string} | |
| 396 * @private | |
| 397 */ | |
| 398 getSpellcheckListTwoLine_: function() { | |
| 399 var spellCheckEnabled = | |
| 400 this.languages.enabled.some(function(languageState) { | |
| 401 return languageState.spellCheckEnabled && | |
| 402 languageState.language.supportsSpellcheck; | |
| 403 }); | |
|
stevenjb
2016/12/01 23:45:33
This looks duplicated at the top of getSpellCheckS
michaelpg
2016/12/02 03:31:05
I've moved this out to a follow-up CL to keep this
| |
| 404 return spellCheckEnabled ? 'two-line' : ''; | |
| 405 }, | |
| 406 | |
| 407 /** | |
| 389 * Returns either the "selected" class, if the language matches the | 408 * Returns either the "selected" class, if the language matches the |
| 390 * prospective UI language, or an empty string. Languages can only be | 409 * prospective UI language, or an empty string. Languages can only be |
| 391 * selected on Chrome OS and Windows. | 410 * selected on Chrome OS and Windows. |
| 392 * @param {string} languageCode The language code identifying a language. | 411 * @param {string} languageCode The language code identifying a language. |
| 393 * @param {string} prospectiveUILanguage The prospective UI language. | 412 * @param {string} prospectiveUILanguage The prospective UI language. |
| 394 * @param {boolean} supportsUI Whether Chrome's UI can be shown in this | 413 * @param {boolean} supportsUI Whether Chrome's UI can be shown in this |
| 395 * language. | 414 * language. |
| 396 * @return {string} The class name for the language item. | 415 * @return {string} The class name for the language item. |
| 397 * @private | 416 * @private |
| 398 */ | 417 */ |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 * @private | 521 * @private |
| 503 */ | 522 */ |
| 504 onRestartTap_: function() { | 523 onRestartTap_: function() { |
| 505 <if expr="chromeos"> | 524 <if expr="chromeos"> |
| 506 settings.LifetimeBrowserProxyImpl.getInstance().signOutAndRestart(); | 525 settings.LifetimeBrowserProxyImpl.getInstance().signOutAndRestart(); |
| 507 </if> | 526 </if> |
| 508 <if expr="not chromeos"> | 527 <if expr="not chromeos"> |
| 509 settings.LifetimeBrowserProxyImpl.getInstance().restart(); | 528 settings.LifetimeBrowserProxyImpl.getInstance().restart(); |
| 510 </if> | 529 </if> |
| 511 }, | 530 }, |
| 531 | |
| 532 /** | |
| 533 * Toggles the expand button within the element being listened to. | |
| 534 * @param {!Event} e | |
| 535 * @private | |
| 536 */ | |
| 537 toggleExpandButton_: function(e) { | |
| 538 // The expand button handles toggling itself. | |
| 539 var expandButtonTag = 'CR-EXPAND-BUTTON'; | |
| 540 if (e.target.tagName == expandButtonTag) | |
| 541 return; | |
| 542 | |
| 543 /** @type {!CrExpandButtonElement} */ | |
| 544 var expandButton = e.currentTarget.querySelector(expandButtonTag); | |
| 545 assert(expandButton); | |
| 546 expandButton.expanded = !expandButton.expanded; | |
| 547 }, | |
| 512 }); | 548 }); |
| 513 })(); | 549 })(); |
| OLD | NEW |