1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview 'cr-settings-languages-page' is the settings page
* for language and input method settings.
*
* @group Chrome Settings Elements
* @element cr-settings-languages-page
*/
(function() {
'use strict';
Polymer({
is: 'cr-settings-languages-page',
properties: {
/**
* The current active route.
*/
currentRoute: {
type: Object,
notify: true,
},
/**
* Preferences state.
*/
prefs: {
type: Object,
notify: true,
},
/**
* Read-only reference to the languages model provided by the
* 'cr-settings-languages' instance.
* @type {LanguagesModel|undefined}
*/
languages: {
type: Object,
notify: true,
},
},
/**
* Handler for clicking a language on the main page, which selects the
* language as the prospective UI language on Chrome OS and Windows.
* @param {!{model: !{item: !LanguageInfo}}} e
*/
onLanguageTap_: function(e) {
// Taps on the paper-icon-button are handled in onShowLanguageDetailTap_.
if (e.target.tagName == 'PAPER-ICON-BUTTON')
return;
// Set the prospective UI language. This won't take effect until a restart.
if (e.model.item.language.supportsUI)
this.$.languages.setUILanguage(e.model.item.language.code);
},
/**
* Handler for enabling or disabling spell check.
* @param {!{target: Element, model: !{item: !LanguageInfo}}} e
*/
onSpellCheckChange_: function(e) {
this.$.languages.toggleSpellCheck(e.model.item.language.code,
e.target.checked);
},
/** @private */
onBackTap_: function() {
this.$.pages.back();
},
/**
* Opens the Manage Languages page.
* @private
*/
onManageLanguagesTap_: function() {
this.$.pages.setSubpageChain(['manage-languages']);
// HACK(michaelpg): This is necessary to show the list when navigating to
// the sub-page. Remove when PolymerElements/neon-animation#60 is fixed.
/** @type {{_render: function()}} */(this.$.manageLanguagesPage.$.list)
._render();
},
/**
* Opens the Language Detail page for the language.
* @param {!{model: !{item}}} e
* @private
*/
onShowLanguageDetailTap_: function(e) {
this.$.languageSelector.select(e.model.item);
this.$.pages.setSubpageChain(['language-detail']);
},
/**
* @param {string} languageCode The language code identifying a language.
* @param {string} prospectiveUILanguage The prospective UI language.
* @return {boolean} True if the given language matches the prospective UI
* pref (which may be different from the actual UI language).
* @private
*/
isUILanguage_: function(languageCode, prospectiveUILanguage) {
return languageCode == this.$.languages.getProspectiveUILanguage();
},
/**
* @param {string} id The input method ID.
* @param {string} currentId The ID of the currently enabled input method.
* @return {boolean} True if the IDs match.
* @private
*/
isCurrentInputMethod_: function(id, currentId) {
assert(cr.isChromeOS);
return id == currentId;
},
});
})();
|