Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / resources / settings / languages_page / languages_page.js
bloba98cef445964dfbf86f3987ee922f59eac2d466d
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
3 // found in the LICENSE file.
5 /**
6 * @fileoverview 'cr-settings-languages-page' is the settings page
7 * for language and input method settings.
9 * @group Chrome Settings Elements
10 * @element cr-settings-languages-page
12 Polymer({
13 is: 'cr-settings-languages-page',
15 properties: {
16 /**
17 * Preferences state.
19 prefs: {
20 type: Object,
21 notify: true,
24 dummyLanguages_: {
25 type: Array,
26 value: function() {
27 return [{code: 'en', displayName: 'English', supportsSpellcheck: true},
28 {code: 'es', displayName: 'Spanish', supportsSpellcheck: true},
29 {code: 'ru', displayName: 'Russian', supportsSpellcheck: true},
30 {code: 'ar', displayName: 'Arabic'}];
34 dummyInputMethods_: {
35 type: Array,
36 value: function() {
37 return [{id: 'us', name: 'US Keyboard'},
38 {id: 'fr', name: 'French Keyboard'}];
42 dummyAppLocale_: {
43 type: String,
44 value: 'en',
47 dummyCurrentInputMethod_: {
48 type: String,
49 value: 'us',
52 dummySpellcheckDictionaries_: {
53 type: Array,
54 value: function() {
55 return ['en', 'es', 'ru'];
59 route: String,
61 /**
62 * Whether the page is a subpage.
64 subpage: {
65 type: Boolean,
66 value: false,
67 readOnly: true
70 /**
71 * ID of the page.
73 PAGE_ID: {
74 type: String,
75 value: 'languages',
76 readOnly: true
79 /**
80 * Title for the page header and navigation menu.
82 pageTitle: {
83 type: String,
84 value: function() {
85 return loadTimeData.getString('languagesPageTitle');
89 /**
90 * Name of the 'iron-icon' to be shown in the settings-page-header.
92 icon: {
93 type: String,
94 value: 'language',
95 readOnly: true
99 /**
100 * @param {!Array<!Language>} languages
101 * @return {!Array<!Language>} The languages from |languages| which support
102 * spell check.
103 * @private
105 getSpellcheckLanguages_: function(languages) {
106 return languages.filter(function(language) {
107 return language.supportsSpellcheck;
112 * @param {string} languageCode The language code identifying a language.
113 * @param {string} dummyAppLocale A fake app locale.
114 * @return {boolean} True if the given language matches the app locale pref
115 * (which may be different from the actual app locale if it was changed).
116 * @private
118 isUILanguage_: function(languageCode, dummyAppLocale) {
119 return languageCode == dummyAppLocale;
123 * @param {string} id The input method ID.
124 * @param {string} currentId The ID of the currently enabled input method.
125 * @return {boolean} True if the IDs match.
126 * @private
128 isCurrentInputMethod_: function(id, currentId) {
129 assert(cr.isChromeOS);
130 return id == currentId;
134 * @param {string} languageCode The language code identifying a language.
135 * @param {!Array<string>} spellcheckDictionaries The list of languages
136 * for which spell check is enabled.
137 * @return {boolean} True if spell check is enabled for the language.
138 * @private
140 isSpellcheckEnabled_: function(languageCode, spellcheckDictionaries) {
141 return spellcheckDictionaries.indexOf(languageCode) != -1;